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