Manage objects in category for cms admin

Former-commit-id: fe6b3a8e06245e6810662a9ec9e4301bb48e29e8
pull/10/head
Jens Pelzetter 2021-02-20 11:22:57 +01:00
parent 086a8622de
commit 6effd9f73b
7 changed files with 176 additions and 7 deletions

View File

@ -548,8 +548,8 @@ public class CategoriesController {
}
}
@POST
@Path("/{context}/categories/{categoryPath:(.+)?}/@index-element")
@GET
@Path("/{context}/categories/{categoryPath:(.+)?}/@index-element/{indexElementUuid}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String setIndexElement(
@ -592,7 +592,7 @@ public class CategoriesController {
return "org/librecms/ui/contentsection/categorysystems/categorization-not-found.xhtml";
}
return String.format(
"redirect:/%s/categorysystems/%s/categories/%s",
"redirect:/%s/categorysystems/%s/categories/%s#objects-sections",
sectionIdentifier,
context,
categoryPath
@ -602,7 +602,7 @@ public class CategoriesController {
}
}
@POST
@GET
@Path("/{context}/categories/{categoryPath:(.+)?}/@index-element/reset")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@ -618,7 +618,7 @@ public class CategoriesController {
final Category category = result.getResult();
categoryManager.resetIndexObject(category);
return String.format(
"redirect:/%s/categorysystems/%s/categories/%s",
"redirect:/%s/categorysystems/%s/categories/%s#objects-sections",
sectionIdentifier,
context,
categoryPath
@ -851,7 +851,7 @@ public class CategoriesController {
@POST
@Path(
"/{context}/categories/{categoryPath:(.+)?}/objects/{objectIdentifier}/@order")
"/{context}/categories/{categoryPath:(.+)?}/@objects/{objectIdentifier}/order")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String orderObjects(
@ -898,7 +898,7 @@ public class CategoriesController {
}
} catch (ObjectNotAssignedToCategoryException ex) {
return String.format(
"redirect:/%s/categorysystems/%s/categories/%s",
"redirect:/%s/categorysystems/%s/categories/%s#objects-sections",
sectionIdentifier,
context,
categoryManager.getCategoryPath(category)
@ -1168,6 +1168,8 @@ public class CategoriesController {
) {
final CcmObject object = categorization.getCategorizedObject();
final CategorizedObjectModel model = new CategorizedObjectModel();
model.setObjectId(object.getObjectId());
model.setObjectUuid(object.getUuid());
model.setDisplayName(object.getDisplayName());
model.setIndexObject(categorization.isIndexObject());
model.setObjectOrder(categorization.getObjectOrder());

View File

@ -11,6 +11,10 @@ package org.librecms.ui.contentsections;
*/
public class CategorizedObjectModel {
private long objectId;
private String objectUuid;
private String displayName;
private String title;
@ -21,6 +25,22 @@ public class CategorizedObjectModel {
private long objectOrder;
public long getObjectId() {
return objectId;
}
public void setObjectId(final long objectId) {
this.objectId = objectId;
}
public String getObjectUuid() {
return objectUuid;
}
public void setObjectUuid(final String objectUuid) {
this.objectUuid = objectUuid;
}
public String getDisplayName() {
return displayName;
}

View File

@ -437,6 +437,121 @@
</table>
</c:otherwise>
</c:choose>
<h2 id="objects-sections">#{CmsAdminMessages['contentsections.categorystems.category.objects.heading']}</h2>
<c:choose>
<c:when test="#{CategorySystemModel.selectedCategory.objects.isEmpty()}">
<p>
#{CmsAdminMessages['contentsections.categorystems.category.objects.none']}
</p>
</c:when>
<c:otherwise>
<table class="categories-table contentsections table table-hover">
<thead>
<tr>
<th scope="col">
#{CmsAdminMessages['contentsections.categorystems.category.objects.name']}
</th>
</tr>
<tr>
<th scope="col">
#{CmsAdminMessages['contentsections.categorystems.category.objects.title']}
</th>
</tr>
<tr>
<th scope="col">
#{CmsAdminMessages['contentsections.categorystems.category.objects.type']}
</th>
</tr>
<tr>
<th scope="col">
#{CmsAdminMessages['contentsections.categorystems.category.objects.index']}
</th>
</tr>
<tr>
<th colspan="3">
#{CmsAdminMessages['contentsections.categorystems.category.objects.actions']}
</th>
</tr>
</thead>
<tbody>
<c:forEach items="#{CategorySystemModel.selectedCategory.objects}"
var="object">
<tr>
<td>
#{object.displayName}
</td>
<td>
#{object.title}
</td>
<td>
#{object.type}
</td>
<td>
<c:choose>
<c:when test="#{object.indexObject}">
#{CmsAdminMessages['contentsections.categorystems.category.objects.index.yes']}
</c:when>
<c:otherwise>
#{CmsAdminMessages['contentsections.categorystems.category.objects.no']}
</c:otherwise>
</c:choose>
</td>
<td class="actions-order-col">
<c:if test="#{object.objectOrder != 1}">
<form action="#"
method="post">
<input name="direction"
value="DECREASE"
type="hidden" />
<button class="btn btn-info"
type="submit">
<bootstrap:svgIcon icon="caret-up-fill" />
<span class="sr-only">#{CmsAdminMessages['contentsections.categorystems.category.objects.reorder.decrease']}</span>
</button>
</form>
</c:if>
</td>
<td class="actions-order-col">
<c:if test="#{object.objectOrder lt CategorySystemModel.selectedCategory.objects.size()}">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/categorysystems/#{CategorySystemModel.selectedCategorySystem.context}/@objects/#{object.objectId}/order"
method="post">
<input name="direction"
value="INCREASE"
type="hidden" />
<button class="btn btn-info"
type="submit">
<bootstrap:svgIcon icon="caret-up-fill" />
<span class="sr-only">#{CmsAdminMessages['contentsections.categorystems.category.objects.reorder.increase']}</span>
</button>
</form>
</c:if>
</td>
<td class="actions-setindex-col">
<c:choose>
<c:when test="#{object.indexObject}">
<a class="btn btn-danger"
href="#{mvc.basePath}/#{ContentSectionModel.sectionName}/categorysystems/#{CategorySystemModel.selectedCategorySystem.context}/@index-element/#{object.objectUuid}">
<bootstrap:svgIcon icon="bookmark-x" />
<span>#{CmsAdminMessages['contentsections.categorystems.category.objects.index_object.reset']}</span>
</a>
</c:when>
<c:otherwise>
<a class="btn btn-info"
href="#{mvc.basePath}/#{ContentSectionModel.sectionName}/categorysystems/#{CategorySystemModel.selectedCategorySystem.context}/@index-element/reset">
<bootstrap:svgIcon icon="bookmark-star" />
<span>#{CmsAdminMessages['contentsections.categorystems.category.objects.index_object.set']}</span>
</a>
</c:otherwise>
</c:choose>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</c:otherwise>
</c:choose>
</div>
</div>
</div>

View File

@ -262,3 +262,16 @@ contentsections.categorysystems.category.subcategories.add.label=Unique ID
contentsections.categorysystems.category.subcategories.add.enabled.label=Enabled?
contentsections.categorysystems.category.subcategories.add.visible.label=Visible?
contentsections.categorysystems.category.subcategories.add.abstractCategory.label=Abstract?
contentsections.categorystems.category.objects.heading=Objects in this category
contentsections.categorystems.category.objects.name=Name
contentsections.categorystems.category.objects.title=Title
contentsections.categorystems.category.objects.type=Type
contentsections.categorystems.category.objects.index=Is Index Object?
contentsections.categorystems.category.objects.actions=Actions
contentsections.categorystems.category.objects.index.yes=Yes
contentsections.categorystems.category.objects.no=No
contentsections.categorystems.category.objects.reorder.decrease=Up
contentsections.categorystems.category.objects.reorder.increase=Down
contentsections.categorystems.category.objects.index_object.reset=Reset index object
contentsections.categorystems.category.objects.index_object.set=Use as index object
contentsections.categorystems.category.objects.none=No objects in this category

View File

@ -263,3 +263,16 @@ contentsections.categorysystems.category.subcategories.add.label=Eindeutige ID
contentsections.categorysystems.category.subcategories.add.enabled.label=Aktiv?
contentsections.categorysystems.category.subcategories.add.visible.label=Sichtbar?
contentsections.categorysystems.category.subcategories.add.abstractCategory.label=Abstrakt?
contentsections.categorystems.category.objects.heading=Objekte in dieser Kategorie
contentsections.categorystems.category.objects.name=Name
contentsections.categorystems.category.objects.title=Titel
contentsections.categorystems.category.objects.type=Typ
contentsections.categorystems.category.objects.index=Index-Objekt?
contentsections.categorystems.category.objects.actions=Aktionen
contentsections.categorystems.category.objects.index.yes=Ja
contentsections.categorystems.category.objects.no=Nein
contentsections.categorystems.category.objects.reorder.decrease=Hoch
contentsections.categorystems.category.objects.reorder.increase=Runter
contentsections.categorystems.category.objects.index_object.reset=Index Objekt zur\u00fccksetzen
contentsections.categorystems.category.objects.index_object.set=Als Index-Objekt nutzen
contentsections.categorystems.category.objects.none=Dieser Kategorie sind keine Objekte zugeordnet

View File

@ -99,4 +99,8 @@ table.contentsections.categories-table {
td.actions-delete-col {
width: 9em;
}
td.actions-setindex-col {
width: 11em;
}
}

View File

@ -714,6 +714,8 @@ public class CategoryManager implements Serializable {
categoryRepo.save(parentCategory);
categoryRepo.save(subCategory);
});
fixSubCategoryOrder(parentCategory);
}
/**