Skip to content

Commit

Permalink
fix: [DHIS2-15464] d2:right on numerical strings (#1809)
Browse files Browse the repository at this point in the history
  • Loading branch information
superskip authored Jun 22, 2023
1 parent 31c6e4f commit d422190
Showing 1 changed file with 15 additions and 22 deletions.
37 changes: 15 additions & 22 deletions d2-tracker/dhis2.angular.services.js
Original file line number Diff line number Diff line change
Expand Up @@ -1779,21 +1779,21 @@ var d2Services = angular.module('d2Services', ['ngResource'])
variables = pushVariable(variables, 'environment', 'WebClient',null,'TEXT',true,'V','',false);
variables = pushVariable(variables, 'current_date', DateUtils.getToday(), null, 'DATE', true, 'V', '', false );

variables = pushVariable(variables, 'event_date', executingEvent.eventDate, null, 'DATE', true, 'V', '', false );
variables = pushVariable(variables, 'due_date', executingEvent.dueDate, null, 'DATE', true, 'V', '' );
variables = pushVariable(variables, 'event_date', executingEvent.eventDate, null, 'DATE', !!executingEvent.eventDate, 'V', '', false );
variables = pushVariable(variables, 'due_date', executingEvent.dueDate, null, 'DATE', !!executingEvent.dueDate, 'V', '' );
variables = pushVariable(variables, 'event_count', evs ? evs.all.length : 0, null, 'INTEGER', true, 'V', '', false );

variables = pushVariable(variables, 'enrollment_date', selectedEnrollment ? selectedEnrollment.enrollmentDate : '', null, 'DATE', selectedEnrollment ? selectedEnrollment.enrollmentDate ? true : false : false, 'V', '', false );
variables = pushVariable(variables, 'enrollment_id', selectedEnrollment ? selectedEnrollment.enrollment : '', null, 'TEXT', selectedEnrollment ? true : false, 'V', '', false );
variables = pushVariable(variables, 'event_id', executingEvent ? executingEvent.event : '', null, 'TEXT', executingEvent ? true : false, 'V', executingEvent ? executingEvent.eventDate : false, false);
variables = pushVariable(variables, 'event_status', executingEvent ? executingEvent.status : '', null, 'TEXT', executingEvent ? true : false, 'V', executingEvent ? executingEvent.eventDate : false, false);
variables = pushVariable(variables, 'enrollment_date', selectedEnrollment ? selectedEnrollment.enrollmentDate : '', null, 'DATE', !!(selectedEnrollment && selectedEnrollment.enrollmentDate), 'V', '', false );
variables = pushVariable(variables, 'enrollment_id', selectedEnrollment ? selectedEnrollment.enrollment : '', null, 'TEXT', !!selectedEnrollment, 'V', '', false );
variables = pushVariable(variables, 'event_id', executingEvent ? executingEvent.event : '', null, 'TEXT', !!executingEvent, 'V', executingEvent ? executingEvent.eventDate : false, false);
variables = pushVariable(variables, 'event_status', executingEvent ? executingEvent.status : '', null, 'TEXT', !!executingEvent, 'V', executingEvent ? executingEvent.eventDate : false, false);

variables = pushVariable(variables, 'incident_date', selectedEnrollment ? selectedEnrollment.incidentDate : '', null, 'DATE', selectedEnrollment ? true : false, 'V', '', false);
variables = pushVariable(variables, 'incident_date', selectedEnrollment ? selectedEnrollment.incidentDate : '', null, 'DATE', !!selectedEnrollment, 'V', '', false);
variables = pushVariable(variables, 'enrollment_count', selectedEnrollment ? 1 : 0, null, 'INTEGER', true, 'V', '', false);
variables = pushVariable(variables, 'tei_count', selectedEnrollment ? 1 : 0, null, 'INTEGER', true, 'V', '', false);

variables = pushVariable(variables, 'program_stage_id',(selectedProgramStage && selectedProgramStage.id) || '', null, 'TEXT', selectedProgramStage && selectedProgramStage.id ? true : false, 'V', '', false);
variables = pushVariable(variables, 'program_stage_name',(selectedProgramStage && selectedProgramStage.name) || '', null, 'TEXT', selectedProgramStage && selectedProgramStage.name ? true : false, 'V', '', false);
variables = pushVariable(variables, 'program_stage_id',(selectedProgramStage && selectedProgramStage.id) || '', null, 'TEXT', !!(selectedProgramStage && selectedProgramStage.id), 'V', '', false);
variables = pushVariable(variables, 'program_stage_name',(selectedProgramStage && selectedProgramStage.name) || '', null, 'TEXT', !!(selectedProgramStage && selectedProgramStage.name), 'V', '', false);


//Push all constant values:
Expand All @@ -1802,7 +1802,7 @@ var d2Services = angular.module('d2Services', ['ngResource'])
});

if(selectedOrgUnit){
variables = pushVariable(variables, 'orgunit_code', selectedOrgUnit.code, null, 'TEXT', selectedOrgUnit.code ? true : false, 'V', '', false);
variables = pushVariable(variables, 'orgunit_code', selectedOrgUnit.code, null, 'TEXT', !!selectedOrgUnit.code, 'V', '', false);
}

return variables;
Expand Down Expand Up @@ -2646,22 +2646,15 @@ var d2Services = angular.module('d2Services', ['ngResource'])
},
"d2:concatenate": {
execute: function(parameters) {
var returnString = "'";
for (var i = 0; i < parameters.length; i++) {
returnString += parameters[i];
}
returnString += "'";
return returnString;
return parameters.join('');
},
},
"d2:addDays": {
parameters: 2,
execute: function(parameters) {
var date = $filter('trimquotes')(parameters[0]);
var daystoadd = $filter('trimquotes')(parameters[1]);
var newdate = DateUtils.format( moment(date, CalendarService.getSetting().momentFormat).add(daystoadd, 'days') );
var newdatestring = "'" + newdate + "'";
return newdatestring
return DateUtils.format( moment(date, CalendarService.getSetting().momentFormat).add(daystoadd, 'days') );
},
},
"d2:zing": {
Expand Down Expand Up @@ -2822,7 +2815,7 @@ var d2Services = angular.module('d2Services', ['ngResource'])
execute: function(parameters, variablesHash) {
var variableName = parameters[0];
var variableObject = variablesHash[variableName];
var valueFound = "''";
var valueFound = "";
if(variableObject)
{
if(variableObject.variableEventDate){
Expand Down Expand Up @@ -2937,7 +2930,7 @@ var d2Services = angular.module('d2Services', ['ngResource'])
var startChar = string.length < parameters[1] - 1 ? -1 : parameters[1];
var endChar = string.length < parameters[2] ? -1 : parameters[2];
if(startChar < 0 || endChar < 0) {
return "''";
return "";
}
var returnString = string.substring(startChar, endChar);
returnString = VariableService.processValue(returnString, 'TEXT');
Expand Down Expand Up @@ -3138,7 +3131,7 @@ var d2Services = angular.module('d2Services', ['ngResource'])
accExpression += 'false';
} else {
const dhisFunctionResult = dhisFunction.execute(evaluatedArguments, variablesHash, selectedOrgUnit);
accExpression += dhisFunctionResult;
accExpression += getInjectionValue(dhisFunctionResult);
}

return {
Expand Down

0 comments on commit d422190

Please sign in to comment.