Some improvements for the PagesAdmin

pull/10/head
Jens Pelzetter 2021-11-25 21:21:53 +01:00
parent f9606862f2
commit f22df77bfe
6 changed files with 68 additions and 14 deletions

View File

@ -30,6 +30,8 @@ import java.util.Map;
*/
public class PageTreeNodeModel {
private String uuid;
private String categoryName;
private String categoryPath;
@ -45,6 +47,14 @@ public class PageTreeNodeModel {
properties = new HashMap<>();
}
public String getUuid() {
return uuid;
}
public void setUuid(final String uuid) {
this.uuid = uuid;
}
public String getCategoryName() {
return categoryName;
}
@ -54,7 +64,7 @@ public class PageTreeNodeModel {
}
public String getCategoryPath() {
return categoryName;
return categoryPath;
}
protected void setCategoryPath(final String categoryPath) {

View File

@ -21,6 +21,7 @@ package org.librecms.ui;
import org.libreccm.api.Identifier;
import org.libreccm.api.IdentifierParser;
import org.libreccm.categorization.Category;
import org.libreccm.categorization.CategoryManager;
import org.libreccm.categorization.CategoryRepository;
import org.libreccm.categorization.Domain;
import org.libreccm.categorization.DomainRepository;
@ -64,6 +65,9 @@ public class PagesController {
private static final String PAGES_LIST_TEMPLATE
= "org/librecms/ui/cms/pages.xhtml";
@Inject
private CategoryManager categoryManager;
@Inject
private CategoryRepository categoryRepo;
@ -241,7 +245,7 @@ public class PagesController {
}
@POST
@Path("/{pagesInstance}/{category}/@add")
@Path("/{pagesInstance}/{category:[\\w\\-/]+}/@add")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
@ -281,7 +285,7 @@ public class PagesController {
}
@GET
@Path("/{pagesInstance}/{category}/@details")
@Path("/{pagesInstance}/{category:[\\w\\-/]+}/@details")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
@ -331,7 +335,7 @@ public class PagesController {
}
@POST
@Path("/{pagesInstance}/{category}/@remove")
@Path("/{pagesInstance}/{category:[\\w\\-/]+}/@remove")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
@ -368,7 +372,7 @@ public class PagesController {
}
@POST
@Path("/{pagesInstance}/{category}/@add-property")
@Path("/{pagesInstance}/{category:[\\w\\-/]+}/@add-property")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
@ -422,7 +426,7 @@ public class PagesController {
}
@POST
@Path("/{pagesInstance}/{category}/{propertyKey}/@edit")
@Path("/{pagesInstance}/{category:[\\w\\-/]+}/{propertyKey}/@edit")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
@ -441,7 +445,7 @@ public class PagesController {
}
@POST
@Path("/{pagesInstance}/{category}/{propertyKey}/@remove")
@Path("/{pagesInstance}/{category:[\\w\\-/]+}/{propertyKey}/@remove")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
@Transactional(Transactional.TxType.REQUIRED)
@ -522,6 +526,8 @@ public class PagesController {
);
final PageTreeNodeModel node = new PageTreeNodeModel();
node.setUuid(pageResult.map(Page::getUuid).orElse(""));
node.setCategoryPath(categoryManager.getCategoryPath(category));
node.setCategoryName(category.getName());
node.setPageAssigned(pageResult.isPresent());
node.setProperties(

View File

@ -93,6 +93,13 @@
<dd>#{CmsPagesDetailsModel.categoryDomain}</dd>
</dl>
<c:if test="#{categoryNotFound}">
<div class="alert alert-danger"
role="alert">
#{CmsAdminMessages.getMessage('pages.details.errors.category_not_found', [categoryDomain, category])}
</div>
</c:if>
<ul>
<ui:include src="pages-tree-node.xhtml">
<ui:param name="basePath" value="#{mvc.basePath}/pages/ID-#{CmsPagesDetailsModel.pagesId}" />

View File

@ -6,6 +6,12 @@
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition>
<li class="pt-3">
<pre>
basePath = #{basePath}
root = #{root}
node.categoryName = #{node.categoryName}
node.categoryPath = #{node.categoryPath}
</pre>
<c:choose>
<c:when test="#{root}">
<span>/ (Root)</span>
@ -22,10 +28,20 @@
<span class="sr-only">#{CmsAdminMessages['pages.page.details']}</span>
</button>
<a class="btn btn-secondary btn-sm"
href="#{basePath}/#{categoryName}/@edit">
href="#{basePath}/#{node.categoryName}/@edit">
<bootstrap:svgIcon icon="pen" />
<span class="sr-only">#{CmsAdminMessages['pages.page.edit']}</span>
</a>
<libreccm:deleteDialog
actionTarget="#{basePath}/#{node.categoryName}"
buttonText="#{CmsAdminMessages['pages.page.remove']}"
buttonTextClass="sr-only"
cancelLabel="#{CmsAdminMessages['pages.page.remove.cancel']}"
confirmLabel="#{CmsAdminMessages['pages.page.remove.confim']}"
dialogId="#{node.uuid}"
dialogTitle="#{CmsAdminMessages['pages.page.remove.title']}"
message="#{CmsAdminMessages.getMessage('pages.page.remove.message', [node.categoryPath])}"
/>
<button class="btn btn-danger btn-sm"
type="button">
<bootstrap:svgIcon icon="x" />
@ -33,11 +49,14 @@
</button>
</c:when>
<c:otherwise>
<a class="btn btn-secondary btn-sm"
href="#{basePath}/#{categoryName}@add">
<bootstrap:svgIcon icon="plus-circle" />
<span class="sr-only">#{CmsAdminMessages['pages.page.add']}</span>
</a>
<form action="#{basePath}/#{node.categoryName}/@add"
method="post">
<button class="btn btn-secondary btn-sm"
type="submit">
<bootstrap:svgIcon icon="plus-circle" />
<span class="sr-only">#{CmsAdminMessages['pages.page.add']}</span>
</button>
</form>
</c:otherwise>
</c:choose>

View File

@ -969,3 +969,9 @@ pages.page.details.properties.remove.label=Remove property
pages.page.details.properties.actions.header=Actions
pages.page.details.properties.value.header=Value
pages.page.details.properties.name.header=Name
pages.page.details.breadcrumbs=Page Details {0}
pages.page.remove.cancel=Cancel
pages.page.remove.confim=Remove page
pages.page.remove.title=Confirm remove of page
pages.page.remove.message=Are sure to remove this page for ceategory {0}
pages.details.errors.category_not_found=Category {1} does not exist in category system {0}.

View File

@ -970,3 +970,9 @@ pages.page.details.properties.remove.label=Eigenschaft entfernen
pages.page.details.properties.actions.header=Aktionen
pages.page.details.properties.value.header=Wert
pages.page.details.properties.name.header=Name
pages.page.details.breadcrumbs=Details Seite {0}
pages.page.remove.cancel=Abbrechen
pages.page.remove.confim=Seite entfernen
pages.page.remove.title=Entfernen der Seite best\u00e4tigen
pages.page.remove.message=Sind Sie sicher, dass Sie die Seite f\u00fcr die Kategorie {0} entfernen wollen?
pages.details.errors.category_not_found=Das Kategoriensystem {0} hat keine Kategorie {1}.