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<>();
if (node.isAssigned()) {
assigned.add(String.join("/", parentPath, node.getTitle()));
assigned.add(String.join("/", parentPath, getCategoryLabel(node)));
}
if (node.isSubCategoryAssigned()) {
@ -311,7 +311,11 @@ public class CategorizationStep extends AbstractMvcAuthoringStep {
.stream()
.map(
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)
.collect(Collectors.toList())
);
node.setSubCategoryAssigned(
category
.getSubCategories()
.stream()
.allMatch(
subCat -> categoryManager.isAssignedToCategory(
subCat, document
)
)
);
// node.setSubCategoryAssigned(
// isSubCategoryAssigned(category)
//// category
//// .getSubCategories()
//// .stream()
//// .allMatch(
//// subCat -> categoryManager.isAssignedToCategory(
//// subCat, document
//// )
//// )
// );
node.setTitle(
globalizationHelper.getValueFromLocalizedString(
category.getTitle()
@ -375,4 +380,25 @@ public class CategorizationStep extends AbstractMvcAuthoringStep {
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;
/**
* Is any subcategory of the category represented by this node assigned to
* the current content item?
*/
private boolean subCategoryAssigned;
// /**
// * Is any subcategory of the category represented by this node assigned to
// * the current content item?
// */
// private boolean subCategoryAssigned;
/**
* Nodes for the subcategories of the category represented by this node.
@ -139,12 +139,16 @@ public class CategorizationTreeNode {
}
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) {
this.subCategoryAssigned = subCategoryAssigned;
}
// public void setSubCategoryAssigned(final boolean subCategoryAssigned) {
// this.subCategoryAssigned = subCategoryAssigned;
// }
public List<CategorizationTreeNode> getSubCategories() {
return Collections.unmodifiableList(subCategories);

View File

@ -34,12 +34,13 @@
</label>
<input class="form-check-input"
id="#{node.categoryUuid}"
checked="#{node.assigned ? 'checked' : ''}"
name="assigned-categories"
type="checkbox"
value="#{node.categoryUuid}" />
</div>
<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}">
<c:forEach items="#{node.subCategories}"
var="subCat">

View File

@ -7,12 +7,14 @@
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml">
<ui:define name="authoringStep">
<h1>#{CmsDefaultStepsMessageBundle.getMessage('categorization.title', [CmsSelectedDocumentModel.itemTitle])}</h1>
<c:forEach items="#{CmsCategorizationStep.categorizationTrees}"
var="tree">
<h2>#{tree.domainTitle}</h2>
<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"
data-target="#edit-categorization-#{tree.domainKey}"
data-toggle="modal"
@ -25,10 +27,10 @@
</div>
<div aria-labelledby="edit-categorization-#{tree.domainKey}-title"
aria-hidden="true"
class="modal modal-xl fade"
class="modal fade"
id="edit-categorization-#{tree.domainKey}"
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}"
class="modal-content"
method="post">
@ -46,7 +48,7 @@
</button>
</div>
<div class="modal-body categorizationtree">
<ul class="#{tree.root.subCategoryAssigned ? 'collapse' : 'collapse.show'}"
<ul class=""
id="#{node.categoryUuid}-subcategories">
<ui:include src="categorization-tree-node.xhtml">
<ui:param name="node"
@ -73,10 +75,12 @@
<c:choose>
<c:when test="#{tree.root.assigned or tree.root.subCategoryAssigned}">
<ul>
<c:forEach items="#{tree.assignedCategories}"
var="assigned">
#{assigned}
<li>#{assigned}</li>
</c:forEach>
</ul>
</c:when>
<c:otherwise>
<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.type.label=Type
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.type.label=Typ
relatedinfo.attachmentlists.order.save.inprogress=Speichere...
categorization.title=Zugeordnete Kategorien Dokument {0}