Skip to content

Commit

Permalink
Merge pull request #140 from OpenSRP/feature/fix_popup_constraints
Browse files Browse the repository at this point in the history
Move popup constraints check from the main page
  • Loading branch information
dubdabasoduba authored Feb 14, 2019
2 parents 0b65b25 + b80a4b8 commit 826bec3
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -242,11 +242,9 @@ public void writeValue(String stepName, String key, String value, String openMrs
@Override
public void writeValue(String stepName, String parentKey, String childObjectKey, String childKey, String value,
String openMrsEntityParent, String openMrsEntity, String openMrsEntityId, boolean popup)
throws JSONException {
throws JSONException {
if (invokeRefreshLogic(stepName, parentKey, childKey, value)) {

cacheFormMapValues(stepName, parentKey, childKey, value);

checkBoxWriteValue(stepName, parentKey, childObjectKey, childKey, value, popup);

}
Expand All @@ -257,9 +255,7 @@ public void writeValue(String stepName, String key, String value, String openMrs
String openMrsEntityId) throws JSONException {

if (invokeRefreshLogic(stepName, null, key, value)) {

cacheFormMapValues(stepName, null, key, value);

widgetsWriteValue(stepName, key, value, openMrsEntityParent, openMrsEntity, openMrsEntityId, false);
}
}
Expand All @@ -268,9 +264,7 @@ public void writeValue(String stepName, String key, String value, String openMrs
public void writeValue(String stepName, String parentKey, String childObjectKey, String childKey, String value,
String openMrsEntityParent, String openMrsEntity, String openMrsEntityId) throws JSONException {
if (invokeRefreshLogic(stepName, parentKey, childKey, value)) {

cacheFormMapValues(stepName, parentKey, childKey, value);

checkBoxWriteValue(stepName, parentKey, childObjectKey, childKey, value, false);

}
Expand Down Expand Up @@ -356,7 +350,7 @@ private boolean checkPopUpValidity(String[] curKey, boolean popup) throws JSONEx
public void invokeRefreshLogic(String value, boolean popup, String parentKey, String childKey) {
refreshCalculationLogic(parentKey, childKey, popup);
refreshSkipLogic(parentKey, childKey, popup);
refreshConstraints(parentKey, childKey);
refreshConstraints(parentKey, childKey, popup);
refreshMediaLogic(parentKey, value);
}

Expand Down Expand Up @@ -724,7 +718,7 @@ private void setReadOnlyAndFocus(View view, boolean visible, boolean popup) {
* @param childKey
*/
@Override
public void refreshConstraints(String parentKey, String childKey) {
public void refreshConstraints(String parentKey, String childKey, boolean popup) {
initComparisons();

// Priorities constraints on the view that has just been changed
Expand All @@ -734,13 +728,13 @@ public void refreshConstraints(String parentKey, String childKey) {
}

if (changedViewKey != null && (constrainedViews != null && constrainedViews.containsKey(changedViewKey))) {
checkViewConstraints(constrainedViews.get(changedViewKey), false);
checkViewConstraints(constrainedViews.get(changedViewKey), popup);
}

for (View curView : constrainedViews.values()) {
String viewKey = getViewKey(curView);
if (changedViewKey == null || (!TextUtils.isEmpty(viewKey) && !viewKey.equals(changedViewKey))) {
checkViewConstraints(curView, false);
checkViewConstraints(curView, popup);
}
}
}
Expand Down Expand Up @@ -1153,7 +1147,6 @@ private void infoDialog(String mediatype, String medialink, String mediatext) {
* @param value {@link String} The value to be checked
* @param view {@link View} The value to be checked
* @param constraint {@link JSONObject} The constraint expression to use
*
* @return An error message if constraint has not been enforced or NULL if constraint enforced
* @throws Exception
*/
Expand Down Expand Up @@ -1234,7 +1227,6 @@ protected JSONArray fetchFields(JSONObject parentJson, boolean popup) {
*
* @param sectionJson
* @param popup
*
* @return
* @throws JSONException
* @author dubdabasoduba
Expand Down Expand Up @@ -1269,7 +1261,6 @@ protected JSONArray returnFormWithSectionFields(JSONObject sectionJson, boolean
*
* @param parentJson
* @param popup
*
* @return fields
* @throws JSONException
* @author dubdabasoduba
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void writeMetaDataValue(String metaDataKey, Map<String, String> values)

JSONObject getObjectUsingAddress(String[] address, boolean popup) throws JSONException;

void refreshConstraints(String parentKey, String childKey);
void refreshConstraints(String parentKey, String childKey, boolean popup);

void addOnActivityResultListener(Integer requestCode, OnActivityResultListener onActivityResultListener);

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION_NAME=1.4.7-SNAPSHOT
VERSION_NAME=1.4.8-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Native Form Json Wizard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,31 @@
}
}
},
{
"key": "Birth_Weight",
"openmrs_entity_parent": "",
"openmrs_entity": "concept",
"openmrs_entity_id": "5916AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"openmrs_data_type": "text",
"type": "edit_text",
"hint": "Birth weight (kg) *",
"v_min": {
"value": "0.1",
"err": "Weight must be greater than 0"
},
"v_max": {
"value": "200",
"err": "Weight must be less than 200"
},
"v_numeric_integer": {
"value": "true",
"err": "Enter a valid weight"
},
"v_required": {
"value": "true",
"err": "Enter the child's birth weight"
}
},
{
"key": "respiratory_exam_radio_button",
"openmrs_entity_parent": "",
Expand Down

0 comments on commit 826bec3

Please sign in to comment.