Search in sources :

Example 1 with EntityFormAction

use of org.broadleafcommerce.openadmin.web.form.entity.EntityFormAction in project BroadleafCommerce by BroadleafCommerce.

the class AdminOfferController method addDuplicateOption.

protected void addDuplicateOption(Model model, String id) {
    if (duplicator.validate(OfferImpl.class, Long.parseLong(id))) {
        EntityForm form = (EntityForm) model.asMap().get("entityForm");
        EntityFormAction duplicate = new EntityFormAction("duplicate").withButtonClass("duplicate-button").withDisplayText("Duplicate");
        form.addAction(duplicate);
    }
}
Also used : EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm) EntityFormAction(org.broadleafcommerce.openadmin.web.form.entity.EntityFormAction)

Example 2 with EntityFormAction

use of org.broadleafcommerce.openadmin.web.form.entity.EntityFormAction in project BroadleafCommerce by BroadleafCommerce.

the class TranslationFormBuilderServiceImpl method buildTranslationForm.

@Override
public EntityForm buildTranslationForm(ClassMetadata cmd, TranslationForm formProperties, TranslationFormAction action) {
    EntityForm ef = new EntityForm();
    EntityFormAction saveAction = DefaultEntityFormActions.SAVE.clone();
    saveAction.setButtonClass("translation-submit-button");
    ef.addAction(saveAction);
    ComboField comboField = getLocaleField(formProperties.getLocaleCode());
    ef.addField(cmd, comboField);
    Field translatedValueValueField = new Field().withName("translatedValue").withFieldType(formProperties.getIsRte() ? "html" : "string").withFriendlyName("Translation_translatedValue").withValue(formProperties.getTranslatedValue()).withOrder(10);
    ef.addField(cmd, translatedValueValueField);
    if (action.equals(TranslationFormAction.UPDATE)) {
        comboField.setReadOnly(true);
    }
    ef.addHiddenField(cmd, new Field().withName("ceilingEntity").withValue(formProperties.getCeilingEntity()));
    ef.addHiddenField(cmd, new Field().withName("entityId").withValue(formProperties.getEntityId()));
    ef.addHiddenField(cmd, new Field().withName("propertyName").withValue(formProperties.getPropertyName()));
    ef.addHiddenField(cmd, new Field().withName("isRte").withValue(String.valueOf(formProperties.getIsRte())));
    return ef;
}
Also used : EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm) ComboField(org.broadleafcommerce.openadmin.web.form.entity.ComboField) ComboField(org.broadleafcommerce.openadmin.web.form.entity.ComboField) Field(org.broadleafcommerce.openadmin.web.form.entity.Field) EntityFormAction(org.broadleafcommerce.openadmin.web.form.entity.EntityFormAction)

Example 3 with EntityFormAction

use of org.broadleafcommerce.openadmin.web.form.entity.EntityFormAction in project BroadleafCommerce by BroadleafCommerce.

the class AdminAssetController method viewEntityList.

@Override
@SuppressWarnings("unchecked")
@RequestMapping(value = "", method = RequestMethod.GET)
public String viewEntityList(HttpServletRequest request, HttpServletResponse response, Model model, @PathVariable Map<String, String> pathVars, @RequestParam MultiValueMap<String, String> requestParams) throws Exception {
    String returnPath = super.viewEntityList(request, response, model, pathVars, requestParams);
    // Remove the default add button and replace it with an upload asset button
    List<EntityFormAction> mainActions = (List<EntityFormAction>) model.asMap().get("mainActions");
    Iterator<EntityFormAction> actions = mainActions.iterator();
    while (actions.hasNext()) {
        EntityFormAction action = actions.next();
        if (EntityFormAction.ADD.equals(action.getId())) {
            actions.remove();
            break;
        }
    }
    mainActions.add(0, new EntityFormAction("UPLOAD_ASSET").withButtonClass("upload-asset").withIconClass("icon-camera").withDisplayText("Upload_Asset"));
    // Change the listGrid view to one that has a hidden form for uploading the image.
    model.addAttribute("viewType", "entityListWithUploadForm");
    ListGrid listGrid = (ListGrid) model.asMap().get("listGrid");
    formService.addImageThumbnailField(listGrid, "fullUrl");
    return returnPath;
}
Also used : EntityFormAction(org.broadleafcommerce.openadmin.web.form.entity.EntityFormAction) List(java.util.List) ListGrid(org.broadleafcommerce.openadmin.web.form.component.ListGrid)

Aggregations

EntityFormAction (org.broadleafcommerce.openadmin.web.form.entity.EntityFormAction)3 EntityForm (org.broadleafcommerce.openadmin.web.form.entity.EntityForm)2 List (java.util.List)1 ListGrid (org.broadleafcommerce.openadmin.web.form.component.ListGrid)1 ComboField (org.broadleafcommerce.openadmin.web.form.entity.ComboField)1 Field (org.broadleafcommerce.openadmin.web.form.entity.Field)1