use of org.broadleafcommerce.openadmin.dto.SectionCrumb in project BroadleafCommerce by BroadleafCommerce.
the class AdminAbstractController method getSectionCrumbs.
protected List<SectionCrumb> getSectionCrumbs(HttpServletRequest request, String currentSection, String currentSectionId) {
String crumbs = request.getParameter("sectionCrumbs");
List<SectionCrumb> myCrumbs = validationService.getSectionCrumbs(crumbs);
if (currentSection != null && currentSectionId != null) {
SectionCrumb crumb = createSectionCrumb(currentSection, currentSectionId);
if (!myCrumbs.contains(crumb)) {
myCrumbs.add(crumb);
}
}
return myCrumbs;
}
use of org.broadleafcommerce.openadmin.dto.SectionCrumb in project BroadleafCommerce by BroadleafCommerce.
the class AdminAbstractController method createSectionCrumb.
protected SectionCrumb createSectionCrumb(String currentSection, String currentSectionId) {
SectionCrumb crumb = new SectionCrumb();
if (currentSection.startsWith("/")) {
currentSection = currentSection.substring(1, currentSection.length());
}
crumb.setSectionIdentifier(currentSection);
crumb.setSectionId(currentSectionId);
return crumb;
}
use of org.broadleafcommerce.openadmin.dto.SectionCrumb in project BroadleafCommerce by BroadleafCommerce.
the class AdminTranslationController method showAddTranslation.
/**
* Renders a modal dialog that has a list grid of translations for the specified field
*
* @param request
* @param response
* @param model
* @param form
* @param result
* @return the return view path
* @throws Exception
*/
@RequestMapping(value = "/add", method = RequestMethod.GET)
public String showAddTranslation(HttpServletRequest request, HttpServletResponse response, Model model, @PathVariable Map<String, String> pathVars, @ModelAttribute(value = "form") TranslationForm form, BindingResult result) throws Exception {
String sectionKey = getSectionKey(pathVars);
String sectionClassName = getClassNameForSection(sectionKey);
List<SectionCrumb> sectionCrumbs = new ArrayList<>();
PersistencePackageRequest ppr = getSectionPersistencePackageRequest(sectionClassName, sectionCrumbs, pathVars);
ClassMetadata cmd = service.getClassMetadata(ppr).getDynamicResultSet().getClassMetaData();
adminRemoteSecurityService.securityCheck(form.getCeilingEntity(), EntityOperationType.FETCH);
EntityForm entityForm = formService.buildTranslationForm(cmd, form, TranslationFormAction.ADD);
model.addAttribute("entityForm", entityForm);
model.addAttribute("viewType", "modal/translationAdd");
model.addAttribute("currentUrl", request.getRequestURL().toString());
model.addAttribute("modalHeaderType", ModalHeaderType.ADD_TRANSLATION.getType());
return "modules/modalContainer";
}
use of org.broadleafcommerce.openadmin.dto.SectionCrumb in project BroadleafCommerce by BroadleafCommerce.
the class AdminTranslationController method deleteTranslation.
/**
* Deletes the translation specified by the translation id
*
* @param request
* @param response
* @param model
* @param id
* @param form
* @param result
* @return the result of a call to {@link #viewTranslation}, which renders the list grid
* @throws Exception
*/
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public String deleteTranslation(HttpServletRequest request, HttpServletResponse response, Model model, @PathVariable Map<String, String> pathVars, @ModelAttribute(value = "form") final TranslationForm form, BindingResult result) throws Exception {
adminRemoteSecurityService.securityCheck(form.getCeilingEntity(), EntityOperationType.UPDATE);
SectionCrumb sectionCrumb = new SectionCrumb();
sectionCrumb.setSectionIdentifier(TranslationImpl.class.getName());
sectionCrumb.setSectionId(String.valueOf(form.getTranslationId()));
List<SectionCrumb> sectionCrumbs = Arrays.asList(sectionCrumb);
String sectionKey = getSectionKey(pathVars);
String sectionClassName = getClassNameForSection(sectionKey);
PersistencePackageRequest ppr = getSectionPersistencePackageRequest(sectionClassName, sectionCrumbs, pathVars);
ClassMetadata cmd = service.getClassMetadata(ppr).getDynamicResultSet().getClassMetaData();
EntityForm entityForm = formService.buildTranslationForm(cmd, form, TranslationFormAction.OTHER);
entityForm.setCeilingEntityClassname(Translation.class.getName());
entityForm.setEntityType(TranslationImpl.class.getName());
Field id = new Field();
id.setName("id");
id.setValue(String.valueOf(form.getTranslationId()));
entityForm.getFields().put("id", id);
entityForm.setId(String.valueOf(form.getTranslationId()));
String[] sectionCriteria = customCriteriaService.mergeSectionCustomCriteria(Translation.class.getName(), getSectionCustomCriteria());
service.removeEntity(entityForm, sectionCriteria, sectionCrumbs);
return viewTranslation(request, response, model, form, result);
}
use of org.broadleafcommerce.openadmin.dto.SectionCrumb in project BroadleafCommerce by BroadleafCommerce.
the class AdminTranslationController method showUpdateTranslation.
@RequestMapping(value = "/update", method = RequestMethod.GET)
public String showUpdateTranslation(HttpServletRequest request, HttpServletResponse response, Model model, @PathVariable Map<String, String> pathVars, @ModelAttribute(value = "form") TranslationForm form, BindingResult result) throws Exception {
String sectionKey = getSectionKey(pathVars);
String sectionClassName = getClassNameForSection(sectionKey);
List<SectionCrumb> sectionCrumbs = new ArrayList<>();
PersistencePackageRequest ppr = getSectionPersistencePackageRequest(sectionClassName, sectionCrumbs, pathVars);
ClassMetadata cmd = service.getClassMetadata(ppr).getDynamicResultSet().getClassMetaData();
adminRemoteSecurityService.securityCheck(form.getCeilingEntity(), EntityOperationType.FETCH);
Translation t = translationService.findTranslationById(form.getTranslationId());
form.setTranslatedValue(t.getTranslatedValue());
EntityForm entityForm = formService.buildTranslationForm(cmd, form, TranslationFormAction.UPDATE);
entityForm.setId(String.valueOf(form.getTranslationId()));
model.addAttribute("entityForm", entityForm);
model.addAttribute("viewType", "modal/translationAdd");
model.addAttribute("currentUrl", request.getRequestURL().toString());
model.addAttribute("modalHeaderType", ModalHeaderType.UPDATE_TRANSLATION.getType());
return "modules/modalContainer";
}
Aggregations