CategoryStep finished

pull/10/head
Jens Pelzetter 2021-08-03 20:52:14 +02:00
parent 46d21adcea
commit 30ee6ddd2a
6 changed files with 64 additions and 27 deletions

View File

@ -301,7 +301,7 @@ public class CategorizationStep extends AbstractMvcAuthoringStep {
) { ) {
final List<String> assigned = new ArrayList<>(); final List<String> assigned = new ArrayList<>();
if (node.isAssigned()) { if (node.isAssigned()) {
assigned.add(String.join("/", parentPath, node.getTitle())); assigned.add(String.join("/", parentPath, getCategoryLabel(node)));
} }
if (node.isSubCategoryAssigned()) { if (node.isSubCategoryAssigned()) {
@ -311,7 +311,11 @@ public class CategorizationStep extends AbstractMvcAuthoringStep {
.stream() .stream()
.map( .map(
subCat -> buildAssignedCategoriesList( subCat -> buildAssignedCategoriesList(
subCat, String.join("/", node.getTitle() subCat,
String.join(
"/",
parentPath,
getCategoryLabel(node)
) )
) )
) )
@ -355,16 +359,17 @@ public class CategorizationStep extends AbstractMvcAuthoringStep {
.map(this::buildCategorizationTreeNode) .map(this::buildCategorizationTreeNode)
.collect(Collectors.toList()) .collect(Collectors.toList())
); );
node.setSubCategoryAssigned( // node.setSubCategoryAssigned(
category // isSubCategoryAssigned(category)
.getSubCategories() //// category
.stream() //// .getSubCategories()
.allMatch( //// .stream()
subCat -> categoryManager.isAssignedToCategory( //// .allMatch(
subCat, document //// subCat -> categoryManager.isAssignedToCategory(
) //// subCat, document
) //// )
); //// )
// );
node.setTitle( node.setTitle(
globalizationHelper.getValueFromLocalizedString( globalizationHelper.getValueFromLocalizedString(
category.getTitle() category.getTitle()
@ -375,4 +380,25 @@ public class CategorizationStep extends AbstractMvcAuthoringStep {
return node; return node;
} }
// private boolean isSubCategoryAssigned(final Category category) {
// boolean result = false;
// for (final Category subCategory : category.getSubCategories()) {
// result = result || categoryManager.isAssignedToCategory(subCategory, getDocument());
//
// if (!subCategory.getSubCategories().isEmpty()) {
// result = result || isSubCategoryAssigned(subCategory);
// }
// }
//
// return result;
// }
private String getCategoryLabel(final CategorizationTreeNode node) {
if (node.getTitle() == null || node.getTitle().isBlank()) {
return node.getCategoryName();
} else {
return node.getTitle();
}
}
} }

View File

@ -71,11 +71,11 @@ public class CategorizationTreeNode {
*/ */
private boolean assigned; private boolean assigned;
/** // /**
* Is any subcategory of the category represented by this node assigned to // * Is any subcategory of the category represented by this node assigned to
* the current content item? // * the current content item?
*/ // */
private boolean subCategoryAssigned; // private boolean subCategoryAssigned;
/** /**
* Nodes for the subcategories of the category represented by this node. * Nodes for the subcategories of the category represented by this node.
@ -139,12 +139,16 @@ public class CategorizationTreeNode {
} }
public boolean isSubCategoryAssigned() { public boolean isSubCategoryAssigned() {
return subCategoryAssigned; // return subCategoryAssigned;
return subCategories
.stream()
.map(CategorizationTreeNode::isAssigned)
.reduce(false, (value1, value2) -> value1 || value2);
} }
public void setSubCategoryAssigned(final boolean subCategoryAssigned) { // public void setSubCategoryAssigned(final boolean subCategoryAssigned) {
this.subCategoryAssigned = subCategoryAssigned; // this.subCategoryAssigned = subCategoryAssigned;
} // }
public List<CategorizationTreeNode> getSubCategories() { public List<CategorizationTreeNode> getSubCategories() {
return Collections.unmodifiableList(subCategories); return Collections.unmodifiableList(subCategories);

View File

@ -34,12 +34,13 @@
</label> </label>
<input class="form-check-input" <input class="form-check-input"
id="#{node.categoryUuid}" id="#{node.categoryUuid}"
checked="#{node.assigned ? 'checked' : ''}"
name="assigned-categories" name="assigned-categories"
type="checkbox" type="checkbox"
value="#{node.categoryUuid}" /> value="#{node.categoryUuid}" />
</div> </div>
<c:if test="#{!node.subCategories.isEmpty()}"> <c:if test="#{!node.subCategories.isEmpty()}">
<ul class="#{node.assigned or isRoot ? 'collapse.show' : 'collapse'} " <ul class="#{node.assigned or node.subCategoryAssigned or isRoot ? 'collapse.show' : 'collapse'} "
id="subcategories-#{node.categoryUuid}"> id="subcategories-#{node.categoryUuid}">
<c:forEach items="#{node.subCategories}" <c:forEach items="#{node.subCategories}"
var="subCat"> var="subCat">

View File

@ -7,12 +7,14 @@
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml"> <ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml">
<ui:define name="authoringStep"> <ui:define name="authoringStep">
<h1>#{CmsDefaultStepsMessageBundle.getMessage('categorization.title', [CmsSelectedDocumentModel.itemTitle])}</h1>
<c:forEach items="#{CmsCategorizationStep.categorizationTrees}" <c:forEach items="#{CmsCategorizationStep.categorizationTrees}"
var="tree"> var="tree">
<h2>#{tree.domainTitle}</h2> <h2>#{tree.domainTitle}</h2>
<div class="d-flex mb-3"> <div class="d-flex mb-3">
<span>#{CmsDefaultStepsMessageBundle['categorization.system.assigned.to']}</span> <span class="mr-2">#{CmsDefaultStepsMessageBundle['categorization.system.assigned.to']}</span>
<button class="btn btn-primary" <button class="btn btn-primary"
data-target="#edit-categorization-#{tree.domainKey}" data-target="#edit-categorization-#{tree.domainKey}"
data-toggle="modal" data-toggle="modal"
@ -25,10 +27,10 @@
</div> </div>
<div aria-labelledby="edit-categorization-#{tree.domainKey}-title" <div aria-labelledby="edit-categorization-#{tree.domainKey}-title"
aria-hidden="true" aria-hidden="true"
class="modal modal-xl fade" class="modal fade"
id="edit-categorization-#{tree.domainKey}" id="edit-categorization-#{tree.domainKey}"
tabindex="-1"> tabindex="-1">
<div class="modal-dialog"> <div class="modal-dialog modal-xl">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@categorization/domains/#{tree.domainKey}" <form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@categorization/domains/#{tree.domainKey}"
class="modal-content" class="modal-content"
method="post"> method="post">
@ -46,7 +48,7 @@
</button> </button>
</div> </div>
<div class="modal-body categorizationtree"> <div class="modal-body categorizationtree">
<ul class="#{tree.root.subCategoryAssigned ? 'collapse' : 'collapse.show'}" <ul class=""
id="#{node.categoryUuid}-subcategories"> id="#{node.categoryUuid}-subcategories">
<ui:include src="categorization-tree-node.xhtml"> <ui:include src="categorization-tree-node.xhtml">
<ui:param name="node" <ui:param name="node"
@ -73,10 +75,12 @@
<c:choose> <c:choose>
<c:when test="#{tree.root.assigned or tree.root.subCategoryAssigned}"> <c:when test="#{tree.root.assigned or tree.root.subCategoryAssigned}">
<ul>
<c:forEach items="#{tree.assignedCategories}" <c:forEach items="#{tree.assignedCategories}"
var="assigned"> var="assigned">
#{assigned} <li>#{assigned}</li>
</c:forEach> </c:forEach>
</ul>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<div class="alert alert-info" role="alert"> <div class="alert alert-info" role="alert">

View File

@ -239,3 +239,4 @@ relatedinfo.attachments.info.dialog.close=Close
relatedinfo.attachments.info.dialog.title.label=Title relatedinfo.attachments.info.dialog.title.label=Title
relatedinfo.attachments.info.dialog.type.label=Type relatedinfo.attachments.info.dialog.type.label=Type
relatedinfo.attachmentlists.order.save.inprogress=Saving... relatedinfo.attachmentlists.order.save.inprogress=Saving...
categorization.title=Categories assigned to content item {0}

View File

@ -239,3 +239,4 @@ relatedinfo.attachments.info.dialog.close=Schlie\u00dfen
relatedinfo.attachments.info.dialog.title.label=Titel relatedinfo.attachments.info.dialog.title.label=Titel
relatedinfo.attachments.info.dialog.type.label=Typ relatedinfo.attachments.info.dialog.type.label=Typ
relatedinfo.attachmentlists.order.save.inprogress=Speichere... relatedinfo.attachmentlists.order.save.inprogress=Speichere...
categorization.title=Zugeordnete Kategorien Dokument {0}