use of com.helger.photon.bootstrap4.button.BootstrapButton in project peppol-practical by phax.
the class CommentUI method getCreateComment.
@Nonnull
public static IHCNode getCreateComment(@Nonnull final ILayoutExecutionContext aLEC, @Nonnull final String sResultDivID, @Nonnull final ITypedObject<String> aObject, @Nullable final ICommentThread aCommentThread, @Nullable final IComment aParentComment, @Nullable final CommentFormErrors aFormErrors, @Nullable final IHCNode aMessageBox) {
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IUser aLoggedInUser = LoggedInUserManager.getInstance().getCurrentUser();
final boolean bIsCreateNewThread = aCommentThread == null || aParentComment == null;
final HCDiv aFormContainer = new HCDiv();
if (bIsCreateNewThread)
if (aFormErrors == null || aFormErrors.isEmpty())
aFormContainer.addStyle(CCSSProperties.DISPLAY_NONE);
aFormContainer.addClass(CCommentCSS.CSS_CLASS_COMMENT_CREATE);
if (aFormErrors != null && !aFormErrors.isEmpty())
aFormContainer.addChild(new BootstrapErrorBox().addChild(EPhotonCoreText.ERR_INCORRECT_INPUT.getDisplayText(aDisplayLocale)));
final BootstrapViewForm aForm = aFormContainer.addAndReturnChild(new BootstrapViewForm());
aForm.setTitle(ECommentText.MSG_CREATE_COMMENT.getDisplayText(aDisplayLocale));
HCEdit aEditAuthor = null;
if (aLoggedInUser != null) {
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory(ECommentText.MSG_FIELD_AUTHOR.getDisplayText(aDisplayLocale)).setCtrl(aLoggedInUser.getDisplayName()));
} else {
aEditAuthor = new HCEdit(new RequestField(FIELD_COMMENT_AUTHOR));
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory(ECommentText.MSG_FIELD_AUTHOR.getDisplayText(aDisplayLocale)).setCtrl(aEditAuthor).setHelpText(ECommentText.DESC_FIELD_AUTHOR.getDisplayText(aDisplayLocale)).setErrorList(aFormErrors == null ? null : aFormErrors.getListOfField(FIELD_COMMENT_AUTHOR)));
}
final HCEdit aEditTitle = new HCEdit(new RequestField(FIELD_COMMENT_TITLE));
aForm.addFormGroup(new BootstrapFormGroup().setLabel(ECommentText.MSG_FIELD_TITLE.getDisplayText(aDisplayLocale)).setCtrl(aEditTitle).setHelpText(ECommentText.DESC_FIELD_TITLE.getDisplayText(aDisplayLocale)).setErrorList(aFormErrors == null ? null : aFormErrors.getListOfField(FIELD_COMMENT_TITLE)));
final HCTextAreaAutosize aTextAreaContent = new HCTextAreaAutosize(new RequestField(FIELD_COMMENT_TEXT)).setRows(5);
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory(ECommentText.MSG_FIELD_TEXT.getDisplayText(aDisplayLocale)).setCtrl(aTextAreaContent).setHelpText(ECommentText.DESC_FIELD_TEXT.getDisplayText(aDisplayLocale)).setErrorList(aFormErrors == null ? null : aFormErrors.getListOfField(FIELD_COMMENT_TEXT)));
final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aLEC);
// What to do on save?
{
final JSAnonymousFunction aOnSuccess = new JSAnonymousFunction();
final JSVar aJSData = aOnSuccess.param("data");
aOnSuccess.body().add(JQuery.idRef(sResultDivID).replaceWith(aJSData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
JQueryInvocation aSaveAction;
if (bIsCreateNewThread) {
// Create a new thread
aSaveAction = new JQueryAjaxBuilder().url(CAjax.COMMENT_CREATE_THREAD.getInvocationURL(aRequestScope)).data(new JSAssocArray().add(AjaxExecutorCommentCreateThread.PARAM_OBJECT_TYPE, aObject.getObjectType().getName()).add(AjaxExecutorCommentCreateThread.PARAM_OBJECT_ID, aObject.getID()).add(AjaxExecutorCommentCreateThread.PARAM_AUTHOR, aLoggedInUser != null ? JSExpr.lit("") : JQuery.idRef(aEditAuthor).val()).add(AjaxExecutorCommentCreateThread.PARAM_TITLE, JQuery.idRef(aEditTitle).val()).add(AjaxExecutorCommentCreateThread.PARAM_TEXT, JQuery.idRef(aTextAreaContent).val())).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aOnSuccess, null)).build();
} else {
// Reply to a previous comment
aSaveAction = new JQueryAjaxBuilder().url(CAjax.COMMENT_ADD.getInvocationURL(aRequestScope)).data(new JSAssocArray().add(AjaxExecutorCommentAdd.PARAM_OBJECT_TYPE, aObject.getObjectType().getName()).add(AjaxExecutorCommentAdd.PARAM_OBJECT_ID, aObject.getID()).add(AjaxExecutorCommentAdd.PARAM_COMMENT_THREAD_ID, aCommentThread.getID()).add(AjaxExecutorCommentAdd.PARAM_COMMENT_ID, aParentComment.getID()).add(AjaxExecutorCommentAdd.PARAM_OBJECT_ID, aObject.getID()).add(AjaxExecutorCommentAdd.PARAM_AUTHOR, aLoggedInUser != null ? JSExpr.lit("") : JQuery.idRef(aEditAuthor).val()).add(AjaxExecutorCommentAdd.PARAM_TITLE, JQuery.idRef(aEditTitle).val()).add(AjaxExecutorCommentAdd.PARAM_TEXT, JQuery.idRef(aTextAreaContent).val())).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aOnSuccess, null)).build();
}
aToolbar.addButtonSave(aDisplayLocale, aSaveAction);
}
BootstrapButton aButtonCreate = null;
if (bIsCreateNewThread) {
// The create button
aButtonCreate = new BootstrapButton().addChild(ECommentText.MSG_CREATE_COMMENT.getDisplayText(aDisplayLocale));
aButtonCreate.setOnClick(new JSStatementList(JQuery.idRef(aFormContainer).show(), JQuery.jQueryThis().disable()));
}
// What to do on cancel?
{
final JSStatementList aCancelAction = new JSStatementList(JQuery.idRefMultiple(aEditTitle, aTextAreaContent).val(""), JQuery.idRef(aFormContainer).hide());
if (aButtonCreate != null)
aCancelAction.add(JQuery.idRef(aButtonCreate).enable());
if (aEditAuthor != null)
aCancelAction.add(JQuery.idRef(aEditAuthor).val(""));
aToolbar.addButtonCancel(aDisplayLocale, aCancelAction);
}
aFormContainer.addChild(aToolbar);
// Show create comment button
final HCNodeList ret = new HCNodeList();
ret.addChild(aButtonCreate);
ret.addChild(aFormContainer);
ret.addChild(aMessageBox);
return ret;
}
use of com.helger.photon.bootstrap4.button.BootstrapButton in project peppol-practical by phax.
the class LayoutAreaContentProviderPublic method _getNavbar.
@Nonnull
private static BootstrapNavbar _getNavbar(final LayoutExecutionContext aLEC) {
final ISimpleURL aLinkToStartPage = aLEC.getLinkToMenuItem(aLEC.getMenuTree().getDefaultMenuItemID());
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
final IUser aUser = LoggedInUserManager.getInstance().getCurrentUser();
final BootstrapNavbar aNavbar = new BootstrapNavbar();
aNavbar.addBrand(new HCSpan().addClass(AppCommonUI.CSS_CLASS_LOGO1).addChild(AppHelper.getApplicationTitle()), aLinkToStartPage);
aNavbar.addChild(new BootstrapButton(EBootstrapButtonType.DEFAULT).addChild("Participant information").setIcon(EFamFamIcon.USER_GREEN).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_TOOLS_PARTICIPANT_INFO)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
aNavbar.addChild(new BootstrapButton(EBootstrapButtonType.DEFAULT).addChild("Document validation").setIcon(EFamFamIcon.SCRIPT_GO).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_VALIDATION_UPLOAD)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
aNavbar.addChild(new BootstrapButton(EBootstrapButtonType.DEFAULT).addChild("ID information").setIcon(EFamFamIcon.CUP).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_TOOLS_ID_INFO)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
if (aUser != null) {
aToggleable.addAndReturnText().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2).addChild("Welcome ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
if (SecurityHelper.hasUserRole(aUser.getID(), CPPApp.ROLE_CONFIG_ID)) {
aToggleable.addChild(new BootstrapButton().setOnClick(LinkHelper.getURLWithContext(AbstractSecureApplicationServlet.SERVLET_DEFAULT_PATH)).addChild("Administration").addClass(CBootstrapCSS.MX_2));
}
aToggleable.addChild(new BootstrapButton().setOnClick(LinkHelper.getURLWithContext(aRequestScope, LogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)).addClass(CBootstrapCSS.MX_2));
} else {
// show login in Navbar
final BootstrapNavbarNav aNav = aToggleable.addAndReturnNav();
final BootstrapDropdownMenu aDropDown = new BootstrapDropdownMenu();
{
final HCDiv aDiv = new HCDiv().addClass(CBootstrapCSS.P_2).addStyle(CCSSProperties.MIN_WIDTH.newValue("400px"));
aDiv.addChild(AppCommonUI.createViewLoginForm(aLEC, null, false));
aDropDown.addChild(aDiv);
}
aNav.addItem().addNavDropDown("Login", aDropDown);
aToggleable.addChild(new BootstrapButton(EBootstrapButtonType.SUCCESS).addChild(EPhotonCoreText.BUTTON_SIGN_UP.getDisplayText(aDisplayLocale)).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_SIGN_UP)).addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2));
}
return aNavbar;
}
use of com.helger.photon.bootstrap4.button.BootstrapButton in project peppol-practical by phax.
the class AppCommonUI method createViewLoginForm.
@Nonnull
public static BootstrapForm createViewLoginForm(@Nonnull final LayoutExecutionContext aLEC, @Nullable final String sPreselectedUserName, final boolean bShowRegistration) {
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
// Use new IDs for both fields, in case the login stuff is displayed more
// than once!
final String sIDUserName = GlobalIDFactory.getNewStringID();
final String sIDPassword = GlobalIDFactory.getNewStringID();
final String sIDErrorField = GlobalIDFactory.getNewStringID();
final BootstrapForm aForm = new BootstrapForm(aLEC).setAction(aLEC.getSelfHref()).setFormType(EBootstrapFormType.DEFAULT);
aForm.setLeft(3);
// Placeholder for error message
aForm.addChild(new HCDiv().setID(sIDErrorField).addStyle(CCSSProperties.MARGIN.newValue("4px 0")));
// User name field
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory(EPhotonCoreText.EMAIL_ADDRESS.getDisplayText(aDisplayLocale)).setCtrl(new HCEdit(new RequestField(CLogin.REQUEST_ATTR_USERID, sPreselectedUserName)).setPlaceholder(EPhotonCoreText.EMAIL_ADDRESS.getDisplayText(aDisplayLocale)).setID(sIDUserName)));
// Password field
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory(EPhotonCoreText.LOGIN_FIELD_PASSWORD.getDisplayText(aDisplayLocale)).setCtrl(new HCEditPassword(CLogin.REQUEST_ATTR_PASSWORD).setPlaceholder(EPhotonCoreText.LOGIN_FIELD_PASSWORD.getDisplayText(aDisplayLocale)).setID(sIDPassword)));
// Login button
final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aLEC));
{
final JSPackage aOnClick = new JSPackage();
final JSAnonymousFunction aJSSuccess = new JSAnonymousFunction();
final JSVar aJSData = aJSSuccess.param("data");
aJSSuccess.body()._if(aJSData.ref(AjaxExecutorPublicLogin.JSON_LOGGEDIN), JSHtml.windowLocationReload(), JQuery.idRef(sIDErrorField).empty().append(aJSData.ref(AjaxExecutorPublicLogin.JSON_HTML)));
aOnClick.add(new JQueryAjaxBuilder().url(CAjax.LOGIN.getInvocationURI(aRequestScope)).method(EHttpMethod.POST).data(new JSAssocArray().add(CLogin.REQUEST_ATTR_USERID, JQuery.idRef(sIDUserName).val()).add(CLogin.REQUEST_ATTR_PASSWORD, JQuery.idRef(sIDPassword).val())).success(aJSSuccess).build());
aOnClick._return(false);
aToolbar.addSubmitButton(EPhotonCoreText.LOGIN_BUTTON_SUBMIT.getDisplayText(aDisplayLocale), aOnClick, EDefaultIcon.YES.getIcon());
}
if (bShowRegistration) {
aToolbar.addChild(new BootstrapButton(EBootstrapButtonType.SUCCESS).addChild(EPhotonCoreText.BUTTON_SIGN_UP.getDisplayText(aDisplayLocale)).setOnClick(aLEC.getLinkToMenuItem(CMenuPublic.MENU_SIGN_UP)));
}
return aForm;
}
use of com.helger.photon.bootstrap4.button.BootstrapButton in project peppol-practical by phax.
the class PageSecureCRMSubscriber method isValidToDisplayPage.
@Override
@Nonnull
protected EValidity isValidToDisplayPage(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final CRMGroupManager aCRMGroupMgr = PPMetaManager.getCRMGroupMgr();
if (aCRMGroupMgr.isEmpty()) {
aNodeList.addChild(warn("No CRM groups is present! At least one CRM group must be present to assign a subscriber to"));
aNodeList.addChild(new BootstrapButton().addChild("Create new CRM group").setOnClick(createCreateURL(aWPEC, CMenuSecure.MENU_CRM_GROUPS)).setIcon(EDefaultIcon.YES));
return EValidity.INVALID;
}
return EValidity.VALID;
}
Aggregations