Form for configuring export

ccm-docs
Jens Pelzetter 2020-12-03 21:10:31 +01:00
parent f9a129cd39
commit 39358f6c02
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;
/**
@ -46,7 +51,7 @@ public class ImExportController {
@Inject
private ImportExportMonitor importExportMonitor;
@Inject
private Models models;
@ -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

@ -41,14 +41,14 @@
</bootstrap:formGroupSelect>
</f:facet>
<f:facet name="footer">
<button class="btn btn-secondary"
data-dismiss="modal"
type="button" >
#{AdminMessages['themes.dialog.new_theme.close']}
</button>
<button type="submit" class="btn btn-primary">
#{AdminMessages['themes.dialog.new_theme.create']}
</button>
<button class="btn btn-secondary"
data-dismiss="modal"
type="button" >
#{AdminMessages['themes.dialog.new_theme.close']}
</button>
<button type="submit" class="btn btn-primary">
#{AdminMessages['themes.dialog.new_theme.create']}
</button>
</f:facet>
</bootstrap:modalForm>
<table class="table table-hover">
@ -81,7 +81,7 @@
</button>
<div aria-labelledby="theme-#{theme.name}-description-title"
aria-hidden="true"
class="modal fade"
class="modal fade"
id="theme-#{theme.name}-description"
tabindex="-1">
<div class="modal-dialog">
@ -90,10 +90,10 @@
id="theme-#{theme.name}-description-title">
<h2>#{AdminMessages.getMessage('themes.dialog.description.title', [theme.name])}</h2>
<button aria-label="#{AdminMessages['themes.dialog.description.close']}"
class="close"
class="close"
data-dismiss="modal"
type="button">
<span aria-hidden="true">&times;</span>
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
@ -119,7 +119,7 @@
<form action="#{mvc.uri('ThemesController#publishTheme', {'themeName': theme.name})}">
<button class="btn btn-primary"
type="button">
#{AdminMessages['themes.table.actions.republish']}
#{AdminMessages['themes.table.actions.republish']}
</button>
</form>
</c:when>
@ -127,7 +127,7 @@
<form action="#{mvc.uri('ThemesController#publishTheme', {'themeName': theme.name})}">
<button class="btn btn-primary"
type="button">
#{AdminMessages['themes.table.actions.publish']}
#{AdminMessages['themes.table.actions.publish']}
</button>
</form>
</c:when>
@ -142,7 +142,7 @@
dialogId="theme-#{theme.name}-unpublish"
dialogTitle="#{AdminMessages['themes.table.actions.unpublish.title']}"
message="#{AdminMessages.getMessage('themes.table.actions.unpublish.message', [theme.name])}"
/>
/>
</c:if>
</td>
<td>
@ -154,7 +154,7 @@
dialogId="theme-#{theme.name}-unpublish"
dialogTitle="#{AdminMessages['themes.table.actions.delete.title']}"
message="#{AdminMessages.getMessage('themes.table.actions.delete.message', [theme.name])}"
/>
/>
</c:if>
</td>
</tr>

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