dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37301
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19094: minor
------------------------------------------------------------
revno: 19094
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-05-06 10:09:03 +0200
message:
minor
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-05-04 07:52:12 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-05-06 08:09:03 +0000
@@ -277,51 +277,41 @@
var prStDe = programStageDataElements[fieldId];
+ var commonInputFieldProperty = this.getAttributesAsString(attributes) +
+ ' d2-validation ' +
+ ' ng-model="currentEvent.' + fieldId + '" ' +
+ ' input-field-id="' + fieldId + '"' +
+ ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
+ ' ng-disabled="selectedEnrollment.status===\'CANCELLED\' || selectedEnrollment.status===\'COMPLETED\' || currentEvent[uid]==\'uid\' || currentEvent.editingNotAllowed"' +
+ ' ng-required="{{prStDes.' + fieldId + '.compulsory}}" ';
+
if( prStDe && prStDe.dataElement && prStDe.dataElement.type ){
//check if dataelement has optionset
if( prStDe.dataElement.optionSetValue){
var optionSetId = prStDe.dataElement.optionSet.id;
- newInputField = '<input type="text" ' +
- this.getAttributesAsString(attributes) +
- ' d2-validation ' +
- ' ng-model="currentEvent.' + fieldId + '" ' +
- ' input-field-id="' + fieldId + '"' +
- ' ng-disabled="selectedEnrollment.status===\'CANCELLED\' || selectedEnrollment.status===\'COMPLETED\' || currentEvent[uid]==\'uid\' || currentEvent.editingNotAllowed"' +
- ' ng-required="{{prStDes.' + fieldId + '.compulsory}}"' +
+ newInputField = '<input type="text" ' +
' typeahead="option.name as option.name for option in optionSets.'+optionSetId+'.options | filter:$viewValue | limitTo:20"' +
' typeahead-editable="false" ' +
' d2-typeahead-validation ' +
' class="typeahead" ' +
- ' placeholder=" " ' +
- ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
+ ' placeholder=" " ' +
' ng-blur="saveDatavalue(prStDes.'+ fieldId + ')"' +
- ' typeahead-open-on-focus ng-required="prStDes.'+fieldId+'.compulsory"> ';
+ ' typeahead-open-on-focus ' +
+ commonInputFieldProperty + ' >';
}
else{
//check data element type and generate corresponding angular input field
if(prStDe.dataElement.type === "int"){
newInputField = '<input type="text" ' +
- this.getAttributesAsString(attributes) +
- ' d2-validation ' +
' d2-number-validation ' +
- ' number-type="' + prStDe.dataElement.numberType + '" ' +
- ' ng-model="currentEvent.' + fieldId + '"' +
- ' input-field-id="' + fieldId + '"' +
- ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
- ' ng-disabled="selectedEnrollment.status===\'CANCELLED\' || selectedEnrollment.status===\'COMPLETED\' || currentEvent.editingNotAllowed"' +
+ ' number-type="' + prStDe.dataElement.numberType + '" ' +
' ng-blur="saveDatavalue(prStDes.'+ fieldId + ')"' +
- ' ng-required="{{prStDes.' + fieldId + '.compulsory}}">';
+ commonInputFieldProperty + ' >';
}
else if(prStDe.dataElement.type === "bool"){
- newInputField = '<select ' +
- this.getAttributesAsString(attributes) +
- ' d2-validation ' +
- ' ng-model="currentEvent.' + fieldId + '" ' +
- ' input-field-id="' + fieldId + '"' +
- ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
- ' ng-disabled="selectedEnrollment.status===\'CANCELLED\' || selectedEnrollment.status===\'COMPLETED\' || currentEvent.editingNotAllowed"' +
- ' ng-change="saveDatavalue(prStDes.'+ fieldId + ')"' +
- ' ng-required="{{prStDes.' + fieldId + '.compulsory}}">' +
+ newInputField = '<select ' +
+ ' ng-change="saveDatavalue(prStDes.'+ fieldId + ')" ' +
+ commonInputFieldProperty + '>' +
'<option value="">{{\'please_select\'| translate}}</option>' +
'<option value="false">{{\'no\'| translate}}</option>' +
'<option value="true">{{\'yes\'| translate}}</option>' +
@@ -329,40 +319,22 @@
}
else if(prStDe.dataElement.type === "date"){
var maxDate = prStDe.allowFutureDate ? '' : 0;
- newInputField = '<input type="text" ' +
- this.getAttributesAsString(attributes) +
- ' d2-validation ' +
- ' ng-model="currentEvent.' + fieldId + '"' +
- ' input-field-id="' + fieldId + '"' +
+ newInputField = '<input type="text" ' +
' placeholder="{{dhis2CalendarFormat.keyDateFormat}}" ' +
' d2-date ' +
- ' max-date="' + maxDate + '"' +
- ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
- ' ng-disabled="selectedEnrollment.status===\'CANCELLED\' || selectedEnrollment.status===\'COMPLETED\' || currentEvent.editingNotAllowed"' +
+ ' max-date="' + maxDate + '"' +
' blur-or-change="saveDatavalue(prStDes.'+ fieldId + ')"' +
- ' ng-required="{{prStDes.' + fieldId + '.compulsory}}"> ';
+ commonInputFieldProperty + ' >';
}
else if(prStDe.dataElement.type.type === "trueOnly"){
newInputField = '<input type="checkbox" ' +
- this.getAttributesAsString(attributes) +
- ' d2-validation ' +
- ' ng-model="currentEvent.' + fieldId + '"' +
- ' input-field-id="' + fieldId + '"' +
- ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
- ' ng-disabled="selectedEnrollment.status===\'CANCELLED\' || selectedEnrollment.status===\'COMPLETED\' || currentEvent.editingNotAllowed"' +
' ng-change="saveDatavalue(prStDes.'+ fieldId + ')"' +
- ' ng-required="{{prStDes.' + fieldId + '.compulsory}}"> ';
+ commonInputFieldProperty + ' >';
}
else{
newInputField = '<input type="text" ' +
- this.getAttributesAsString(attributes) +
- ' d2-validation ' +
- ' ng-model="currentEvent.' + fieldId + '" ' +
- ' input-field-id="' + fieldId + '"' +
- ' ng-disabled="selectedEnrollment.status===\'CANCELLED\' || selectedEnrollment.status===\'COMPLETED\' || currentEvent[uid]==\'uid\' || currentEvent.editingNotAllowed"' +
- ' ng-class="getInputNotifcationClass(prStDes.' + fieldId + '.dataElement.id,true)"' +
' ng-blur="saveDatavalue(prStDes.'+ fieldId + ')"' +
- ' ng-required="prStDes.' + fieldId + '.compulsory"> ';
+ commonInputFieldProperty + ' >';
}
}
}
@@ -415,18 +387,21 @@
var att = trackedEntityFormAttributes[attId];
- if( att ){
- //check if attribute has optionset
- if(att.optionSetValue){
- var optionSetId = att.optionSet.id;
- newInputField = '<input type="text" ' +
- ' name="' + fieldName + '"' +
+ if( att ){
+
+ var commonInputFieldProperty = ' name="' + fieldName + '"' +
' element-id="' + i + '"' +
this.getAttributesAsString(attributes) +
' d2-focus-next-on-enter' +
' ng-model="selectedTei.' + attId + '" ' +
' ng-disabled="editingDisabled"' +
' d2-validation ' +
+ ' ng-required=" ' + (att.mandatory || att.unique) + '" ';
+
+ //check if attribute has optionset
+ if(att.optionSetValue){
+ var optionSetId = att.optionSet.id;
+ newInputField = '<input type="text" ' +
' d2-typeahead-validation ' +
' class="typeahead" ' +
' placeholder=" " ' +
@@ -434,89 +409,48 @@
' typeahead="option.name as option.name for option in optionSets.' + optionSetId + '.options | filter:$viewValue | limitTo:50"' +
' typeahead-open-on-focus ' +
' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
- ' ng-required=" ' + (att.mandatory || att.unique) + '"> ';
+ commonInputFieldProperty + ' >';
}
else{
//check attribute type and generate corresponding angular input field
if(att.valueType === "number"){
newInputField = '<input type="text" ' +
- ' name="' + fieldName + '"' +
- ' element-id="' + i + '"' +
- this.getAttributesAsString(attributes) +
- ' d2-validation ' +
' d2-number-validation ' +
- ' d2-focus-next-on-enter' +
- ' ng-model="selectedTei.' + attId + '" ' +
- ' ng-disabled="editingDisabled"' +
' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
- ' ng-required=" ' + (att.mandatory || att.unique) + '"> ';
+ commonInputFieldProperty + ' >';
}
else if(att.valueType === "bool"){
- newInputField = '<select ' +
- ' name="' + fieldName + '"' +
- ' element-id="' + i + '"' +
- this.getAttributesAsString(attributes) +
- ' d2-focus-next-on-enter' +
- ' ng-model="selectedTei.' + attId + '" ' +
- ' ng-disabled="editingDisabled"' +
- ' ng-change="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
- ' ng-required=" ' + (att.mandatory || att.unique) + '"> ' +
+ newInputField = '<select ' +
+ ' ng-change="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
+ commonInputFieldProperty + ' > ' +
' <option value="">{{\'please_select\'| translate}}</option>' +
' <option value="false">{{\'no\'| translate}}</option>' +
' <option value="true">{{\'yes\'| translate}}</option>' +
'</select> ';
}
else if(att.valueType === "date"){
- newInputField = '<input type="text" ' +
- ' name="' + fieldName + '"' +
- ' element-id="' + i + '"' +
- this.getAttributesAsString(attributes) +
- ' d2-focus-next-on-enter' +
+ newInputField = '<input type="text" ' +
' placeholder="{{dhis2CalendarFormat.keyDateFormat}}" ' +
- ' ng-model="selectedTei.' + attId + '" ' +
- ' ng-disabled="editingDisabled"' +
' max-date="' + attMaxDate + '"' + '\'' +
' d2-date' +
- ' d2-validation ' +
' blur-or-change="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
- ' ng-required=" ' + (att.mandatory || att.unique) + '"> ';
+ commonInputFieldProperty + ' >';
}
else if(att.valueType === "trueOnly"){
- newInputField = '<input type="checkbox" ' +
- ' name="' + fieldName + '"' +
- ' element-id="' + i + '"' +
- this.getAttributesAsString(attributes) +
- ' d2-validation ' +
- ' d2-focus-next-on-enter' +
- ' ng-model="selectedTei.' + attId + '" ' +
- ' ng-disabled="editingDisabled"' +
+ newInputField = '<input type="checkbox" ' +
' ng-change="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
- ' ng-required=" ' + (att.mandatory || att.unique) + '"> ';
+ commonInputFieldProperty + ' >';
}
else if(att.valueType === "email"){
- newInputField = '<input type="email" ' +
- ' name="' + fieldName + '"' +
- ' element-id="' + i + '"' +
- this.getAttributesAsString(attributes) +
- ' d2-validation ' +
- ' d2-focus-next-on-enter' +
- ' ng-model="selectedTei.' + attId + '" ' +
- ' ng-disabled="editingDisabled"' +
+ newInputField = '<input type="email" ' +
' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
- ' ng-required=" ' + (att.mandatory || att.unique) + '"> ';
+ commonInputFieldProperty + ' >';
}
else {
newInputField = '<input type="text" ' +
- ' name="' + fieldName + '"' +
- ' element-id="' + i + '"' +
- this.getAttributesAsString(attributes) +
- ' d2-validation ' +
- ' d2-focus-next-on-enter' +
- ' ng-model="selectedTei.' + attId + '" ' +
- ' ng-disabled="editingDisabled"' +
' ng-blur="validationAndSkipLogic(selectedTei,\'' + attId + '\')" ' +
- ' ng-required=" ' + (att.mandatory || att.unique) + '"> ';
+ commonInputFieldProperty + ' >';
}
}
}