Search in sources :

Example 6 with CRMGroupManager

use of com.helger.peppol.crm.CRMGroupManager 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;
}
Also used : HCNodeList(com.helger.html.hc.impl.HCNodeList) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) CRMGroupManager(com.helger.peppol.crm.CRMGroupManager) Nonnull(javax.annotation.Nonnull)

Example 7 with CRMGroupManager

use of com.helger.peppol.crm.CRMGroupManager in project peppol-practical by phax.

the class PageSecureCRMSubscriber method showInputForm.

@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ICRMSubscriber aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
    final CRMGroupManager aCRMGroupMgr = PPMetaManager.getCRMGroupMgr();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    aForm.addChild(getUIHandler().createActionHeader(eFormAction.isEdit() ? "Edit CRM subscriber" : "Create new CRM subscriber"));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Salutation").setCtrl(new HCSalutationSelect(new RequestField(FIELD_SALUTATION, aSelectedObject == null ? null : aSelectedObject.getSalutationID()), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_SALUTATION)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Name").setCtrl(new HCEdit(new RequestField(FIELD_NAME, aSelectedObject == null ? null : aSelectedObject.getName()))).setErrorList(aFormErrors.getListOfField(FIELD_NAME)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Email address").setCtrl(new HCEdit(new RequestField(FIELD_EMAIL_ADDRESS, aSelectedObject == null ? null : aSelectedObject.getEmailAddress()))).setErrorList(aFormErrors.getListOfField(FIELD_EMAIL_ADDRESS)));
    {
        final HCNodeList aGroups = new HCNodeList();
        for (final ICRMGroup aCRMGroup : aCRMGroupMgr.getAll().getSortedInline(IHasDisplayName.getComparatorCollating(aDisplayLocale))) {
            final String sCRMGroupID = aCRMGroup.getID();
            final RequestFieldBooleanMultiValue aRFB = new RequestFieldBooleanMultiValue(FIELD_GROUP, sCRMGroupID, aSelectedObject != null && aSelectedObject.isAssignedToGroup(aCRMGroup));
            aGroups.addChild(div(new HCCheckBox(aRFB).setValue(sCRMGroupID)).addChild(" " + aCRMGroup.getDisplayName()));
        }
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Assigned groups").setCtrl(aGroups).setErrorList(aFormErrors.getListOfField(FIELD_GROUP)));
    }
}
Also used : Locale(java.util.Locale) RequestFieldBooleanMultiValue(com.helger.photon.core.form.RequestFieldBooleanMultiValue) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCEdit(com.helger.html.hc.html.forms.HCEdit) PDTToString(com.helger.commons.datetime.PDTToString) HCCheckBox(com.helger.html.hc.html.forms.HCCheckBox) CRMGroupManager(com.helger.peppol.crm.CRMGroupManager) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) HCSalutationSelect(com.helger.photon.uicore.html.select.HCSalutationSelect) ICRMGroup(com.helger.peppol.crm.ICRMGroup) RequestField(com.helger.photon.core.form.RequestField)

Aggregations

CRMGroupManager (com.helger.peppol.crm.CRMGroupManager)7 HCNodeList (com.helger.html.hc.impl.HCNodeList)6 ICRMGroup (com.helger.peppol.crm.ICRMGroup)4 CRMSubscriberManager (com.helger.peppol.crm.CRMSubscriberManager)3 Locale (java.util.Locale)3 CommonsHashSet (com.helger.commons.collection.impl.CommonsHashSet)2 PDTToString (com.helger.commons.datetime.PDTToString)2 HCCheckBox (com.helger.html.hc.html.forms.HCCheckBox)2 HCEdit (com.helger.html.hc.html.forms.HCEdit)2 ESalutation (com.helger.masterdata.person.ESalutation)2 ICRMSubscriber (com.helger.peppol.crm.ICRMSubscriber)2 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)2 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)2 RequestField (com.helger.photon.core.form.RequestField)2 RequestFieldBooleanMultiValue (com.helger.photon.core.form.RequestFieldBooleanMultiValue)2 HCSalutationSelect (com.helger.photon.uicore.html.select.HCSalutationSelect)2 ICommonsList (com.helger.commons.collection.impl.ICommonsList)1 InitializationException (com.helger.commons.exception.InitializationException)1 ISimpleURL (com.helger.commons.url.ISimpleURL)1 DAOException (com.helger.dao.DAOException)1