use of j2html.tags.ContainerTag in project civiform by seattle-uat.
the class ProgramIndexViewV2 method renderManageTranslationsLink.
private Tag renderManageTranslationsLink(ProgramDefinition program) {
String linkDestination = routes.AdminProgramTranslationsController.edit(program.id(), LocalizedStrings.DEFAULT_LOCALE.toLanguageTag()).url();
ContainerTag button = makeSvgTextButton("Manage translations", Icons.LANGUAGE_SVG_PATH).withId("program-translations-link-" + program.id()).withClass(AdminStyles.TERTIARY_BUTTON_STYLES);
return asRedirectButton(button, linkDestination);
}
use of j2html.tags.ContainerTag in project civiform by seattle-uat.
the class ProgramIndexViewV2 method maybeRenderViewApplicationsLink.
private Optional<Tag> maybeRenderViewApplicationsLink(ProgramDefinition activeProgram, CiviFormProfile userProfile) {
// TODO(#2582): Determine if this has N+1 query behavior and fix if
// necessary.
boolean userIsAuthorized;
try {
userProfile.checkProgramAuthorization(activeProgram.adminName()).join();
userIsAuthorized = true;
} catch (CompletionException e) {
userIsAuthorized = false;
}
if (userIsAuthorized) {
String editLink = routes.AdminApplicationController.index(activeProgram.id(), Optional.empty(), Optional.empty()).url();
ContainerTag button = makeSvgTextButton("Applications", Icons.TEXT_SNIPPET_SVG_PATH).withId("program-view-apps-link-" + activeProgram.id()).withClass(AdminStyles.TERTIARY_BUTTON_STYLES);
return Optional.of(asRedirectButton(button, editLink));
}
return Optional.empty();
}
use of j2html.tags.ContainerTag 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);
}
use of j2html.tags.ContainerTag in project civiform by seattle-uat.
the class QuestionConfig method multiOptionQuestionField.
/**
* Creates an individual text field where an admin can enter a single multi-option question
* answer, along with a button to remove the option.
*/
private static ContainerTag multiOptionQuestionField(Optional<LocalizedQuestionOption> existingOption, Messages messages, boolean isForNewOption) {
ContainerTag optionInput = FieldWithLabel.input().setFieldName(isForNewOption ? "newOptions[]" : "options[]").setLabelText("Question option").addReferenceClass(ReferenceClasses.MULTI_OPTION_INPUT).setValue(existingOption.map(LocalizedQuestionOption::optionText)).setFieldErrors(messages, ImmutableSet.of(ValidationErrorMessage.create(MessageKey.MULTI_OPTION_VALIDATION))).showFieldErrors(false).getContainer().withClasses(Styles.FLEX, Styles.ML_2, Styles.GAP_X_3);
ContainerTag optionIndexInput = isForNewOption ? div() : FieldWithLabel.input().setFieldName("optionIds[]").setValue(String.valueOf(existingOption.get().id())).setScreenReaderText("option ids").getContainer().withClasses(Styles.HIDDEN);
Tag removeOptionButton = button("Remove").withType("button").withClasses(Styles.FLEX, Styles.ML_4, "multi-option-question-field-remove-button");
return div().withClasses(ReferenceClasses.MULTI_OPTION_QUESTION_OPTION, Styles.FLEX, Styles.FLEX_ROW, Styles.MB_4).with(optionInput, optionIndexInput, removeOptionButton);
}
use of j2html.tags.ContainerTag in project civiform by seattle-uat.
the class QuestionEditView method buildNewQuestionForm.
private ContainerTag buildNewQuestionForm(QuestionForm questionForm, ImmutableList<EnumeratorQuestionDefinition> enumeratorQuestionDefinitions) {
SelectWithLabel enumeratorOptions = enumeratorOptionsFromEnumerationQuestionDefinitions(questionForm, enumeratorQuestionDefinitions);
ContainerTag formTag = buildSubmittableQuestionForm(questionForm, enumeratorOptions, true);
formTag.withAction(controllers.admin.routes.AdminQuestionController.create(questionForm.getQuestionType().toString()).url()).with(submitButton("Create").withClass(Styles.M_4));
return formTag;
}
Aggregations