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