Search in sources :

Example 1 with Modal

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

the class ProgramIndexView method render.

public Content render(ActiveAndDraftPrograms programs, Http.Request request, Optional<CiviFormProfile> profile) {
    if (profile.isPresent() && profile.get().isProgramAdmin() && !profile.get().isCiviFormAdmin()) {
        layout.setOnlyProgramAdminType();
    }
    String pageTitle = "All programs";
    ContainerTag publishAllModalContent = div().withClasses(Styles.FLEX, Styles.FLEX_COL, Styles.GAP_4).with(p("Are you sure you want to publish all programs?").withClasses(Styles.P_2)).with(maybeRenderPublishButton(programs, request));
    Modal publishAllModal = Modal.builder("publish-all-programs-modal", publishAllModalContent).setModalTitle("Confirmation").setTriggerButtonText("Publish all programs").build();
    Tag contentDiv = div().withClasses(Styles.PX_20).with(h1(pageTitle).withClasses(Styles.MY_4), div().withClasses(Styles.FLEX, Styles.ITEMS_CENTER).with(renderNewProgramButton()).with(div().withClass(Styles.FLEX_GROW)).condWith(programs.anyDraft(), publishAllModal.getButton()), each(programs.getProgramNames(), name -> this.renderProgramListItem(programs.getActiveProgramDefinition(name), programs.getDraftProgramDefinition(name), request, profile))).with(renderDownloadExportCsvButton());
    HtmlBundle htmlBundle = layout.getBundle().setTitle(pageTitle).addMainContent(contentDiv).addModals(publishAllModal);
    return layout.renderCentered(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle) ContainerTag(j2html.tags.ContainerTag) ContainerTag(j2html.tags.ContainerTag) Tag(j2html.tags.Tag) Modal(views.components.Modal)

Example 2 with Modal

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

the class ProgramBlockEditView method render.

public Content render(Request request, ProgramDefinition programDefinition, long blockId, BlockForm blockForm, BlockDefinition blockDefinition, ImmutableList<ProgramQuestionDefinition> blockQuestions, String message, ImmutableList<QuestionDefinition> questions) {
    Tag csrfTag = makeCsrfTokenInputTag(request);
    String title = String.format("Edit %s", blockDefinition.name());
    String blockUpdateAction = controllers.admin.routes.AdminProgramBlocksController.update(programDefinition.id(), blockId).url();
    Modal blockDescriptionEditModal = blockDescriptionModal(csrfTag, blockForm, blockUpdateAction);
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainStyles(Styles.FLEX, Styles.FLEX_COL).addMainContent(addFormEndpoints(csrfTag, programDefinition.id(), blockId), layout.renderProgramInfo(programDefinition), div().withId("program-block-info").withClasses(Styles.FLEX, Styles.FLEX_GROW, Styles._MX_2).with(blockOrderPanel(request, programDefinition, blockId)).with(blockEditPanel(programDefinition, blockDefinition, blockForm, blockQuestions, questions, blockDefinition.isEnumerator(), csrfTag, blockDescriptionEditModal.getButton())).with(questionBankPanel(questions, programDefinition, blockDefinition, csrfTag))).addModals(blockDescriptionEditModal);
    // Add toast messages
    if (request.flash().get("error").isPresent()) {
        htmlBundle.addToastMessages(ToastMessage.error(request.flash().get("error").get()).setDuration(-1));
    }
    if (message.length() > 0) {
        htmlBundle.addToastMessages(ToastMessage.error(message).setDismissible(false));
    }
    return layout.renderCentered(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle) ContainerTag(j2html.tags.ContainerTag) Tag(j2html.tags.Tag) Modal(views.components.Modal)

Example 3 with Modal

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

the class ProgramBlockPredicatesEditView method render.

public Content render(Http.Request request, ProgramDefinition programDefinition, BlockDefinition blockDefinition, ImmutableList<QuestionDefinition> potentialPredicateQuestions) {
    String title = String.format("Visibility condition for %s", blockDefinition.name());
    Tag csrfTag = makeCsrfTokenInputTag(request);
    String predicateUpdateUrl = routes.AdminProgramBlockPredicatesController.update(programDefinition.id(), blockDefinition.id()).url();
    ImmutableList<Modal> modals = predicateFormModals(blockDefinition.name(), potentialPredicateQuestions, predicateUpdateUrl, csrfTag);
    String removePredicateUrl = routes.AdminProgramBlockPredicatesController.destroy(programDefinition.id(), blockDefinition.id()).url();
    String removePredicateFormId = "visibility-predicate-form-remove";
    Tag removePredicateForm = form(csrfTag).withId(removePredicateFormId).withMethod(POST).withAction(removePredicateUrl).with(submitButton("Remove visibility condition").attr(Attr.FORM, removePredicateFormId).attr(blockDefinition.visibilityPredicate().isEmpty() ? Attr.DISABLED : ""));
    String editBlockUrl = routes.AdminProgramBlocksController.edit(programDefinition.id(), blockDefinition.id()).url();
    ContainerTag content = div().withClasses(Styles.MX_6, Styles.MY_10, Styles.FLEX, Styles.FLEX_COL, Styles.GAP_6).with(div().withClasses(Styles.FLEX, Styles.FLEX_ROW).with(h1(title).withClasses(Styles.FONT_BOLD, Styles.TEXT_XL)).with(div().withClasses(Styles.FLEX_GROW)).with(new LinkElement().setHref(editBlockUrl).setText(String.format("Return to edit %s", blockDefinition.name())).asAnchorText())).with(div().with(h2(H2_CURRENT_VISIBILITY_CONDITION).withClasses(Styles.FONT_SEMIBOLD, Styles.TEXT_LG)).with(div(blockDefinition.visibilityPredicate().isPresent() ? blockDefinition.visibilityPredicate().get().toDisplayString(blockDefinition.name(), potentialPredicateQuestions) : TEXT_NO_VISIBILITY_CONDITIONS).withClasses(ReferenceClasses.PREDICATE_DISPLAY))).with(removePredicateForm).with(div().with(h2(H2_NEW_VISIBILITY_CONDITION).withClasses(Styles.FONT_SEMIBOLD, Styles.TEXT_LG)).with(div(TEXT_NEW_VISIBILITY_CONDITION).withClasses(Styles.MB_2)).with(modals.isEmpty() ? text(TEXT_NO_AVAILABLE_QUESTIONS) : renderPredicateModalTriggerButtons(modals)));
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(layout.renderProgramInfo(programDefinition), content);
    Http.Flash flash = request.flash();
    if (flash.get("error").isPresent()) {
        htmlBundle.addToastMessages(ToastMessage.error(flash.get("error").get()).setDuration(-1));
    } else if (flash.get("success").isPresent()) {
        htmlBundle.addToastMessages(ToastMessage.success(flash.get("success").get()).setDuration(-1));
    }
    for (Modal modal : modals) {
        htmlBundle = htmlBundle.addModals(modal);
    }
    return layout.renderCentered(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle) LinkElement(views.components.LinkElement) Http(play.mvc.Http) ContainerTag(j2html.tags.ContainerTag) Tag(j2html.tags.Tag) ContainerTag(j2html.tags.ContainerTag) Modal(views.components.Modal)

Aggregations

ContainerTag (j2html.tags.ContainerTag)3 Tag (j2html.tags.Tag)3 HtmlBundle (views.HtmlBundle)3 Modal (views.components.Modal)3 Http (play.mvc.Http)1 LinkElement (views.components.LinkElement)1