Search in sources :

Example 1 with FieldWithLabel

use of views.components.FieldWithLabel in project civiform by seattle-uat.

the class QuestionEditView method buildQuestionForm.

private ContainerTag buildQuestionForm(QuestionForm questionForm, SelectWithLabel enumeratorOptions, boolean submittable, boolean forCreate) {
    QuestionType questionType = questionForm.getQuestionType();
    ContainerTag formTag = form().withMethod("POST");
    // The question enumerator and name fields should not be changed after the question is created.
    // If this form is not for creation, the fields are disabled, and hidden fields to pass
    // enumerator
    // and name data are added.
    formTag.with(enumeratorOptions.setDisabled(!forCreate).getContainer());
    formTag.with(repeatedQuestionInformation());
    FieldWithLabel nameField = FieldWithLabel.input().setId("question-name-input").setFieldName(QUESTION_NAME_FIELD).setLabelText("Name").setDisabled(!submittable).setPlaceholderText("The name displayed in the question builder").setValue(questionForm.getQuestionName());
    formTag.with(nameField.setDisabled(!forCreate).getContainer());
    if (!forCreate) {
        formTag.with(input().isHidden().withName(QUESTION_NAME_FIELD).withValue(questionForm.getQuestionName()), input().isHidden().withName(QUESTION_ENUMERATOR_FIELD).withValue(questionForm.getEnumeratorId().map(String::valueOf).orElse(NO_ENUMERATOR_ID_STRING)));
    }
    ContainerTag questionHelpTextField = FieldWithLabel.textArea().setId("question-help-text-textarea").setFieldName("questionHelpText").setLabelText("Question help text").setPlaceholderText("The question help text displayed to the applicant").setDisabled(!submittable).setValue(questionForm.getQuestionHelpText()).getContainer();
    if (questionType.equals(QuestionType.STATIC)) {
        // Hide help text for static questions.
        questionHelpTextField.withClasses(Styles.HIDDEN);
    }
    formTag.with(FieldWithLabel.textArea().setId("question-description-textarea").setFieldName("questionDescription").setLabelText("Description").setPlaceholderText("The description displayed in the question builder").setDisabled(!submittable).setValue(questionForm.getQuestionDescription()).getContainer(), FieldWithLabel.textArea().setId("question-text-textarea").setFieldName("questionText").setLabelText("Question text").setPlaceholderText("The question text displayed to the applicant").setDisabled(!submittable).setValue(questionForm.getQuestionText()).getContainer(), questionHelpTextField).with(formQuestionTypeSelect(questionType));
    formTag.with(QuestionConfig.buildQuestionConfig(questionForm, messages));
    if (!ExporterService.NON_EXPORTED_QUESTION_TYPES.contains(questionType)) {
        formTag.with(div().withId("demographic-field-content").with(buildDemographicFields(questionForm, submittable)));
    }
    return formTag;
}
Also used : QuestionType(services.question.types.QuestionType) ContainerTag(j2html.tags.ContainerTag) FieldWithLabel(views.components.FieldWithLabel)

Example 2 with FieldWithLabel

use of views.components.FieldWithLabel in project civiform by seattle-uat.

the class TrustedIntermediaryGroupListView method renderAddNewButton.

private Tag renderAddNewButton(Http.Request request) {
    ContainerTag formTag = form().withMethod("POST").withAction(routes.TrustedIntermediaryManagementController.create().url());
    FieldWithLabel nameField = FieldWithLabel.input().setId("group-name-input").setFieldName("name").setLabelText("Name").setValue(request.flash().get("providedName").orElse("")).setPlaceholderText("The name of this Trusted Intermediary Group.");
    FieldWithLabel descriptionField = FieldWithLabel.input().setId("group-description-input").setFieldName("description").setLabelText("Description").setValue(request.flash().get("providedDescription").orElse("")).setPlaceholderText("The description of this group.");
    return div().with(formTag.with(nameField.getContainer(), descriptionField.getContainer(), makeCsrfTokenInputTag(request), submitButton("Create").withClasses(Styles.ML_2, Styles.MB_6))).withClasses(Styles.BORDER, Styles.BORDER_GRAY_300, Styles.SHADOW_MD, Styles.W_1_2, Styles.MT_6);
}
Also used : ContainerTag(j2html.tags.ContainerTag) FieldWithLabel(views.components.FieldWithLabel)

Example 3 with FieldWithLabel

use of views.components.FieldWithLabel in project civiform by seattle-uat.

the class CurrencyQuestionRenderer method render.

@Override
public Tag render(ApplicantQuestionRendererParams params) {
    CurrencyQuestion currencyQuestion = question.createCurrencyQuestion();
    FieldWithLabel currencyField = FieldWithLabel.currency().setFieldName(currencyQuestion.getCurrencyPath().toString()).addReferenceClass(ReferenceClasses.CURRENCY_VALUE).setScreenReaderText(question.getQuestionText()).setFieldErrors(params.messages(), ImmutableSet.of(ValidationErrorMessage.create(MessageKey.CURRENCY_VALIDATION_MISFORMATTED))).showFieldErrors(false);
    if (currencyQuestion.getValue().isPresent()) {
        currencyField.setValue(currencyQuestion.getValue().get());
    }
    Tag dollarSign = div().withText("$").withClasses(Styles.FLEX, Styles.ITEMS_CENTER, // Same height and padding as the input field.
    Styles.H_12, Styles.MB_2, // Pad the right side.
    Styles.MR_2, // Same text as the input field.
    Styles.TEXT_LG);
    Tag currencyQuestionFormContent = div().withClasses(Styles.FLEX).with(dollarSign).with(currencyField.getContainer());
    return renderInternal(params.messages(), currencyQuestionFormContent, false);
}
Also used : Tag(j2html.tags.Tag) FieldWithLabel(views.components.FieldWithLabel) CurrencyQuestion(services.applicant.question.CurrencyQuestion)

Example 4 with FieldWithLabel

use of views.components.FieldWithLabel in project civiform by seattle-uat.

the class TrustedIntermediaryDashboardView method renderAddNewForm.

private Tag renderAddNewForm(TrustedIntermediaryGroup tiGroup, Http.Request request) {
    ContainerTag formTag = form().withMethod("POST").withAction(routes.TrustedIntermediaryController.addApplicant(tiGroup.id).url());
    FieldWithLabel firstNameField = FieldWithLabel.input().setId("first-name-input").setFieldName("firstName").setLabelText("First Name").setValue(request.flash().get("providedFirstName").orElse("")).setPlaceholderText("Applicant first name (Required)");
    FieldWithLabel middleNameField = FieldWithLabel.input().setId("middle-name-input").setFieldName("middleName").setLabelText("Middle Name").setValue(request.flash().get("providedMiddleName").orElse("")).setPlaceholderText("Applicant middle name (Optional)");
    FieldWithLabel lastNameField = FieldWithLabel.input().setId("last-name-input").setFieldName("lastName").setLabelText("Last Name").setValue(request.flash().get("providedLastName").orElse("")).setPlaceholderText("Applicant last name (Required)");
    // TODO: do something with this field.  currently doesn't do anything.
    FieldWithLabel dateOfBirthField = FieldWithLabel.date().setId("date-of-birth-input").setFieldName("dob").setLabelText("Date Of Birth").setValue(request.flash().get("providedDob").orElse("")).setPlaceholderText("Applicant Date of Birth");
    FieldWithLabel emailField = FieldWithLabel.input().setId("email-input").setFieldName("emailAddress").setLabelText("Email Address").setValue(request.flash().get("providedEmail").orElse("")).setPlaceholderText("Email address (if provided, applicant can access account by logging in)");
    return div().with(formTag.with(emailField.getContainer(), firstNameField.getContainer(), middleNameField.getContainer(), lastNameField.getContainer(), dateOfBirthField.getContainer(), makeCsrfTokenInputTag(request), submitButton("Add").withClasses(Styles.ML_2, Styles.MB_6))).withClasses(Styles.BORDER, Styles.BORDER_GRAY_300, Styles.SHADOW_MD, Styles.W_1_2, Styles.MT_6);
}
Also used : ContainerTag(j2html.tags.ContainerTag) FieldWithLabel(views.components.FieldWithLabel)

Example 5 with FieldWithLabel

use of views.components.FieldWithLabel in project civiform by seattle-uat.

the class EditTrustedIntermediaryGroupView method renderAddNewButton.

private Tag renderAddNewButton(TrustedIntermediaryGroup tiGroup, Http.Request request) {
    ContainerTag formTag = form().withMethod("POST").withAction(routes.TrustedIntermediaryManagementController.addIntermediary(tiGroup.id).url());
    FieldWithLabel emailField = FieldWithLabel.input().setId("group-name-input").setFieldName("emailAddress").setLabelText("Member Email Address").setValue(request.flash().get("providedEmail").orElse("")).setPlaceholderText("The email address of the member you want to add.");
    return div().with(formTag.with(emailField.getContainer(), makeCsrfTokenInputTag(request), submitButton("Add").withClasses(Styles.ML_2, Styles.MB_6))).withClasses(Styles.BORDER, Styles.BORDER_GRAY_300, Styles.SHADOW_MD, Styles.MT_6);
}
Also used : ContainerTag(j2html.tags.ContainerTag) FieldWithLabel(views.components.FieldWithLabel)

Aggregations

FieldWithLabel (views.components.FieldWithLabel)8 ContainerTag (j2html.tags.ContainerTag)5 Tag (j2html.tags.Tag)3 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)1 LocalDate (java.time.LocalDate)1 OptionalLong (java.util.OptionalLong)1 CurrencyQuestion (services.applicant.question.CurrencyQuestion)1 DateQuestion (services.applicant.question.DateQuestion)1 NumberQuestion (services.applicant.question.NumberQuestion)1 QuestionType (services.question.types.QuestionType)1 HtmlBundle (views.HtmlBundle)1