Search in sources :

Example 1 with LinkElement

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

the class BaseHtmlView method renderPaginationDiv.

protected ContainerTag renderPaginationDiv(int page, int pageCount, Function<Integer, Call> linkForPage) {
    ContainerTag div = div();
    if (page <= 1) {
        div.with(new LinkElement().setText("∅").asButton());
    } else {
        div.with(new LinkElement().setText("←").setHref(linkForPage.apply(page - 1).url()).asButton());
    }
    div.with(div("Page " + page + " of " + pageCount).withClasses(Styles.LEADING_3, Styles.FLOAT_LEFT, Styles.INLINE_BLOCK, Styles.P_2, Styles.M_4));
    if (pageCount > page) {
        div.with(new LinkElement().setText("→").setHref(linkForPage.apply(page + 1).url()).asButton());
    } else {
        div.with(new LinkElement().setText("∅").asButton());
    }
    return div.with(br());
}
Also used : LinkElement(views.components.LinkElement) ContainerTag(j2html.tags.ContainerTag)

Example 2 with LinkElement

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

the class ProgramIndexView method maybeRenderManageTranslationsLink.

private Tag maybeRenderManageTranslationsLink(Optional<ProgramDefinition> draftProgram) {
    if (draftProgram.isPresent()) {
        String linkText = "Manage Translations →";
        String linkDestination = routes.AdminProgramTranslationsController.edit(draftProgram.get().id(), LocalizedStrings.DEFAULT_LOCALE.toLanguageTag()).url();
        return new LinkElement().setId("program-translations-link-" + draftProgram.get().id()).setHref(linkDestination).setText(linkText).setStyles(Styles.MR_2).asAnchorText();
    } else {
        return div();
    }
}
Also used : LinkElement(views.components.LinkElement)

Example 3 with LinkElement

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

the class ProgramIndexView method renderManageProgramAdminsLink.

private Tag renderManageProgramAdminsLink(Optional<ProgramDefinition> draftProgram, Optional<ProgramDefinition> activeProgram) {
    // We can use the ID of either, since we just add the program name and not ID to indicate
    // ownership.
    long programId = draftProgram.isPresent() ? draftProgram.get().id() : activeProgram.orElseThrow().id();
    String adminLink = routes.ProgramAdminManagementController.edit(programId).url();
    return new LinkElement().setId("manage-program-admin-link-" + programId).setHref(adminLink).setText("Manage Admins →").setStyles(Styles.MR_2).asAnchorText();
}
Also used : LinkElement(views.components.LinkElement)

Example 4 with LinkElement

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

the class ProgramIndexView method maybeRenderEditLink.

Tag maybeRenderEditLink(Optional<ProgramDefinition> draftProgram, Optional<ProgramDefinition> activeProgram, Http.Request request) {
    String editLinkText = "Edit →";
    String newVersionText = "New Version";
    if (draftProgram.isPresent()) {
        String editLink = controllers.admin.routes.AdminProgramController.edit(draftProgram.get().id()).url();
        return new LinkElement().setId("program-edit-link-" + draftProgram.get().id()).setHref(editLink).setText(editLinkText).setStyles(Styles.MR_2).asAnchorText();
    } else if (activeProgram.isPresent()) {
        String newVersionLink = controllers.admin.routes.AdminProgramController.newVersionFrom(activeProgram.get().id()).url();
        return new LinkElement().setId("program-new-version-link-" + activeProgram.get().id()).setHref(newVersionLink).setText(newVersionText).setStyles(Styles.MR_2).asHiddenForm(request);
    } else {
        // obsolete or deleted, no edit link, empty div.
        return div();
    }
}
Also used : LinkElement(views.components.LinkElement)

Example 5 with LinkElement

use of views.components.LinkElement 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, 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.idcsLoginWithRedirect(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)

Aggregations

LinkElement (views.components.LinkElement)9 ContainerTag (j2html.tags.ContainerTag)6 HtmlBundle (views.HtmlBundle)2 DomContent (j2html.tags.DomContent)1 Tag (j2html.tags.Tag)1 LocalDate (java.time.LocalDate)1 Http (play.mvc.Http)1 RepeatedEntity (services.applicant.RepeatedEntity)1 QuestionType (services.question.types.QuestionType)1 Modal (views.components.Modal)1