Commit b4bf90c9 by Kunj Gupta

UOFLMA-94: Fix - In Variables form, do not display active=false items.

parent 48819ab5
...@@ -42,6 +42,10 @@ public class CatalogueVariable { ...@@ -42,6 +42,10 @@ public class CatalogueVariable {
@SerializedName("reference_display_column") @SerializedName("reference_display_column")
@Expose @Expose
private String referenceColumnName; private String referenceColumnName;
@SerializedName("Active")
@Expose
private boolean active;
// @SerializedName("type") // @SerializedName("type")
// @Expose // @Expose
...@@ -161,6 +165,14 @@ public class CatalogueVariable { ...@@ -161,6 +165,14 @@ public class CatalogueVariable {
this.referenceColumnName = referenceColumnName; this.referenceColumnName = referenceColumnName;
} }
public boolean isActive() {
return active;
}
public void setActive(boolean active) {
this.active = active;
}
public List<VariableChoice> getVariableChoiceList() { public List<VariableChoice> getVariableChoiceList() {
return mVariableChoiceList; return mVariableChoiceList;
} }
...@@ -228,6 +240,8 @@ public class CatalogueVariable { ...@@ -228,6 +240,8 @@ public class CatalogueVariable {
", isNoneRequired=" + isNoneRequired + ", isNoneRequired=" + isNoneRequired +
", referenceTable='" + referenceTable + '\'' + ", referenceTable='" + referenceTable + '\'' +
", order=" + order + ", order=" + order +
", referenceColumnName='" + referenceColumnName + '\'' +
", active=" + active +
", type=" + type + ", type=" + type +
", mVariableChoiceList=" + mVariableChoiceList + ", mVariableChoiceList=" + mVariableChoiceList +
'}'; '}';
......
...@@ -228,76 +228,79 @@ public class CatalogueVariableScreen extends AppCompatActivity { ...@@ -228,76 +228,79 @@ public class CatalogueVariableScreen extends AppCompatActivity {
if(!mCatalogueVariableList.isEmpty()) { if(!mCatalogueVariableList.isEmpty()) {
for (int i = 0; i < mCatalogueVariableList.size(); i++) { for (int i = 0; i < mCatalogueVariableList.size(); i++) {
CatalogueVariable catalogueVariable = mCatalogueVariableList.get(i); CatalogueVariable catalogueVariable = mCatalogueVariableList.get(i);
ViewType viewType = catalogueVariable.getType(); /*If API return active false for a variable, there is no need show that variable*/
CatalogueLog.e("viewType: " + viewType + ", Question: " + catalogueVariable.getQuestionText() + ", Order: " + catalogueVariable.getOrder()); if(catalogueVariable.isActive()) {
if (catalogueVariable.getName() == null) { ViewType viewType = catalogueVariable.getType();
TextView nameNullView = new TextView(CatalogueVariableScreen.this); CatalogueLog.e("viewType: " + viewType + ", Question: " + catalogueVariable.getQuestionText() + ", Order: " + catalogueVariable.getOrder());
nameNullView.setText(R.string.name_null_view_string); if (catalogueVariable.getName() == null) {
nameNullView.setBackgroundColor(ContextCompat.getColor(CatalogueVariableScreen.this, R.color.name_null_view_color)); TextView nameNullView = new TextView(CatalogueVariableScreen.this);
childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin); nameNullView.setText(R.string.name_null_view_string);
nameNullView.setPadding((int) getResources().getDimension(R.dimen.small_margin), nameNullView.setBackgroundColor(ContextCompat.getColor(CatalogueVariableScreen.this, R.color.name_null_view_color));
(int) getResources().getDimension(R.dimen.small_margin), childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin);
(int) getResources().getDimension(R.dimen.small_margin), nameNullView.setPadding((int) getResources().getDimension(R.dimen.small_margin),
(int) getResources().getDimension(R.dimen.small_margin)); (int) getResources().getDimension(R.dimen.small_margin),
mContainerLayout.addView(nameNullView, childLabelViewLayoutParams); (int) getResources().getDimension(R.dimen.small_margin),
} else if (viewType != ViewType.MACRO && viewType != ViewType.CONTAINER_START && viewType != ViewType.CONTAINER_END && viewType != ViewType.CONTAINER_SPLIT) { (int) getResources().getDimension(R.dimen.small_margin));
/*For MACRO, CONTAINER_START, CONTAINER_END and CONTAINER_SPLIT, there is no need to render any view*/ mContainerLayout.addView(nameNullView, childLabelViewLayoutParams);
if (viewType != ViewType.LABEL && viewType != ViewType.CHECK_BOX && viewType != ViewType.BREAK) { } else if (viewType != ViewType.MACRO && viewType != ViewType.CONTAINER_START && viewType != ViewType.CONTAINER_END && viewType != ViewType.CONTAINER_SPLIT) {
/*Create label for every type*/ /*For MACRO, CONTAINER_START, CONTAINER_END and CONTAINER_SPLIT, there is no need to render any view*/
if (!catalogueVariable.isMandatory()) { if (viewType != ViewType.LABEL && viewType != ViewType.CHECK_BOX && viewType != ViewType.BREAK) {
TextView label = new TextView(CatalogueVariableScreen.this); /*Create label for every type*/
label.setText(catalogueVariable.getQuestionText()); if (!catalogueVariable.isMandatory()) {
childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin); TextView label = new TextView(CatalogueVariableScreen.this);
mContainerLayout.addView(label, childLabelViewLayoutParams); label.setText(catalogueVariable.getQuestionText());
} else { childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin);
/*Create label with mandatory value*/ mContainerLayout.addView(label, childLabelViewLayoutParams);
LinearLayout labelLayout = new LinearLayout(CatalogueVariableScreen.this); } else {
labelLayout.setOrientation(LinearLayout.HORIZONTAL); /*Create label with mandatory value*/
TextView label = new TextView(CatalogueVariableScreen.this); LinearLayout labelLayout = new LinearLayout(CatalogueVariableScreen.this);
label.setText(catalogueVariable.getQuestionText()); labelLayout.setOrientation(LinearLayout.HORIZONTAL);
childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin); TextView label = new TextView(CatalogueVariableScreen.this);
labelLayout.addView(label, childLabelViewLayoutParams); label.setText(catalogueVariable.getQuestionText());
childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin);
TextView mandatory = new TextView(CatalogueVariableScreen.this); labelLayout.addView(label, childLabelViewLayoutParams);
mandatory.setText("*");
mandatory.setTextColor(ContextCompat.getColor(CatalogueVariableScreen.this, R.color.error_color)); TextView mandatory = new TextView(CatalogueVariableScreen.this);
labelLayout.addView(mandatory); mandatory.setText("*");
mandatory.setTextColor(ContextCompat.getColor(CatalogueVariableScreen.this, R.color.error_color));
mContainerLayout.addView(labelLayout); labelLayout.addView(mandatory);
}
} mContainerLayout.addView(labelLayout);
}
View controlView = Util.getView(CatalogueVariableScreen.this, viewType, catalogueVariable);
if (controlView != null) {
controlView.setTag(new TagObject(i, null));
if (viewType == ViewType.DATE) {
controlView.setOnClickListener(dateListener);
} else if (viewType == ViewType.DATE_AND_TIME) {
controlView.setOnClickListener(dateTimeListener);
} else if (viewType == ViewType.REFERENCE) {
controlView.setOnTouchListener(referenceListener);
} }
/*Set bottom margin for custom view*/ View controlView = Util.getView(CatalogueVariableScreen.this, viewType, catalogueVariable);
if (viewType != ViewType.BREAK) {
mContainerLayout.addView(controlView, childControlViewLayoutParams); if (controlView != null) {
} else controlView.setTag(new TagObject(i, null));
mContainerLayout.addView(controlView); if (viewType == ViewType.DATE) {
controlView.setOnClickListener(dateListener);
/*Mandatory variable contain error view*/ } else if (viewType == ViewType.DATE_AND_TIME) {
if (catalogueVariable.isMandatory()) { controlView.setOnClickListener(dateTimeListener);
/*Add error view for validation*/ } else if (viewType == ViewType.REFERENCE) {
View errorView = getErrorView(); controlView.setOnTouchListener(referenceListener);
errorView.setTag("error_" + i); }
mContainerLayout.addView(errorView);
/*Set bottom margin for custom view*/
if (viewType != ViewType.BREAK) {
mContainerLayout.addView(controlView, childControlViewLayoutParams);
} else
mContainerLayout.addView(controlView);
/*Mandatory variable contain error view*/
if (catalogueVariable.isMandatory()) {
/*Add error view for validation*/
View errorView = getErrorView();
errorView.setTag("error_" + i);
mContainerLayout.addView(errorView);
}
} else {
TextView viewNotImplemented = new TextView(CatalogueVariableScreen.this);
viewNotImplemented.setText(String.format(getString(R.string.view_not_implemented_string), viewType.getDisplayString()));
viewNotImplemented.setBackgroundColor(ContextCompat.getColor(CatalogueVariableScreen.this, R.color.view_not_implemented_color));
childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin);
mContainerLayout.addView(viewNotImplemented, childLabelViewLayoutParams);
} }
} else {
TextView viewNotImplemented = new TextView(CatalogueVariableScreen.this);
viewNotImplemented.setText(String.format(getString(R.string.view_not_implemented_string), viewType.getDisplayString()));
viewNotImplemented.setBackgroundColor(ContextCompat.getColor(CatalogueVariableScreen.this, R.color.view_not_implemented_color));
childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin);
mContainerLayout.addView(viewNotImplemented, childLabelViewLayoutParams);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment