diff --git a/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsController.java b/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsController.java index 6ad132aed..f46434f2e 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsController.java +++ b/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsController.java @@ -6,6 +6,7 @@ package org.librecms.ui; import org.libreccm.security.AuthorizationRequired; +import org.librecms.contentsection.ContentSectionRepository; import java.net.URI; import java.net.URISyntaxException; @@ -16,6 +17,7 @@ import javax.mvc.Controller; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.GET; +import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; @@ -29,9 +31,12 @@ import javax.ws.rs.core.Response; @Path("/") public class ContentSectionsController { + @Inject + private ContentSectionRepository sectionRepo; + @Inject private HttpServletRequest request; - + @Inject private ServletContext servletContext; @@ -83,4 +88,20 @@ public class ContentSectionsController { return "org/librecms/ui/content-sections/search.xhtml"; } + @GET + @Path("/{sectionIdentifier}/details") + public String getContentSectionDetails() { + throw new WebApplicationException( + Response.status(Response.Status.NOT_FOUND).build() + ); + } + + @POST + @Path("/new") + public String createContentSection() { + throw new WebApplicationException( + Response.status(Response.Status.NOT_FOUND).build() + ); + } + } diff --git a/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsTableModel.java b/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsTableModel.java new file mode 100644 index 000000000..6f4c44046 --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsTableModel.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2021 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.librecms.ui; + +import org.libreccm.security.AuthorizationRequired; +import org.librecms.contentsection.ContentSection; +import org.librecms.contentsection.ContentSectionRepository; + +import java.util.List; +import java.util.stream.Collectors; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Inject; +import javax.inject.Named; +import javax.transaction.Transactional; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("ContentSectionsTableModel") +public class ContentSectionsTableModel { + + @Inject + private ContentSectionRepository sectionRepo; + + @AuthorizationRequired + @Transactional + public List getContentSections() { + return sectionRepo + .findAll() + .stream() + .map(this::buildTableRow) + .sorted() + .collect(Collectors.toList()); + } + + private ContentSectionsTableRow buildTableRow( + final ContentSection section + ) { + final ContentSectionsTableRow row = new ContentSectionsTableRow(); + + row.setSectionId(section.getObjectId()); + row.setLabel(section.getLabel()); + + return row; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsTableRow.java b/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsTableRow.java new file mode 100644 index 000000000..cf51ac49f --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/ContentSectionsTableRow.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2021 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.librecms.ui; + +import java.util.Objects; + +/** + * + * @author Jens Pelzetter + */ +public class ContentSectionsTableRow implements + Comparable { + + private long sectionId; + + private String label; + + public long getSectionId() { + return sectionId; + } + + public void setSectionId(final long sectionId) { + this.sectionId = sectionId; + } + + public String getLabel() { + return label; + } + + public void setLabel(final String label) { + this.label = label; + } + + @Override + public int compareTo(final ContentSectionsTableRow other) { + int result; + result = Objects.compare( + label, other.getLabel(), String::compareTo + ); + + if (result == 0) { + result = Objects.compare( + sectionId, other.getSectionId(), Long::compareTo + ); + } + + return result; + } + +} diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/create.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/create.xhtml new file mode 100644 index 000000000..e7cff7ca4 --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/create.xhtml @@ -0,0 +1,27 @@ + + + + + + + + + + +
+

#{CmsAdminMessages['contentsections.list.label']}

+ + Content Section Create Placeholder +

+
MVC base path: #{mvc.basePath}
+ + + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/details.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/details.xhtml new file mode 100644 index 000000000..d09ca604c --- /dev/null +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/details.xhtml @@ -0,0 +1,26 @@ + + + + + + + + + + +
+

#{CmsAdminMessages['contentsections.list.label']}

+
+ Content Section Details Placeholder +

+ + + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/list.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/list.xhtml index d46da3ae1..b7a9e07a2 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/list.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/content-sections/list.xhtml @@ -5,21 +5,54 @@ xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> - + - +

#{CmsAdminMessages['contentsections.list.label']}

-

- Content Sections List Placeholder -

-
MVC base path: #{mvc.basePath}
+ + +
+ + + + + + + + + + + + + + +
+ #{CmsAdminMessages['contentsections.list.table.headers.label']} + #{CmsAdminMessages['contentsections.list.table.headers.actions']}
+ + #{section.label} + + + + + #{CmsAdminMessages['contentsections.list.table.actions.show_details']} + +
diff --git a/ccm-cms/src/main/resources/org/librecms/CmsAdminMessages.properties b/ccm-cms/src/main/resources/org/librecms/CmsAdminMessages.properties index 3fdac5f4c..e6f3a4ae9 100644 --- a/ccm-cms/src/main/resources/org/librecms/CmsAdminMessages.properties +++ b/ccm-cms/src/main/resources/org/librecms/CmsAdminMessages.properties @@ -4,3 +4,7 @@ contentsections.search.nav.link.title=Search contentsections.list.label=Content Sections contentsections.pages.label=Pages contentsections.search.label=Search +contentsections.list.add=Add Content Section +contentsections.list.table.headers.label=Name +contentsections.list.table.headers.actions=Actions +contentsections.list.table.actions.show_details=Details diff --git a/ccm-cms/src/main/resources/org/librecms/CmsAdminMessages_de.properties b/ccm-cms/src/main/resources/org/librecms/CmsAdminMessages_de.properties index 79092122a..9da5a5146 100644 --- a/ccm-cms/src/main/resources/org/librecms/CmsAdminMessages_de.properties +++ b/ccm-cms/src/main/resources/org/librecms/CmsAdminMessages_de.properties @@ -4,3 +4,7 @@ contentsections.search.nav.link.title=Suche contentsections.list.label=Content Sections contentsections.pages.label=Seitenb\u00e4ume contentsections.search.label=Suche +contentsections.list.add=Content Section hinzuf\u00fcgen +contentsections.list.table.headers.label=Name +contentsections.list.table.headers.actions=Aktionen +contentsections.list.table.actions.show_details=Details