Table for Root Categories

ccm-docs
Jens Pelzetter 2020-11-15 16:11:56 +01:00
parent 73a0a79454
commit 08bfb9eb97
5 changed files with 287 additions and 4 deletions

View File

@ -20,9 +20,7 @@ package org.libreccm.ui.admin.categories;
import org.libreccm.categorization.Domain; import org.libreccm.categorization.Domain;
import org.libreccm.categorization.DomainOwnership; import org.libreccm.categorization.DomainOwnership;
import org.libreccm.configuration.ConfigurationManager;
import org.libreccm.l10n.GlobalizationHelper; import org.libreccm.l10n.GlobalizationHelper;
import org.libreccm.l10n.LocalizedTextsUtil;
import org.libreccm.ui.Message; import org.libreccm.ui.Message;
import org.libreccm.web.ApplicationRepository; import org.libreccm.web.ApplicationRepository;
import org.libreccm.web.CcmApplication; import org.libreccm.web.CcmApplication;
@ -82,6 +80,10 @@ public class CategorySystemDetailsModel {
private List<CategorySystemOwnerRow> owners; private List<CategorySystemOwnerRow> owners;
private List<CategorySystemOwnerOption> ownerOptions; private List<CategorySystemOwnerOption> ownerOptions;
private String rootIdentifier;
private List<CategoryTableRow> categories;
private final List<Message> messages; private final List<Message> messages;
@ -103,6 +105,14 @@ public class CategorySystemDetailsModel {
public String getIdentifier() { public String getIdentifier() {
return String.format("ID-%d", categorySystemId); return String.format("ID-%d", categorySystemId);
} }
public String getRootIdentifier() {
return String.format("UUID-%s", rootIdentifier);
}
protected void setRootIdentifier(final String rootIdentifier) {
this.rootIdentifier = rootIdentifier;
}
public String getUuid() { public String getUuid() {
return uuid; return uuid;
@ -184,6 +194,10 @@ public class CategorySystemDetailsModel {
return Collections.unmodifiableList(ownerOptions); return Collections.unmodifiableList(ownerOptions);
} }
public List<CategoryTableRow> getCategories() {
return Collections.unmodifiableList(categories);
}
public boolean isNew() { public boolean isNew() {
return categorySystemId == 0; return categorySystemId == 0;
} }
@ -288,6 +302,17 @@ public class CategorySystemDetailsModel {
.map(CategorySystemOwnerOption::new) .map(CategorySystemOwnerOption::new)
.sorted() .sorted()
.collect(Collectors.toList()); .collect(Collectors.toList());
rootIdentifier = String.format("UUID-%s", domain.getRoot().getUuid());
categories = domain
.getRoot()
.getSubCategories()
.stream()
.map(CategoryTableRow::new)
.sorted()
.collect(Collectors.toList());
} }
private CategorySystemOwnerRow buildOwnerRow( private CategorySystemOwnerRow buildOwnerRow(

View File

@ -0,0 +1,137 @@
/*
* Copyright (C) 2020 LibreCCM Foundation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
* MA 02110-1301 USA
*/
package org.libreccm.ui.admin.categories;
import org.libreccm.categorization.Category;
import java.util.Objects;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class CategoryTableRow implements Comparable<CategoryTableRow> {
private long categoryId;
private String uuid;
private String uniqueId;
private String name;
private boolean enabled;
private boolean visible;
private boolean abstractCategory;
private long categoryOrder;
public CategoryTableRow() {
super();
}
public CategoryTableRow(final Category category) {
categoryId = category.getObjectId();
uuid = category.getUuid();
uniqueId = category.getUniqueId();
name = category.getName();
enabled = category.isEnabled();
visible = category.isVisible();
abstractCategory = category.isAbstractCategory();
categoryOrder = category.getCategoryOrder();
}
public long getCategoryId() {
return categoryId;
}
protected void setCategoryId(final long categoryId) {
this.categoryId = categoryId;
}
public String getUuid() {
return uuid;
}
protected void setUuid(final String uuid) {
this.uuid = uuid;
}
public String getIdentifier() {
return String.format("UUID-%s", uuid);
}
public String getUniqueId() {
return uniqueId;
}
protected void setUniqueId(final String uniqueId) {
this.uniqueId = uniqueId;
}
public String getName() {
return name;
}
protected void setName(final String name) {
this.name = name;
}
public boolean isEnabled() {
return enabled;
}
protected void setEnabled(final boolean enabled) {
this.enabled = enabled;
}
public boolean isVisible() {
return visible;
}
protected void setVisible(final boolean visible) {
this.visible = visible;
}
public boolean isAbstractCategory() {
return abstractCategory;
}
protected void setAbstractCategory(final boolean abstractCategory) {
this.abstractCategory = abstractCategory;
}
public long getCategoryOrder() {
return categoryOrder;
}
protected void setCategoryOrder(final long categoryOrder) {
this.categoryOrder = categoryOrder;
}
@Override
public int compareTo(final CategoryTableRow other) {
return Long.compare(
categoryOrder, Objects.requireNonNull(other).getCategoryOrder()
);
}
}

View File

@ -115,7 +115,7 @@
title="#{AdminMessages['categorysystems.details.title.heading']}" title="#{AdminMessages['categorysystems.details.title.heading']}"
unusedLocales="#{CategorySystemDetailsModel.unusedTitleLocales}" unusedLocales="#{CategorySystemDetailsModel.unusedTitleLocales}"
values="#{CategorySystemDetailsModel.title}" /> values="#{CategorySystemDetailsModel.title}" />
<libreccm:localizedStringEditor addMethod="CategorySystemsController#addDescription" <libreccm:localizedStringEditor addMethod="CategorySystemsController#addDescription"
addButtonLabel="#{AdminMessages['categorysystems.details.description.add']}" addButtonLabel="#{AdminMessages['categorysystems.details.description.add']}"
addDialogCancelLabel="#{AdminMessages['categorysystems.details.description.add.dialog.close']}" addDialogCancelLabel="#{AdminMessages['categorysystems.details.description.add.dialog.close']}"
@ -322,6 +322,99 @@
</table> </table>
</c:otherwise> </c:otherwise>
</c:choose> </c:choose>
<h2>#{AdminMessages['categorysystems.details.categories.heading']}</h2>
<div class="mb-2">
<div class="text-right">
<a class="btn btn-secondary"
data-target="#categorysystem-category-add"
data-toggle="modal"
href="#{mvc.uri('CategoriesController#newSubCategory', {'categoryIdentifier': CategorySystemDetailsModel.rootIdentifier})}"
type="button">
<bootstrap:svgIcon icon="plus-circle" />
<span>#{AdminMessages['categorysystems.details.categories.add']}</span>
</a>
</div>
</div>
<c:choose>
<c:when test="#{CategorySystemDetailsModel.categories.isEmpty()}">
<p>
#{AdminMessages['categorysystems.details.categories.none']}
</p>
</c:when>
<c:otherwise>
<table class="table table-hover">
<thead>
<tr>
<th scope="col">
#{AdminMessages['categorysystems.details.categories.table.headings.name']}
</th>
<th>
#{AdminMessages['categorysystems.details.categories.table.headings.enabled']}
</th>
<th>
#{AdminMessages['categorysystems.details.categories.table.headings.visible']}
</th>
<th>
#{AdminMessages['categorysystems.details.categories.table.headings.abstract']}
</th>
</tr>
</thead>
<tbody>
<c:forEach items="#{CategorySystemDetailsModel.categories}"
var="category">
<tr>
<td>
<a href="#{mvc.uri('CategoriesController#getCategory', { 'categoryIdentifier': category.identifier})}">
#{category.name}
</a>
</td>
<td>
<c:choose>
<c:when test="#{category.enabled}">
#{AdminMessages['categorysystems.details.categories.table.headings.enabled.true']}
</c:when>
<c:otherwise>
#{AdminMessages['categorysystems.details.categories.table.headings.enabled.false']}
</c:otherwise>
</c:choose>
</td>
<td>
<c:choose>
<c:when test="#{category.visible}">
#{AdminMessages['categorysystems.details.categories.table.headings.visible.true']}
</c:when>
<c:otherwise>
#{AdminMessages['categorysystems.details.categories.table.headings.visible.false']}
</c:otherwise>
</c:choose>
</td>
<td>
<c:choose>
<c:when test="#{category.abstractCategory}">
#{AdminMessages['categorysystems.details.categories.table.headings.abstract.true']}
</c:when>
<c:otherwise>
#{AdminMessages['categorysystems.details.categories.table.headings.abstract.false']}
</c:otherwise>
</c:choose>
</td>
<td class="text-center">
<button class="btn btn-danger"
data-target="#categorysystem-categories-#{category.uuid}-delete"
data-toggle="modal"
type="button">
<bootstrap:svgIcon icon="x-circle" />
<span>#{AdminMessages['categorysystems.details.categories.delete']}</span>
</button>
<!-- ToDo: Delete Dialog -->
</td>
</tr>
</c:forEach>
</tbody>
</table>
</c:otherwise>
</c:choose>
</div> </div>
</ui:define> </ui:define>

View File

@ -344,3 +344,17 @@ categorysystems.details.owners.remove.message=Are your sure to remove the mappin
categorysystems.details.owners.remove.submit=Remove mapping categorysystems.details.owners.remove.submit=Remove mapping
categorysystems.details.owner.add.dialog.context.label=Context categorysystems.details.owner.add.dialog.context.label=Context
categorysystems.details.owner.add.dialog.context.help=Context for the mapping categorysystems.details.owner.add.dialog.context.help=Context for the mapping
categorysystems.details.categories.heading=Categories
categorysystems.details.categories.add=Add category
categorysystems.details.categories.none=No categories
categorysystems.details.categories.table.headings.name=Name
categorysystems.details.categories.table.headings.enabled=Enabled?
categorysystems.details.categories.table.headings.visible=Visible?
categorysystems.details.categories.table.headings.abstract=Abstract category?
categorysystems.details.categories.table.headings.enabled.true=Yes
categorysystems.details.categories.table.headings.enabled.false=No
categorysystems.details.categories.table.headings.visible.true=Yes
categorysystems.details.categories.table.headings.visible.false=No
categorysystems.details.categories.table.headings.abstract.true=Yes
categorysystems.details.categories.table.headings.abstract.false=No
categorysystems.details.categories.delete=Delete

View File

@ -331,7 +331,7 @@ categorysystems.details.description.edit.dialog.value.help=Die lokalisierte Besc
categorysystems.details.description.edit.dialog.submit=Speichern categorysystems.details.description.edit.dialog.submit=Speichern
categorysystems.details.description.table.actions.remove.dialog.title=Lokalisierte Beschreibung entfernen categorysystems.details.description.table.actions.remove.dialog.title=Lokalisierte Beschreibung entfernen
categorysystems.details.description.remove.dialog.close=Abbrechen categorysystems.details.description.remove.dialog.close=Abbrechen
categorysystems.details.description.remove.dialog.message=Sind Sie sicher das die Beschreibung f\u00fcr die Sprache {0} entfernen wollen? categorysystems.details.description.remove.dialog.message=Sind Sie sicher, dass Sie die folgende Lokalisierung f\u00fcr die Sprache entfernen wollen:
categorysystems.details.description.remove.dialog.submit=Lokalisierte Beschreibung entfernen categorysystems.details.description.remove.dialog.submit=Lokalisierte Beschreibung entfernen
categorysstems.details.owner.add.dialog.title=Applikation hinzuf\u00fcgen categorysstems.details.owner.add.dialog.title=Applikation hinzuf\u00fcgen
categorysystems.details.owner.add.dialog.application.label=Anwendung categorysystems.details.owner.add.dialog.application.label=Anwendung
@ -344,3 +344,17 @@ categorysystems.details.owners.remove.message=Sind Sie sicher das die Applicatio
categorysystems.details.owners.remove.submit=Zuordnung entfernen categorysystems.details.owners.remove.submit=Zuordnung entfernen
categorysystems.details.owner.add.dialog.context.label=Context categorysystems.details.owner.add.dialog.context.label=Context
categorysystems.details.owner.add.dialog.context.help=Context for the mapping categorysystems.details.owner.add.dialog.context.help=Context for the mapping
categorysystems.details.categories.heading=Kategorien
categorysystems.details.categories.add=Kategorie hinzuf\u00fcgen
categorysystems.details.categories.none=Keine Kategorien vorhanden
categorysystems.details.categories.table.headings.name=Name
categorysystems.details.categories.table.headings.enabled=Aktiv?
categorysystems.details.categories.table.headings.visible=Sichtbar?
categorysystems.details.categories.table.headings.abstract=Abstrakte Kategorie?
categorysystems.details.categories.table.headings.enabled.true=Ja
categorysystems.details.categories.table.headings.enabled.false=Nein
categorysystems.details.categories.table.headings.visible.true=Ja
categorysystems.details.categories.table.headings.visible.false=Nein
categorysystems.details.categories.table.headings.abstract.true=Ja
categorysystems.details.categories.table.headings.abstract.false=Nein
categorysystems.details.categories.delete=L\u00f6schen