dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #39446
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19967: event-capture: some refactoring; type -> valueType - WIP
------------------------------------------------------------
revno: 19967
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-09-03 15:13:08 +0200
message:
event-capture: some refactoring; type -> valueType - WIP
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js
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-apps/src/main/webapp/dhis-web-event-capture/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html 2015-06-15 12:08:18 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html 2015-09-03 13:13:08 +0000
@@ -70,7 +70,7 @@
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.js"></script>
<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js"></script>
- <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>
+ <!--<script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>-->
<script type="text/javascript" src="../dhis-web-commons/ouwt/ouwt.js"></script>
<script type="text/javascript" src="scripts/event-capture.js"></script>
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-09-03 10:36:07 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js 2015-09-03 13:13:08 +0000
@@ -16,7 +16,6 @@
orderByFilter,
SessionStorageService,
Paginator,
- OptionSetService,
MetaDataFactory,
ProgramFactory,
DHIS2EventFactory,
@@ -30,6 +29,7 @@
CurrentSelection,
ModalService,
DialogService,
+ CommonUtils,
AuthorityService,
TrackerRulesExecutionService,
TrackerRulesFactory) {
@@ -189,9 +189,14 @@
showFilter: false,
show: prStDe.displayInReports});
- $scope.filterTypes[prStDe.dataElement.id] = prStDe.dataElement.type;
+ $scope.filterTypes[prStDe.dataElement.id] = prStDe.dataElement.valueType;
- if(prStDe.dataElement.type === 'date' || prStDe.dataElement.type === 'int' ){
+ if(prStDe.dataElement.type === 'DATE' ||
+ prStDe.dataElement.type === 'NUMBER' ||
+ prStDe.dataElement.type === 'INTEGER' ||
+ prStDe.dataElement.type === 'INTEGER_POSITIVE' ||
+ prStDe.dataElement.type === 'INTEGER_NEGATIVE' ||
+ prStDe.dataElement.type === 'INTEGER_ZERO_OR_POSITIVE'){
$scope.filterText[prStDe.dataElement.id]= {};
}
});
@@ -260,46 +265,13 @@
//converting event.datavalues[i].datavalue.dataelement = value to
//event[dataElement] = value for easier grid display.
- if($scope.prStDes[dataValue.dataElement]){
-
- var val = dataValue.value;
- if(angular.isObject($scope.prStDes[dataValue.dataElement].dataElement)){
-
- //converting int string value to number for proper sorting.
- if($scope.prStDes[dataValue.dataElement].dataElement.type === 'int'){
- if( dhis2.validation.isNumber(val) ){
- //val = new Number(val);
- val = parseFloat(val, 10);
- }
- }
- if($scope.prStDes[dataValue.dataElement].dataElement.optionSetValue){
- if($scope.prStDes[dataValue.dataElement].dataElement.optionSet &&
- $scope.prStDes[dataValue.dataElement].dataElement.optionSet.id &&
- $scope.optionSets[$scope.prStDes[dataValue.dataElement].dataElement.optionSet.id] &&
- $scope.optionSets[$scope.prStDes[dataValue.dataElement].dataElement.optionSet.id].options ){
- val = OptionSetService.getName($scope.optionSets[$scope.prStDes[dataValue.dataElement].dataElement.optionSet.id].options, val);
- }
- }
- if($scope.prStDes[dataValue.dataElement].dataElement.type === 'date'){
- val = DateUtils.formatFromApiToUser(val);
- }
-
- if($scope.prStDes[dataValue.dataElement].dataElement.type === 'bool'){
- val = val === 'true' ? $scope.yesLabel : $scope.noLabel;
- }
-
- if( $scope.prStDes[dataValue.dataElement].dataElement.type === 'trueOnly'){
- if(val === 'true'){
- val = true;
- }
- else{
- val = false;
- }
- }
+ if($scope.prStDes[dataValue.dataElement]){
+ var val = dataValue.value;
+ if(angular.isObject($scope.prStDes[dataValue.dataElement].dataElement)){
+ val = CommonUtils.formatDataValue(val, $scope.prStDes[dataValue.dataElement].dataElement, $scope.optionSets, 'USER');
}
$scope.dhis2Events[i][dataValue.dataElement] = val;
}
-
});
$scope.dhis2Events[i]['uid'] = $scope.dhis2Events[i].event;
@@ -520,16 +492,8 @@
for(var dataElement in $scope.prStDes){
var val = $scope.currentEvent[dataElement];
if(val){
- valueExists = true;
- if($scope.prStDes[dataElement].dataElement.optionSetValue){
- if($scope.prStDes[dataElement].dataElement.optionSet){
- val = OptionSetService.getCode($scope.optionSets[$scope.prStDes[dataElement].dataElement.optionSet.id].options,val);
- }
- }
-
- if($scope.prStDes[dataElement].dataElement.type === 'date'){
- val = DateUtils.formatFromUserToApi(val);
- }
+ valueExists = true;
+ val = CommonUtils.formatDataValue(val, $scope.prStDes[dataElement].dataElement, $scope.optionSets, 'API');
}
dataValues.push({dataElement: dataElement, value: val});
}
@@ -564,7 +528,7 @@
dhis2Event.event = newEvent['uid'];
}
- if(!angular.isUndefined($scope.note.value) && $scope.note.value != ''){
+ if(!angular.isUndefined($scope.note.value) && $scope.note.value !== ''){
dhis2Event.notes = [{value: $scope.note.value}];
newEvent.notes = [{value: $scope.note.value, storedDate: $scope.today, storedBy: storedBy}];
@@ -644,16 +608,8 @@
//the form is valid, get the values
var dataValues = [];
for(var dataElement in $scope.prStDes){
- var val = $scope.currentEvent[dataElement];
-
- if(val && $scope.prStDes[dataElement].dataElement.optionSetValue){
- if($scope.prStDes[dataElement].dataElement.optionSet){
- val = OptionSetService.getCode($scope.optionSets[$scope.prStDes[dataElement].dataElement.optionSet.id].options,val);
- }
- }
- if(val && $scope.prStDes[dataElement].dataElement.type === 'date'){
- val = DateUtils.formatFromUserToApi(val);
- }
+ var val = $scope.currentEvent[dataElement];
+ val = CommonUtils.formatDataValue(val, $scope.prStDes[dataElement].dataElement, $scope.optionSets, 'API');
dataValues.push({dataElement: dataElement, value: val});
}
@@ -672,7 +628,7 @@
longitude: $scope.currentEvent.coordinate.longitude ? $scope.currentEvent.coordinate.longitude : ''};
}
- if(!angular.isUndefined($scope.note.value) && $scope.note.value != ''){
+ if(!angular.isUndefined($scope.note.value) && $scope.note.value !== ''){
updatedEvent.notes = [{value: $scope.note.value}];
@@ -724,17 +680,8 @@
return;
}
- if( newValue != oldValue ){
-
- if($scope.prStDes[dataElement].dataElement.optionSetValue){
- if($scope.prStDes[dataElement].dataElement.optionSet){
- newValue = OptionSetService.getCode($scope.optionSets[$scope.prStDes[dataElement].dataElement.optionSet.id].options, newValue);
- }
- }
- if($scope.prStDes[dataElement].dataElement.type === 'date'){
- newValue = DateUtils.formatFromUserToApi(newValue);
- }
-
+ if( newValue !== oldValue ){
+ newValue = CommonUtils.formatDataValue(newValue, $scope.prStDes[dataElement].dataElement, $scope.optionSets, 'API');
var updatedSingleValueEvent = {event: $scope.currentEvent.event, dataValues: [{value: newValue, dataElement: dataElement}]};
var updatedFullValueEvent = DHIS2EventService.reconstructEvent($scope.currentEvent, $scope.selectedProgramStage.programStageDataElements);
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2015-09-03 10:36:07 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/defaultForm.html 2015-09-03 13:13:08 +0000
@@ -74,44 +74,44 @@
{{eventGridColumn.name}} - {{eventGridColumn.valueType}}<span ng-if="eventGridColumn.compulsory" class="required">*</span>
</td>
<td >
- <ng-form name="innerForm">
- <div ng-switch="eventGridColumn.valueType">
- <div ng-switch-when="OPTION_SET">
- <div ng-if="!selectedProgram.dataEntryMethod || optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options.length >= 7">
- <ui-select ng-model="currentEvent[eventGridColumn.id]"
- theme="select2"
- ng-required={{eventGridColumn.compulsory}}
- name="foo"
- input-field-id={{eventGridColumn.id}}
- on-select={{saveDatavalue()}}
- class='form-control'>
- <ui-select-match allow-clear="true" class="form-control" placeholder="{{'select_or_search' | translate}}">{{$select.selected.name || $select.selected}}</ui-select-match>
- <ui-select-choices repeat="option.name as option in optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options | filter: $select.search | limitTo:30">
- <span ng-bind-html="option.name | highlight: $select.search"></span>
- </ui-select-choices>
- </ui-select>
- </div>
- <div ng-if="selectedProgram.dataEntryMethod && optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options.length < 7">
- <label>
- <input type="radio"
- name="foo"
- input-field-id={{eventGridColumn.id}}
- ng-change="saveDatavalue()"
- ng-required={{eventGridColumn.compulsory}}
- ng-model="currentEvent[eventGridColumn.id]"
- value=""> {{'no_value' | translate}}<br>
- </label>
- <label ng-repeat="option in optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options">
- <input type="radio"
- name={{eventGridColumn.id}}
- input-field-id={{eventGridColumn.id}}
- ng-change="saveDatavalue()"
- ng-required={{eventGridColumn.compulsory}}
- ng-model="currentEvent[eventGridColumn.id]"
- value={{option.name}}> {{option.name}}<br>
- </label>
- </div>
+ <ng-form name="innerForm">
+ <div ng-if="prStDes[eventGridColumn.id].dataElement.optionSetValue">
+ <div ng-if="!selectedProgram.dataEntryMethod || optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options.length >= 7">
+ <ui-select ng-model="currentEvent[eventGridColumn.id]"
+ theme="select2"
+ ng-required={{eventGridColumn.compulsory}}
+ name="foo"
+ input-field-id={{eventGridColumn.id}}
+ on-select={{saveDatavalue()}}
+ class='form-control'>
+ <ui-select-match allow-clear="true" class="form-control" placeholder="{{'select_or_search' | translate}}">{{$select.selected.name || $select.selected}}</ui-select-match>
+ <ui-select-choices repeat="option.name as option in optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options | filter: $select.search | limitTo:30">
+ <span ng-bind-html="option.name | highlight: $select.search"></span>
+ </ui-select-choices>
+ </ui-select>
+ </div>
+ <div ng-if="selectedProgram.dataEntryMethod && optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options.length < 7">
+ <label>
+ <input type="radio"
+ name="foo"
+ input-field-id={{eventGridColumn.id}}
+ ng-change="saveDatavalue()"
+ ng-required={{eventGridColumn.compulsory}}
+ ng-model="currentEvent[eventGridColumn.id]"
+ value=""> {{'no_value' | translate}}<br>
+ </label>
+ <label ng-repeat="option in optionSets[prStDes[eventGridColumn.id].dataElement.optionSet.id].options">
+ <input type="radio"
+ name={{eventGridColumn.id}}
+ input-field-id={{eventGridColumn.id}}
+ ng-change="saveDatavalue()"
+ ng-required={{eventGridColumn.compulsory}}
+ ng-model="currentEvent[eventGridColumn.id]"
+ value={{option.name}}> {{option.name}}<br>
+ </label>
</div>
+ </div>
+ <div ng-if="!prStDes[eventGridColumn.id].dataElement.optionSetValue" ng-switch="eventGridColumn.valueType">
<div ng-switch-when="NUMBER">
<input type="number"
d2-number-validator
@@ -333,49 +333,48 @@
<tbody>
<tr ng-repeat="de in section.programStageDataElements" ng-if="!isHidden(de.dataElement.id)">
<td >
- {{prStDes[de.dataElement.id].dataElement.formName ? prStDes[de.dataElement.id].dataElement.formName : prStDes[de.dataElement.id].dataElement.name}}
- {{prStDes[de.dataElement.id].dataElement.valueType}}
+ {{prStDes[de.dataElement.id].dataElement.formName ? prStDes[de.dataElement.id].dataElement.formName : prStDes[de.dataElement.id].dataElement.name}}
<span ng-if="prStDes[de.dataElement.id].compulsory" class="required">*</span>
</td>
<td >
- <ng-form name="innerForm">
- <div ng-switch="prStDes[de.dataElement.id].dataElement.valueType">
- <div ng-switch-when="OPTION_SET">
- <div ng-if="!selectedProgram.dataEntryMethod || optionSets[prStDes[de.dataElement.id].dataElement.optionSet.id].options.length >= 7">
- <ui-select ng-model="currentEvent[de.dataElement.id]"
- theme="select2"
- ng-required={{prStDes[de.dataElement.id].compulsory}}
- name="foo"
- input-field-id={{de.dataElement.id}}
- on-select={{saveDatavalue()}}
- class='form-control'>
- <ui-select-match allow-clear="true" class="form-control" placeholder="{{'select_or_search' | translate}}">{{$select.selected.name || $select.selected}}</ui-select-match>
- <ui-select-choices repeat="option.name as option in optionSets[prStDes[de.dataElement.id].dataElement.optionSet.id].options | filter: $select.search | limitTo:30">
- <span ng-bind-html="option.name | highlight: $select.search"></span>
- </ui-select-choices>
- </ui-select>
- </div>
- <div ng-if="selectedProgram.dataEntryMethod && prStDes[de.dataElement.id].dataElement.optionSet.options.length < 7">
- <label>
- <input type="radio"
- name="foo"
- input-field-id={{de.dataElement.id}}
- ng-change="saveDatavalue()"
- ng-required={{prStDes[de.dataElement.id].compulsory}}
- ng-model="currentEvent[de.dataElement.id]"
- value="">{{'no_value' | translate}}<br>
- </label>
- <label ng-repeat="option in optionSets[prStDes[de.dataElement.id].dataElement.optionSet.id].options">
- <input type="radio"
- name={{de.dataElement.id}}
- input-field-id={{de.dataElement.id}}
- ng-change="saveDatavalue()"
- ng-required={{prStDes[de.dataElement.id].compulsory}}
- ng-model="currentEvent[de.dataElement.id]"
- value={{option.name}}> {{option.name}}<br>
- </label>
- </div>
- </div>
+ <ng-form name="innerForm">
+ <div ng-if="prStDes[de.dataElement.id].dataElement.optionSetValue">
+ <span ng-if="!selectedProgram.dataEntryMethod || optionSets[prStDes[de.dataElement.id].dataElement.optionSet.id].options.length > 8">
+ <ui-select ng-model="currentEvent[de.dataElement.id]"
+ theme="select2"
+ ng-required={{prStDes[de.dataElement.id].compulsory}}
+ name="foo"
+ input-field-id={{de.dataElement.id}}
+ on-select={{saveDatavalue()}}
+ class='form-control'>
+ <ui-select-match allow-clear="true" class="form-control" placeholder="{{'select_or_search' | translate}}">{{$select.selected.name || $select.selected}}</ui-select-match>
+ <ui-select-choices repeat="option.name as option in optionSets[prStDes[de.dataElement.id].dataElement.optionSet.id].options | filter: $select.search | limitTo:30">
+ <span ng-bind-html="option.name | highlight: $select.search"></span>
+ </ui-select-choices>
+ </ui-select>
+ </span>
+ <span ng-if="selectedProgram.dataEntryMethod && prStDes[de.dataElement.id].dataElement.optionSet.options.length < 7">
+ <label>
+ <input type="radio"
+ name="foo"
+ input-field-id={{de.dataElement.id}}
+ ng-change="saveDatavalue()"
+ ng-required={{prStDes[de.dataElement.id].compulsory}}
+ ng-model="currentEvent[de.dataElement.id]"
+ value="">{{'no_value' | translate}}<br>
+ </label>
+ <label ng-repeat="option in optionSets[prStDes[de.dataElement.id].dataElement.optionSet.id].options">
+ <input type="radio"
+ name={{de.dataElement.id}}
+ input-field-id={{de.dataElement.id}}
+ ng-change="saveDatavalue()"
+ ng-required={{prStDes[de.dataElement.id].compulsory}}
+ ng-model="currentEvent[de.dataElement.id]"
+ value={{option.name}}> {{option.name}}<br>
+ </label>
+ </span>
+ </div>
+ <div ng-if="!prStDes[de.dataElement.id].dataElement.optionSetValue" ng-switch="prStDes[de.dataElement.id].dataElement.valueType">
<div ng-switch-when="NUMBER">
<input type="number"
d2-number-validator
=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-08-25 21:48:10 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js 2015-09-03 13:13:08 +0000
@@ -1560,7 +1560,7 @@
};
})
-.service('EventUtils', function(DateUtils, PeriodService, CalendarService, OptionSetService, $filter, orderByFilter){
+.service('EventUtils', function(DateUtils, CommonUtils, PeriodService, CalendarService, OptionSetService, $filter, orderByFilter){
var getEventDueDate = function(eventsByStage, programStage, enrollment){
@@ -1597,45 +1597,6 @@
return dueDate;
};
- function formatDataElementValue(val, dataElement, optionSets, destination){
-
- if(val && dataElement.type === 'int' ){
- if( dhis2.validation.isNumber(val) ){
- val = parseInt(val);
- //val = new Number(val);
- }
- }
- if(val && dataElement.optionSetValue && optionSets[dataElement.optionSet.id].options ){
- if(destination === 'USER'){
- val = OptionSetService.getName(optionSets[dataElement.optionSet.id].options, val);
- }
- else{
- val = OptionSetService.getCode(optionSets[dataElement.optionSet.id].options, val);
- }
-
- }
- if(val && dataElement.type === 'date'){
- if(destination === 'USER'){
- val = DateUtils.formatFromApiToUser(val);
- }
- else{
- val = DateUtils.formatFromUserToApi(val);
- }
- }
- if(dataElement.type === 'trueOnly'){
-
- if(destination === 'USER'){
- val = val === 'true' ? true : '';
- }
- else{
- val = val === true ? 'true' : '';
- }
- }
-
- return val;
-
- };
-
var getEventDuePeriod = function(eventsByStage, programStage, enrollment){
var evs = [];
@@ -1776,7 +1737,7 @@
angular.forEach(programStage.programStageDataElements, function(prStDe){
if(dhis2Event[prStDe.dataElement.id]){
- var value = formatDataElementValue(dhis2Event[prStDe.dataElement.id], prStDe.dataElement, optionSets, 'API');
+ var value = CommonUtils.formatDataValue(dhis2Event[prStDe.dataElement.id], prStDe.dataElement, optionSets, 'API');
var val = {value: value, dataElement: prStDe.dataElement.id};
if(dhis2Event.providedElsewhere[prStDe.dataElement.id]){
val.providedElsewhere = dhis2Event.providedElsewhere[prStDe.dataElement.id];
@@ -1805,7 +1766,7 @@
if( prStDe ){
var val = dataValue.value;
if(prStDe.dataElement){
- val = formatDataElementValue(val, prStDe.dataElement, optionSets, 'USER');
+ val = CommonUtils.formatDataValue(val, prStDe.dataElement, optionSets, 'USER');
}
event[dataValue.dataElement] = val;
if(dataValue.providedElsewhere){
=== 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-08-27 19:05:47 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js 2015-09-03 13:13:08 +0000
@@ -216,6 +216,78 @@
};
})
+/* Service for option name<->code conversion */
+.factory('OptionSetService', function() {
+ return {
+ getCode: function(options, key){
+ if(options){
+ for(var i=0; i<options.length; i++){
+ if( key === options[i].name){
+ return options[i].code;
+ }
+ }
+ }
+ return key;
+ },
+ getName: function(options, key){
+ if(options){
+ for(var i=0; i<options.length; i++){
+ if( key === options[i].code){
+ return options[i].name;
+ }
+ }
+ }
+ return key;
+ }
+ };
+})
+
+/* service for common utils */
+.service('CommonUtils', function(DateUtils, OptionSetService){
+
+ return {
+ formatDataValue: function(val, obj, optionSets, destination){
+ if(val &&
+ obj.valueType === 'NUMBER' ||
+ obj.valueType === 'INTEGER' ||
+ obj.valueType === 'INTEGER_POSITIVE' ||
+ obj.valueType === 'INTEGER_NEGATIVE' ||
+ obj.valueType === 'INTEGER_ZERO_OR_POSITIVE'){
+ if( dhis2.validation.isNumber(val) ){
+ val = parseInt(val);
+ }
+ }
+ if(val && obj.optionSetValue && obj.optionSet && obj.optionSet.id && optionSets[obj.optionSet.id].options ){
+ if(destination === 'USER'){
+ val = OptionSetService.getName(optionSets[obj.optionSet.id].options, val);
+ }
+ else{
+ val = OptionSetService.getCode(optionSets[obj.optionSet.id].options, val);
+ }
+
+ }
+ if(val && obj.valueType === 'DATE'){
+ if(destination === 'USER'){
+ val = DateUtils.formatFromApiToUser(val);
+ }
+ else{
+ val = DateUtils.formatFromUserToApi(val);
+ }
+ }
+ if(obj.valueType === 'TRUE_ONLY'){
+
+ if(destination === 'USER'){
+ val = val === 'true' ? true : '';
+ }
+ else{
+ val = val === true ? 'true' : '';
+ }
+ }
+ return val;
+ }
+ };
+})
+
/* service for dealing with custom form */
.service('CustomFormService', function ($translate) {