use of com.helger.photon.core.form.RequestField in project phoss-directory by phax.
the class PagePublicSearchExtended method fillContent.
@Override
protected void fillContent(@Nonnull final WebPageExecutionContext aWPEC) {
final HCNodeList aNodeList = aWPEC.getNodeList();
final Locale aDisplayLocale = aWPEC.getDisplayLocale();
aNodeList.addChild(info("This is a placeholder page - has no effect yet!"));
final BootstrapViewForm aViewForm = new BootstrapViewForm();
// Add all search fields
for (final EPDSearchField eField : EPDSearchField.values()) {
final HCSearchOperatorSelect aSelect = new HCSearchOperatorSelect(new RequestField(PREFIX_OPERATOR + eField.getFieldName(), ESearchOperator.EQ.getID()), eField.getDataType(), aDisplayLocale);
final HCNodeList aCtrl = _createCtrl(eField, aDisplayLocale);
final BootstrapRow aRow = new BootstrapRow();
aRow.createColumn(2).addChild(aSelect);
aRow.createColumn(10).addChild(aCtrl);
aViewForm.addFormGroup(new BootstrapFormGroup().setLabel(eField.getDisplayText(aDisplayLocale)).setCtrl(aRow));
}
aNodeList.addChild(aViewForm);
}
use of com.helger.photon.core.form.RequestField 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.photon.core.form.RequestField 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.photon.core.form.RequestField 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;
}
use of com.helger.photon.core.form.RequestField in project phoss-smp by phax.
the class PageSecureBusinessCard method showInputForm.
@Override
protected void showInputForm(@Nonnull final WebPageExecutionContext aWPEC, @Nullable final ISMPBusinessCard 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 IRequestWebScopeWithoutResponse aRequestScope = aWPEC.getRequestScope();
final ISMPBusinessCardManager aBusinessCardMgr = SMPMetaManager.getBusinessCardMgr();
aForm.addChild(getUIHandler().createActionHeader(bEdit ? "Edit Business Card" : "Create new Business Card"));
if (bEdit) {
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Service Group").setCtrl(aSelectedObject.getID()).setErrorList(aFormErrors.getListOfField(FIELD_SERVICE_GROUP_ID)));
} else {
// Show only service groups that don't have a BC already
aForm.addFormGroup(new BootstrapFormGroup().setLabelMandatory("Service Group").setCtrl(new HCServiceGroupSelect(new RequestField(FIELD_SERVICE_GROUP_ID, aSelectedObject != null ? aSelectedObject.getID() : null), aDisplayLocale, x -> aBusinessCardMgr.getSMPBusinessCardOfServiceGroup(x) == null)).setErrorList(aFormErrors.getListOfField(FIELD_SERVICE_GROUP_ID)));
}
final HCDiv aEntityContainer = aForm.addAndReturnChild(new HCDiv().setID("entitycontainer"));
final IRequestParamMap aEntities = aWPEC.getRequestParamMap().getMap(PREFIX_ENTITY);
if (bFormSubmitted) {
// Re-show of form
if (aEntities != null)
for (final String sEntityRowID : aEntities.keySet()) aEntityContainer.addChild(_createEntityInputForm(aWPEC, null, sEntityRowID, aFormErrors, bFormSubmitted));
} else {
if (aSelectedObject != null) {
// add all existing stored entities
for (final SMPBusinessCardEntity aEntity : aSelectedObject.getAllEntities()) aEntityContainer.addChild(_createEntityInputForm(aWPEC, aEntity, (String) null, aFormErrors, bFormSubmitted));
}
}
{
final JSAnonymousFunction aJSAppend = new JSAnonymousFunction();
final JSVar aJSAppendData = aJSAppend.param("data");
aJSAppend.body().add(JQuery.idRef(aEntityContainer).append(aJSAppendData.ref(PhotonUnifiedResponse.HtmlHelper.PROPERTY_HTML)));
final JSPackage aOnAdd = new JSPackage();
aOnAdd.add(new JQueryAjaxBuilder().url(AJAX_CREATE_ENTITY.getInvocationURL(aRequestScope)).data(new JSAssocArray()).success(JSJQueryHelper.jqueryAjaxSuccessHandler(aJSAppend, null)).build());
aForm.addChild(new BootstrapButton().addChild("Add Entity").setIcon(EDefaultIcon.PLUS).setOnClick(aOnAdd));
}
}
Aggregations