use of com.helger.photon.bootstrap4.form.BootstrapViewForm in project phoss-smp by phax.
the class PageSecureBusinessCard method _createEntityInputForm.
@Nonnull
private static IHCNode _createEntityInputForm(@Nonnull final LayoutExecutionContext aLEC, @Nullable final SMPBusinessCardEntity aExistingEntity, @Nullable final String sExistingID, @Nonnull final FormErrorList aFormErrors, final boolean bFormSubmitted) {
final Locale aDisplayLocale = aLEC.getDisplayLocale();
final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
final String sEntityID = StringHelper.hasText(sExistingID) ? sExistingID : TMP_ID_PREFIX + Integer.toString(GlobalIDFactory.getNewIntID());
final BootstrapCard aPanel = new BootstrapCard().setID(sEntityID);
aPanel.createAndAddHeader().addChild("Business Entity");
final BootstrapCardBody aBody = aPanel.createAndAddBody();
final BootstrapViewForm aForm = aBody.addAndReturnChild(new BootstrapViewForm());
final String sFieldName = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_NAME);
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Name").setCtrl(new HCEdit(new RequestField(sFieldName, aExistingEntity == null ? null : aExistingEntity.names().getFirst().getName()))).setErrorList(aFormErrors.getListOfField(sFieldName)));
final String sFieldCountryCode = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_COUNTRY_CODE);
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Country").setCtrl(new HCCountrySelect(new RequestField(sFieldCountryCode, aExistingEntity == null ? null : aExistingEntity.getCountryCode()), aDisplayLocale, HCCountrySelect.getAllCountries(EWithDeprecated.DEFAULT), (aLocale, aContentLocale) -> aLocale.getDisplayCountry(aContentLocale) + " (" + aLocale.getCountry() + ")")).setErrorList(aFormErrors.getListOfField(sFieldCountryCode)));
final String sFieldGeoInfo = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_GEO_INFO);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Geographical Information").setCtrl(new HCTextArea(new RequestField(sFieldGeoInfo, aExistingEntity == null ? null : aExistingEntity.getGeographicalInformation()))).setErrorList(aFormErrors.getListOfField(sFieldGeoInfo)));
// Identifiers
{
final String sBodyID = sEntityID + PREFIX_IDENTIFIER;
final HCNodeList aNL = new HCNodeList();
final BootstrapTable aTable = aNL.addAndReturnChild(new BootstrapTable(HCCol.star(), HCCol.star(), HCCol.star()));
aTable.addHeaderRow().addCells("Scheme", "Value", "");
aTable.setBodyID(sBodyID);
final IRequestParamMap aIdentifiers = aLEC.getRequestParamMap().getMap(PREFIX_ENTITY, sEntityID, PREFIX_IDENTIFIER);
if (bFormSubmitted) {
// Re-show of form
if (aIdentifiers != null)
for (final String sIdentifierRowID : aIdentifiers.keySet()) aTable.addBodyRow(_createIdentifierInputForm(aLEC, sEntityID, null, sIdentifierRowID, aFormErrors));
} else {
if (aExistingEntity != null) {
// add all existing stored entities
for (final SMPBusinessCardIdentifier aIdentifier : aExistingEntity.identifiers()) aTable.addBodyRow(_createIdentifierInputForm(aLEC, sEntityID, aIdentifier, (String) null, aFormErrors));
}
}
{
final JSAnonymousFunction aJSAppend = new JSAnonymousFunction();
final JSVar aJSAppendData = aJSAppend.param("data");
aJSAppend.body().add(JQuery.idRef(sBodyID).append(aJSAppendData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
final JSPackage aOnAdd = new JSPackage();
aOnAdd.add(new JQueryAjaxBuilder().url(AJAX_CREATE_IDENTIFIER.getInvocationURL(aRequestScope).add(PARAM_ENTITY_ID, sEntityID)).data(new JSAssocArray()).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aJSAppend, null)).build());
aNL.addChild(new BootstrapButton().setIcon(EDefaultIcon.PLUS).addChild("Add Identifier").setOnClick(aOnAdd));
}
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Identifiers").setCtrl(aNL));
}
// Website URIs
final String sFieldWebsiteURIs = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_WEBSITE_URIS);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Website URIs").setCtrl(new HCTextArea(new RequestField(sFieldWebsiteURIs, aExistingEntity == null ? null : StringHelper.getImploded('\n', aExistingEntity.websiteURIs())))).setHelpText("Put each Website URI in a separate line").setErrorList(aFormErrors.getListOfField(sFieldWebsiteURIs)));
// Contacts
{
final String sBodyID = sEntityID + PREFIX_CONTACT;
final HCNodeList aNL = new HCNodeList();
final BootstrapTable aTable = aNL.addAndReturnChild(new BootstrapTable(HCCol.star(), HCCol.star(), HCCol.star(), HCCol.star(), HCCol.star()));
aTable.addHeaderRow().addCells("Type", "Name", "Phone number", "Email address", "");
aTable.setBodyID(sBodyID);
final IRequestParamMap aContacts = aLEC.getRequestParamMap().getMap(PREFIX_ENTITY, sEntityID, PREFIX_CONTACT);
if (bFormSubmitted) {
// Re-show of form
if (aContacts != null)
for (final String sIdentifierRowID : aContacts.keySet()) aTable.addBodyRow(_createContactInputForm(aLEC, sEntityID, null, sIdentifierRowID, aFormErrors));
} else {
if (aExistingEntity != null) {
// add all existing stored entities
for (final SMPBusinessCardContact aContact : aExistingEntity.contacts()) aTable.addBodyRow(_createContactInputForm(aLEC, sEntityID, aContact, (String) null, aFormErrors));
}
}
{
final JSAnonymousFunction aJSAppend = new JSAnonymousFunction();
final JSVar aJSAppendData = aJSAppend.param("data");
aJSAppend.body().add(JQuery.idRef(sBodyID).append(aJSAppendData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
final JSPackage aOnAdd = new JSPackage();
aOnAdd.add(new JQueryAjaxBuilder().url(AJAX_CREATE_CONTACT.getInvocationURL(aRequestScope).add(PARAM_ENTITY_ID, sEntityID)).data(new JSAssocArray()).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aJSAppend, null)).build());
aNL.addChild(new BootstrapButton().setIcon(EDefaultIcon.PLUS).addChild("Add Contact").setOnClick(aOnAdd));
}
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Contacts").setCtrl(aNL));
}
final String sFieldAdditionalInfo = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_ADDITIONAL_INFO);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Additional Information").setCtrl(new HCTextArea(new RequestField(sFieldAdditionalInfo, aExistingEntity == null ? null : aExistingEntity.getAdditionalInformation()))).setErrorList(aFormErrors.getListOfField(sFieldAdditionalInfo)));
final String sFieldRegDate = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, SUFFIX_REG_DATE);
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Registration Date").setCtrl(BootstrapDateTimePicker.create(sFieldRegDate, aExistingEntity == null ? null : aExistingEntity.getRegistrationDate(), aDisplayLocale)).setErrorList(aFormErrors.getListOfField(sFieldRegDate)));
final BootstrapButtonToolbar aToolbar = aBody.addAndReturnChild(new BootstrapButtonToolbar(aLEC));
aToolbar.addButton("Delete this Entity", JQuery.idRef(aPanel).remove(), EDefaultIcon.DELETE);
return aPanel;
}
use of com.helger.photon.bootstrap4.form.BootstrapViewForm in project phoss-smp by phax.
the class PageSecureServiceGroup method showSelectedObject.
@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ISMPServiceGroup aSelectedObject) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final ISMPSettings aSettings = SMPMetaManager.getSettings();
final boolean bShowBusinessCard = CSMP.ENABLE_ISSUE_56 && aSettings.isDirectoryIntegrationEnabled();
aNodeList.addChild(getUIHandler().createActionHeader("Show details of service group '" + aSelectedObject.getID() + "'"));
final BootstrapViewForm aForm = new BootstrapViewForm();
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Participant ID").setCtrl(aSelectedObject.getParticipantIdentifier().getURIEncoded()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Owning user").setCtrl(SMPCommonUI.getOwnerName(aSelectedObject.getOwnerID())));
if (aSelectedObject.extensions().isNotEmpty())
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Extension").setCtrl(SMPCommonUI.getExtensionDisplay(aSelectedObject)));
if (bShowBusinessCard) {
aForm.addChild(getUIHandler().createDataGroupHeader("Business Card Details"));
final ISMPBusinessCardManager aBCMgr = SMPMetaManager.getBusinessCardMgr();
final ISMPBusinessCard aBC = aBCMgr.getSMPBusinessCardOfServiceGroup(aSelectedObject);
if (aBC != null) {
int nIndex = 0;
for (final SMPBusinessCardEntity aEntity : aBC.getAllEntities()) {
++nIndex;
aForm.addChild(PageSecureBusinessCard.showBusinessCardEntity(aEntity, nIndex, aDisplayLocale));
}
}
}
aNodeList.addChild(aForm);
}
use of com.helger.photon.bootstrap4.form.BootstrapViewForm in project phoss-smp by phax.
the class PageSecureServiceGroupMigrationOutbound method showSelectedObject.
@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, @Nonnull final ISMPParticipantMigration aSelectedObject) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
aNodeList.addChild(getUIHandler().createActionHeader("Show details of outbound Participant Migration"));
final BootstrapViewForm aForm = new BootstrapViewForm();
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Service Group").setCtrl(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_SERVICE_GROUPS, aSelectedObject.getParticipantIdentifier().getURIEncoded())).addChild(aSelectedObject.getParticipantIdentifier().getURIEncoded())));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Migration state").setCtrl(aSelectedObject.getState().getDisplayName()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Initiation datetime").setCtrl(PDTToString.getAsString(aSelectedObject.getInitiationDateTime(), aDisplayLocale)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Migration Key").setCtrl(code(aSelectedObject.getMigrationKey())));
aNodeList.addChild(aForm);
}
use of com.helger.photon.bootstrap4.form.BootstrapViewForm in project peppol-practical by phax.
the class PageSecureCRMGroup method showSelectedObject.
@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, final ICRMGroup aSelectedObject) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final CRMSubscriberManager aCRMSubscriberMgr = PPMetaManager.getCRMSubscriberMgr();
final BootstrapViewForm aForm = aNodeList.addAndReturnChild(new BootstrapViewForm());
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Name").setCtrl(aSelectedObject.getDisplayName()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Sender email address").setCtrl(aSelectedObject.getSenderEmailAddress()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Assigned participants").setCtrl(Long.toString(aCRMSubscriberMgr.getCRMSubscriberCountOfGroup(aSelectedObject))));
}
use of com.helger.photon.bootstrap4.form.BootstrapViewForm in project peppol-practical by phax.
the class PageSecureCRMSubscriber method showSelectedObject.
@Override
protected void showSelectedObject(@Nonnull final WebPageExecutionContext aWPEC, final ICRMSubscriber aSelectedObject) {
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
final HCNodeList aNodeList = aWPEC.getNodeList();
final BootstrapViewForm aForm = aNodeList.addAndReturnChild(new BootstrapViewForm());
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Status").setCtrl(aSelectedObject.isDeleted() ? "Deleted" : "Active"));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Salutation").setCtrl(aSelectedObject.getSalutationDisplayName(aDisplayLocale)));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Name").setCtrl(aSelectedObject.getName()));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Email address").setCtrl(aSelectedObject.getEmailAddress()));
{
final HCNodeList aGroups = new HCNodeList();
for (final ICRMGroup aCRMGroup : CollectionHelper.getSorted(aSelectedObject.getAllAssignedGroups(), IHasDisplayName.getComparatorCollating(aDisplayLocale))) aGroups.addChild(div(new HCA(createViewURL(aWPEC, CMenuSecure.MENU_CRM_GROUPS, aCRMGroup)).addChild(aCRMGroup.getDisplayName())));
aForm.addFormGroup(new BootstrapFormGroup().setLabel("Assigned groups").setCtrl(aGroups));
}
}
Aggregations