Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set hidden raw val tag with injected JSON values #388

Merged
merged 18 commits into from
Mar 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ language: android
# Setting sudo to required prevents Travis from testing the project in a Docker container.
sudo: required
jdk: oraclejdk8
dist: precise
dist: trusty

before_cache:
-rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
Expand Down Expand Up @@ -36,19 +36,19 @@ android:
- android-28

licenses:
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'
- 'android-sdk-preview-license-.+'
- 'android-sdk-license-.+'
- 'google-gdk-license-.+'

script:
- echo "Travis branch is $TRAVIS_BRANCH"
- echo "Travis branch is in pull request $TRAVIS_PULL+REQUEST"
- chmod 755 gradlew
- ls -la

- travis_wait ./gradlew clean --stacktrace
#Run All tests Unit and Instrumentation
- travis_wait ./gradlew :android-json-form-wizard:jacocoTestReport coveralls --stacktrace

- travis_wait ./gradlew :android-json-form-wizard:jacocoTestReport --stacktrace
- travis_wait ./gradlew :android-json-form-wizard:coveralls
# Generate javadoc
- travis_wait ./gradlew javadoc

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,10 @@ public synchronized void afterTextChanged(Editable editable) {
String openMrsEntity = (String) mView.getTag(R.id.openmrs_entity);
String openMrsEntityId = (String) mView.getTag(R.id.openmrs_entity_id);
Boolean popup = (Boolean) mView.getTag(R.id.extraPopup);
popup = popup == null ? false : popup; // Handle nulls as a result of injected values
ValidationStatus validationStatus = JsonFormFragmentPresenter.validate(formFragment, mView,
false);
if(validationStatus.isValid()) {
if (validationStatus.isValid()) {
try {
api.writeValue(mStepName, key, text, openMrsEntityParent, openMrsEntity,
openMrsEntityId, popup);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.vijay.jsonwizard.interfaces.FormWidgetFactory;
import com.vijay.jsonwizard.interfaces.JsonApi;

import org.apache.commons.lang3.StringUtils;
import org.json.JSONArray;
import org.json.JSONObject;

Expand Down Expand Up @@ -79,6 +80,7 @@ protected void attachJson(String stepName, Context context, JsonFormFragment for
hiddenText.setVisibility(View.GONE);

hiddenText.addTextChangedListener(new GenericTextWatcher(stepName, formFragment, hiddenText));

if (!TextUtils.isEmpty(relevance) && context instanceof JsonApi) {
hiddenText.setTag(R.id.relevance, relevance);
((JsonApi) context).addSkipLogicView(hiddenText);
Expand All @@ -93,6 +95,13 @@ protected void attachJson(String stepName, Context context, JsonFormFragment for
hiddenText.setTag(R.id.calculation, calculation);
((JsonApi) context).addCalculationLogicView(hiddenText);
}

// Handle setting injected value (if exists) after attaching listener so that changes can be
// effected by the listener and calculations applied
String value = jsonObject.optString(JsonFormConstants.VALUE);
if (StringUtils.isNotBlank(value)) {
hiddenText.setText(value);
}
}

protected int getLayout() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ public void testNumericDatePickerSetMaxValueThrowsExceptionDateMoreThanMax() {
Assert.assertEquals(maxTimeStamp, datePicker.getMaxDate());

//Try set a date outside max

Date dateTwoYearsFromToday = localDate.plusDays(10).toDate();
Date dateTwoYearsFromToday = localDate.plusYears(2).toDate();
datePicker.setDate(dateTwoYearsFromToday);
}

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.7.26-SNAPSHOT
VERSION_NAME=1.7.27-SNAPSHOT
VERSION_CODE=1
GROUP=org.smartregister
POM_SETTING_DESCRIPTION=OpenSRP Client Native Form Json Wizard
Expand Down