Search in sources :

Example 96 with ContainerTag

use of j2html.tags.ContainerTag in project civiform by seattle-uat.

the class ProgramIndexViewV2 method renderManageTranslationsLink.

private Tag renderManageTranslationsLink(ProgramDefinition program) {
    String linkDestination = routes.AdminProgramTranslationsController.edit(program.id(), LocalizedStrings.DEFAULT_LOCALE.toLanguageTag()).url();
    ContainerTag button = makeSvgTextButton("Manage translations", Icons.LANGUAGE_SVG_PATH).withId("program-translations-link-" + program.id()).withClass(AdminStyles.TERTIARY_BUTTON_STYLES);
    return asRedirectButton(button, linkDestination);
}
Also used : ContainerTag(j2html.tags.ContainerTag)

Example 97 with ContainerTag

use of j2html.tags.ContainerTag in project civiform by seattle-uat.

the class ProgramIndexViewV2 method maybeRenderViewApplicationsLink.

private Optional<Tag> maybeRenderViewApplicationsLink(ProgramDefinition activeProgram, CiviFormProfile userProfile) {
    // TODO(#2582): Determine if this has N+1 query behavior and fix if
    // necessary.
    boolean userIsAuthorized;
    try {
        userProfile.checkProgramAuthorization(activeProgram.adminName()).join();
        userIsAuthorized = true;
    } catch (CompletionException e) {
        userIsAuthorized = false;
    }
    if (userIsAuthorized) {
        String editLink = routes.AdminApplicationController.index(activeProgram.id(), Optional.empty(), Optional.empty()).url();
        ContainerTag button = makeSvgTextButton("Applications", Icons.TEXT_SNIPPET_SVG_PATH).withId("program-view-apps-link-" + activeProgram.id()).withClass(AdminStyles.TERTIARY_BUTTON_STYLES);
        return Optional.of(asRedirectButton(button, editLink));
    }
    return Optional.empty();
}
Also used : CompletionException(java.util.concurrent.CompletionException) ContainerTag(j2html.tags.ContainerTag)

Example 98 with ContainerTag

use of j2html.tags.ContainerTag in project civiform by seattle-uat.

the class ProgramNewOneView method render.

public Content render(Request request, ProgramForm programForm, String message) {
    String title = "New program information";
    ContainerTag contentDiv = div(ProgramFormBuilder.buildProgramForm(programForm, /* editExistingProgram = */
    false).with(makeCsrfTokenInputTag(request)).withAction(controllers.admin.routes.AdminProgramController.create().url()));
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(renderHeader(title), contentDiv);
    if (!message.isEmpty()) {
        htmlBundle.addToastMessages(ToastMessage.error(message).setDismissible(false));
    }
    return layout.renderCentered(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle) ContainerTag(j2html.tags.ContainerTag)

Example 99 with ContainerTag

use of j2html.tags.ContainerTag in project civiform by seattle-uat.

the class QuestionConfig method multiOptionQuestionField.

/**
 * Creates an individual text field where an admin can enter a single multi-option question
 * answer, along with a button to remove the option.
 */
private static ContainerTag multiOptionQuestionField(Optional<LocalizedQuestionOption> existingOption, Messages messages, boolean isForNewOption) {
    ContainerTag optionInput = FieldWithLabel.input().setFieldName(isForNewOption ? "newOptions[]" : "options[]").setLabelText("Question option").addReferenceClass(ReferenceClasses.MULTI_OPTION_INPUT).setValue(existingOption.map(LocalizedQuestionOption::optionText)).setFieldErrors(messages, ImmutableSet.of(ValidationErrorMessage.create(MessageKey.MULTI_OPTION_VALIDATION))).showFieldErrors(false).getContainer().withClasses(Styles.FLEX, Styles.ML_2, Styles.GAP_X_3);
    ContainerTag optionIndexInput = isForNewOption ? div() : FieldWithLabel.input().setFieldName("optionIds[]").setValue(String.valueOf(existingOption.get().id())).setScreenReaderText("option ids").getContainer().withClasses(Styles.HIDDEN);
    Tag removeOptionButton = button("Remove").withType("button").withClasses(Styles.FLEX, Styles.ML_4, "multi-option-question-field-remove-button");
    return div().withClasses(ReferenceClasses.MULTI_OPTION_QUESTION_OPTION, Styles.FLEX, Styles.FLEX_ROW, Styles.MB_4).with(optionInput, optionIndexInput, removeOptionButton);
}
Also used : ContainerTag(j2html.tags.ContainerTag) ContainerTag(j2html.tags.ContainerTag) Tag(j2html.tags.Tag)

Example 100 with ContainerTag

use of j2html.tags.ContainerTag in project civiform by seattle-uat.

the class QuestionEditView method buildNewQuestionForm.

private ContainerTag buildNewQuestionForm(QuestionForm questionForm, ImmutableList<EnumeratorQuestionDefinition> enumeratorQuestionDefinitions) {
    SelectWithLabel enumeratorOptions = enumeratorOptionsFromEnumerationQuestionDefinitions(questionForm, enumeratorQuestionDefinitions);
    ContainerTag formTag = buildSubmittableQuestionForm(questionForm, enumeratorOptions, true);
    formTag.withAction(controllers.admin.routes.AdminQuestionController.create(questionForm.getQuestionType().toString()).url()).with(submitButton("Create").withClass(Styles.M_4));
    return formTag;
}
Also used : ContainerTag(j2html.tags.ContainerTag) SelectWithLabel(views.components.SelectWithLabel)

Aggregations

ContainerTag (j2html.tags.ContainerTag)150 Tag (j2html.tags.Tag)30 TagCreator.div (j2html.TagCreator.div)20 HtmlBundle (views.HtmlBundle)20 Inject (javax.inject.Inject)17 List (java.util.List)13 TagCreator (j2html.TagCreator)12 DomContent (j2html.tags.DomContent)12 Mav (io.datarouter.web.handler.mav.Mav)11 LinkElement (views.components.LinkElement)11 J2HtmlTable (io.datarouter.web.html.j2html.J2HtmlTable)10 DatarouterWebRequireJsV2 (io.datarouter.web.requirejs.DatarouterWebRequireJsV2)10 TagCreator.a (j2html.TagCreator.a)10 BaseHandler (io.datarouter.web.handler.BaseHandler)9 Bootstrap4PageFactory (io.datarouter.web.html.j2html.bootstrap4.Bootstrap4PageFactory)8 TagCreator.td (j2html.TagCreator.td)8 ArrayList (java.util.ArrayList)8 Optional (java.util.Optional)8 TagCreator.each (j2html.TagCreator.each)7 ZoneId (java.time.ZoneId)7