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;
}
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)));
}
}
Aggregations