Search in sources :

Example 1 with HCEdit

use of com.helger.html.hc.html.forms.HCEdit in project phoss-directory by phax.

the class PageSecureAdminSMLConfiguration method showInputForm.

@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMLInfo aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
    final boolean bEdit = eFormAction.isEdit();
    aForm.addChild(getUIHandler().createActionHeader(bEdit ? "Edit SML configuration '" + aSelectedObject.getDisplayName() + "'" : "Create new SML configuration"));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Name").setCtrl(new HCEdit(new RequestField(FIELD_DISPLAY_NAME, aSelectedObject != null ? aSelectedObject.getDisplayName() : null))).setHelpText("The name of the SML configuration. This is for informational purposes only and has no effect on the functionality.").setErrorList(aFormErrors.getListOfField(FIELD_DISPLAY_NAME)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("DNS Zone").setCtrl(new HCEdit(new RequestField(FIELD_DNS_ZONE, aSelectedObject != null ? aSelectedObject.getDNSZone() : null))).setHelpText(new HCTextNode("The name of the DNS Zone that this SML is working upon (e.g. "), new HCCode().addChild("sml.peppolcentral.org"), new HCTextNode("). The value will automatically converted to all-lowercase!")).setErrorList(aFormErrors.getListOfField(FIELD_DNS_ZONE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Management Service URL").setCtrl(new HCEdit(new RequestField(FIELD_MANAGEMENT_ADDRESS_URL, aSelectedObject != null ? aSelectedObject.getManagementServiceURL() : null))).setHelpText("The service URL where the SML management application is running on including the host name. It may not contain the '" + CSMLDefault.MANAGEMENT_SERVICE_METADATA + "' or '" + CSMLDefault.MANAGEMENT_SERVICE_PARTICIPANTIDENTIFIER + "' path elements!").setErrorList(aFormErrors.getListOfField(FIELD_MANAGEMENT_ADDRESS_URL)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Client Certificate required?").setCtrl(new HCCheckBox(new RequestFieldBoolean(FIELD_CLIENT_CERTIFICATE_REQUIRED, aSelectedObject != null ? aSelectedObject.isClientCertificateRequired() : true))).setHelpText("Check this if this SML requires a client certificate for access. Both Peppol production SML and SMK require a client certificate. Only a locally running SML software may not require a client certificate.").setErrorList(aFormErrors.getListOfField(FIELD_CLIENT_CERTIFICATE_REQUIRED)));
}
Also used : HCCode(com.helger.html.hc.html.textlevel.HCCode) RequestFieldBoolean(com.helger.photon.core.form.RequestFieldBoolean) HCEdit(com.helger.html.hc.html.forms.HCEdit) HCCheckBox(com.helger.html.hc.html.forms.HCCheckBox) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) HCTextNode(com.helger.html.hc.impl.HCTextNode) RequestField(com.helger.photon.core.form.RequestField)

Example 2 with HCEdit

use of com.helger.html.hc.html.forms.HCEdit in project phoss-directory by phax.

the class PagePublicContact method fillContent.

@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final boolean bShowForm = true;
    final FormErrorList aFormErrors = new FormErrorList();
    if (aWPEC.hasAction(CPageParam.ACTION_PERFORM)) {
        final String sName = StringHelper.trim(aWPEC.params().getAsString(FIELD_NAME));
        final String sEmail = StringHelper.trim(aWPEC.params().getAsString(FIELD_EMAIL));
        final String sTopic = aWPEC.params().getAsString(FIELD_TOPIC);
        final String sText = StringHelper.trim(aWPEC.params().getAsString(FIELD_TEXT));
        final String sReCaptcha = StringHelper.trim(aWPEC.params().getAsString("g-recaptcha-response"));
        if (StringHelper.hasNoText(sName))
            aFormErrors.addFieldError(FIELD_NAME, "Your name must be provided.");
        if (StringHelper.hasNoText(sEmail))
            aFormErrors.addFieldError(FIELD_EMAIL, "Your email address must be provided.");
        else if (!EmailAddressHelper.isValid(sEmail))
            aFormErrors.addFieldError(FIELD_EMAIL, "The provided email address is invalid.");
        if (StringHelper.hasNoText(sText))
            aFormErrors.addFieldError(FIELD_TEXT, "A message text must be provided.");
        if (aFormErrors.isEmpty() || StringHelper.hasText(sReCaptcha)) {
            if (!CaptchaSessionSingleton.getInstance().isChecked()) {
                // Check only if no other errors occurred
                if (ReCaptchaServerSideValidator.check("6LfZFS0UAAAAAONDJHyDnuUUvMB_oNmJxz9Utxza", sReCaptcha).isFailure())
                    aFormErrors.addFieldError(FIELD_CAPTCHA, "Please confirm you are not a robot!");
                else
                    CaptchaSessionSingleton.getInstance().setChecked();
            }
        }
        if (aFormErrors.isEmpty()) {
            final EmailData aEmailData = new EmailData(EEmailType.TEXT);
            aEmailData.setFrom(CPDPublisher.EMAIL_SENDER);
            aEmailData.to().add(new EmailAddress("pd@helger.com"));
            aEmailData.replyTo().add(new EmailAddress(sEmail, sName));
            aEmailData.setSubject("[" + CPDPublisher.getApplication() + "] Contact Form - " + sName);
            final StringBuilder aSB = new StringBuilder();
            aSB.append("Contact form from " + CPDPublisher.getApplication() + " was filled out.\n\n");
            aSB.append("Name: ").append(sName).append("\n");
            aSB.append("Email: ").append(sEmail).append("\n");
            aSB.append("Topic: ").append(sTopic).append("\n");
            aSB.append("Text:\n").append(sText).append("\n");
            aEmailData.setBody(aSB.toString());
            ScopedMailAPI.getInstance().queueMail(InternalErrorSettings.getSMTPSettings(), aEmailData);
            aWPEC.postRedirectGetInternal(success("Thank you for your message. We will come back to you asap."));
        }
    }
    if (bShowForm) {
        aNodeList.addChild(info("Alternatively write an email to pd[at]helger.com - usually using the below form is more effective!"));
        aNodeList.addChild(warn("Please don't request any change of data via this contact form - contact your service provider instead. Thank you."));
        final BootstrapForm aForm = aNodeList.addAndReturnChild(getUIHandler().createFormSelf(aWPEC));
        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))).setErrorList(aFormErrors.getListOfField(FIELD_EMAIL)));
        final HCExtSelect aSelect = new HCExtSelect(new RequestField(FIELD_TOPIC));
        aSelect.addOption("SMP integration");
        aSelect.addOption("Website");
        aSelect.addOption("REST service");
        aSelect.addOption("SMP Statement of use");
        aSelect.addOption("General question");
        aSelect.addOptionPleaseSelect(aDisplayLocale);
        aForm.addFormGroup(new BootstrapFormGroup().setLabel("Topic").setCtrl(aSelect).setErrorList(aFormErrors.getListOfField(FIELD_TOPIC)));
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Your message").setCtrl(new HCTextAreaAutosize(new RequestField(FIELD_TEXT)).setRows(5)).setErrorList(aFormErrors.getListOfField(FIELD_TEXT)));
        if (!CaptchaSessionSingleton.getInstance().isChecked()) {
            // Add visible Captcha
            aForm.addFormGroup(new BootstrapFormGroup().setCtrl(HCReCaptchaV2.create("6LfZFS0UAAAAAJaqpHJdFS_xxY7dqMQjXoBIQWOD", aDisplayLocale)).setErrorList(aFormErrors.getListOfField(FIELD_CAPTCHA)));
        }
        aForm.addChild(new HCHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM));
        aForm.addChild(new BootstrapSubmitButton().addChild("Send message").setIcon(EDefaultIcon.YES));
        aForm.addChild(new BootstrapButton().addChild("No thanks").setIcon(EDefaultIcon.CANCEL).setOnClick(aWPEC.getLinkToMenuItem(CMenuPublic.MENU_SEARCH_SIMPLE)));
    }
}
Also used : Locale(java.util.Locale) HCExtSelect(com.helger.photon.uicore.html.select.HCExtSelect) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCHiddenField(com.helger.html.hc.html.forms.HCHiddenField) HCTextAreaAutosize(com.helger.photon.uictrls.autosize.HCTextAreaAutosize) FormErrorList(com.helger.photon.core.form.FormErrorList) HCEdit(com.helger.html.hc.html.forms.HCEdit) EmailData(com.helger.smtp.data.EmailData) EmailAddress(com.helger.commons.email.EmailAddress) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapSubmitButton(com.helger.photon.bootstrap4.button.BootstrapSubmitButton) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) RequestField(com.helger.photon.core.form.RequestField)

Example 3 with HCEdit

use of com.helger.html.hc.html.forms.HCEdit in project phoss-directory by phax.

the class PageSecureDeleteManually method fillContent.

@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();
    final FormErrorList aFormErrors = new FormErrorList();
    if (aWPEC.hasAction(CPageParam.ACTION_PERFORM)) {
        final String sParticipantID = aWPEC.params().getAsString(FIELD_PARTICIPANT_ID);
        final IParticipantIdentifier aParticipantID = aIdentifierFactory.parseParticipantIdentifier(sParticipantID);
        if (StringHelper.hasNoText(sParticipantID))
            aFormErrors.addFieldError(FIELD_PARTICIPANT_ID, "A participant ID must be provided.");
        else if (aParticipantID == null)
            aFormErrors.addFieldError(FIELD_PARTICIPANT_ID, "The provided participant ID is syntactically invalid.");
        if (aFormErrors.isEmpty()) {
            int nDeleted = 0;
            try {
                nDeleted = PDMetaManager.getStorageMgr().deleteEntry(aParticipantID, null, false);
            } catch (final IOException ex) {
                // ignore
                nDeleted = -1;
            }
            if (nDeleted > 0)
                aWPEC.postRedirectGetInternal(success("The participant ID '" + aParticipantID.getURIEncoded() + "' was deleted (" + nDeleted + " rows)"));
            else
                aWPEC.postRedirectGetInternal(error("Error deleting participant ID '" + aParticipantID.getURIEncoded() + "'"));
        }
    }
    final BootstrapForm aForm = aNodeList.addAndReturnChild(getUIHandler().createFormSelf(aWPEC));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Participant ID").setCtrl(new HCEdit(new RequestField(FIELD_PARTICIPANT_ID, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME + CIdentifier.URL_SCHEME_VALUE_SEPARATOR))).setHelpText(span().addChild("Enter the fully qualified Peppol participant ID (including the scheme) you want to delete.\nExample identifier layout: ").addChild(code(aIdentifierFactory.createParticipantIdentifier(PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "9999:test").getURIEncoded()))).setErrorList(aFormErrors.getListOfField(FIELD_PARTICIPANT_ID)));
    final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aWPEC));
    aToolbar.addHiddenField(CPageParam.PARAM_ACTION, CPageParam.ACTION_PERFORM);
    aToolbar.addSubmitButton("Delete from index", EDefaultIcon.DELETE);
}
Also used : HCNodeList(com.helger.html.hc.impl.HCNodeList) FormErrorList(com.helger.photon.core.form.FormErrorList) HCEdit(com.helger.html.hc.html.forms.HCEdit) IOException(java.io.IOException) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) RequestField(com.helger.photon.core.form.RequestField)

Example 4 with HCEdit

use of com.helger.html.hc.html.forms.HCEdit in project phoss-smp by phax.

the class AbstractPageSecureEndpoint method showInputForm.

@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPServiceInformation aSelectedObject, @Nonnull final BootstrapForm aForm, final boolean bFormSubmitted, @Nonnull final EWebPageFormAction eFormAction, @Nonnull final FormErrorList aFormErrors) {
    final boolean bEdit = eFormAction.isEdit();
    final Locale aDisplayLocale = aWPEC.getDisplayLocale();
    final ISMPProcess aSelectedProcess = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_PROCESS);
    final ISMPEndpoint aSelectedEndpoint = aWPEC.getRequestScope().attrs().getCastedValue(REQUEST_ATTR_ENDPOINT);
    final IIdentifierFactory aIdentifierFactory = SMPMetaManager.getIdentifierFactory();
    aForm.addChild(getUIHandler().createActionHeader(bEdit ? "Edit endpoint" : "Create new endpoint"));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Service group").setCtrl(new HCServiceGroupSelect(new RequestField(FIELD_SERVICE_GROUP_ID, aSelectedObject != null ? aSelectedObject.getServiceGroupID() : null), aDisplayLocale).setReadOnly(bEdit)).setErrorList(aFormErrors.getListOfField(FIELD_SERVICE_GROUP_ID)));
    {
        final BootstrapRow aRow = new BootstrapRow();
        aRow.createColumn(GS_IDENTIFIER_SCHEME).addChild(new HCEdit(new RequestField(FIELD_DOCTYPE_ID_SCHEME, aSelectedObject != null ? aSelectedObject.getDocumentTypeIdentifier().getScheme() : aIdentifierFactory.getDefaultDocumentTypeIdentifierScheme())).setPlaceholder("Identifier scheme").setReadOnly(bEdit));
        aRow.createColumn(GS_IDENTIFIER_VALUE).addChild(new HCEdit(new RequestField(FIELD_DOCTYPE_ID_VALUE, aSelectedObject != null ? aSelectedObject.getDocumentTypeIdentifier().getValue() : null)).setPlaceholder("Identifier value").setReadOnly(bEdit));
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Document type ID").setCtrl(aRow).setErrorList(aFormErrors.getListOfFields(FIELD_DOCTYPE_ID_SCHEME, FIELD_DOCTYPE_ID_VALUE)));
    }
    {
        final BootstrapRow aRow = new BootstrapRow();
        aRow.createColumn(GS_IDENTIFIER_SCHEME).addChild(new HCEdit(new RequestField(FIELD_PROCESS_ID_SCHEME, aSelectedProcess != null ? aSelectedProcess.getProcessIdentifier().getScheme() : aIdentifierFactory.getDefaultProcessIdentifierScheme())).setPlaceholder("Identifier scheme").setReadOnly(bEdit));
        aRow.createColumn(GS_IDENTIFIER_VALUE).addChild(new HCEdit(new RequestField(FIELD_PROCESS_ID_VALUE, aSelectedProcess != null ? aSelectedProcess.getProcessIdentifier().getValue() : null)).setPlaceholder("Identifier value").setReadOnly(bEdit));
        aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Process ID").setCtrl(aRow).setErrorList(aFormErrors.getListOfFields(FIELD_PROCESS_ID_SCHEME, FIELD_PROCESS_ID_VALUE)));
    }
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Transport Profile").setCtrl(new HCSMPTransportProfileSelect(new RequestField(FIELD_TRANSPORT_PROFILE, aSelectedEndpoint != null ? aSelectedEndpoint.getTransportProfile() : ESMPTransportProfile.TRANSPORT_PROFILE_AS2.getID())).setReadOnly(bEdit)).setErrorList(aFormErrors.getListOfField(FIELD_TRANSPORT_PROFILE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Endpoint Reference").setCtrl(new HCEdit(new RequestField(FIELD_ENDPOINT_REFERENCE, aSelectedEndpoint != null ? aSelectedEndpoint.getEndpointReference() : null))).setHelpText("The URL where messsages of this type should be targeted to.").setErrorList(aFormErrors.getListOfField(FIELD_ENDPOINT_REFERENCE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Requires Business Level Signature").setCtrl(new HCCheckBox(new RequestFieldBoolean(FIELD_REQUIRES_BUSINESS_LEVEL_SIGNATURE, aSelectedEndpoint != null ? aSelectedEndpoint.isRequireBusinessLevelSignature() : SMPEndpoint.DEFAULT_REQUIRES_BUSINESS_LEVEL_SIGNATURE))).setHelpText("Check the box if the recipient requires business-level signatures for " + "the message, meaning a signature applied to the business message " + "before the message is put on the transport. This is independent of " + "the transport-level signatures that a specific transport profile, such " + "as the START profile, might mandate. This flag does not indicate " + "which type of business-level signature might be required. Setting or " + "consuming business-level signatures would typically be the " + "responsibility of the final senders and receivers of messages, rather " + "than a set of APs.").setErrorList(aFormErrors.getListOfField(FIELD_REQUIRES_BUSINESS_LEVEL_SIGNATURE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Minimum Authentication Level").setCtrl(new HCEdit(new RequestField(FIELD_MINIMUM_AUTHENTICATION_LEVEL, aSelectedEndpoint != null ? aSelectedEndpoint.getMinimumAuthenticationLevel() : null))).setHelpText("Indicates the minimum authentication level that recipient requires. " + "The specific semantics of this field is defined in a specific instance " + "of the BUSDOX infrastructure. It could for example reflect the " + "value of the \"urn:eu:busdox:attribute:assurance-level\" SAML " + "attribute defined in the START specification.").setErrorList(aFormErrors.getListOfField(FIELD_MINIMUM_AUTHENTICATION_LEVEL)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Not before").setCtrl(BootstrapDateTimePicker.create(FIELD_NOT_BEFORE, aSelectedEndpoint != null ? aSelectedEndpoint.getServiceActivationDate() : null, aDisplayLocale)).setHelpText("Activation date of the service. Senders should ignore services that " + "are not yet activated.").setErrorList(aFormErrors.getListOfField(FIELD_NOT_BEFORE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Not after").setCtrl(BootstrapDateTimePicker.create(FIELD_NOT_AFTER, aSelectedEndpoint != null ? aSelectedEndpoint.getServiceExpirationDate() : null, aDisplayLocale)).setHelpText("Expiration date of the service. Senders should ignore services that " + "are expired.").setErrorList(aFormErrors.getListOfField(FIELD_NOT_AFTER)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Certificate").setCtrl(new HCTextArea(new RequestField(FIELD_CERTIFICATE, aSelectedEndpoint != null ? aSelectedEndpoint.getCertificate() : null))).setHelpText("Holds the complete signing certificate of the recipient AP, as a " + "PEM base 64 encoded X509 DER formatted value.").setErrorList(aFormErrors.getListOfField(FIELD_CERTIFICATE)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Service Description").setCtrl(new HCEdit(new RequestField(FIELD_SERVICE_DESCRIPTION, aSelectedEndpoint != null ? aSelectedEndpoint.getServiceDescription() : null))).setHelpText("A human readable description of the service.").setErrorList(aFormErrors.getListOfField(FIELD_SERVICE_DESCRIPTION)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Technical Contact").setCtrl(new HCEdit(new RequestField(FIELD_TECHNICAL_CONTACT, aSelectedEndpoint != null ? aSelectedEndpoint.getTechnicalContactUrl() : null))).setHelpText("Represents a link to human readable contact information. This " + "might also be an email address.").setErrorList(aFormErrors.getListOfField(FIELD_TECHNICAL_CONTACT)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Technical Information").setCtrl(new HCEdit(new RequestField(FIELD_TECHNICAL_INFORMATION, aSelectedEndpoint != null ? aSelectedEndpoint.getTechnicalInformationUrl() : null))).setHelpText("A URL to human readable documentation of the service format. " + "This could for example be a web site containing links to XML " + "Schemas, WSDLs, Schematrons and other relevant resources.").setErrorList(aFormErrors.getListOfField(FIELD_TECHNICAL_INFORMATION)));
    aForm.addFormGroup(new BootstrapFormGroup().setLabel("Extension").setCtrl(new HCTextArea(new RequestField(FIELD_EXTENSION, aSelectedEndpoint != null ? aSelectedEndpoint.getFirstExtensionXML() : null))).setHelpText("Optional extension to the endpoint. If present it must be valid XML content!").setErrorList(aFormErrors.getListOfField(FIELD_EXTENSION)));
}
Also used : Locale(java.util.Locale) HCTextArea(com.helger.html.hc.html.forms.HCTextArea) RequestFieldBoolean(com.helger.photon.core.form.RequestFieldBoolean) HCEdit(com.helger.html.hc.html.forms.HCEdit) ISMPEndpoint(com.helger.phoss.smp.domain.serviceinfo.ISMPEndpoint) HCSMPTransportProfileSelect(com.helger.phoss.smp.ui.secure.hc.HCSMPTransportProfileSelect) HCServiceGroupSelect(com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect) BootstrapRow(com.helger.photon.bootstrap4.grid.BootstrapRow) HCCheckBox(com.helger.html.hc.html.forms.HCCheckBox) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) ISMPProcess(com.helger.phoss.smp.domain.serviceinfo.ISMPProcess) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) RequestField(com.helger.photon.core.form.RequestField)

Example 5 with HCEdit

use of com.helger.html.hc.html.forms.HCEdit 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;
}
Also used : Locale(java.util.Locale) GlobalIDFactory(com.helger.commons.id.factory.GlobalIDFactory) ILayoutExecutionContext(com.helger.photon.core.execcontext.ILayoutExecutionContext) PDClientProvider(com.helger.phoss.smp.app.PDClientProvider) EWithDeprecated(com.helger.photon.uicore.html.select.HCCountrySelect.EWithDeprecated) ISMPSettings(com.helger.phoss.smp.settings.ISMPSettings) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) FormErrorList(com.helger.photon.core.form.FormErrorList) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) IIdentifierFactory(com.helger.peppolid.factory.IIdentifierFactory) HCServiceGroupSelect(com.helger.phoss.smp.ui.secure.hc.HCServiceGroupSelect) Nonempty(com.helger.commons.annotation.Nonempty) SMPBusinessCardIdentifier(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardIdentifier) HCA(com.helger.html.hc.html.textlevel.HCA) HCTextArea(com.helger.html.hc.html.forms.HCTextArea) CPageParam(com.helger.photon.uicore.css.CPageParam) PDTToString(com.helger.commons.datetime.PDTToString) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) IHCCell(com.helger.html.hc.html.tabular.IHCCell) HCDiv(com.helger.html.hc.html.grouping.HCDiv) HCTextNode(com.helger.html.hc.impl.HCTextNode) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) ICommonsList(com.helger.commons.collection.impl.ICommonsList) HCExtHelper(com.helger.html.hc.ext.HCExtHelper) RegExHelper(com.helger.commons.regex.RegExHelper) IValidityIndicator(com.helger.commons.state.IValidityIndicator) DTCol(com.helger.photon.uictrls.datatables.column.DTCol) RequestParamMap(com.helger.servlet.request.RequestParamMap) ICommonsMap(com.helger.commons.collection.impl.ICommonsMap) BootstrapCardBody(com.helger.photon.bootstrap4.card.BootstrapCardBody) JSJQueryHelper(com.helger.photon.uicore.js.JSJQueryHelper) ISMPBusinessCardManager(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCardManager) DataTables(com.helger.photon.uictrls.datatables.DataTables) IRequestParamMap(com.helger.servlet.request.IRequestParamMap) LinkHelper(com.helger.photon.app.url.LinkHelper) JSAssocArray(com.helger.html.jscode.JSAssocArray) BootstrapDateTimePicker(com.helger.photon.bootstrap4.uictrls.datetimepicker.BootstrapDateTimePicker) PDTFromString(com.helger.commons.datetime.PDTFromString) HCEdit(com.helger.html.hc.html.forms.HCEdit) IHCNode(com.helger.html.hc.IHCNode) JQuery(com.helger.html.jquery.JQuery) SMPBusinessCardEntity(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardEntity) Nullable(javax.annotation.Nullable) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) StringHelper(com.helger.commons.string.StringHelper) WorkInProgress(com.helger.commons.annotation.WorkInProgress) SMPMetaManager(com.helger.phoss.smp.domain.SMPMetaManager) BootstrapFormHelper(com.helger.photon.bootstrap4.form.BootstrapFormHelper) CAjax(com.helger.phoss.smp.ui.ajax.CAjax) HCA_MailTo(com.helger.html.hc.ext.HCA_MailTo) HCCol(com.helger.html.hc.html.tabular.HCCol) RequestField(com.helger.photon.core.form.RequestField) AbstractBootstrapWebPageActionHandler(com.helger.photon.bootstrap4.pages.handler.AbstractBootstrapWebPageActionHandler) ESortOrder(com.helger.commons.compare.ESortOrder) JSAnonymousFunction(com.helger.html.jscode.JSAnonymousFunction) LayoutExecutionContext(com.helger.photon.core.execcontext.LayoutExecutionContext) JSVar(com.helger.html.jscode.JSVar) WebPageExecutionContext(com.helger.photon.uicore.page.WebPageExecutionContext) EDefaultIcon(com.helger.photon.uicore.icon.EDefaultIcon) BootstrapSuccessBox(com.helger.photon.bootstrap4.alert.BootstrapSuccessBox) AbstractBootstrapWebPageActionHandlerDelete(com.helger.photon.bootstrap4.pages.handler.AbstractBootstrapWebPageActionHandlerDelete) BootstrapDataTables(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDataTables) Locale(java.util.Locale) BootstrapDTColAction(com.helger.photon.bootstrap4.uictrls.datatables.BootstrapDTColAction) EmailAddressValidator(com.helger.smtp.util.EmailAddressValidator) SMPCommonUI(com.helger.phoss.smp.ui.SMPCommonUI) BootstrapErrorBox(com.helger.photon.bootstrap4.alert.BootstrapErrorBox) HCCountrySelect(com.helger.photon.uicore.html.select.HCCountrySelect) EWebPageFormAction(com.helger.photon.uicore.page.EWebPageFormAction) BootstrapCard(com.helger.photon.bootstrap4.card.BootstrapCard) IAjaxFunctionDeclaration(com.helger.photon.ajax.decl.IAjaxFunctionDeclaration) PDClient(com.helger.pd.client.PDClient) CountryCache(com.helger.commons.locale.country.CountryCache) EFamFamIcon(com.helger.photon.uictrls.famfam.EFamFamIcon) LocalDate(java.time.LocalDate) SMPWebAppConfiguration(com.helger.phoss.smp.app.SMPWebAppConfiguration) ISMPServiceGroupManager(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroupManager) ESuccess(com.helger.commons.state.ESuccess) ISMPBusinessCard(com.helger.phoss.smp.domain.businesscard.ISMPBusinessCard) HCRow(com.helger.html.hc.html.tabular.HCRow) EValidity(com.helger.commons.state.EValidity) PhotonUnifiedResponse(com.helger.photon.app.PhotonUnifiedResponse) AbstractSMPWebPageForm(com.helger.phoss.smp.ui.AbstractSMPWebPageForm) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) ISMPServiceGroup(com.helger.phoss.smp.domain.servicegroup.ISMPServiceGroup) CompareHelper(com.helger.commons.compare.CompareHelper) URLValidator(com.helger.commons.url.URLValidator) IParticipantIdentifier(com.helger.peppolid.IParticipantIdentifier) Nonnull(javax.annotation.Nonnull) ISimpleURL(com.helger.commons.url.ISimpleURL) HCNodeList(com.helger.html.hc.impl.HCNodeList) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) CommonsArrayList(com.helger.commons.collection.impl.CommonsArrayList) CBootstrapCSS(com.helger.photon.bootstrap4.CBootstrapCSS) HCTable(com.helger.html.hc.html.tabular.HCTable) JQueryAjaxBuilder(com.helger.html.jquery.JQueryAjaxBuilder) SMPBusinessCardName(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardName) EBootstrapButtonSize(com.helger.photon.bootstrap4.button.EBootstrapButtonSize) EShowList(com.helger.photon.uicore.page.EShowList) EFamFamFlagIcon(com.helger.photon.uictrls.famfam.EFamFamFlagIcon) SMPBusinessCardContact(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardContact) JSPackage(com.helger.html.jscode.JSPackage) BootstrapCard(com.helger.photon.bootstrap4.card.BootstrapCard) JSAnonymousFunction(com.helger.html.jscode.JSAnonymousFunction) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCTextArea(com.helger.html.hc.html.forms.HCTextArea) JSVar(com.helger.html.jscode.JSVar) BootstrapViewForm(com.helger.photon.bootstrap4.form.BootstrapViewForm) HCEdit(com.helger.html.hc.html.forms.HCEdit) PDTToString(com.helger.commons.datetime.PDTToString) PDTFromString(com.helger.commons.datetime.PDTFromString) SMPBusinessCardIdentifier(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardIdentifier) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) SMPBusinessCardContact(com.helger.phoss.smp.domain.businesscard.SMPBusinessCardContact) HCCountrySelect(com.helger.photon.uicore.html.select.HCCountrySelect) BootstrapTable(com.helger.photon.bootstrap4.table.BootstrapTable) JQueryAjaxBuilder(com.helger.html.jquery.JQueryAjaxBuilder) BootstrapCardBody(com.helger.photon.bootstrap4.card.BootstrapCardBody) JSPackage(com.helger.html.jscode.JSPackage) JSAssocArray(com.helger.html.jscode.JSAssocArray) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) IRequestParamMap(com.helger.servlet.request.IRequestParamMap) BootstrapButtonToolbar(com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar) BootstrapFormGroup(com.helger.photon.bootstrap4.form.BootstrapFormGroup) RequestField(com.helger.photon.core.form.RequestField) Nonnull(javax.annotation.Nonnull)

Aggregations

HCEdit (com.helger.html.hc.html.forms.HCEdit)20 RequestField (com.helger.photon.core.form.RequestField)19 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)16 Locale (java.util.Locale)13 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)8 BootstrapForm (com.helger.photon.bootstrap4.form.BootstrapForm)8 HCNodeList (com.helger.html.hc.impl.HCNodeList)7 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)7 FormErrorList (com.helger.photon.core.form.FormErrorList)6 Nonnull (javax.annotation.Nonnull)6 PDTToString (com.helger.commons.datetime.PDTToString)5 HCCheckBox (com.helger.html.hc.html.forms.HCCheckBox)5 HCTextArea (com.helger.html.hc.html.forms.HCTextArea)5 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)5 RequestFieldBoolean (com.helger.photon.core.form.RequestFieldBoolean)5 HCRow (com.helger.html.hc.html.tabular.HCRow)4 HCTextNode (com.helger.html.hc.impl.HCTextNode)4 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)4 BootstrapRow (com.helger.photon.bootstrap4.grid.BootstrapRow)4 HCDiv (com.helger.html.hc.html.grouping.HCDiv)3