List of content sections

Former-commit-id: cf4ec00f5d
pull/10/head
Jens Pelzetter 2021-01-14 21:09:22 +01:00
parent 7ba904f3f1
commit ec19b3f7e2
8 changed files with 254 additions and 7 deletions

View File

@ -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,6 +31,9 @@ import javax.ws.rs.core.Response;
@Path("/")
public class ContentSectionsController {
@Inject
private ContentSectionRepository sectionRepo;
@Inject
private HttpServletRequest request;
@ -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()
);
}
}

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
@Named("ContentSectionsTableModel")
public class ContentSectionsTableModel {
@Inject
private ContentSectionRepository sectionRepo;
@AuthorizationRequired
@Transactional
public List<ContentSectionsTableRow> 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;
}
}

View File

@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
public class ContentSectionsTableRow implements
Comparable<ContentSectionsTableRow> {
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;
}
}

View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:bootstrap="http://xmlns.jcp.org/jsf/composite/components/bootstrap"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/librecms/ui/content-sections/content-sections.xhtml">
<ui:param name="activePage" value="contentSections" />
<ui:define name="breadcrumb">
<li class="breadcrumb-item">
#{CmsAdminMessages['contentsections.list.label']}
</li>
</ui:define>
<ui:define name="main">
<div class="container">
<h1>#{CmsAdminMessages['contentsections.list.label']}</h1>
<table class="table"
<p>
Content Section Create Placeholder
</p>
<pre>MVC base path: #{mvc.basePath}</pre>
</div>
</ui:define>
</ui:composition>
</html>

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:bootstrap="http://xmlns.jcp.org/jsf/composite/components/bootstrap"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/librecms/ui/content-sections/content-sections.xhtml">
<ui:param name="activePage" value="contentSections" />
<ui:define name="breadcrumb">
<li class="breadcrumb-item">
#{CmsAdminMessages['contentsections.list.label']}
</li>
</ui:define>
<ui:define name="main">
<div class="container">
<h1>#{CmsAdminMessages['contentsections.list.label']}</h1>
<table class="table"
<p>
Content Section Details Placeholder
</p>
</div>
</ui:define>
</ui:composition>
</html>

View File

@ -16,10 +16,43 @@
<ui:define name="main">
<div class="container">
<h1>#{CmsAdminMessages['contentsections.list.label']}</h1>
<p>
Content Sections List Placeholder
</p>
<pre>MVC base path: #{mvc.basePath}</pre>
<div class="text-right mb-2">
<a class="btn btn-secondary"
href="#{mvc.basePath}/new">
<bootstrap:svgIcon icon="plus-circle" />
<span>#{CmsAdminMessages['contentsections.list.add']}</span>
</a>
</div>
<table class="table table-hover">
<thead class="thead-light">
<tr>
<th>
#{CmsAdminMessages['contentsections.list.table.headers.label']}
</th>
<th class="text-center">#{CmsAdminMessages['contentsections.list.table.headers.actions']}</th>
</tr>
</thead>
<tbody>
<c:forEach items="#{ContentSectionsTableModel.contentSections}"
var="section">
<tr>
<td>
<a href="#{mvc.basePath}/#{section.label}/contentitems">
#{section.label}
</a>
</td>
<td>
<a class="btn btn-info"
href="#{mvc.basePath}/#{section.label}/details">
<bootstrap:svgIcon icon="eye"/>
#{CmsAdminMessages['contentsections.list.table.actions.show_details']}
</a>
</td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
</ui:define>
</ui:composition>

View File

@ -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

View File

@ -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