Search in sources :

Example 1 with HtmlBundle

use of views.HtmlBundle in project civiform by seattle-uat.

the class ProgramEditView method render.

public Content render(Request request, long id, ProgramForm program, String message) {
    ContainerTag formTag = ProgramFormBuilder.buildProgramForm(program, /* editExistingProgram = */
    true).with(makeCsrfTokenInputTag(request)).with(buildManageQuestionLink(id)).withAction(controllers.admin.routes.AdminProgramController.update(id).url());
    String title = String.format("Edit program: %s", program.getAdminName());
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(renderHeader(title), formTag);
    if (!message.isEmpty()) {
        htmlBundle.addToastMessages(ToastMessage.error(message).setDismissible(false));
    }
    return layout.renderCentered(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle) ContainerTag(j2html.tags.ContainerTag)

Example 2 with HtmlBundle

use of views.HtmlBundle 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 3 with HtmlBundle

use of views.HtmlBundle in project civiform by seattle-uat.

the class ProgramTranslationView method render.

public Content render(Http.Request request, Locale locale, long programId, Optional<String> localizedName, Optional<String> localizedDescription, Optional<String> errors) {
    String formAction = controllers.admin.routes.AdminProgramTranslationsController.update(programId, locale.toLanguageTag()).url();
    ContainerTag form = renderTranslationForm(request, locale, formAction, formFields(localizedName, localizedDescription));
    String title = "Manage program translations";
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(renderHeader(title), renderLanguageLinks(programId, locale), form);
    errors.ifPresent(s -> htmlBundle.addToastMessages(ToastMessage.error(s).setDismissible(false)));
    return layout.renderCentered(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle) ContainerTag(j2html.tags.ContainerTag)

Example 4 with HtmlBundle

use of views.HtmlBundle in project civiform by seattle-uat.

the class QuestionEditView method renderWithPreview.

private Content renderWithPreview(ContainerTag formContent, QuestionType type, String title) {
    ContainerTag previewContent = QuestionPreview.renderQuestionPreview(type, messages, fileUploadViewStrategy);
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(formContent, previewContent);
    return layout.render(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle) ContainerTag(j2html.tags.ContainerTag)

Example 5 with HtmlBundle

use of views.HtmlBundle in project civiform by seattle-uat.

the class QuestionsListView method render.

/**
 * Renders a page with a table view of all questions.
 */
public Content render(ActiveAndDraftQuestions activeAndDraftQuestions, Optional<String> maybeFlash, Http.Request request) {
    String title = "All Questions";
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(renderHeader(title), renderAddQuestionLink(), div(renderQuestionTable(activeAndDraftQuestions, request)).withClasses(Styles.M_4), renderSummary(activeAndDraftQuestions));
    if (maybeFlash.isPresent()) {
        // Right now, we only show success messages when this page is rendered with maybeFlash set,
        // so we use the success ToastMessage type by default.
        htmlBundle.addToastMessages(ToastMessage.success(maybeFlash.get()).setDismissible(false));
    }
    return layout.renderCentered(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle)

Aggregations

HtmlBundle (views.HtmlBundle)27 ContainerTag (j2html.tags.ContainerTag)15 Tag (j2html.tags.Tag)10 LinkElement (views.components.LinkElement)6 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)4 TagCreator.div (j2html.TagCreator.div)4 TagCreator.each (j2html.TagCreator.each)4 TagCreator.p (j2html.TagCreator.p)4 Content (play.twirl.api.Content)4 BaseHtmlView (views.BaseHtmlView)4 ReferenceClasses (views.style.ReferenceClasses)4 Styles (views.style.Styles)4 ImmutableList (com.google.common.collect.ImmutableList)3 Inject (com.google.inject.Inject)3 controllers.admin.routes (controllers.admin.routes)3 TagCreator.h1 (j2html.TagCreator.h1)3 Optional (java.util.Optional)3 Http (play.mvc.Http)3 Modal (views.components.Modal)3 ZoneId (java.time.ZoneId)2