Templates for CategorizationStep
parent
12b8f59b76
commit
1e3c3c3f61
|
|
@ -19,6 +19,7 @@ import org.librecms.contentsection.ContentItem;
|
|||
import org.librecms.contentsection.ContentItemManager;
|
||||
import org.librecms.contentsection.ContentSection;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
|
@ -247,9 +248,40 @@ public class CategorizationStep implements MvcAuthoringStep {
|
|||
);
|
||||
tree.setRoot(buildCategorizationTreeNode(domain.getRoot()));
|
||||
|
||||
tree.setAssignedCategories(
|
||||
buildAssignedCategoriesList(tree.getRoot(), "")
|
||||
);
|
||||
|
||||
return tree;
|
||||
}
|
||||
|
||||
private List<String> buildAssignedCategoriesList(
|
||||
final CategorizationTreeNode node, final String parentPath
|
||||
) {
|
||||
final List<String> assigned = new ArrayList<>();
|
||||
if (node.isAssigned()) {
|
||||
assigned.add(String.join("/", parentPath, node.getTitle()));
|
||||
}
|
||||
|
||||
if (node.isSubCategoryAssigned()) {
|
||||
assigned.addAll(
|
||||
node
|
||||
.getSubCategories()
|
||||
.stream()
|
||||
.map(
|
||||
subCat -> buildAssignedCategoriesList(
|
||||
subCat, String.join("/", node.getTitle()
|
||||
)
|
||||
)
|
||||
)
|
||||
.flatMap(result -> result.stream())
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
return assigned;
|
||||
}
|
||||
|
||||
private CategorizationTreeNode buildCategorizationTreeNode(
|
||||
final Category category
|
||||
) {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@
|
|||
*/
|
||||
package org.librecms.ui.contentsections.documents;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
|
|
@ -19,6 +23,8 @@ public class CategorizationTree {
|
|||
|
||||
private CategorizationTreeNode root;
|
||||
|
||||
private List<String> assignedCategories;
|
||||
|
||||
public String getDomainKey() {
|
||||
return domainKey;
|
||||
}
|
||||
|
|
@ -51,4 +57,12 @@ public class CategorizationTree {
|
|||
this.root = root;
|
||||
}
|
||||
|
||||
public List<String> getAssignedCategories() {
|
||||
return Collections.unmodifiableList(assignedCategories);
|
||||
}
|
||||
|
||||
public void setAssignedCategories(final List<String> assignedCategories) {
|
||||
this.assignedCategories = new ArrayList<>(assignedCategories);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,29 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package org.librecms.ui.contentsections.documents;
|
||||
|
||||
import org.libreccm.ui.AbstractMessagesBean;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Named("CmsDefaultStepsMessageBundle")
|
||||
public class DefaultStepsMessageBundle extends AbstractMessagesBean {
|
||||
|
||||
@Override
|
||||
protected String getMessageBundle() {
|
||||
return DefaultAuthoringStepConstants.BUNDLE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
data-toggle="collapse"
|
||||
data-target="##{folder.name}-subfolders"
|
||||
aria-expanded="#{folder.open ? 'true' : 'false'}"
|
||||
aria-controls="##{folder.name}-subfolders"
|
||||
aria-controls="#{folder.name}-subfolders"
|
||||
type="button">
|
||||
<span class="sr-only">#{CmsAdminMessages['contentsection.documentfolder.foldersnav.subfolders.expand']}
|
||||
</span>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,48 @@
|
|||
<!DOCTYPE html [<!ENTITY times '×'>]>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:bootstrap="http://xmlns.jcp.org/jsf/composite/components/bootstrap"
|
||||
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
||||
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
<ui:composition>
|
||||
|
||||
<li class="form-check">
|
||||
<div class="d-flex">
|
||||
<c:if test="#{!node.subCategories.isEmpty()}">
|
||||
<button aria-label="#{CmsDefaultStepsMessageBundle['categorization.tree.show_subcategories']}"
|
||||
class="btn btn-light p-0 subfolders-toggler"
|
||||
data-toggle="collapse"
|
||||
data-target="##{node.categoryUuid}-subcategories"
|
||||
aria-expanded="#{node.subCategoryAssigned or isRoot ? 'true' : 'false'}"
|
||||
aria-controls="#{node.categoryUuid}-subcategories"
|
||||
type="button">
|
||||
|
||||
</button>
|
||||
</c:if>
|
||||
<label class="form-check-label"
|
||||
for="#{node.categoryUuid}">
|
||||
#{node.title}
|
||||
</label>
|
||||
<input class="form-check-input"
|
||||
id="#{node.categoryUuid}"
|
||||
type="checkbox"
|
||||
value="#{node.categoryUuid}" />
|
||||
</div>
|
||||
<c:if test="#{!node.subCategories.isEmpty()}">
|
||||
<ul class="#{node.subCategoryAssigned or isRoot ? 'collapse' : 'collapse.show'} "
|
||||
id="#{node.categoryUuid}-subcategories">
|
||||
<c:forEach items="#{node.subCategories}"
|
||||
var="subCat">
|
||||
<ui:include src="categorization-tree-node.xhtml">
|
||||
<ui:param name="node"
|
||||
value="#{subCat}" />
|
||||
<ui:param name="isRoot"
|
||||
value="false" />
|
||||
</ui:include>
|
||||
</c:forEach>
|
||||
</ul>
|
||||
</c:if>
|
||||
</li>
|
||||
|
||||
</ui:composition>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,90 @@
|
|||
<!DOCTYPE html [<!ENTITY times '×'>]>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:bootstrap="http://xmlns.jcp.org/jsf/composite/components/bootstrap"
|
||||
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
||||
xmlns:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml">
|
||||
|
||||
<c:forEach items="#{CmsCategorizationStep.categorizationTrees}"
|
||||
var="tree">
|
||||
<h2>#{tree.domainTitle}</h2>
|
||||
|
||||
<div class="d-flex">
|
||||
<span>#{CmsDefaultStepsMessageBundle['categorization.system.assigned.to']}</span>
|
||||
<button class="btn btn-primary"
|
||||
data-target="#edit-categorization-#{tree.domainKey}"
|
||||
data-toggle="modal"
|
||||
type="button">
|
||||
<bootstrap:svgIcon icon="pen" />
|
||||
<span class="sr-only">
|
||||
#{CmsDefaultStepsMessageBundle['categorization.system.assigned.edit']}
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
<div aria-labelledby="edit-categorization-#{tree.domainKey}-title"
|
||||
aria-hidden="true"
|
||||
class="modal fade"
|
||||
id="edit-categorization-#{tree.domainKey}"
|
||||
tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringSteps/categorization/#{tree.domainKey}"
|
||||
class="modal-content"
|
||||
method="post">
|
||||
<div class="modal-header">
|
||||
<h3 class="modal-title"
|
||||
id="edit-categorization-#{tree.domainKey}-title">
|
||||
#{CmsDefaultStepsMessageBundle.getMessage('categorization.edit.title', tree.domainKey, CmsCategorizationStep.contentItemTitle)}
|
||||
<button aria-label="#{CmsDefaultStepsMessageBundle['categorization.edit.cancel']}"
|
||||
class="close"
|
||||
data-dismiss="modal"
|
||||
type="button">
|
||||
<bootstrap:svgIcon icon="x-circle" />
|
||||
</button>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul class="#{tree.root.subCategoryAssigned ? 'collapse' : 'collapse.show'} "
|
||||
id="#{node.categoryUuid}-subcategories">
|
||||
<ui:include src="categorization-tree-node.xhtml">
|
||||
<ui:param name="node"
|
||||
value="#{tree.root}" />
|
||||
<ui:param name="isRoot"
|
||||
value="true" />
|
||||
</ui:include>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-warning"
|
||||
data-dismiss="modal"
|
||||
type="button">
|
||||
#{CmsDefaultStepsMessageBundle['categorization.edit.cancel']}
|
||||
</button>
|
||||
<button class="btn btn-success"
|
||||
type="submit">
|
||||
#{CmsDefaultStepsMessageBundle['categorization.edit.apply']}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<c:choose>
|
||||
<c:when test="#{tree.root.assigned or tree.root.subCategoryAssigned}">
|
||||
<c:forEach items="#{tree.assignedCategories}"
|
||||
var="assigned">
|
||||
#{assigned}
|
||||
</c:forEach>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<div class="alert alert-info" role="alert">
|
||||
#{CmsDefaultStepsMessageBundle['categorization.system.assigned.none']}
|
||||
</div>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
|
||||
</c:forEach>
|
||||
|
||||
</ui:composition>
|
||||
</html>
|
||||
Loading…
Reference in New Issue