Form for configuring export

Former-commit-id: beef038b62
pull/7/head
Jens Pelzetter 2020-12-03 21:10:31 +01:00
parent b987fd763d
commit c3f1c74890
7 changed files with 141 additions and 29 deletions

View File

@ -21,15 +21,20 @@ package org.libreccm.ui.admin.imexport;
import com.arsdigita.ui.admin.importexport.ImportExportMonitor;
import org.libreccm.core.CoreConstants;
import org.libreccm.imexport.AbstractEntityImExporter;
import org.libreccm.imexport.EntityImExporterTreeNode;
import org.libreccm.imexport.ImportExport;
import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.mvc.Controller;
import javax.mvc.Models;
import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.Path;
/**
@ -63,8 +68,27 @@ public class ImExportController {
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
public String exportEntities() {
models.put("exportables", importExport.getExportableEntityTypes());
models.put(
"exportableEntities",
importExport
.getExportableEntityTypes()
.stream()
.map(EntityImExporterTreeNode::getEntityImExporter)
.map(AbstractEntityImExporter::getEntityClass)
.map(Class::getName)
.sorted()
.collect(Collectors.toList())
);
return "org/libreccm/ui/admin/imexport/export.xhtml";
}
@GET
@Path("/import")
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
public String importEntities() {
throw new NotFoundException();
}
}

View File

@ -43,8 +43,7 @@ public class ApplicationImExporter
private ApplicationRepository applicationRepository;
@Override
protected Class<CcmApplication> getEntityClass() {
public Class<CcmApplication> getEntityClass() {
return CcmApplication.class;
}

View File

@ -1,7 +1,9 @@
<!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:libreccm="http://xmlns.jcp.org/jsf/composite/components/libreccm"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
@ -24,14 +26,32 @@
<div class="container">
<h1>#{AdminMessages['imexport.export.label']}</h1>
<p>Exportable classes</p>
<ul>
<c:forEach items="#{exportables}" var="exportable">
<li><code>${exportable}</code></li>
</c:forEach>
</ul>
<form action="#"
aria-describedby="export-help">
<p id="export-help">#{AdminMessages['imexport.export.help']}</p>
<p>Placeholder</p>
<c:forEach items="#{exportableEntities}" var="entity">
<bootstrap:formCheck
inputId="#{entity.replace('.', '-')}"
label="#{entity}"
name="#{entity.replace('.', '-')}"
value="#{entity}" />
</c:forEach>
<bootstrap:formGroupText
help="#{AdminMessages['imexport.export.export_name.help']}"
inputId="exportName"
label="#{AdminMessages['imexport.export.export_name.label']}"
name="exportName" />
<a class="btn btn-warning"
href="#{mvc.uri('ImExportController#getImExportDashboard')}">
#{AdminMessages['imexport.export.cancel']}
</a>
<button class="btn btn-success" type="submit">
#{AdminMessages['imexport.export.submit']}
</button>
</form>
</div>
</ui:define>

View File

@ -2,7 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml"
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">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:xlink="http://www.w3.org/1999/xlink">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="imexport" />
@ -17,7 +18,55 @@
<ui:define name="main">
<div class="container">
<h1>#{AdminMessages['imexport.label']}</h1>
<p>Placeholder</p>
<div class="row row-cols-1 row-cols-sm-1 row-cols-sm-2 row-cols-md-3 row-cols-lg-4 row-cols-xl-5">
<div class="col mb-4">
<div aria-describedby="import-card-body"
class="card pt-2"
id="import-card">
<svg aria-hidden="true"
class="card-img-top"
fill="currentColor">
<use xlink:href="#{request.contextPath}/assets/bootstrap/bootstrap-icons.svg#download" />
</svg>
<div class="card-body"
id="import-card-body">
<h2 class="card-title">
<a class="stretched-link"
href="#{mvc.uri('ImExportController#importEntities')}">
#{AdminMessages['import.label']}
</a>
</h2>
<p class="card-text">
#{import.description}
</p>
</div>
</div>
</div>
<div class="col mb-4">
<div aria-describedby="export-card-body"
class="card pt-2"
id="export-card">
<svg aria-hidden="true"
class="card-img-top"
fill="currentColor">
<use xlink:href="#{request.contextPath}/assets/bootstrap/bootstrap-icons.svg#download" />
</svg>
<div class="card-body"
id="export-card-body">
<h2 class="card-title">
<a class="stretched-link"
href="#{mvc.uri('ImExportController#exportEntities')}">
#{AdminMessages['export.label']}
</a>
</h2>
<p class="card-text">
#{export.description}
</p>
</div>
</div>
</div>
</div>
</div>
</ui:define>

View File

@ -526,3 +526,13 @@ themes.table.actions.delete.cancel=Cancel
themes.table.actions.delete.confirm=Delete theme
themes.table.actions.delete.title=Confirm theme deletion
themes.table.actions.delete.message=Are you sure to delete the theme {0}?
imexport.export.label=Export
import.label=Import
import.description=Import entities from import archives
export.label=Export
export.description=Export entities
imexport.export.help=Export the following entities
imexport.export.export_name.help=Name of the export archive
imexport.export.export_name.label=to
imexport.export.submit=Export
imexport.export.cancel=Cancel

View File

@ -526,3 +526,13 @@ themes.table.actions.delete.cancel=Abbrechen
themes.table.actions.delete.confirm=Theme l\u00f6schen
themes.table.actions.delete.title=L\u00f6schen des Themes best\u00e4tigen
themes.table.actions.delete.message=Sind Sie sicher, dass Sie das Theme {0} l\u00f6schen wollen?
imexport.export.label=Export
import.label=Import
import.description=Entities aus Import-Archiven importieren
export.label=Export
export.description=Entitities exportieren
imexport.export.help=Export the following entities
imexport.export.export_name.help=Name des Export Archives
imexport.export.export_name.label=nach
imexport.export.submit=Exportieren
imexport.export.cancel=Abbrechen