Commit d278102c by Kunj Gupta

UOFLMA-116: Fixed - Mandatory fields issue.

parents 7062c7e8 b73ee666
......@@ -30,6 +30,7 @@ import android.support.v7.widget.Toolbar;
import android.text.Html;
import android.text.TextUtils;
import android.text.method.LinkMovementMethod;
import android.util.StringBuilderPrinter;
import android.util.TypedValue;
import android.view.MenuItem;
import android.view.MotionEvent;
......@@ -308,20 +309,18 @@ public class CatalogueVariableScreen extends AppCompatActivity {
childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin);
mContainerLayout.addView(label, childLabelViewLayoutParams);
} else {
/*Create label with mandatory value*/
LinearLayout labelLayout = new LinearLayout(CatalogueVariableScreen.this);
labelLayout.setOrientation(LinearLayout.HORIZONTAL);
TextView label = new TextView(CatalogueVariableScreen.this);
label.setText(catalogueVariable.getQuestionText());
childLabelViewLayoutParams.topMargin = (int) getResources().getDimension(R.dimen.small_margin);
labelLayout.addView(label, childLabelViewLayoutParams);
TextView mandatory = new TextView(CatalogueVariableScreen.this);
mandatory.setText("*");
mandatory.setTextColor(ContextCompat.getColor(CatalogueVariableScreen.this, R.color.error_color));
labelLayout.addView(mandatory);
/*Create labelWithMandatory with mandatory value*/
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(catalogueVariable.getQuestionText());
stringBuilder.append(getString(R.string.variable_form_view_mandatory_sign_string));
mContainerLayout.addView(labelLayout);
TextView labelWithMandatory = new TextView(CatalogueVariableScreen.this);
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.N) {
labelWithMandatory.setText(Html.fromHtml(stringBuilder.toString(), Html.FROM_HTML_MODE_LEGACY));
} else {
labelWithMandatory.setText(Html.fromHtml(stringBuilder.toString()));
}
mContainerLayout.addView(labelWithMandatory, childLabelViewLayoutParams);
}
}
......@@ -415,7 +414,8 @@ public class CatalogueVariableScreen extends AppCompatActivity {
jsonColumnValue = Util.getDateTime(Util.getDateTimeFromString(value));
}
if(viewType != ViewType.SELECT_BOX && viewType != ViewType.UI_PAGE) {
if(catalogueVariable.isMandatory()) {
if (viewType != ViewType.SELECT_BOX && viewType != ViewType.UI_PAGE) {
if (TextUtils.isEmpty(jsonColumnValue)) {
hasErrors = true;
// show error view
......@@ -438,6 +438,7 @@ public class CatalogueVariableScreen extends AppCompatActivity {
errorView.setVisibility(View.GONE);
}
}
}
try {
jsonObject.put(catalogueVariable.getName(), jsonColumnValue);
......
......@@ -52,6 +52,7 @@
<!--Variable Screen-->
<string name="variable_form_misc_info_string">%1$s [add %2$s]</string>
<string name="variable_form_header_string">Submit Order</string>
<string name="variable_form_view_mandatory_sign_string">&lt;font color="#FF0000"&gt;*&lt;/font&gt;</string>
<string name="variable_form_reference_dialog_title_string">Search \'%s\'</string>
<string name="variable_form_radio_text_string">%d</string>
<string name="variable_form_ui_page_button_label_string">Add Attachment</string>
......
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