Search in sources :

Example 26 with BootstrapButton

use of com.helger.photon.bootstrap4.button.BootstrapButton in project phoss-smp by phax.

the class PageSecureServiceGroupMigrationOutbound method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMPParticipantMigrationManager aParticipantMigrationMgr = SMPMetaManager.getParticipantMigrationMgr();
    final ISMPSettings aSettings = SMPMetaManager.getSettings();
    final ISMPServiceGroupManager aServiceGroupManager = SMPMetaManager.getServiceGroupMgr();
    {
        final HCOL aOL = new HCOL();
        aOL.addItem("The migration is initiated on this SMP, and the SML is informed about the upcoming migration");
        aOL.addItem("The other SMP, that is taking over the Service Group, must acknowledge the migration by providing the same migration code (created by this SMP) to the SML");
        aOL.addItem("If the migration was successful, the Service Group must be deleted from this SMP, ideally a temporary redirect to the new SMP is created. If the migration was cancelled no action is needed.");
        aNodeList.addChild(info().addChild(div("The process of migrating a Service Group to another SMP consists of multiple steps:")).addChild(aOL).addChild(div("Therefore each open Migration must either be finished (deleting the Service Group) or cancelled (no action taken)." + " If a Migration is cancelled, it can be retried later.")));
    }
    EValidity eCanStartMigration = EValidity.VALID;
    if (aSettings.getSMLInfo() == null) {
        final BootstrapWarnBox aWarn = aNodeList.addAndReturnChild(warn().addChild(div("No valid SML Configuration is selected hence no participant can be migrated.")).addChild(div(new BootstrapButton().addChild("Select SML Configuration in the Settings").setOnClick(aWPEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).setIcon(EDefaultIcon.EDIT))));
        if (aSettings.isSMLEnabled() || aSettings.isSMLRequired()) {
            aWarn.addChild(div(new BootstrapButton().addChild("Create a new SML Configuration").setOnClick(createCreateURL(aWPEC, CMenuSecure.MENU_SML_CONFIGURATION)).setIcon(EDefaultIcon.YES)));
        }
        eCanStartMigration = EValidity.INVALID;
    } else if (!aSettings.isSMLEnabled()) {
        aNodeList.addChild(warn().addChild(div("SML Connection is not enabled hence no participant can be migrated.")).addChild(div(new BootstrapButton().addChild("Enable SML in the Settings").setOnClick(aWPEC.getLinkToMenuItem(CMenuSecure.MENU_SMP_SETTINGS)).setIcon(EDefaultIcon.EDIT))));
        eCanStartMigration = EValidity.INVALID;
    } else {
        if (aServiceGroupManager.getSMPServiceGroupCount() <= 0) {
            aNodeList.addChild(warn("No Service Group is present! At least one Service Group must be present to migrate it."));
            // Note: makes no to allow to create a new Service Group here and than
            // directly migrate it away
            eCanStartMigration = EValidity.INVALID;
        }
    }
    {
        final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
        aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
        aToolbar.addChild(new BootstrapButton().addChild("Start Participant Migration").setOnClick(createCreateURL(aWPEC)).setDisabled(eCanStartMigration.isInvalid()).setIcon(EDefaultIcon.NEW));
        aNodeList.addChild(aToolbar);
    }
    final BootstrapTabBox aTabBox = aNodeList.addAndReturnChild(new BootstrapTabBox());
    final ICommonsList<ISMPParticipantMigration> aAllMigs = aParticipantMigrationMgr.getAllOutboundParticipantMigrations(null);
    for (final EParticipantMigrationState eState : EParticipantMigrationState.values()) if (eState.isOutboundState()) {
        final ICommonsList<ISMPParticipantMigration> aMatchingMigs = aAllMigs.getAll(x -> x.getState() == eState);
        aTabBox.addTab(eState.getID(), eState.getDisplayName() + " (" + aMatchingMigs.size() + ")", _createTable(aWPEC, aMatchingMigs, eState));
    }
}
Also used : HCOL(com.helger.html.hc.html.grouping.HCOL) WebPageExecutionContext(com.helger.photon.uicore.page.WebPageExecutionContext) EDefaultIcon(com.helger.photon.uicore.icon.EDefaultIcon) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) LoggerFactory(org.slf4j.LoggerFactory) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) AbstractBootstrapWebPageActionHandlerDelete(com.helger.photon.bootstrap4.pages.handler.AbstractBootstrapWebPageActionHandlerDelete) FormErrorList(com.helger.photon.core.form.FormErrorList) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) ICommonsIterable(com.helger.commons.collection.impl.ICommonsIterable) HCServiceGroupSelect(com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect) Nonempty(com.helger.commons.annotation.Nonempty) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) Locale(java.util.Locale) HCA(com.helger.html.hc.html.textlevel.HCA) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) CPageParam(com.helger.photon.uicore.css.CPageParam) ISMPParticipantMigrationManager(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager) SMPCommonUI(com.helger.phoss.smp.ui.SMPCommonUI) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) BootstrapTabBox(com.helger.photon.bootstrap4.nav.BootstrapTabBox) IHCCell(com.helger.html.hc.html.tabular.IHCCell) EWebPageFormAction(com.helger.photon.uicore.page.EWebPageFormAction) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) ICommonsList(com.helger.commons.collection.impl.ICommonsList) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ManageParticipantIdentifierServiceCaller(com.helger.peppol.smlclient.ManageParticipantIdentifierServiceCaller) ICommonsSet(com.helger.commons.collection.impl.ICommonsSet) DataTables(com.helger.photon.uictrls.datatables.DataTables) HCRow(com.helger.html.hc.html.tabular.HCRow) EValidity(com.helger.commons.state.EValidity) AbstractSMPWebPageForm(com.helger.phoss.smp.ui.AbstractSMPWebPageForm) IHCNode(com.helger.html.hc.IHCNode) EParticipantMigrationState(com.helger.phoss.smp.domain.pmigration.EParticipantMigrationState) SMPKeyManager(com.helger.phoss.smp.security.SMPKeyManager) EDTColType(com.helger.photon.uictrls.datatables.column.EDTColType) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) ISimpleURL(com.helger.commons.url.ISimpleURL) HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapWarnBox(com.helger.photon.bootstrap4.alert.BootstrapWarnBox) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) Logger(org.slf4j.Logger) StringHelper(com.helger.commons.string.StringHelper) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) HCTable(com.helger.html.hc.html.tabular.HCTable) SMPMetaManager(com.helger.phoss.smp.domain.SMPMetaManager) RequestField(com.helger.photon.core.form.RequestField) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) SMPServerConfiguration(com.helger.phoss.smp.SMPServerConfiguration) ESortOrder(com.helger.commons.compare.ESortOrder) AbstractBootstrapWebPageActionHandlerWithQuery(com.helger.photon.bootstrap4.pages.handler.AbstractBootstrapWebPageActionHandlerWithQuery) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) EValidity(com.helger.commons.state.EValidity) ICommonsList(com.helger.commons.collection.impl.ICommonsList) HCNodeList(com.helger.html.hc.impl.HCNodeList) EParticipantMigrationState(com.helger.phoss.smp.domain.pmigration.EParticipantMigrationState) BootstrapTabBox(com.helger.photon.bootstrap4.nav.BootstrapTabBox) BootstrapWarnBox(com.helger.photon.bootstrap4.alert.BootstrapWarnBox) ISMPParticipantMigration(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigration) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) HCOL(com.helger.html.hc.html.grouping.HCOL) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) ISMPParticipantMigrationManager(com.helger.phoss.smp.domain.pmigration.ISMPParticipantMigrationManager) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Example 27 with BootstrapButton

use of com.helger.photon.bootstrap4.button.BootstrapButton in project phoss-smp by phax.

the class PageSecureTransportProfiles method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMPTransportProfileManager aTransportProfileMgr = SMPMetaManager.getTransportProfileMgr();
    aNodeList.addChild(info("This page lets you create custom transport profiles that can be used in service information endpoints."));
    final ICommonsList<ISMPTransportProfile> aList = aTransportProfileMgr.getAllSMPTransportProfiles();
    final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
    aToolbar.addChild(new BootstrapButton().addChild("Create new transport profile").setOnClick(createCreateURL(aWPEC)).setIcon(EDefaultIcon.NEW));
    final ICommonsSet<String> aExistingIDs = new CommonsHashSet<>(aList, ISMPTransportProfile::getID);
    if (!aExistingIDs.containsAll(DEFAULT_PROFILE_IDS)) {
        // Show button only on demand
        aToolbar.addChild(new BootstrapButton().addChild("Ensure all default transport profiles").setOnClick(aWPEC.getSelfHref().add(CPageParam.PARAM_ACTION, ACTION_ENSURE_DEFAULT)).setIcon(EDefaultIcon.PLUS));
    }
    aNodeList.addChild(aToolbar);
    final HCTable aTable = new HCTable(new DTCol("ID").setInitialSorting(ESortOrder.ASCENDING), new DTCol("Name"), new DTCol("Deprecated?"), new BootstrapDTColAction(aDisplayLocale)).setID(getID());
    for (final ISMPTransportProfile aCurObject : aList) {
        final ISimpleURL aViewLink = createViewURL(aWPEC, aCurObject);
        final HCRow aRow = aTable.addBodyRow();
        aRow.addCell(new HCA(aViewLink).addChild(aCurObject.getID()));
        aRow.addCell(aCurObject.getName());
        aRow.addCell(EPhotonCoreText.getYesOrNo(aCurObject.isDeprecated(), aDisplayLocale));
        aRow.addCell(createEditLink(aWPEC, aCurObject, "Edit " + aCurObject.getID()), new HCTextNode(" "), createCopyLink(aWPEC, aCurObject, "Copy " + aCurObject.getID()), new HCTextNode(" "), isActionAllowed(aWPEC, EWebPageFormAction.DELETE, aCurObject) ? createDeleteLink(aWPEC, aCurObject, "Delete " + aCurObject.getID()) : createEmptyAction());
    }
    final DataTables aDataTables = BootstrapDataTables.createDefaultDataTables(aWPEC, aTable);
    aNodeList.addChild(aTable).addChild(aDataTables);
}
Also used : Locale(java.util.Locale) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCA(com.helger.html.hc.html.textlevel.HCA) HCRow(com.helger.html.hc.html.tabular.HCRow) HCTable(com.helger.html.hc.html.tabular.HCTable) ISMPTransportProfileManager(com.helger.phoss.smp.domain.transportprofile.ISMPTransportProfileManager) ISMPTransportProfile(com.helger.peppol.smp.ISMPTransportProfile) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) ISimpleURL(com.helger.commons.url.ISimpleURL) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) HCTextNode(com.helger.html.hc.impl.HCTextNode) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) DataTables(com.helger.photon.uictrls.datatables.DataTables) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables)

Example 28 with BootstrapButton

use of com.helger.photon.bootstrap4.button.BootstrapButton in project phoss-smp by phax.

the class PageSecureServiceGroup method isValidToDisplayPage.

@Override
@Nonnull
protected IValidityIndicator isValidToDisplayPage(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final IUserManager aUserMgr = PhotonSecurityManager.getUserMgr();
    if (aUserMgr.getActiveUserCount() == 0) {
        aNodeList.addChild(warn("No user is present! At least one user must be present to create a service group."));
        aNodeList.addChild(new BootstrapButton().addChild("Create new user").setOnClick(createCreateURL(aWPEC, BootstrapPagesMenuConfigurator.MENU_ADMIN_SECURITY_USER)).setIcon(EDefaultIcon.YES));
        return EValidity.INVALID;
    }
    return super.isValidToDisplayPage(aWPEC);
}
Also used : HCNodeList(com.helger.html.hc.impl.HCNodeList) IUserManager(com.helger.photon.security.user.IUserManager) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) Nonnull(javax.annotation.Nonnull)

Example 29 with BootstrapButton

use of com.helger.photon.bootstrap4.button.BootstrapButton in project phoss-smp by phax.

the class PageSecureServiceGroupExport method fillContent.

@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
    final ISMPSettings aSettings = SMPMetaManager.getSettings();
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final long nServiceGroupCount = aServiceGroupMgr.getSMPServiceGroupCount();
    final boolean bHandleBusinessCards = aSettings.isDirectoryIntegrationEnabled();
    if (nServiceGroupCount < 0)
        aNodeList.addChild(error("The number of service groups is unknown, hence nothing can be exported!"));
    else if (nServiceGroupCount == 0)
        aNodeList.addChild(warn("Since no service group is present, nothing can be exported!"));
    else {
        aNodeList.addChild(info("Export " + (nServiceGroupCount == 1 ? "service group" : "all " + nServiceGroupCount + " service groups") + (bHandleBusinessCards ? " and business card" + (nServiceGroupCount == 1 ? "" : "s") : "") + " to an XML file."));
    }
    // The main export logic happens in the AJAX handler
    final BootstrapButtonToolbar aToolbar = aNodeList.addAndReturnChild(getUIHandler().createToolbar(aWPEC));
    aToolbar.addChild(new BootstrapButton().addChild("Export all Service Groups").setIcon(EDefaultIcon.SAVE_ALL).setOnClick(AJAX_EXPORT_SG.getInvocationURL(aRequestScope)).setDisabled(nServiceGroupCount <= 0));
}
Also used : IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)

Example 30 with BootstrapButton

use of com.helger.photon.bootstrap4.button.BootstrapButton 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

BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)34 HCNodeList (com.helger.html.hc.impl.HCNodeList)25 Locale (java.util.Locale)23 Nonnull (javax.annotation.Nonnull)21 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)14 IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)14 ISimpleURL (com.helger.commons.url.ISimpleURL)12 HCDiv (com.helger.html.hc.html.grouping.HCDiv)10 HCRow (com.helger.html.hc.html.tabular.HCRow)10 ISMPServiceGroupManager (com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager)10 PDTToString (com.helger.commons.datetime.PDTToString)9 HCEdit (com.helger.html.hc.html.forms.HCEdit)9 RequestField (com.helger.photon.core.form.RequestField)9 IUser (com.helger.photon.security.user.IUser)9 DTCol (com.helger.photon.uictrls.datatables.column.DTCol)8 HCTable (com.helger.html.hc.html.tabular.HCTable)7 HCA (com.helger.html.hc.html.textlevel.HCA)7 HCStrong (com.helger.html.hc.html.textlevel.HCStrong)7 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)7 ISMPSettings (com.helger.phoss.smp.settings.ISMPSettings)6