Search in sources :

Example 11 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 12 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 13 with HtmlBundle

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

the class ApplicantUpsellCreateAccountView method render.

/**
 * Renders a sign-up page with a baked-in redirect.
 */
public Content render(Http.Request request, String redirectTo, Account account, String programTitle, Optional<String> applicantName, Long applicationId, Messages messages, Optional<String> banner) {
    String title = messages.at(MessageKey.TITLE_APPLICATION_CONFIRMATION.getKeyName());
    HtmlBundle bundle = layout.getBundle().setTitle(title);
    ContainerTag createAccountBox = div().withClasses(Styles.BORDER, Styles.BORDER_GRAY_200, Styles.ROUNDED_2XL, Styles.SHADOW_MD, Styles.BG_WHITE, Styles.P_4, StyleUtils.responsiveSmall(Styles.P_6), Styles.MY_6).with(h2(messages.at(MessageKey.TITLE_CREATE_AN_ACCOUNT.getKeyName())).withClasses(Styles.MB_4)).with(div(messages.at(MessageKey.CONTENT_PLEASE_CREATE_ACCOUNT.getKeyName())).withClasses(Styles.MB_4)).with(div().withClasses(Styles.FLEX, Styles.FLEX_COL, Styles.GAP_4, StyleUtils.responsiveSmall(Styles.FLEX_ROW)).with(div().withClasses(Styles.FLEX_GROW)).with(new LinkElement().setHref(redirectTo).setText(messages.at(MessageKey.LINK_APPLY_TO_ANOTHER_PROGRAM.getKeyName())).asButton().withClasses(ApplicantStyles.BUTTON_NOT_RIGHT_NOW)).with(new LinkElement().setHref(org.pac4j.play.routes.LogoutController.logout().url()).setText(messages.at(MessageKey.LINK_ALL_DONE.getKeyName())).asButton().withClasses(ApplicantStyles.BUTTON_NOT_RIGHT_NOW)).with(new LinkElement().setHref(routes.LoginController.applicantLogin(Optional.of(redirectTo)).url()).setText(messages.at(MessageKey.LINK_CREATE_ACCOUNT_OR_SIGN_IN.getKeyName())).asButton().withClasses(ApplicantStyles.BUTTON_CREATE_ACCOUNT)));
    ContainerTag content = div().with(div(messages.at(MessageKey.CONTENT_CONFIRMED.getKeyName(), programTitle, applicationId)).withClasses(Styles.TEXT_LG));
    // Don't show "create an account" upsell box to TIs, or anyone with an email address already.
    if (Strings.isNullOrEmpty(account.getEmailAddress()) && account.getMemberOfGroup().isEmpty()) {
        content.with(createAccountBox);
    } else {
        content.with(new LinkElement().setHref(redirectTo).setText(messages.at(MessageKey.LINK_APPLY_TO_ANOTHER_PROGRAM.getKeyName())).asAnchorText());
    }
    if (banner.isPresent()) {
        bundle.addToastMessages(ToastMessage.error(banner.get()));
    }
    bundle.addMainStyles(ApplicantStyles.MAIN_PROGRAM_APPLICATION).addMainContent(h1(title).withClasses(ApplicantStyles.H1_PROGRAM_APPLICATION), content);
    return layout.renderWithNav(request, applicantName, messages, bundle);
}
Also used : HtmlBundle(views.HtmlBundle) LinkElement(views.components.LinkElement) ContainerTag(j2html.tags.ContainerTag)

Example 14 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)

Example 15 with HtmlBundle

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

the class EditTrustedIntermediaryGroupView method render.

public Content render(TrustedIntermediaryGroup tiGroup, Http.Request request) {
    String title = "Trusted Intermediary Groups";
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(div().withClasses(Styles.MY_5).with(renderAddNewButton(tiGroup, request)), div(table().withClasses(Styles.BORDER, Styles.BORDER_GRAY_300, Styles.SHADOW_MD, Styles.W_FULL).with(renderGroupTableHeader()).with(tbody(each(tiGroup.getTrustedIntermediaries(), account -> renderTIRow(tiGroup, account, request))))));
    return layout.renderCentered(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle)

Aggregations

HtmlBundle (views.HtmlBundle)37 ContainerTag (j2html.tags.ContainerTag)21 Tag (j2html.tags.Tag)13 LinkElement (views.components.LinkElement)10 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)6 TagCreator.div (j2html.TagCreator.div)6 TagCreator.each (j2html.TagCreator.each)6 TagCreator.p (j2html.TagCreator.p)6 ZoneId (java.time.ZoneId)6 Content (play.twirl.api.Content)6 BaseHtmlView (views.BaseHtmlView)6 ReferenceClasses (views.style.ReferenceClasses)6 Styles (views.style.Styles)6 Inject (com.google.inject.Inject)5 controllers.admin.routes (controllers.admin.routes)5 TagCreator.h1 (j2html.TagCreator.h1)5 Optional (java.util.Optional)5 Http (play.mvc.Http)5 ProgramDefinition (services.program.ProgramDefinition)4 AdminLayout (views.admin.AdminLayout)4