Search in sources :

Example 6 with HCDiv

use of com.helger.html.hc.html.grouping.HCDiv in project phoss-smp by phax.

the class PageSecureEndpointTree method showListOfExistingObjects.

@Override
protected void showListOfExistingObjects(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final ISMPServiceGroupManager aServiceGroupMgr = SMPMetaManager.getServiceGroupMgr();
    final ISMPServiceInformationManager aServiceInfoMgr = SMPMetaManager.getServiceInformationMgr();
    final BootstrapButtonToolbar aToolbar = new BootstrapButtonToolbar(aWPEC);
    aToolbar.addButton("Create new Endpoint", createCreateURL(aWPEC), EDefaultIcon.NEW);
    aToolbar.addButton("Refresh", aWPEC.getSelfHref(), EDefaultIcon.REFRESH);
    aToolbar.addButton("List view", aWPEC.getLinkToMenuItem(CMenuSecure.MENU_ENDPOINT_LIST), EDefaultIcon.MAGNIFIER);
    aNodeList.addChild(aToolbar);
    // Create list of service groups
    final ICommonsMap<ISMPServiceGroup, ICommonsList<ISMPServiceInformation>> aMap = new CommonsHashMap<>();
    aServiceInfoMgr.getAllSMPServiceInformation().forEach(x -> aMap.computeIfAbsent(x.getServiceGroup(), k -> new CommonsArrayList<>()).add(x));
    final HCUL aULSG = new HCUL();
    final ICommonsList<ISMPServiceGroup> aServiceGroups = aServiceGroupMgr.getAllSMPServiceGroups().getSortedInline(ISMPServiceGroup.comparator());
    for (final ISMPServiceGroup aServiceGroup : aServiceGroups) {
        // Print service group
        final IParticipantIdentifier aParticipantID = aServiceGroup.getParticipantIdentifier();
        final HCLI aLISG = aULSG.addAndReturnItem(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_SERVICE_GROUPS, aServiceGroup)).addChild(aParticipantID.getURIEncoded()));
        final HCUL aULDT = new HCUL();
        final ICommonsList<ISMPServiceInformation> aServiceInfos = aMap.get(aServiceGroup);
        if (aServiceInfos != null) {
            for (final ISMPServiceInformation aServiceInfo : aServiceInfos.getSortedInline(ISMPServiceInformation.comparator())) {
                final HCUL aULP = new HCUL();
                final IDocumentTypeIdentifier aDocTypeID = aServiceInfo.getDocumentTypeIdentifier();
                final ICommonsList<ISMPProcess> aProcesses = aServiceInfo.getAllProcesses().getSortedInline(ISMPProcess.comparator());
                for (final ISMPProcess aProcess : aProcesses) {
                    final BootstrapTable aEPTable = new BootstrapTable(HCCol.perc(40), HCCol.perc(40), HCCol.perc(20)).setBordered(true);
                    final ICommonsList<ISMPEndpoint> aEndpoints = aProcess.getAllEndpoints().getSortedInline(ISMPEndpoint.comparator());
                    for (final ISMPEndpoint aEndpoint : aEndpoints) {
                        final StringMap aParams = createParamMap(aServiceInfo, aProcess, aEndpoint);
                        final HCRow aBodyRow = aEPTable.addBodyRow();
                        final String sTransportProfile = aEndpoint.getTransportProfile();
                        final ISimpleURL aViewURL = createViewURL(aWPEC, aServiceInfo, aParams);
                        aBodyRow.addCell(new HCA(aViewURL).addChild(NiceNameUI.getTransportProfile(sTransportProfile, false)));
                        aBodyRow.addCell(aEndpoint.getEndpointReference());
                        final ISimpleURL aEditURL = createEditURL(aWPEC, aServiceInfo).addAll(aParams);
                        final ISimpleURL aCopyURL = createCopyURL(aWPEC, aServiceInfo).addAll(aParams);
                        final ISimpleURL aDeleteURL = createDeleteURL(aWPEC, aServiceInfo).addAll(aParams);
                        final ISimpleURL aPreviewURL = LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded());
                        aBodyRow.addAndReturnCell(new HCA(aViewURL).setTitle("View endpoint").addChild(EDefaultIcon.MAGNIFIER.getAsNode()), new HCTextNode(" "), new HCA(aEditURL).setTitle("Edit endpoint").addChild(EDefaultIcon.EDIT.getAsNode()), new HCTextNode(" "), new HCA(aCopyURL).setTitle("Copy endpoint").addChild(EDefaultIcon.COPY.getAsNode()), new HCTextNode(" "), new HCA(aDeleteURL).setTitle("Delete endpoint").addChild(EDefaultIcon.DELETE.getAsNode()), new HCTextNode(" "), new HCA(aPreviewURL).setTitle("Perform SMP query on endpoint").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode())).addClass(CSS_CLASS_RIGHT);
                    }
                    // Show process + endpoints
                    final HCLI aLI = aULP.addItem();
                    final HCDiv aDiv = div(NiceNameUI.getProcessID(aDocTypeID, aProcess.getProcessIdentifier(), false));
                    aLI.addChild(aDiv);
                    if (aEndpoints.isEmpty()) {
                        aDiv.addChild(" ").addChild(new HCA(aWPEC.getSelfHref().addAll(createParamMap(aServiceInfo, aProcess, (ISMPEndpoint) null)).add(CPageParam.PARAM_ACTION, ACTION_DELETE_PROCESS)).setTitle("Delete process").addChild(EDefaultIcon.DELETE.getAsNode()));
                    } else
                        aLI.addChild(aEPTable);
                }
                // Show document types + children
                final HCLI aLI = aULDT.addItem();
                final HCDiv aDiv = div().addChild(NiceNameUI.getDocumentTypeID(aServiceInfo.getDocumentTypeIdentifier(), false)).addChild(" ").addChild(new HCA(LinkHelper.getURLWithServerAndContext(aParticipantID.getURIPercentEncoded() + SMPRestFilter.PATH_SERVICES + aDocTypeID.getURIPercentEncoded())).setTitle("Perform SMP query on document type ").setTargetBlank().addChild(EFamFamIcon.SCRIPT_GO.getAsNode()));
                aLI.addChild(aDiv);
                if (aProcesses.isEmpty()) {
                    aDiv.addChild(" ").addChild(new HCA(aWPEC.getSelfHref().addAll(createParamMap(aServiceInfo, (ISMPProcess) null, (ISMPEndpoint) null)).add(CPageParam.PARAM_ACTION, ACTION_DELETE_DOCUMENT_TYPE)).setTitle("Delete document type").addChild(EDefaultIcon.DELETE.getAsNode()));
                } else
                    aLI.addChild(aULP);
            }
        }
        if (aServiceInfos == null || aServiceInfos.isEmpty() || aULDT.hasNoChildren())
            aLISG.addChild(" ").addChild(badgeInfo("This service group has no assigned endpoints!"));
        else
            aLISG.addChild(aULDT);
    }
    aNodeList.addChild(aULSG);
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ICommonsList(com.helger.commons.collection.impl.ICommonsList) StringMap(com.helger.commons.collection.attr.StringMap) HCNodeList(com.helger.html.hc.impl.HCNodeList) IDocumentTypeIdentifier(com.helger.peppolid.IDocumentTypeIdentifier) HCRow(com.helger.html.hc.html.tabular.HCRow) CommonsHashMap(com.helger.commons.collection.impl.CommonsHashMap) ISimpleURL(com.helger.commons.url.ISimpleURL) HCLI(com.helger.html.hc.html.grouping.HCLI) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) ISMPServiceInformationManager(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformationManager) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) HCA(com.helger.html.hc.html.textlevel.HCA) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) ISMPServiceInformation(com.helger.phoss.smp.domain.serviceinfo.ISMPServiceInformation) HCUL(com.helger.html.hc.html.grouping.HCUL) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) HCTextNode(com.helger.html.hc.impl.HCTextNode) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier)

Example 7 with HCDiv

use of com.helger.html.hc.html.grouping.HCDiv in project phoss-smp by phax.

the class SMPRendererSecure method getContent.

@Nonnull
public static IHCNode getContent(@Nonnull final ILayoutExecutionContext aLEC) {
    final HCNodeList ret = new HCNodeList();
    final BootstrapContainer aOuterContainer = ret.addAndReturnChild(new BootstrapContainer().setFluid(true));
    // Header
    aOuterContainer.addChild(_getNavbar(aLEC));
    // Breadcrumbs
    if (false) {
        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).addClass(CBootstrapCSS.MT_2));
        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)));
        aCol1.addChild(new HCDiv().setID(CLayout.LAYOUT_AREAID_SPECIAL));
        // content - determine is exactly same as for view
        aCol2.addChild(BootstrapPageRenderer.getPageContent(aLEC));
    }
    aOuterContainer.addChild(SMPRendererPublic.createDefaultFooter(true, true, true));
    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) BootstrapBreadcrumb(com.helger.photon.bootstrap4.breadcrumb.BootstrapBreadcrumb) Nonnull(javax.annotation.Nonnull)

Example 8 with HCDiv

use of com.helger.html.hc.html.grouping.HCDiv in project peppol-practical by phax.

the class PagePublicToolsParticipantInformation method _printTecInfo.

private void _printTecInfo(@Nonnull final IHCLI<?> aLIEndpoint, final String sTecInfo, final String sTecContact) {
    final HCDiv aDiv = div("Technical info: ");
    if (StringHelper.hasText(sTecInfo)) {
        final boolean bIsEmail = EmailAddressHelper.isValid(sTecInfo);
        aDiv.addChild(bIsEmail ? HCA_MailTo.createLinkedEmail(sTecInfo) : new HCTextNode(sTecInfo));
    }
    if (StringHelper.hasText(sTecContact)) {
        if (aDiv.getChildCount() > 1)
            aDiv.addChild(" / ");
        final boolean bIsEmail = EmailAddressHelper.isValid(sTecContact);
        aDiv.addChild(bIsEmail ? HCA_MailTo.createLinkedEmail(sTecContact) : new HCTextNode(sTecContact));
    }
    if (aDiv.getChildCount() > 1)
        aLIEndpoint.addChild(aDiv);
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) HCTextNode(com.helger.html.hc.impl.HCTextNode)

Example 9 with HCDiv

use of com.helger.html.hc.html.grouping.HCDiv in project peppol-practical by phax.

the class LayoutAreaContentProviderSecure 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)));
        aCol1.addChild(new HCDiv().setID(CLayout.LAYOUT_AREAID_SPECIAL));
        // content - determine is exactly same as for view
        aCol2.addChild(LayoutAreaContentProviderPublic.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) BootstrapBreadcrumb(com.helger.photon.bootstrap4.breadcrumb.BootstrapBreadcrumb) Nonnull(javax.annotation.Nonnull)

Example 10 with HCDiv

use of com.helger.html.hc.html.grouping.HCDiv in project peppol-practical by phax.

the class PagePublicNewsletterSubscribe method fillContent.

@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final CRMGroupManager aCRMGroupMgr = PPMetaManager.getCRMGroupMgr();
    final CRMSubscriberManager aCRMSubscriberMgr = PPMetaManager.getCRMSubscriberMgr();
    final FormErrorList aFormErrors = new FormErrorList();
    ICommonsList<String> aSelectedCRMGroupIDs = null;
    if (aWPEC.hasAction(CPageParam.ACTION_SAVE)) {
        final String sSalutationID = aWPEC.params().getAsString(FIELD_SALUTATION);
        final ESalutation eSalutation = ESalutation.getFromIDOrNull(sSalutationID);
        final String sName = aWPEC.params().getAsString(FIELD_NAME);
        final String sEmailAddress = aWPEC.params().getAsString(FIELD_EMAIL_ADDRESS);
        aSelectedCRMGroupIDs = aWPEC.params().getAsStringList(FIELD_GROUP);
        final ICommonsSet<ICRMGroup> aSelectedCRMGroups = new CommonsHashSet<>();
        ICRMSubscriber aSameEmailAddressSubscriber = null;
        if (StringHelper.hasNoText(sName))
            aFormErrors.addFieldError(FIELD_NAME, "You must provide your name!");
        if (StringHelper.hasNoText(sEmailAddress))
            aFormErrors.addFieldError(FIELD_EMAIL_ADDRESS, "You must provide your email address!");
        else if (!EmailAddressHelper.isValid(sEmailAddress))
            aFormErrors.addFieldError(FIELD_EMAIL_ADDRESS, "The provided email address is invalid!");
        else {
            // Check if the email address is already in use
            aSameEmailAddressSubscriber = aCRMSubscriberMgr.getCRMSubscriberOfEmailAddress(sEmailAddress);
        }
        if (aSelectedCRMGroupIDs != null)
            for (final String sCRMGroupID : aSelectedCRMGroupIDs) {
                final ICRMGroup aGroup = aCRMGroupMgr.getCRMGroupOfID(sCRMGroupID);
                if (aGroup == null)
                    aFormErrors.addFieldError(FIELD_GROUP, "The selected mailing list is not existing!");
                else
                    aSelectedCRMGroups.add(aGroup);
            }
        if (aSelectedCRMGroups.isEmpty())
            aFormErrors.addFieldError(FIELD_GROUP, "At least one mailing list must be selected!");
        else {
            if (aSameEmailAddressSubscriber != null) {
                // Merge with existing subscriber
                aSelectedCRMGroups.addAll(aSameEmailAddressSubscriber.getAllAssignedGroups());
            }
        }
        if (aFormErrors.isEmpty()) {
            // Save
            if (aSameEmailAddressSubscriber == null) {
                // Create a new one
                aCRMSubscriberMgr.createCRMSubscriber(eSalutation, sName, sEmailAddress, aSelectedCRMGroups);
            } else {
                // Update an existing one
                aCRMSubscriberMgr.updateCRMSubscriber(aSameEmailAddressSubscriber.getID(), eSalutation, sName, sEmailAddress, aSelectedCRMGroups);
            }
            aNodeList.addChild(success("Successfully subscribed '" + sEmailAddress + "' to mailing lists"));
        } else {
            aNodeList.addChild(getUIHandler().createIncorrectInputBox(aWPEC));
        }
    }
    final BootstrapForm aForm = getUIHandler().createFormSelf(aWPEC);
    aForm.setLeft(3);
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Your salutation").setCtrl(new HCSalutationSelect(new RequestField(FIELD_SALUTATION), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_SALUTATION)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your name").setCtrl(new HCEdit(new RequestField(FIELD_NAME))).setErrorList(aFormErrors.getListOfField(FIELD_NAME)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your email address").setCtrl(new HCEdit(new RequestField(FIELD_EMAIL_ADDRESS))).setErrorList(aFormErrors.getListOfField(FIELD_EMAIL_ADDRESS)));
    {
        final ICommonsList<? extends ICRMGroup> aAllCRMGroups = aCRMGroupMgr.getAll();
        if (aAllCRMGroups.size() == 1) {
            // No need for selection - use hidden field
            aForm.addChild(new HCHiddenField(FIELD_GROUP, aAllCRMGroups.getFirst().getID()));
        } else if (aAllCRMGroups.isNotEmpty()) {
            // Show selection
            final HCNodeList aGroups = new HCNodeList();
            for (final ICRMGroup aCRMGroup : aAllCRMGroups.getSorted(IHasDisplayName.getComparatorCollating(aDisplayLocale))) {
                final String sCRMGroupID = aCRMGroup.getID();
                final RequestFieldBooleanMultiValue aRFB = new RequestFieldBooleanMultiValue(FIELD_GROUP, sCRMGroupID, false);
                aGroups.addChild(new HCDiv().addChild(new HCCheckBox(aRFB)).addChild(" " + aCRMGroup.getDisplayName()));
            }
            aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Mailing lists to subscribe to").setCtrl(aGroups).setErrorList(aFormErrors.getListOfField(FIELD_GROUP)));
        }
    }
    // Toolbar
    final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
    aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_SAVE);
    aToolbar.addSubmitButton("Subscribe", EDefaultIcon.YES);
    aNodeList.addChild(aForm);
}
Also used : Locale(java.util.Locale) HCDiv(com.helger.html.hc.html.grouping.HCDiv) CRMSubscriberManager(com.helger.peppol.crm.CRMSubscriberManager) RequestFieldBooleanMultiValue(com.helger.photon.core.form.RequestFieldBooleanMultiValue) ICommonsList(com.helger.commons.collection.impl.ICommonsList) HCNodeList(com.helger.html.hc.impl.HCNodeList) ESalutation(com.helger.masterdata.person.ESalutation) HCHiddenField(com.helger.html.hc.html.forms.HCHiddenField) FormErrorList(com.helger.photon.core.form.FormErrorList) HCEdit(com.helger.html.hc.html.forms.HCEdit) ICRMSubscriber(com.helger.peppol.crm.ICRMSubscriber) CRMGroupManager(com.helger.peppol.crm.CRMGroupManager) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) HCCheckBox(com.helger.html.hc.html.forms.HCCheckBox) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) CommonsHashSet(com.helger.commons.collection.impl.CommonsHashSet) ICRMGroup(com.helger.peppol.crm.ICRMGroup) HCSalutationSelect(com.helger.photon.uicore.html.select.HCSalutationSelect) RequestField(com.helger.photon.core.form.RequestField)

Aggregations

HCDiv (com.helger.html.hc.html.grouping.HCDiv)32 Nonnull (javax.annotation.Nonnull)21 HCNodeList (com.helger.html.hc.impl.HCNodeList)18 Locale (java.util.Locale)16 IRequestWebScopeWithoutResponse (com.helger.web.scope.IRequestWebScopeWithoutResponse)11 HCEdit (com.helger.html.hc.html.forms.HCEdit)9 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)9 PDTToString (com.helger.commons.datetime.PDTToString)8 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)8 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)8 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)7 BootstrapTable (com.helger.photon.bootstrap4.table.BootstrapTable)7 RequestField (com.helger.photon.core.form.RequestField)7 HCSpan (com.helger.html.hc.html.textlevel.HCSpan)6 HCTextNode (com.helger.html.hc.impl.HCTextNode)6 JQueryAjaxBuilder (com.helger.html.jquery.JQueryAjaxBuilder)6 JSAnonymousFunction (com.helger.html.jscode.JSAnonymousFunction)6 JSAssocArray (com.helger.html.jscode.JSAssocArray)6 JSVar (com.helger.html.jscode.JSVar)6 BootstrapForm (com.helger.photon.bootstrap4.form.BootstrapForm)6