Search in sources :

Example 16 with HCEdit

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

the class PagePublicSearchSimple method _createInitialSearchForm.

@Nonnull
private BootstrapRow _createInitialSearchForm(final WebPageExecutionContext aWPEC) {
    final HCForm aBigQueryBox = new HCForm().setAction(aWPEC.getSelfHref()).setMethod(EHCFormMethod.GET);
    final HCEdit aQueryEdit = _createQueryEdit();
    aBigQueryBox.addChild(div(aQueryEdit).addClass(CSS_CLASS_BIG_QUERY_BOX));
    {
        final String sHelpText = "Enter the name, address, ID or any other keyword of the entity you are looking for.";
        if (UI_MODE.isUseHelptext())
            aBigQueryBox.addChild(div(sHelpText).addClass(CSS_CLASS_BIG_QUERY_HELPTEXT));
        else
            aQueryEdit.setPlaceholder(sHelpText);
    }
    {
        final BootstrapButton aButton = new BootstrapSubmitButton().addChild("Search " + CPDPublisher.getApplication()).setIcon(EDefaultIcon.MAGNIFIER);
        if (UI_MODE.isUseGreenButton())
            aButton.setButtonType(EBootstrapButtonType.SUCCESS);
        aBigQueryBox.addChild(new HCDiv().addClass(CSS_CLASS_BIG_QUERY_BUTTONS).addChild(aButton));
    }
    final BootstrapRow aBodyRow = new BootstrapRow();
    aBodyRow.createColumn(-1, -1, 1, 2, 3).addClasses(CBootstrapCSS.D_NONE, CBootstrapCSS.D_MD_BLOCK);
    aBodyRow.createColumn(12, 12, 10, 8, 6).addChild(aBigQueryBox);
    aBodyRow.createColumn(-1, -1, 1, 2, 3).addClasses(CBootstrapCSS.D_NONE, CBootstrapCSS.D_MD_BLOCK);
    return aBodyRow;
}
Also used : HCDiv(com.helger.html.hc.html.grouping.HCDiv) HCForm(com.helger.html.hc.html.forms.HCForm) BootstrapRow(com.helger.photon.bootstrap4.grid.BootstrapRow) HCEdit(com.helger.html.hc.html.forms.HCEdit) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) BootstrapSubmitButton(com.helger.photon.bootstrap4.button.BootstrapSubmitButton) Nonnull(javax.annotation.Nonnull)

Example 17 with HCEdit

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

the class PageSecureIndexManually method fillContent.

@Override
protected void fillContent(final WebPageExecutionContext aWPEC) {
    final HCNodeList aNodeList = aWPEC.getNodeList();
    final IIdentifierFactory aIdentifierFactory = PDMetaManager.getIdentifierFactory();
    final FormErrorList aFormErrors = new FormErrorList();
    {
        final IPDBusinessCardProvider aBCProv = PDMetaManager.getBusinessCardProvider();
        if (aBCProv instanceof SMPBusinessCardProvider) {
            final SMPBusinessCardProvider aSMPBCProv = (SMPBusinessCardProvider) aBCProv;
            if (aSMPBCProv.isFixedSMP()) {
                aNodeList.addChild(info("Fixed SMP URI " + aSMPBCProv.getFixedSMPURI() + " is used."));
            } else {
                aNodeList.addChild(info("The following SMLs are crawled for entries: " + StringHelper.getImplodedMapped(", ", aSMPBCProv.getAllSMLsToUse(), ISMLInfo::getDisplayName)));
            }
        }
    }
    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()) {
            if (PDMetaManager.getIndexerMgr().queueWorkItem(aParticipantID, EIndexerWorkItemType.CREATE_UPDATE, CPDStorage.OWNER_MANUALLY_TRIGGERED, PDIndexerManager.HOST_LOCALHOST).isChanged()) {
                aWPEC.postRedirectGetInternal(success("The indexing of participant ID '" + sParticipantID + "' was successfully triggered!"));
            } else {
                aWPEC.postRedirectGetInternal(warn("Participant ID '" + sParticipantID + "' is already in the indexing queue!"));
            }
        }
    }
    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 index.\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("Add to queue", EDefaultIcon.YES);
}
Also used : SMPBusinessCardProvider(com.helger.pd.indexer.businesscard.SMPBusinessCardProvider) HCNodeList(com.helger.html.hc.impl.HCNodeList) ISMLInfo(com.helger.peppol.sml.ISMLInfo) FormErrorList(com.helger.photon.core.form.FormErrorList) HCEdit(com.helger.html.hc.html.forms.HCEdit) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) IPDBusinessCardProvider(com.helger.pd.indexer.businesscard.IPDBusinessCardProvider) 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) RequestField(com.helger.photon.core.form.RequestField)

Example 18 with HCEdit

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

the class PagePublicSearchExtended method _createCtrl.

@Nonnull
private static HCNodeList _createCtrl(@Nonnull final EPDSearchField eField, @Nonnull final Locale aDisplayLocale) {
    final String sFieldName = eField.getFieldName();
    final HCNodeList ret = new HCNodeList();
    switch(eField) {
        case COUNTRY:
            ret.addChild(new HCCountrySelect(new RequestField(PREFIX_SPECIAL + sFieldName), aDisplayLocale));
            break;
        case REGISTRATION_DATE:
            ret.addChild(BootstrapDateTimePicker.create(PREFIX_SPECIAL + sFieldName, aDisplayLocale, EBootstrap4DateTimePickerMode.DATE));
            break;
    }
    // Default to String
    ret.addChild(new HCEdit(new RequestField(sFieldName)));
    return ret;
}
Also used : HCCountrySelect(com.helger.photon.uicore.html.select.HCCountrySelect) HCNodeList(com.helger.html.hc.impl.HCNodeList) HCEdit(com.helger.html.hc.html.forms.HCEdit) RequestField(com.helger.photon.core.form.RequestField) Nonnull(javax.annotation.Nonnull)

Example 19 with HCEdit

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

the class AppCommonUI method createViewLoginForm.

@Nonnull
public static BootstrapForm createViewLoginForm(@Nonnull final LayoutExecutionContext aLEC, @Nullable final String sPreselectedUserName) {
    final Locale aDisplayLocale = aLEC.getDisplayLocale();
    final IRequestWebScopeWithoutResponse aRequestScope = aLEC.getRequestScope();
    // Use new IDs for both fields, in case the login stuff is displayed more
    // than once!
    final String sIDUserName = GlobalIDFactory.getNewStringID();
    final String sIDPassword = GlobalIDFactory.getNewStringID();
    final String sIDErrorField = GlobalIDFactory.getNewStringID();
    final BootstrapForm aForm = new BootstrapForm(aLEC).setAction(aLEC.getSelfHref()).setFormType(EBootstrapFormType.DEFAULT);
    aForm.setLeft(3);
    // User name field
    aForm.addFormGroup(new BootstrapFormGroup().setLabel(EPhotonCoreText.EMAIL_ADDRESS.getDisplayText(aDisplayLocale)).setCtrl(new HCEdit(new RequestField(CLogin.REQUEST_ATTR_USERID, sPreselectedUserName)).setID(sIDUserName)));
    // Password field
    aForm.addFormGroup(new BootstrapFormGroup().setLabel(EPhotonCoreText.LOGIN_FIELD_PASSWORD.getDisplayText(aDisplayLocale)).setCtrl(new HCEditPassword(CLogin.REQUEST_ATTR_PASSWORD).setID(sIDPassword)));
    // Placeholder for error message
    aForm.addChild(new HCDiv().setID(sIDErrorField).addStyle(CCSSProperties.MARGIN.newValue("4px 0")));
    // Login button
    final BootstrapButtonToolbar aToolbar = aForm.addAndReturnChild(new BootstrapButtonToolbar(aLEC));
    final JSPackage aOnClick = new JSPackage();
    {
        final JSAnonymousFunction aJSSuccess = new JSAnonymousFunction();
        final JSVar aJSData = aJSSuccess.param("data");
        aJSSuccess.body()._if(aJSData.ref(AjaxExecutorPublicLogin.JSON_LOGGEDIN), JSHtml.windowLocationReload(), JQuery.idRef(sIDErrorField).empty().append(aJSData.ref(AjaxExecutorPublicLogin.JSON_HTML)));
        aOnClick.add(new JQueryAjaxBuilder().url(CAjax.LOGIN.getInvocationURI(aRequestScope)).method(EHttpMethod.POST).data(new JSAssocArray().add(CLogin.REQUEST_ATTR_USERID, JQuery.idRef(sIDUserName).val()).add(CLogin.REQUEST_ATTR_PASSWORD, JQuery.idRef(sIDPassword).val())).success(aJSSuccess).build());
    }
    aOnClick._return(false);
    aToolbar.addSubmitButton(EPhotonCoreText.LOGIN_BUTTON_SUBMIT.getDisplayText(aDisplayLocale), aOnClick);
    return aForm;
}
Also used : Locale(java.util.Locale) HCDiv(com.helger.html.hc.html.grouping.HCDiv) JSAnonymousFunction(com.helger.html.jscode.JSAnonymousFunction) JSVar(com.helger.html.jscode.JSVar) HCEdit(com.helger.html.hc.html.forms.HCEdit) HCEditPassword(com.helger.html.hc.html.forms.HCEditPassword) BootstrapForm(com.helger.photon.bootstrap4.form.BootstrapForm) IRequestWebScopeWithoutResponse(com.helger.web.scope.IRequestWebScopeWithoutResponse) JQueryAjaxBuilder(com.helger.html.jquery.JQueryAjaxBuilder) JSPackage(com.helger.html.jscode.JSPackage) JSAssocArray(com.helger.html.jscode.JSAssocArray) 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)

Example 20 with HCEdit

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

the class PageSecureBusinessCard method _createContactInputForm.

@Nonnull
private static HCRow _createContactInputForm(@Nonnull final ILayoutExecutionContext aLEC, @Nonnull final String sEntityID, @Nullable final SMPBusinessCardContact aExistingContact, @Nullable final String sExistingID, @Nonnull final FormErrorList aFormErrors) {
    final Locale aDisplayLocale = aLEC.getDisplayLocale();
    final String sContactID = StringHelper.hasText(sExistingID) ? sExistingID : TMP_ID_PREFIX + Integer.toString(GlobalIDFactory.getNewIntID());
    final HCRow aRow = new HCRow();
    // Type
    {
        final String sFieldType = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, PREFIX_CONTACT, sContactID, SUFFIX_TYPE);
        final HCEdit aCtrl = new HCEdit(new RequestField(sFieldType, aExistingContact == null ? null : aExistingContact.getType())).setPlaceholder("Contact type");
        aCtrl.addClass(CBootstrapCSS.FORM_CONTROL);
        aRow.addCell(aCtrl, BootstrapFormHelper.createDefaultErrorNode(aFormErrors.getListOfField(sFieldType), aDisplayLocale));
    }
    // Name
    {
        final String sFieldName = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, PREFIX_CONTACT, sContactID, SUFFIX_NAME);
        final HCEdit aCtrl = new HCEdit(new RequestField(sFieldName, aExistingContact == null ? null : aExistingContact.getName())).setPlaceholder("Contact name");
        aCtrl.addClass(CBootstrapCSS.FORM_CONTROL);
        aRow.addCell(aCtrl, BootstrapFormHelper.createDefaultErrorNode(aFormErrors.getListOfField(sFieldName), aDisplayLocale));
    }
    // Phone number
    {
        final String sFieldPhone = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, PREFIX_CONTACT, sContactID, SUFFIX_PHONE);
        final HCEdit aCtrl = new HCEdit(new RequestField(sFieldPhone, aExistingContact == null ? null : aExistingContact.getPhoneNumber())).setPlaceholder("Contact phone number");
        aCtrl.addClass(CBootstrapCSS.FORM_CONTROL);
        aRow.addCell(aCtrl, BootstrapFormHelper.createDefaultErrorNode(aFormErrors.getListOfField(sFieldPhone), aDisplayLocale));
    }
    // Email address
    {
        final String sFieldEmail = RequestParamMap.getFieldName(PREFIX_ENTITY, sEntityID, PREFIX_CONTACT, sContactID, SUFFIX_EMAIL);
        final HCEdit aCtrl = new HCEdit(new RequestField(sFieldEmail, aExistingContact == null ? null : aExistingContact.getEmail())).setPlaceholder("Contact email address");
        aCtrl.addClass(CBootstrapCSS.FORM_CONTROL);
        aRow.addCell(aCtrl, BootstrapFormHelper.createDefaultErrorNode(aFormErrors.getListOfField(sFieldEmail), aDisplayLocale));
    }
    aRow.addCell(new BootstrapButton(EBootstrapButtonSize.SMALL).setIcon(EDefaultIcon.DELETE).setOnClick(JQuery.idRef(aRow).remove()));
    return aRow;
}
Also used : Locale(java.util.Locale) HCEdit(com.helger.html.hc.html.forms.HCEdit) HCRow(com.helger.html.hc.html.tabular.HCRow) BootstrapButton(com.helger.photon.bootstrap4.button.BootstrapButton) PDTToString(com.helger.commons.datetime.PDTToString) PDTFromString(com.helger.commons.datetime.PDTFromString) RequestField(com.helger.photon.core.form.RequestField) Nonnull(javax.annotation.Nonnull)

Aggregations

HCEdit (com.helger.html.hc.html.forms.HCEdit)34 RequestField (com.helger.photon.core.form.RequestField)33 BootstrapFormGroup (com.helger.photon.bootstrap4.form.BootstrapFormGroup)30 Locale (java.util.Locale)22 BootstrapForm (com.helger.photon.bootstrap4.form.BootstrapForm)18 HCNodeList (com.helger.html.hc.impl.HCNodeList)16 BootstrapButtonToolbar (com.helger.photon.bootstrap4.buttongroup.BootstrapButtonToolbar)14 FormErrorList (com.helger.photon.core.form.FormErrorList)13 HCCheckBox (com.helger.html.hc.html.forms.HCCheckBox)10 IIdentifierFactory (com.helger.peppolid.factory.IIdentifierFactory)10 Nonnull (javax.annotation.Nonnull)9 PDTToString (com.helger.commons.datetime.PDTToString)8 HCDiv (com.helger.html.hc.html.grouping.HCDiv)8 RequestFieldBoolean (com.helger.photon.core.form.RequestFieldBoolean)8 BootstrapButton (com.helger.photon.bootstrap4.button.BootstrapButton)7 HCTextArea (com.helger.html.hc.html.forms.HCTextArea)6 HCHiddenField (com.helger.html.hc.html.forms.HCHiddenField)5 HCTextNode (com.helger.html.hc.impl.HCTextNode)5 IParticipantIdentifier (com.helger.peppolid.IParticipantIdentifier)5 HCEditPassword (com.helger.html.hc.html.forms.HCEditPassword)4