From 08bfb9eb976ef5f301e2b739d6f591c87501fdb4 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sun, 15 Nov 2020 16:11:56 +0100 Subject: [PATCH] Table for Root Categories --- .../CategorySystemDetailsModel.java | 29 +++- .../ui/admin/categories/CategoryTableRow.java | 137 ++++++++++++++++++ .../categories/categorysystem-details.xhtml | 95 +++++++++++- .../org/libreccm/ui/AdminBundle.properties | 14 ++ .../org/libreccm/ui/AdminBundle_de.properties | 16 +- 5 files changed, 287 insertions(+), 4 deletions(-) create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryTableRow.java diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java index 0baf31e0d..03cd16803 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategorySystemDetailsModel.java @@ -20,9 +20,7 @@ package org.libreccm.ui.admin.categories; import org.libreccm.categorization.Domain; import org.libreccm.categorization.DomainOwnership; -import org.libreccm.configuration.ConfigurationManager; import org.libreccm.l10n.GlobalizationHelper; -import org.libreccm.l10n.LocalizedTextsUtil; import org.libreccm.ui.Message; import org.libreccm.web.ApplicationRepository; import org.libreccm.web.CcmApplication; @@ -82,6 +80,10 @@ public class CategorySystemDetailsModel { private List owners; private List ownerOptions; + + private String rootIdentifier; + + private List categories; private final List messages; @@ -103,6 +105,14 @@ public class CategorySystemDetailsModel { public String getIdentifier() { 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() { return uuid; @@ -184,6 +194,10 @@ public class CategorySystemDetailsModel { return Collections.unmodifiableList(ownerOptions); } + public List getCategories() { + return Collections.unmodifiableList(categories); + } + public boolean isNew() { return categorySystemId == 0; } @@ -288,6 +302,17 @@ public class CategorySystemDetailsModel { .map(CategorySystemOwnerOption::new) .sorted() .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( diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryTableRow.java b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryTableRow.java new file mode 100644 index 000000000..ddb95eb26 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/categories/CategoryTableRow.java @@ -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 Jens Pelzetter + */ +public class CategoryTableRow implements Comparable { + + 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() + ); + } + +} diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/categories/categorysystem-details.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/categories/categorysystem-details.xhtml index c972edf9f..c6b4e5da1 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/categories/categorysystem-details.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/categories/categorysystem-details.xhtml @@ -115,7 +115,7 @@ title="#{AdminMessages['categorysystems.details.title.heading']}" unusedLocales="#{CategorySystemDetailsModel.unusedTitleLocales}" values="#{CategorySystemDetailsModel.title}" /> - + + +

#{AdminMessages['categorysystems.details.categories.heading']}

+ + + +

+ #{AdminMessages['categorysystems.details.categories.none']} +

+
+ + + + + + + + + + + + + + + + + + + + + +
+ #{AdminMessages['categorysystems.details.categories.table.headings.name']} + + #{AdminMessages['categorysystems.details.categories.table.headings.enabled']} + + #{AdminMessages['categorysystems.details.categories.table.headings.visible']} + + #{AdminMessages['categorysystems.details.categories.table.headings.abstract']} +
+ + #{category.name} + + + + + #{AdminMessages['categorysystems.details.categories.table.headings.enabled.true']} + + + #{AdminMessages['categorysystems.details.categories.table.headings.enabled.false']} + + + + + + #{AdminMessages['categorysystems.details.categories.table.headings.visible.true']} + + + #{AdminMessages['categorysystems.details.categories.table.headings.visible.false']} + + + + + + #{AdminMessages['categorysystems.details.categories.table.headings.abstract.true']} + + + #{AdminMessages['categorysystems.details.categories.table.headings.abstract.false']} + + + + + +
+
+
diff --git a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties index 7def2b78c..84b772845 100644 --- a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties +++ b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle.properties @@ -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.owner.add.dialog.context.label=Context 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 diff --git a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties index 8dd46c8eb..893282d4c 100644 --- a/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties +++ b/ccm-core/src/main/resources/org/libreccm/ui/AdminBundle_de.properties @@ -331,7 +331,7 @@ categorysystems.details.description.edit.dialog.value.help=Die lokalisierte Besc categorysystems.details.description.edit.dialog.submit=Speichern categorysystems.details.description.table.actions.remove.dialog.title=Lokalisierte Beschreibung entfernen 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 categorysstems.details.owner.add.dialog.title=Applikation hinzuf\u00fcgen 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.owner.add.dialog.context.label=Context 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