Skip to content

Commit 27573e6

Browse files
authored
RA-1857: appConfig to always provide dateFormat and JSDateFormat.
1 parent b66a48e commit 27573e6

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

omod/src/main/java/org/openmrs/module/coreapps/fragment/controller/program/ProgramHistoryFragmentController.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,12 @@
77
import org.openmrs.Patient;
88
import org.openmrs.PatientProgram;
99
import org.openmrs.Program;
10+
import org.openmrs.api.AdministrationService;
1011
import org.openmrs.api.ProgramWorkflowService;
1112
import org.openmrs.api.context.Context;
1213
import org.openmrs.module.appframework.domain.AppDescriptor;
1314
import org.openmrs.module.emrapi.patient.PatientDomainWrapper;
15+
import org.openmrs.ui.framework.UiFrameworkConstants;
1416
import org.openmrs.ui.framework.annotation.FragmentParam;
1517
import org.openmrs.ui.framework.annotation.InjectBeans;
1618
import org.openmrs.ui.framework.annotation.SpringBean;
@@ -25,7 +27,9 @@
2527
public class ProgramHistoryFragmentController {
2628

2729
public void controller(FragmentConfiguration config, @FragmentParam("app") AppDescriptor app, @InjectBeans PatientDomainWrapper patientWrapper,
28-
@SpringBean("programWorkflowService") ProgramWorkflowService programWorkflowService) throws IOException {
30+
@SpringBean("programWorkflowService") ProgramWorkflowService programWorkflowService,
31+
@SpringBean("adminService")AdministrationService adminService
32+
) throws IOException {
2933

3034
ObjectMapper mapper = new ObjectMapper();
3135

@@ -51,6 +55,13 @@ public void controller(FragmentConfiguration config, @FragmentParam("app") AppDe
5155
ObjectNode appConfig = app.getConfig();
5256
appConfig.put("patientUuid", patientWrapper.getPatient().getUuid());
5357

58+
if (appConfig.get("dateFormat") == null) {
59+
appConfig.put("dateFormat", adminService.getGlobalProperty(UiFrameworkConstants.GP_FORMATTER_DATE_FORMAT, "yyyy-MM-dd"));
60+
}
61+
if (appConfig.get("JSDateFormat") == null) {
62+
appConfig.put("JSDateFormat", adminService.getGlobalProperty(UiFrameworkConstants.GP_FORMATTER_JS_DATE_FORMAT, "YYYY-MMM-DD"));
63+
}
64+
5465
if (appConfig.get("program") == null || StringUtils.isEmpty(appConfig.get("program").getTextValue())) {
5566
throw new MissingPropertyException("Program must be specified");
5667
}
@@ -82,6 +93,7 @@ public void controller(FragmentConfiguration config, @FragmentParam("app") AppDe
8293
Map<String, Object> appConfigMap = mapper.convertValue(appConfig, Map.class);
8394
config.merge(appConfigMap);
8495
config.addAttribute("programJson", programJson);
96+
8597
}
8698

8799
}

0 commit comments

Comments
 (0)