Search in sources :

Example 21 with EntityForm

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

the class AdminProductController method showAddAdditionalSku.

protected String showAddAdditionalSku(HttpServletRequest request, HttpServletResponse response, Model model, String id, Map<String, String> pathVars) throws Exception {
    String collectionField = "additionalSkus";
    String mainClassName = getClassNameForSection(SECTION_KEY);
    List<SectionCrumb> sectionCrumbs = getSectionCrumbs(request, SECTION_KEY, id);
    ClassMetadata mainMetadata = service.getClassMetadata(getSectionPersistencePackageRequest(mainClassName, sectionCrumbs, pathVars)).getDynamicResultSet().getClassMetaData();
    Property collectionProperty = mainMetadata.getPMap().get(collectionField);
    FieldMetadata md = collectionProperty.getMetadata();
    PersistencePackageRequest ppr = PersistencePackageRequest.fromMetadata(md, sectionCrumbs).withCustomCriteria(new String[] { id });
    BasicCollectionMetadata fmd = (BasicCollectionMetadata) md;
    ClassMetadata cmd = service.getClassMetadata(ppr).getDynamicResultSet().getClassMetaData();
    // If the entity type isn't specified, we need to determine if there are various polymorphic types
    // for this entity.
    String entityType = null;
    if (request.getParameter("entityType") != null) {
        entityType = request.getParameter("entityType");
    }
    if (StringUtils.isBlank(entityType)) {
        if (cmd.getPolymorphicEntities().getChildren().length == 0) {
            entityType = cmd.getPolymorphicEntities().getFullyQualifiedClassname();
        } else {
            entityType = getDefaultEntityType();
        }
    } else {
        entityType = URLDecoder.decode(entityType, "UTF-8");
    }
    if (StringUtils.isBlank(entityType)) {
        List<ClassTree> entityTypes = getAddEntityTypes(cmd.getPolymorphicEntities());
        model.addAttribute("entityTypes", entityTypes);
        model.addAttribute("viewType", "modal/entityTypeSelection");
        model.addAttribute("entityFriendlyName", cmd.getPolymorphicEntities().getFriendlyName());
        String requestUri = request.getRequestURI();
        if (!request.getContextPath().equals("/") && requestUri.startsWith(request.getContextPath())) {
            requestUri = requestUri.substring(request.getContextPath().length() + 1, requestUri.length());
        }
        model.addAttribute("currentUri", requestUri);
        model.addAttribute("modalHeaderType", ModalHeaderType.ADD_ENTITY.getType());
        setModelAttributes(model, SECTION_KEY);
        return "modules/modalContainer";
    } else {
        ppr = ppr.withCeilingEntityClassname(entityType);
    }
    ClassMetadata collectionMetadata = service.getClassMetadata(ppr).getDynamicResultSet().getClassMetaData();
    EntityForm entityForm = formService.createEntityForm(collectionMetadata, sectionCrumbs);
    entityForm.setCeilingEntityClassname(ppr.getCeilingEntityClassname());
    entityForm.setEntityType(ppr.getCeilingEntityClassname());
    formService.removeNonApplicableFields(collectionMetadata, entityForm, ppr.getCeilingEntityClassname());
    entityForm.removeAction(DefaultEntityFormActions.DELETE);
    model.addAttribute("entityForm", entityForm);
    model.addAttribute("viewType", "modal/simpleAddEntity");
    model.addAttribute("currentUrl", request.getRequestURL().toString());
    model.addAttribute("modalHeaderType", ModalHeaderType.ADD_COLLECTION_ITEM.getType());
    model.addAttribute("collectionProperty", collectionProperty);
    setModelAttributes(model, SECTION_KEY);
    return "modules/modalContainer";
}
Also used : SectionCrumb(org.broadleafcommerce.openadmin.dto.SectionCrumb) ClassMetadata(org.broadleafcommerce.openadmin.dto.ClassMetadata) EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm) FieldMetadata(org.broadleafcommerce.openadmin.dto.FieldMetadata) ClassTree(org.broadleafcommerce.openadmin.dto.ClassTree) PersistencePackageRequest(org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest) BasicCollectionMetadata(org.broadleafcommerce.openadmin.dto.BasicCollectionMetadata) Property(org.broadleafcommerce.openadmin.dto.Property)

Example 22 with EntityForm

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

the class AdminOfferControllerExtensionHandler method setAdditionalModelAttributes.

@Override
public ExtensionResultStatusType setAdditionalModelAttributes(Model model, String sectionKey) {
    if (AdminOfferController.SECTION_KEY.equals(sectionKey)) {
        EntityForm form = (EntityForm) model.asMap().get("entityForm");
        if (form != null) {
            // UX Meta-Data to display the Rule Builders on the Offer Screen
            FieldGroup ruleConfigGroup = form.findGroup(OfferAdminPresentation.GroupName.RuleConfiguration);
            if (ruleConfigGroup != null) {
                ruleConfigGroup.getGroupAttributes().put("additionalGroupClasses", "card");
            }
            // Qualifier and Target Item Builders
            Field qualField = form.findField("qualifyingItemCriteria");
            if (qualField != null) {
                qualField.setDisplayType(RuleBuilderDisplayType.NORMAL.name());
            }
            Field fgField = form.findField("offerMatchRules---FULFILLMENT_GROUP");
            if (fgField != null) {
                fgField.setDisplayType(RuleBuilderDisplayType.NORMAL.name());
            }
            Field tarField = form.findField("targetItemCriteria");
            if (tarField != null) {
                tarField.setDisplayType(RuleBuilderDisplayType.NORMAL.name());
            }
            // Activity Range Builder
            Field timeField = form.findField("offerMatchRules---TIME");
            if (timeField != null) {
                timeField.setDisplayType(RuleBuilderDisplayType.MODAL.name());
            }
            // Usage Builders
            Field custField = form.findField("offerMatchRules---CUSTOMER");
            if (custField != null) {
                custField.setDisplayType(RuleBuilderDisplayType.MODAL.name());
            }
            Field orderField = form.findField("offerMatchRules---ORDER");
            if (orderField != null) {
                orderField.setDisplayType(RuleBuilderDisplayType.MODAL.name());
            }
        }
    }
    return ExtensionResultStatusType.HANDLED_CONTINUE;
}
Also used : EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm) Field(org.broadleafcommerce.openadmin.web.form.entity.Field) FieldGroup(org.broadleafcommerce.openadmin.web.form.entity.FieldGroup)

Example 23 with EntityForm

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

the class FormBuilderServiceImpl method createEntityForm.

@Override
public EntityForm createEntityForm(ClassMetadata cmd, Entity entity, List<SectionCrumb> sectionCrumbs) throws ServiceException {
    EntityForm ef = createStandardEntityForm();
    populateEntityForm(cmd, entity, ef, sectionCrumbs);
    addAdditionalFormActions(ef);
    extensionManager.getProxy().addAdditionalFormActions(ef);
    return ef;
}
Also used : EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm)

Example 24 with EntityForm

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

the class FormBuilderServiceImpl method createEntityForm.

@Override
public EntityForm createEntityForm(ClassMetadata cmd, List<SectionCrumb> sectionCrumbs) throws ServiceException {
    EntityForm ef = createStandardEntityForm();
    populateEntityForm(cmd, ef, sectionCrumbs);
    return ef;
}
Also used : EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm)

Example 25 with EntityForm

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

the class AdminBasicEntityController method showViewCollectionItem.

@RequestMapping(value = "/{id}/{collectionField:.*}/{collectionItemId}/view", method = RequestMethod.GET)
public String showViewCollectionItem(HttpServletRequest request, HttpServletResponse response, Model model, @PathVariable Map<String, String> pathVars, @PathVariable(value = "id") String id, @PathVariable(value = "collectionField") String collectionField, @PathVariable(value = "collectionItemId") String collectionItemId) throws Exception {
    String returnPath = showViewUpdateCollection(request, model, pathVars, id, collectionField, collectionItemId, null, ModalHeaderType.VIEW_COLLECTION_ITEM.getType());
    // Since this is a read-only view, actions don't make sense in this context
    EntityForm ef = (EntityForm) model.asMap().get("entityForm");
    ef.removeAllActions();
    ef.setReadOnly();
    return returnPath;
}
Also used : EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

EntityForm (org.broadleafcommerce.openadmin.web.form.entity.EntityForm)33 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)13 PersistencePackageRequest (org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest)12 ClassMetadata (org.broadleafcommerce.openadmin.dto.ClassMetadata)10 Field (org.broadleafcommerce.openadmin.web.form.entity.Field)10 SectionCrumb (org.broadleafcommerce.openadmin.dto.SectionCrumb)8 DynamicEntityFormInfo (org.broadleafcommerce.openadmin.web.form.entity.DynamicEntityFormInfo)7 ArrayList (java.util.ArrayList)6 Entity (org.broadleafcommerce.openadmin.dto.Entity)5 HashMap (java.util.HashMap)3 Map (java.util.Map)3 FieldMetadata (org.broadleafcommerce.openadmin.dto.FieldMetadata)3 Property (org.broadleafcommerce.openadmin.dto.Property)3 Page (org.broadleafcommerce.cms.page.domain.Page)2 Translation (org.broadleafcommerce.common.i18n.domain.Translation)2 BasicCollectionMetadata (org.broadleafcommerce.openadmin.dto.BasicCollectionMetadata)2 BasicFieldMetadata (org.broadleafcommerce.openadmin.dto.BasicFieldMetadata)2 DynamicResultSet (org.broadleafcommerce.openadmin.dto.DynamicResultSet)2 ListGrid (org.broadleafcommerce.openadmin.web.form.component.ListGrid)2 EntityFormAction (org.broadleafcommerce.openadmin.web.form.entity.EntityFormAction)2