Search in sources :

Example 26 with IRequestWebScopeWithoutResponse

use of com.helger.web.scope.IRequestWebScopeWithoutResponse 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;
}
Also used : Locale(java.util.Locale) HCDiv(com.helger.html.hc.html.grouping.HCDiv) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCSpan(com.helger.html.hc.html.textlevel.HCSpan) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) BootstrapNavbarNav(com.helger.photon.bootstrap4.navbar.BootstrapNavbarNav) BootstrapNavbar(com.helger.photon.bootstrap4.navbar.BootstrapNavbar) BootstrapDropdownMenu(com.helger.photon.bootstrap4.dropdown.BootstrapDropdownMenu) ISimpleURL(com.helger.commons.url.ISimpleURL) IUser(com.helger.photon.security.user.IUser) BootstrapNavbarToggleable(com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) Nonnull(javax.annotation.Nonnull)

Example 27 with IRequestWebScopeWithoutResponse

use of com.helger.web.scope.IRequestWebScopeWithoutResponse in project peppol-practical by phax.

the class AppCommonUI method init.

public static void init() {
    RequestParameterManager.getInstance().setParameterHandler(new RequestParameterHandlerURLPathNamed());
    BootstrapDataTables.setConfigurator((aLEC, aTable, aDataTables) -> {
        final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
        aDataTables.setAutoWidth(false).setLengthMenu(LENGTH_MENU).setAjaxBuilder(new JQueryAjaxBuilder().url(CAjax.DATATABLES.getInvocationURL(aRequestScope)).data(new JSAssocArray().add(AjaxExecutorDataTables.OBJECT_ID, aTable.getID()))).setServerFilterType(EDataTablesFilterType.ALL_TERMS_PER_ROW).setTextLoadingURL(CAjax.DATATABLES_I18N.getInvocationURL(aRequestScope), AjaxExecutorDataTablesI18N.LANGUAGE_ID).addPlugin(new DataTablesPluginSearchHighlight());
    });
    // By default allow markdown in system message
    BootstrapSystemMessage.setDefaultUseMarkdown(true);
    // Register comment handlers
    CommentThreadManager.getInstance().registerObjectType(CPPApp.OT_PAGE);
}
Also used : IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) JQueryAjaxBuilder(com.helger.html.jquery.JQueryAjaxBuilder) RequestParameterHandlerURLPathNamed(com.helger.photon.core.requestparam.RequestParameterHandlerURLPathNamed) JSAssocArray(com.helger.html.jscode.JSAssocArray) DataTablesPluginSearchHighlight(com.helger.photon.uictrls.datatables.plugins.DataTablesPluginSearchHighlight)

Example 28 with IRequestWebScopeWithoutResponse

use of com.helger.web.scope.IRequestWebScopeWithoutResponse 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;
}
Also used : Locale(java.util.Locale) HCDiv(com.helger.html.hc.html.grouping.HCDiv) JSAnonymousFunction(com.helger.html.jscode.JSAnonymousFunction) JSVar(com.helger.html.jscode.JSVar) HCEdit(com.helger.html.hc.html.forms.HCEdit) HCEditPassword(com.helger.html.hc.html.forms.HCEditPassword) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) JQueryAjaxBuilder(com.helger.html.jquery.JQueryAjaxBuilder) JSPackage(com.helger.html.jscode.JSPackage) JSAssocArray(com.helger.html.jscode.JSAssocArray) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) RequestField(com.helger.photon.core.form.RequestField) Nonnull(javax.annotation.Nonnull)

Example 29 with IRequestWebScopeWithoutResponse

use of com.helger.web.scope.IRequestWebScopeWithoutResponse in project peppol-practical by phax.

the class AppLayoutHTMLProvider method fillBody.

@Override
protected void fillBody(@Nonnull final ISimpleWebExecutionContext aSWEC, @Nonnull final HCHtml aHtml) throws ForcedRedirectException {
    final IRequestWebScopeWithoutResponse aRequestScope = aSWEC.getRequestScope();
    final Locale aDisplayLocale = aSWEC.getDisplayLocale();
    final IMenuItemPage aMenuItem = RequestSettings.getMenuItem(aRequestScope);
    final LayoutExecutionContext aLEC = new LayoutExecutionContext(aSWEC, aMenuItem);
    final HCHead aHead = aHtml.head();
    final HCBody aBody = aHtml.body();
    // Add menu item in page title
    aHead.setPageTitle(StringHelper.getConcatenatedOnDemand(AppHelper.getApplicationTitle(), " - ", aMenuItem.getDisplayText(aDisplayLocale)));
    final IHCNode aNode = m_aFactory.apply(aLEC);
    aBody.addChild(aNode);
}
Also used : Locale(java.util.Locale) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) LayoutExecutionContext(com.helger.photon.core.execcontext.LayoutExecutionContext) HCBody(com.helger.html.hc.html.sections.HCBody) HCHead(com.helger.html.hc.html.metadata.HCHead) IMenuItemPage(com.helger.photon.core.menu.IMenuItemPage) IHCNode(com.helger.html.hc.IHCNode)

Aggregations

IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)29 Locale (java.util.Locale)23 Nonnull (javax.annotation.Nonnull)16 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)14 HCDiv (com.helger.html.hc.html.grouping.HCDiv)13 HCNodeList (com.helger.html.hc.impl.HCNodeList)13 ISimpleURL (com.helger.commons.url.ISimpleURL)9 JQueryAjaxBuilder (com.helger.html.jquery.JQueryAjaxBuilder)9 JSAssocArray (com.helger.html.jscode.JSAssocArray)9 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)9 IUser (com.helger.photon.security.user.IUser)9 IHCNode (com.helger.html.hc.IHCNode)8 HCEdit (com.helger.html.hc.html.forms.HCEdit)7 HCStrong (com.helger.html.hc.html.textlevel.HCStrong)7 ICommonsList (com.helger.commons.collection.impl.ICommonsList)6 PDTToString (com.helger.commons.datetime.PDTToString)6 HCA (com.helger.html.hc.html.textlevel.HCA)6 JSAnonymousFunction (com.helger.html.jscode.JSAnonymousFunction)6 JSVar (com.helger.html.jscode.JSVar)6 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)6