diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoriesController.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoriesController.java index 45aa38a6e..6a094f920 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoriesController.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoriesController.java @@ -59,7 +59,7 @@ public class CategoriesController { @Inject private ContentSectionModel sectionModel; - + @Inject private ContentSectionRepository sectionRepo; @@ -100,14 +100,29 @@ public class CategoriesController { } @GET - @Path("/{key}/categories") + @Path("/{context}") + @AuthorizationRequired + @Transactional(Transactional.TxType.REQUIRED) + public String showCategorySystemRoot( + @PathParam("sectionIdentifier") final String sectionIdentifier, + @PathParam("context") final String context + ) { + return String.format( + "redirect:/%s/categorysystems/%s/categories", + sectionIdentifier, + context + ); + } + + @GET + @Path("/{context}/categories") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) public String showCategorySystem( @PathParam("sectionIdentifier") final String sectionIdentifier, - @PathParam("key") final String domainKey + @PathParam("context") final String context ) { - return showCategorySystem(sectionIdentifier, domainKey, ""); + return showCategorySystem(sectionIdentifier, context, ""); } @GET @@ -126,6 +141,7 @@ public class CategoriesController { return "org/librecms/ui/contentsection/contentsection-not-found.xhtml"; } final ContentSection section = sectionResult.get(); + sectionModel.setSection(section); final Optional domainResult = section .getDomains() @@ -153,7 +169,15 @@ public class CategoriesController { ); final Domain domain = domainResult.get().getDomain(); - categorySystemModel.setCategoryTree(buildCategoryTree(domain)); + final String activePath; + if (categoryPath.isEmpty()) { + activePath = "/"; + } else { + activePath = categoryPath; + } + categorySystemModel.setCategoryTree( + buildCategoryTree(domain, activePath) + ); final Category category; if (categoryPath.isEmpty()) { @@ -175,71 +199,6 @@ public class CategoriesController { return "org/librecms/ui/contentsection/categorysystems/categorysystem.xhtml"; } - @POST - @Path("/{context}/categories/{categoryPath:(.+)?}") - @AuthorizationRequired - @Transactional(Transactional.TxType.REQUIRED) - public String renameCategory( - @PathParam("sectionIdentifier") final String sectionIdentifier, - @PathParam("context") final String context, - @PathParam("categoryPath") final String categoryPath, - @FormParam("categoryName") final String categoryName - ) { -// final Optional sectionResult = retrieveContentSection( -// sectionIdentifier); -// if (!sectionResult.isPresent()) { -// models.put("sectionIdentifier", sectionIdentifier); -// return "org/librecms/ui/contentsection/contentsection-not-found.xhtml"; -// } -// final ContentSection section = sectionResult.get(); -// -// final Optional domainResult = section -// .getDomains() -// .stream() -// .filter(domain -> domain.getContext().equals(context)) -// .findAny(); -// if (!domainResult.isPresent()) { -// models.put("sectionIdentifier", sectionIdentifier); -// models.put("context", context); -// return "org/librecms/ui/contentsection/categorysystems/categorysystem-not-found.xhtml"; -// } -// final Domain domain = domainResult.get().getDomain(); - if (categoryPath.isEmpty()) { - models.put("sectionIdentifier", sectionIdentifier); - models.put("context", context); - models.put("categoryPath", categoryPath); - return "org/librecms/ui/contentsection/categorysystems/category-not-found.xhtml"; - } -// final Category category; -// final Optional categoryResult = categoryRepo -// .findByPath(domain, categoryPath); -// if (!categoryResult.isPresent()) { -// models.put("sectionIdentifier", sectionIdentifier); -// models.put("context", context); -// models.put("categoryPath", categoryPath); -// return "org/librecms/ui/contentsection/categorysystems/category-not-found.xhtml"; -// } -// category = categoryResult.get(); - - final RetrieveResult result = retrieveCategory( - sectionIdentifier, context, categoryPath - ); - if (result.isSuccessful()) { - final Category category = result.getResult(); - category.setName(categoryName); - categoryRepo.save(category); - - return String.format( - "redirect:/%s/categorysystems/%s/categories/%s", - sectionIdentifier, - context, - categoryPath - ); - } else { - return result.getResponseTemplate(); - } - } - @POST @Path("/{context}/categories/@title/add") @AuthorizationRequired @@ -485,10 +444,12 @@ public class CategoriesController { @Path("/{context}/categories/{categoryPath:(.+)?}/@attributes") @AuthorizationRequired @Transactional(Transactional.TxType.REQUIRED) - public String updateAttributes( + public String updateCategory( @PathParam("sectionIdentifier") final String sectionIdentifier, @PathParam("context") final String context, @PathParam("categoryPath") final String categoryPath, + @FormParam("categoryName") final String categoryName, + @FormParam("uniqueId") final String uniqueId, @FormParam("isEnabled") final String isEnabled, @FormParam("isVisible") final String isVisible, @FormParam("isAbstract") final String isAbstract @@ -498,15 +459,19 @@ public class CategoriesController { ); if (result.isSuccessful()) { final Category category = result.getResult(); + category.setName(categoryName); + category.setUniqueId(uniqueId); category.setEnabled(Objects.equals("true", isEnabled)); category.setVisible(Objects.equals("true", isVisible)); category.setAbstractCategory(Objects.equals("true", isAbstract)); categoryRepo.save(category); + return String.format( - "redirect:/%s/categorysystems/%s/categories/%s", + "redirect:/%s/categorysystems/%s/categories/%s/%s", sectionIdentifier, context, - categoryPath + categoryManager.getCategoryPath(category.getParentCategory()), + categoryName ); } else { return result.getResponseTemplate(); @@ -602,6 +567,7 @@ public class CategoriesController { @PathParam("context") final String context, @PathParam("categoryPath") final String categoryPath, @FormParam("categoryName") final String categoryName, + @FormParam("uniqueId") final String uniqueId, @FormParam("isEnabled") final String isEnabled, @FormParam("isVisible") final String isVisible, @FormParam("isAbstract") final String isAbstract @@ -613,6 +579,7 @@ public class CategoriesController { final Category category = result.getResult(); final Category subCategory = new Category(); subCategory.setName(categoryName); + subCategory.setUniqueId(uniqueId); subCategory.setEnabled(Objects.equals("true", isEnabled)); subCategory.setVisible(Objects.equals("true", isVisible)); subCategory.setAbstractCategory(Objects.equals("true", isAbstract)); @@ -935,27 +902,39 @@ public class CategoriesController { return model; } - private CategoryTreeNodeModel buildCategoryTree(final Domain domain) { - return buildCategoryTreeNode(domain.getRoot()); + private CategoryTreeNodeModel buildCategoryTree( + final Domain domain, final String activePath + ) { + return buildCategoryTreeNode(domain.getRoot(), activePath); } private CategoryTreeNodeModel buildCategoryTreeNode( - final Category category + final Category category, final String activePath ) { final CategoryTreeNodeModel model = new CategoryTreeNodeModel(); - model.setTitle( - globalizationHelper.getValueFromLocalizedString( - category.getTitle() - ) - ); - model.setPath(categoryManager.getCategoryPath(category)); + model.setUuid(category.getUuid()); + if (category.getTitle().getValues().isEmpty()) { + model.setTitle(category.getName()); + } else { + model.setTitle( + globalizationHelper.getValueFromLocalizedString( + category.getTitle() + ) + ); + } + final String path = categoryManager.getCategoryPath(category); + model.setActive(activePath.equals(path)); + model.setPath(path); if (!category.getSubCategories().isEmpty()) { model.setSubCategories( category .getSubCategories() .stream() - .map(this::buildCategoryTreeNode) - .collect(Collectors.toList()) + .map( + subCategory -> buildCategoryTreeNode( + subCategory, activePath + ) + ).collect(Collectors.toList()) ); } @@ -995,6 +974,7 @@ public class CategoriesController { ) ); model.setUniqueId(category.getUniqueId()); + model.setUuid(category.getUuid()); model.setVisible(category.isVisible()); return model; } @@ -1018,6 +998,7 @@ public class CategoriesController { ) ); model.setUniqueId(category.getUniqueId()); + model.setUuid(category.getUuid()); model.setVisible(category.isVisible()); return model; } diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoryModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoryModel.java index 9ee776a6c..23b7336f6 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoryModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoryModel.java @@ -17,6 +17,8 @@ public class CategoryModel { private long categoryId; + private String uuid; + private String uniqueId; private String name; @@ -51,6 +53,14 @@ public class CategoryModel { public void setCategoryId(final long categoryId) { this.categoryId = categoryId; } + + public String getUuid() { + return uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } public String getUniqueId() { return uniqueId; diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoryTreeNodeModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoryTreeNodeModel.java index add2b1028..696dc0c75 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoryTreeNodeModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/CategoryTreeNodeModel.java @@ -16,6 +16,10 @@ import java.util.List; */ public class CategoryTreeNodeModel { + private String uuid; + + private boolean active; + private String path; private String title; @@ -52,4 +56,21 @@ public class CategoryTreeNodeModel { this.subCategories = new ArrayList<>(subCategories); } + public String getUuid() { + return uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + public boolean isActive() { + return active; + } + + public void setActive(final boolean active) { + this.active = active; + } + + } diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/assetfolder/asset-folder-tree-node.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/assetfolder/asset-folder-tree-node.xhtml index 8caea7b5f..b15d0b33a 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/assetfolder/asset-folder-tree-node.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/assetfolder/asset-folder-tree-node.xhtml @@ -13,7 +13,7 @@ + #{category.title} + +
    + + + + + + +
+ + + +
  • + #{category.title} +
  • +
    + + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/categorysystems/categorysystem-not-found.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/categorysystems/categorysystem-not-found.xhtml new file mode 100644 index 000000000..5eb3e6228 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/categorysystems/categorysystem-not-found.xhtml @@ -0,0 +1,26 @@ +]> + + + + + + + + + + +
    + +
    +
    +
    + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/categorysystems/categorysystem.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/categorysystems/categorysystem.xhtml new file mode 100644 index 000000000..502fcf983 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/categorysystems/categorysystem.xhtml @@ -0,0 +1,123 @@ +]> + + + + + + + + + + + +
    +

    #{CmsAdminMessages.getMessage("contentsection.categories.category.heading", [ContentSectionModel.sectionName, CategorySystemModel.selectedCategorySystem.context, CategorySystemModel.selectedCategory.path])}

    + +
    +
    + +

    #{CmsAdminMessages['contentsection.categorysystems.categorytree.heading']}

    + +
    +
    +

    #{CmsAdminMessages.getMessage("contentsection.categorysystems.category.properties.heading", [CategorySystemModel.selectedCategory.name])}

    +
    +
    +
    #{CmsAdminMessages['contentsection.categorysystems.category.properties.id']}
    +
    #{CategorySystemModel.selectedCategory.id}
    +
    +
    +
    #{CmsAdminMessages['contentsection.categorysystems.category.properties.uuid']}
    +
    #{CategorySystemModel.selectedCategory.uuid}
    +
    +
    +
    #{CmsAdminMessages['contentsection.categorysystems.category.properties.uniqueId']}
    +
    #{CategorySystemModel.selectedCategory.uniqueId}
    +
    +
    +
    #{CmsAdminMessages['contentsection.categorysystems.category.properties.name']}
    +
    #{CategorySystemModel.selectedCategory.name}
    +
    +
    +
    #{CmsAdminMessages['contentsection.categorysystems.category.properties.enabled']}
    +
    + + + #{CmsAdminMessages['contentsection.categorysystems.category.properties.enabled.yes']} + + + #{CmsAdminMessages['contentsection.categorysystems.category.properties.enabled.no']} + + +
    +
    +
    +
    #{CmsAdminMessages['contentsection.categorysystems.category.properties.visible']}
    +
    + + + #{CmsAdminMessages['contentsection.categorysystems.category.properties.visible.yes']} + + + #{CmsAdminMessages['contentsection.categorysystems.category.properties.visible.no']} + + +
    +
    +
    +
    #{CmsAdminMessages['contentsection.categorysystems.category.properties.abstract_category']}
    +
    + + + #{CmsAdminMessages['contentsection.categorysystems.category.properties.abstract_category.yes']} + + + #{CmsAdminMessages['contentsection.categorysystems.category.properties.abstract_category.no']} + + +
    +
    +
    +
    +
    +
    +
    + + + +
    + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/categorysystems/categorysystems.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/categorysystems/categorysystems.xhtml index fa3cb246e..826524431 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/categorysystems/categorysystems.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/categorysystems/categorysystems.xhtml @@ -8,7 +8,8 @@ - +