Search in sources :

Example 6 with HCSpan

use of com.helger.html.hc.html.textlevel.HCSpan in project phoss-directory by phax.

the class SecureHTMLProvider method _getNavbar.

@Nonnull
private static IHCNode _getNavbar(@Nonnull final SimpleWebExecutionContext aSWEC) {
    final Locale aDisplayLocale = aSWEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aSWEC.getRequestScope();
    final ISimpleURL aLinkToStartPage = aSWEC.getLinkToMenuItem(aSWEC.getMenuTree().getDefaultMenuItemID());
    final BootstrapNavbar aNavbar = new BootstrapNavbar();
    aNavbar.addBrand(new HCNodeList().addChild(new HCSpan().addClass(AppCommonUI.CSS_CLASS_LOGO1).addChild(CPDPublisher.getApplicationTitle())).addChild(new HCSpan().addClass(AppCommonUI.CSS_CLASS_LOGO2).addChild(" Administration")), aLinkToStartPage);
    final BootstrapNavbarToggleable aToggleable = aNavbar.addAndReturnToggleable();
    {
        final IUser aUser = LoggedInUserManager.getInstance().getCurrentUser();
        aToggleable.addAndReturnText().addClass(CBootstrapCSS.ML_AUTO).addClass(CBootstrapCSS.MX_2).addChild("Welcome ").addChild(new HCStrong().addChild(SecurityHelper.getUserDisplayName(aUser, aDisplayLocale)));
        aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MX_2).addChild("Goto public area").setOnClick(LinkHelper.getURLWithContext(AbstractPublicApplicationServlet.SERVLET_DEFAULT_PATH + "/")));
        aToggleable.addChild(new BootstrapButton().addClass(CBootstrapCSS.MX_2).setOnClick(LinkHelper.getURLWithContext(aRequestScope, LogoutServlet.SERVLET_DEFAULT_PATH)).addChild(EPhotonCoreText.LOGIN_LOGOUT.getDisplayText(aDisplayLocale)));
    }
    return aNavbar;
}
Also used : Locale(java.util.Locale) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) HCSpan(com.helger.html.hc.html.textlevel.HCSpan) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapNavbar(com.helger.photon.bootstrap4.navbar.BootstrapNavbar) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapNavbarToggleable(com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable) IUser(com.helger.photon.security.user.IUser) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) Nonnull(javax.annotation.Nonnull)

Example 7 with HCSpan

use of com.helger.html.hc.html.textlevel.HCSpan in project phoss-directory by phax.

the class PublicHTMLProvider method _getNavbar.

@Nonnull
private static BootstrapNavbar _getNavbar(@Nonnull final LayoutExecutionContext aLEC) {
    final ISimpleURL aLinkToStartPage = aLEC.getLinkToMenuItem(aLEC.getMenuTree().getDefaultMenuItemID());
    final BootstrapNavbar aNavbar = new BootstrapNavbar();
    final HCImg aImg = AppCommonUI.createLogoImg();
    if (aImg != null)
        aNavbar.addBrand(aImg, aLinkToStartPage);
    aNavbar.addBrand(new HCSpan().addClass(AppCommonUI.CSS_CLASS_LOGO1).addChild(CPDPublisher.getApplicationTitle()), aLinkToStartPage);
    _addNavbarLoginLogout(aLEC, aNavbar);
    return aNavbar;
}
Also used : HCSpan(com.helger.html.hc.html.textlevel.HCSpan) BootstrapNavbar(com.helger.photon.bootstrap4.navbar.BootstrapNavbar) ISimpleURL(com.helger.commons.url.ISimpleURL) HCImg(com.helger.html.hc.html.embedded.HCImg) Nonnull(javax.annotation.Nonnull)

Example 8 with HCSpan

use of com.helger.html.hc.html.textlevel.HCSpan in project phoss-directory by phax.

the class SecureHTMLProvider method getContent.

@Nonnull
public static IHCNode getContent(@Nonnull final LayoutExecutionContext aLEC) {
    final HCNodeList ret = new HCNodeList();
    // Header
    ret.addChild(_getNavbar(aLEC));
    final BootstrapContainer aOuterContainer = ret.addAndReturnChild(new BootstrapContainer().setFluid(true));
    // Breadcrumbs
    {
        final BootstrapBreadcrumb aBreadcrumbs = BootstrapBreadcrumbProvider.createBreadcrumb(aLEC);
        aBreadcrumbs.addClasses(CBootstrapCSS.D_NONE, CBootstrapCSS.D_SM_BLOCK);
        aOuterContainer.addChild(aBreadcrumbs);
    }
    // Content
    {
        final HCDiv aRow = aOuterContainer.addAndReturnChild(new HCDiv().addClass(CBootstrapCSS.D_MD_FLEX));
        final HCDiv aCol1 = aRow.addAndReturnChild(new HCDiv().addClass(CBootstrapCSS.D_MD_FLEX).addClass(CBootstrapCSS.MR_2));
        final HCDiv aCol2 = aRow.addAndReturnChild(new HCDiv().addClass(CBootstrapCSS.FLEX_FILL));
        // left
        // We need a wrapper span for easy AJAX content replacement
        aCol1.addClass(CBootstrapCSS.D_PRINT_NONE).addChild(new HCSpan().setID(CLayout.LAYOUT_AREAID_MENU).addChild(getMenuContent(aLEC)).addChild(new HCDiv().addChild(new HCSmall().addChild(CDirectoryVersion.BUILD_VERSION))).addChild(new HCDiv().addChild(new HCSmall().addChild(CDirectoryVersion.BUILD_TIMESTAMP))));
        aCol1.addChild(new HCDiv().setID(CLayout.LAYOUT_AREAID_SPECIAL));
        // content - determine is exactly same as for view
        aCol2.addChild(BootstrapPageRenderer.getPageContent(aLEC));
    }
    return ret;
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) HCSpan(com.helger.html.hc.html.textlevel.HCSpan) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapContainer(com.helger.photon.bootstrap4.layout.BootstrapContainer) HCSmall(com.helger.html.hc.html.textlevel.HCSmall) BootstrapBreadcrumb(com.helger.photon.bootstrap4.breadcrumb.BootstrapBreadcrumb) Nonnull(javax.annotation.Nonnull)

Example 9 with HCSpan

use of com.helger.html.hc.html.textlevel.HCSpan in project phoss-smp by phax.

the class SMPRendererPublic method _getNavbar.

@Nonnull
private static BootstrapNavbar _getNavbar(@Nonnull final ILayoutExecutionContext aLEC) {
    final ISimpleURL aLinkToStartPage = aLEC.getLinkToMenuItem(aLEC.getMenuTree().getDefaultMenuItemID());
    final BootstrapNavbar aNavBar = new BootstrapNavbar();
    aNavBar.addBrand(createLogo(aLEC), aLinkToStartPage);
    aNavBar.addBrand(new HCSpan().addChild(CSMP.getApplicationTitle()), aLinkToStartPage);
    _addNavbarLoginLogout(aLEC, aNavBar);
    return aNavBar;
}
Also used : HCSpan(com.helger.html.hc.html.textlevel.HCSpan) BootstrapNavbar(com.helger.photon.bootstrap4.navbar.BootstrapNavbar) ISimpleURL(com.helger.commons.url.ISimpleURL) Nonnull(javax.annotation.Nonnull)

Example 10 with HCSpan

use of com.helger.html.hc.html.textlevel.HCSpan in project peppol-practical by phax.

the class CommentUI method getCommentList.

@Nonnull
public static IHCNode getCommentList(@Nonnull final ILayoutExecutionContext aLEC, @Nonnull final ITypedObject<String> aObject, @Nonnull final CommentAction aCommentAction, @Nullable final CommentFormErrors aFormErrors, @Nullable final IHCNode aMessageBox, final boolean bShowCreateComments) {
    ValueEnforcer.notNull(aLEC, "LEC");
    ValueEnforcer.notNull(aObject, "Object");
    ValueEnforcer.notNull(aCommentAction, "CommentAction");
    final Locale aDisplayLocale = aLEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    final HCDiv ret = new HCDiv();
    final String sResultDivID = ret.ensureID().getID();
    final boolean bUserCanCreateComments = CommentSecurity.canCurrentUserPostComments();
    final boolean bIsAdmin = aLEC.isLoggedInUserAdministrator();
    // Get all existing comments
    final List<ICommentThread> aComments = CommentThreadManager.getInstance().getAllCommentThreadsOfObject(aObject);
    if (CollectionHelper.isNotEmpty(aComments)) {
        final IUserManager aUserMgr = PhotonSecurityManager.getUserMgr();
        final boolean bIsCommentModerator = CommentSecurity.isCurrentUserCommentModerator();
        // Container for all threads
        final HCDiv aAllThreadsContainer = new HCDiv().addClass(CCommentCSS.CSS_CLASS_COMMENT_CONTAINER);
        for (final ICommentThread aCommentThread : CollectionHelper.getSorted(aComments, Comparator.comparing(ICommentThread::getInitialCommentCreationDateTime))) {
            // Container for this thread
            final HCDiv aThreadContainer = new HCDiv();
            aThreadContainer.addClass(CCommentCSS.CSS_CLASS_COMMENT_THREAD);
            final NonBlockingStack<AbstractHCDiv<?>> aStack = new NonBlockingStack<>();
            aStack.push(aThreadContainer);
            aCommentThread.iterateAllComments(new ICommentIterationCallback() {

                public void onCommentStart(final int nLevel, @Nullable final IComment aParentComment, @Nonnull final IComment aComment) {
                    // Show only approved comments
                    final boolean bIsApproved = aComment.getState().isApproved();
                    if (bIsApproved || bIsCommentModerator) {
                        // Get author name and determine if it is a registered user
                        boolean bRegisteredUser = false;
                        String sAuthor = null;
                        if (StringHelper.hasText(aComment.getUserID())) {
                            final IUser aUser = aUserMgr.getUserOfID(aComment.getUserID());
                            if (aUser != null) {
                                sAuthor = aUser.getDisplayName();
                                bRegisteredUser = true;
                            }
                        }
                        if (sAuthor == null)
                            sAuthor = aComment.getCreatorName();
                        // Fill panel header
                        final BootstrapCard aCommentPanel = new BootstrapCard();
                        final BootstrapCardHeader aHeader = aCommentPanel.createAndAddHeader();
                        final BootstrapCardBody aBody = aCommentPanel.createAndAddBody();
                        if (!bIsApproved)
                            aHeader.addClass(CBootstrapCSS.BG_DANGER);
                        // Is comment deleted?
                        if (aComment.isDeleted())
                            aHeader.addChild(new HCStrong().addChild(ECommentText.MSG_IS_DELETED.getDisplayText(aDisplayLocale)));
                        // Creation date
                        aHeader.addChild(new HCSpan().addChild(PDTToString.getAsString(aComment.getCreationDateTime(), aDisplayLocale)).addClass(CCommentCSS.CSS_CLASS_COMMENT_CREATIONDT));
                        // Author
                        aHeader.addChild(ECommentText.MSG_BY.getDisplayText(aDisplayLocale));
                        final HCSpan aAuthor = new HCSpan().addChild(sAuthor).addClass(CCommentCSS.CSS_CLASS_COMMENT_AUTHOR);
                        if (bRegisteredUser)
                            aAuthor.addClass(CCommentCSS.CSS_CLASS_COMMENT_REGISTERED_USER);
                        if (bIsAdmin)
                            aAuthor.addChild(bRegisteredUser ? " [registered]" : " [not-registered]");
                        aHeader.addChild(aAuthor);
                        // Title
                        if (StringHelper.hasText(aComment.getTitle())) {
                            aHeader.addChild(ECommentText.MSG_SEPARATOR_AUTHOR_TITLE.getDisplayText(aDisplayLocale));
                            aHeader.addChild(new HCSpan().addChild(aComment.getTitle()).addClass(CCommentCSS.CSS_CLASS_COMMENT_TITLE));
                        }
                        // Toolbar
                        final HCSpan aCommentToolbar = new HCSpan().addClass(CCommentCSS.CSS_CLASS_COMMENT_TOOLBAR);
                        HCDiv aCommentResponseContainer = null;
                        // Respond to a comment - at maximum 6 levels
                        if (bShowCreateComments && bUserCanCreateComments && !aComment.isDeleted() && nLevel < 6) {
                            aCommentResponseContainer = new HCDiv();
                            final BootstrapButton aResponseButton = new BootstrapButton(EBootstrapButtonSize.SMALL).setIcon(EDefaultIcon.ADD);
                            aCommentToolbar.addChild(aResponseButton);
                            aCommentToolbar.addChild(new BootstrapTooltip(aResponseButton).setTitle(ECommentText.TOOLTIP_RESPONSE.getDisplayText(aDisplayLocale)));
                            if (aCommentAction.isMatching(ECommentAction.ADD_COMMENT, aCommentThread, aComment) && aFormErrors != null && aFormErrors.isReplyTo(aCommentThread, aComment)) {
                                // Upon adding a response
                                if (aMessageBox == null || !aFormErrors.isEmpty()) {
                                    // Show the input form again
                                    aCommentResponseContainer.addChild(getCreateComment(aLEC, sResultDivID, aObject, aCommentThread, aComment, aFormErrors, aMessageBox));
                                } else {
                                    // Show the success or error message
                                    aBody.addChild(aMessageBox);
                                }
                            } else {
                                // Add the JS to show the input form
                                final JSAnonymousFunction aOnSuccess = new JSAnonymousFunction();
                                final JSVar aJSData = aOnSuccess.param("data");
                                aOnSuccess.body().add(JQuery.idRef(aCommentResponseContainer).empty().append(aJSData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
                                final JQueryInvocation aResponseAction = new JQueryAjaxBuilder().url(CAjax.COMMENT_SHOW_INPUT.getInvocationURL(aRequestScope)).data(new JSAssocArray().add(AjaxExecutorCommentShowInput.PARAM_OBJECT_TYPE, aObject.getObjectType().getName()).add(AjaxExecutorCommentShowInput.PARAM_OBJECT_ID, aObject.getID()).add(AjaxExecutorCommentShowInput.PARAM_COMMENT_THREAD_ID, aCommentThread.getID()).add(AjaxExecutorCommentShowInput.PARAM_COMMENT_ID, aComment.getID()).add(AjaxExecutorCommentShowInput.PARAM_RESULT_DIV_ID, sResultDivID)).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aOnSuccess, null)).build();
                                aResponseButton.setOnClick(aResponseAction);
                            }
                        }
                        if (bIsCommentModerator) {
                            if (aCommentAction.isMatching(ECommentAction.DELETE_COMMENT, aCommentThread, aComment))
                                aBody.addChild(aMessageBox);
                            // Can the comment be deleted?
                            if (!aComment.isDeleted()) {
                                final BootstrapButton aDeleteButton = new BootstrapButton(EBootstrapButtonSize.SMALL).setIcon(EDefaultIcon.DELETE);
                                aCommentToolbar.addChild(aDeleteButton);
                                aCommentToolbar.addChild(new BootstrapTooltip(aDeleteButton).setTitle(ECommentText.TOOLTIP_DELETE.getDisplayText(aDisplayLocale)));
                                final JSAnonymousFunction aOnSuccess = new JSAnonymousFunction();
                                final JSVar aJSData = aOnSuccess.param("data");
                                aOnSuccess.body().add(JQuery.idRef(sResultDivID).replaceWith(aJSData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
                                final JQueryInvocation aDeleteAction = new JQueryAjaxBuilder().url(CAjax.COMMENT_DELETE.getInvocationURL(aRequestScope)).data(new JSAssocArray().add(AjaxExecutorCommentDelete.PARAM_OBJECT_TYPE, aObject.getObjectType().getName()).add(AjaxExecutorCommentDelete.PARAM_OBJECT_ID, aObject.getID()).add(AjaxExecutorCommentDelete.PARAM_COMMENT_THREAD_ID, aCommentThread.getID()).add(AjaxExecutorCommentDelete.PARAM_COMMENT_ID, aComment.getID())).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aOnSuccess, null)).build();
                                aDeleteButton.setOnClick(aDeleteAction);
                            }
                            // Show source host and further info
                            aCommentToolbar.addChild(BootstrapSimpleTooltip.createSimpleTooltip(ECommentText.TOOLTIP_HOST.getDisplayTextWithArgs(aDisplayLocale, aComment.getHost())));
                        }
                        if (aCommentToolbar.hasChildren())
                            aHeader.addChild(aCommentToolbar);
                        // Last modification
                        if (aComment.getLastModificationDateTime() != null) {
                            final String sLastModDT = PDTToString.getAsString(aComment.getLastModificationDateTime(), aDisplayLocale);
                            final String sLastModText = aComment.getEditCount() > 0 ? ECommentText.MSG_EDITED_AND_LAST_MODIFICATION.getDisplayTextWithArgs(aDisplayLocale, Integer.valueOf(aComment.getEditCount()), sLastModDT) : ECommentText.MSG_LAST_MODIFICATION.getDisplayTextWithArgs(aDisplayLocale, sLastModDT);
                            aHeader.addChild(new HCDiv().addChild(sLastModText).addClass(CCommentCSS.CSS_CLASS_COMMENT_LAST_MODIFICATION));
                        }
                        // Show the main comment text
                        aBody.addClass(CCommentCSS.CSS_CLASS_SINGLE_COMMENT);
                        // Always put the text as the first part of the body
                        aBody.addChildAt(0, new HCDiv().addChildren(HCExtHelper.nl2brList(aComment.getText())).addClass(CCommentCSS.CSS_CLASS_COMMENT_TEXT));
                        // the dummy container for new comment form
                        aBody.addChild(aCommentResponseContainer);
                        aStack.peek().addChild(aCommentPanel);
                        aStack.push(aBody);
                    } else {
                        // Don't display - push the previous item
                        aStack.push(aStack.peek());
                    }
                }

                public void onCommentEnd(final int nLevel, @Nullable final IComment aParentComment, @Nonnull final IComment aComment) {
                    aStack.pop();
                }
            });
            // Show only thread panels which contain at least one comment
            if (aThreadContainer.hasChildren())
                aAllThreadsContainer.addChild(aThreadContainer);
        }
        ret.addChild(aAllThreadsContainer);
    }
    if (bShowCreateComments) {
        // Create comment only for logged in users
        if (bUserCanCreateComments) {
            // Add "create comment" button
            final boolean bIsForCreateThread = aCommentAction.isMatching(ECommentAction.CREATE_THREAD);
            ret.addChild(getCreateComment(aLEC, sResultDivID, aObject, null, null, bIsForCreateThread ? aFormErrors : null, bIsForCreateThread ? aMessageBox : null));
        } else
            ret.addChild(new BootstrapBadge(EBootstrapBadgeType.INFO).addChild(ECommentText.MSG_LOGIN_TO_COMMENT.getDisplayText(aDisplayLocale)));
    }
    return ret;
}
Also used : Locale(java.util.Locale) HCDiv(com.helger.html.hc.html.grouping.HCDiv) AbstractHCDiv(com.helger.html.hc.html.grouping.AbstractHCDiv) BootstrapCardHeader(com.helger.photon.bootstrap4.card.BootstrapCardHeader) IComment(com.helger.peppol.comment.domain.IComment) JQueryInvocation(com.helger.html.jquery.JQueryInvocation) IUserManager(com.helger.photon.security.user.IUserManager) PDTToString(com.helger.commons.datetime.PDTToString) ICommentThread(com.helger.peppol.comment.domain.ICommentThread) HCSpan(com.helger.html.hc.html.textlevel.HCSpan) JQueryAjaxBuilder(com.helger.html.jquery.JQueryAjaxBuilder) IUser(com.helger.photon.security.user.IUser) ICommentIterationCallback(com.helger.peppol.comment.domain.ICommentIterationCallback) BootstrapCard(com.helger.photon.bootstrap4.card.BootstrapCard) HCStrong(com.helger.html.hc.html.textlevel.HCStrong) JSAnonymousFunction(com.helger.html.jscode.JSAnonymousFunction) BootstrapBadge(com.helger.photon.bootstrap4.badge.BootstrapBadge) JSVar(com.helger.html.jscode.JSVar) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) AbstractHCDiv(com.helger.html.hc.html.grouping.AbstractHCDiv) BootstrapTooltip(com.helger.photon.bootstrap4.tooltip.BootstrapTooltip) BootstrapCardBody(com.helger.photon.bootstrap4.card.BootstrapCardBody) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) JSAssocArray(com.helger.html.jscode.JSAssocArray) NonBlockingStack(com.helger.commons.collection.NonBlockingStack) Nonnull(javax.annotation.Nonnull)

Aggregations

HCSpan (com.helger.html.hc.html.textlevel.HCSpan)12 Nonnull (javax.annotation.Nonnull)12 ISimpleURL (com.helger.commons.url.ISimpleURL)8 HCDiv (com.helger.html.hc.html.grouping.HCDiv)6 HCNodeList (com.helger.html.hc.impl.HCNodeList)6 BootstrapNavbar (com.helger.photon.bootstrap4.navbar.BootstrapNavbar)6 Locale (java.util.Locale)6 HCStrong (com.helger.html.hc.html.textlevel.HCStrong)5 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)5 BootstrapContainer (com.helger.photon.bootstrap4.layout.BootstrapContainer)5 IUser (com.helger.photon.security.user.IUser)5 IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)5 BootstrapBreadcrumb (com.helger.photon.bootstrap4.breadcrumb.BootstrapBreadcrumb)4 BootstrapNavbarToggleable (com.helger.photon.bootstrap4.navbar.BootstrapNavbarToggleable)4 SimpleURL (com.helger.commons.url.SimpleURL)2 HCP (com.helger.html.hc.html.grouping.HCP)2 HCA (com.helger.html.hc.html.textlevel.HCA)2 HCSmall (com.helger.html.hc.html.textlevel.HCSmall)2 NonBlockingStack (com.helger.commons.collection.NonBlockingStack)1 CommonsHashSet (com.helger.commons.collection.impl.CommonsHashSet)1