Skip to content

Commit

Permalink
LMH1-73: Allow config for form started in family profile
Browse files Browse the repository at this point in the history
Upgrade native forms to 1.14.5.5.2-TEST-SNAPSHOT
[draft commit] Please edit
  • Loading branch information
LZRS committed Oct 28, 2021
1 parent e18d335 commit 5e5f5ab
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 15 deletions.
2 changes: 1 addition & 1 deletion opensrp-chw-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ dependencies {
exclude group: 'xpp3', module: 'xpp3'
}

api('org.smartregister:opensrp-client-native-form:1.14.5.5.1-SNAPSHOT@aar') {
api('org.smartregister:opensrp-client-native-form:1.14.5.5.2-TEST-SNAPSHOT@aar') {
transitive = true
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.android.support', module: 'cardview-v7'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.vijay.jsonwizard.domain.Form;

import org.jeasy.rules.api.Rules;
import org.joda.time.LocalDate;
import org.joda.time.Months;
Expand Down Expand Up @@ -109,9 +111,17 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}

public Form getForm(){
Form form = new Form();
form.setActionBarBackground(R.color.family_actionbar);
form.setWizard(false);
return form;
}

public void startFormActivity(JSONObject formJson) {
startActivityForResult(CoreJsonFormUtils.getJsonIntent(this, formJson,
Utils.metadata().familyMemberFormActivity), JsonFormUtils.REQUEST_CODE_GET_JSON);
startActivityForResult(
CoreJsonFormUtils.getJsonIntent(this, formJson,Utils.metadata().familyMemberFormActivity, getForm()),
JsonFormUtils.REQUEST_CODE_GET_JSON);
}

// to chw
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import androidx.viewpager.widget.ViewPager;

import com.google.android.material.appbar.AppBarLayout;
import com.vijay.jsonwizard.domain.Form;

import org.apache.commons.lang3.tuple.Triple;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -323,10 +324,18 @@ public Context getContext() {
return this;
}

public Form getForm(){
Form form = new Form();
form.setActionBarBackground(R.color.family_actionbar);
form.setWizard(false);
return form;
}

@Override
public void startFormActivity(JSONObject jsonForm) {
startActivityForResult(CoreJsonFormUtils.getJsonIntent(this, jsonForm,
Utils.metadata().familyMemberFormActivity), JsonFormUtils.REQUEST_CODE_GET_JSON);
startActivityForResult(
CoreJsonFormUtils.getJsonIntent(this, jsonForm,Utils.metadata().familyMemberFormActivity, getForm()),
JsonFormUtils.REQUEST_CODE_GET_JSON);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,19 @@ protected abstract BaseProfileContract.Presenter getFamilyOtherMemberActivityPre

protected abstract CoreFamilyMemberFloatingMenu getFamilyMemberFloatingMenu();

public Form getForm(){
Form form = new Form();
form.setActionBarBackground(R.color.family_actionbar);
form.setWizard(false);
return form;
}

public void startFormActivity(JSONObject jsonForm) {

Intent intent = new Intent(this, Utils.metadata().familyMemberFormActivity);
intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString());


Form form = new Form();
form.setActionBarBackground(R.color.family_actionbar);
form.setWizard(false);
intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, form);
intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, getForm());

startActivityForResult(intent, JsonFormUtils.REQUEST_CODE_GET_JSON);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.vijay.jsonwizard.constants.JsonFormConstants;
import com.vijay.jsonwizard.domain.Form;

import org.apache.commons.lang3.StringUtils;
import org.greenrobot.eventbus.EventBus;
import org.json.JSONObject;
Expand Down Expand Up @@ -278,6 +281,23 @@ public void updateHasPhone(boolean hasPhone) {
}
}

public Form getFormConfig(){
Form form = new Form();
form.setActionBarBackground(R.color.family_actionbar);
form.setWizard(false);
return form;
}

@Override
public void startFormActivity(JSONObject jsonForm) {
Intent intent = new Intent(this, Utils.metadata().familyMemberFormActivity);
intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString());

intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, getFormConfig());

startActivityForResult(intent, JsonFormUtils.REQUEST_CODE_GET_JSON);
}

@Override
protected void initializePresenter() {
familyBaseEntityId = getIntent().getStringExtra(Constants.INTENT_KEY.FAMILY_BASE_ENTITY_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.vijay.jsonwizard.domain.Form;

import org.json.JSONObject;
import org.smartregister.chw.anc.domain.MemberObject;
import org.smartregister.chw.anc.util.NCUtils;
Expand Down Expand Up @@ -101,10 +103,18 @@ protected static CommonPersonObjectClient getClientDetailsByBaseEntityID(@NonNul
return getCommonPersonObjectClient(baseEntityId);
}

public Form getForm(){
Form form = new Form();
form.setActionBarBackground(R.color.family_actionbar);
form.setWizard(false);
return form;
}

@Override
public void startFormActivity(JSONObject formJson) {
startActivityForResult(CoreJsonFormUtils.getJsonIntent(this, formJson,
org.smartregister.family.util.Utils.metadata().familyMemberFormActivity), JsonFormUtils.REQUEST_CODE_GET_JSON);
startActivityForResult(
CoreJsonFormUtils.getJsonIntent(this, formJson,org.smartregister.family.util.Utils.metadata().familyMemberFormActivity, getForm()),
JsonFormUtils.REQUEST_CODE_GET_JSON);
}

protected List<CommonPersonObjectClient> getChildren(MemberObject memberObject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@ public class CoreJsonFormUtils extends org.smartregister.family.util.JsonFormUti
private static final String LOCATION_UUIDS = "location_uuids";

public static Intent getJsonIntent(Context context, JSONObject jsonForm, Class activityClass) {
Intent intent = new Intent(context, activityClass);
intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString());
Form form = new Form();
form.setActionBarBackground(R.color.family_actionbar);
form.setWizard(false);
intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, form);
return getJsonIntent(context, jsonForm, activityClass, form);
}

public static Intent getJsonIntent(Context context, JSONObject jsonForm, Class activityClass, Form formConfig){
Intent intent = new Intent(context, activityClass);
intent.putExtra(Constants.JSON_FORM_EXTRA.JSON, jsonForm.toString());
intent.putExtra(JsonFormConstants.JSON_FORM_KEY.FORM, formConfig);
return intent;
}

Expand Down

0 comments on commit 5e5f5ab

Please sign in to comment.