Search in sources :

Example 16 with SectionCrumb

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;
}
Also used : SectionCrumb(org.broadleafcommerce.openadmin.dto.SectionCrumb)

Example 17 with SectionCrumb

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;
}
Also used : SectionCrumb(org.broadleafcommerce.openadmin.dto.SectionCrumb)

Example 18 with SectionCrumb

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";
}
Also used : SectionCrumb(org.broadleafcommerce.openadmin.dto.SectionCrumb) ClassMetadata(org.broadleafcommerce.openadmin.dto.ClassMetadata) EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm) ArrayList(java.util.ArrayList) PersistencePackageRequest(org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with SectionCrumb

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);
}
Also used : SectionCrumb(org.broadleafcommerce.openadmin.dto.SectionCrumb) ClassMetadata(org.broadleafcommerce.openadmin.dto.ClassMetadata) EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm) Field(org.broadleafcommerce.openadmin.web.form.entity.Field) Translation(org.broadleafcommerce.common.i18n.domain.Translation) TranslationImpl(org.broadleafcommerce.common.i18n.domain.TranslationImpl) PersistencePackageRequest(org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 20 with SectionCrumb

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";
}
Also used : SectionCrumb(org.broadleafcommerce.openadmin.dto.SectionCrumb) ClassMetadata(org.broadleafcommerce.openadmin.dto.ClassMetadata) EntityForm(org.broadleafcommerce.openadmin.web.form.entity.EntityForm) Translation(org.broadleafcommerce.common.i18n.domain.Translation) ArrayList(java.util.ArrayList) PersistencePackageRequest(org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

SectionCrumb (org.broadleafcommerce.openadmin.dto.SectionCrumb)42 ClassMetadata (org.broadleafcommerce.openadmin.dto.ClassMetadata)32 PersistencePackageRequest (org.broadleafcommerce.openadmin.server.domain.PersistencePackageRequest)29 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)28 Entity (org.broadleafcommerce.openadmin.dto.Entity)19 Property (org.broadleafcommerce.openadmin.dto.Property)19 DynamicResultSet (org.broadleafcommerce.openadmin.dto.DynamicResultSet)15 FieldMetadata (org.broadleafcommerce.openadmin.dto.FieldMetadata)13 BasicFieldMetadata (org.broadleafcommerce.openadmin.dto.BasicFieldMetadata)12 ListGrid (org.broadleafcommerce.openadmin.web.form.component.ListGrid)9 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)9 BasicCollectionMetadata (org.broadleafcommerce.openadmin.dto.BasicCollectionMetadata)8 EntityForm (org.broadleafcommerce.openadmin.web.form.entity.EntityForm)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 PersistenceResponse (org.broadleafcommerce.openadmin.server.service.persistence.PersistenceResponse)6 AdornedTargetCollectionMetadata (org.broadleafcommerce.openadmin.dto.AdornedTargetCollectionMetadata)5 Field (org.broadleafcommerce.openadmin.web.form.entity.Field)5 Map (java.util.Map)4 Translation (org.broadleafcommerce.common.i18n.domain.Translation)4