Search in sources :

Example 21 with HtmlBundle

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

the class ProgramEditView method render.

public Content render(Request request, ProgramDefinition program) {
    ContainerTag formTag = ProgramFormBuilder.buildProgramForm(program, /* editExistingProgram = */
    true).with(makeCsrfTokenInputTag(request)).with(buildManageQuestionLink(program.id())).withAction(controllers.admin.routes.AdminProgramController.update(program.id()).url());
    String title = String.format("Edit program: %s", program.adminName());
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(renderHeader(title), formTag);
    return layout.renderCentered(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle) ContainerTag(j2html.tags.ContainerTag)

Example 22 with HtmlBundle

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

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

the class QuestionTranslationView method render.

private Content render(Http.Request request, Locale locale, QuestionDefinition question, Optional<String> errors) {
    String formAction = controllers.admin.routes.AdminQuestionTranslationsController.update(question.getId(), locale.toLanguageTag()).url();
    // Add form fields for questions.
    ImmutableList.Builder<FieldWithLabel> inputFields = ImmutableList.builder();
    inputFields.addAll(questionTextFields(locale, question.getQuestionText(), question.getQuestionHelpText()));
    inputFields.addAll(getQuestionTypeSpecificFields(question, locale));
    ContainerTag form = renderTranslationForm(request, locale, formAction, inputFields.build());
    String title = "Manage Question Translations";
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(renderHeader(title), renderLanguageLinks(question.getId(), locale), form);
    errors.ifPresent(s -> htmlBundle.addToastMessages(ToastMessage.error(s).setDismissible(false)));
    return layout.renderCentered(htmlBundle);
}
Also used : HtmlBundle(views.HtmlBundle) ImmutableList.toImmutableList(com.google.common.collect.ImmutableList.toImmutableList) ImmutableList(com.google.common.collect.ImmutableList) ContainerTag(j2html.tags.ContainerTag) FieldWithLabel(views.components.FieldWithLabel)

Example 24 with HtmlBundle

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

the class VersionListView method render.

public Content render(List<Version> allVersions, Http.Request request) {
    Optional<Version> draftVersion = allVersions.stream().filter(version -> version.getLifecycleStage().equals(LifecycleStage.DRAFT)).findAny();
    Optional<Version> activeVersion = allVersions.stream().filter(version -> version.getLifecycleStage().equals(LifecycleStage.ACTIVE)).findAny();
    ImmutableList<Version> olderVersions = allVersions.stream().filter(version -> version.getLifecycleStage().equals(LifecycleStage.OBSOLETE)).sorted((a, b) -> a.id.compareTo(b.id)).collect(ImmutableList.toImmutableList()).reverse();
    String title = "Program Versions";
    HtmlBundle htmlBundle = layout.getBundle().setTitle(title).addMainContent(renderHeader("Current Versions"), renderVersionCard(draftVersion), renderVersionCard(activeVersion), renderHeader("Older Versions"), renderPastVersionTable(olderVersions, request));
    return layout.renderCentered(htmlBundle);
}
Also used : NavPage(views.admin.AdminLayout.NavPage) Inject(com.google.inject.Inject) Styles(views.style.Styles) LinkElement(views.components.LinkElement) Content(play.twirl.api.Content) Version(models.Version) AdminLayoutFactory(views.admin.AdminLayoutFactory) ImmutableList(com.google.common.collect.ImmutableList) HtmlBundle(views.HtmlBundle) BaseHtmlView(views.BaseHtmlView) BaseStyles(views.style.BaseStyles) TagCreator.p(j2html.TagCreator.p) TagCreator.table(j2html.TagCreator.table) Config(com.typesafe.config.Config) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) TagCreator.each(j2html.TagCreator.each) StyleUtils(views.style.StyleUtils) LifecycleStage(models.LifecycleStage) Collectors(java.util.stream.Collectors) controllers.admin.routes(controllers.admin.routes) ZoneId(java.time.ZoneId) List(java.util.List) TagCreator.th(j2html.TagCreator.th) AdminLayout(views.admin.AdminLayout) TagCreator.td(j2html.TagCreator.td) TagCreator.tr(j2html.TagCreator.tr) Optional(java.util.Optional) ReferenceClasses(views.style.ReferenceClasses) TagCreator.tbody(j2html.TagCreator.tbody) TagCreator.div(j2html.TagCreator.div) Http(play.mvc.Http) TagCreator.thead(j2html.TagCreator.thead) Tag(j2html.tags.Tag) HtmlBundle(views.HtmlBundle) Version(models.Version)

Example 25 with HtmlBundle

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

the class ApplicantProgramInfoView method render.

public Content render(Messages messages, ProgramDefinition program, Http.Request request, long applicantId, Optional<String> userName) {
    Locale preferredLocale = messages.lang().toLocale();
    String programTitle = program.localizedName().getOrDefault(preferredLocale);
    String programInfo = program.localizedDescription().getOrDefault(preferredLocale);
    HtmlBundle bundle = layout.getBundle().addMainStyles(Styles.MX_12, Styles.MY_8).addMainContent(topContent(programTitle, programInfo, messages)).addMainContent(createButtons(applicantId, program.id(), messages));
    return layout.renderWithNav(request, userName, messages, bundle);
}
Also used : Locale(java.util.Locale) 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