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 com.arsdigita.ui.admin.importexport.ImportExportMonitor;
import org.libreccm.core.CoreConstants; import org.libreccm.core.CoreConstants;
import org.libreccm.imexport.AbstractEntityImExporter;
import org.libreccm.imexport.EntityImExporterTreeNode;
import org.libreccm.imexport.ImportExport; import org.libreccm.imexport.ImportExport;
import org.libreccm.security.AuthorizationRequired; import org.libreccm.security.AuthorizationRequired;
import org.libreccm.security.RequiresPrivilege; import org.libreccm.security.RequiresPrivilege;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
import javax.mvc.Controller; import javax.mvc.Controller;
import javax.mvc.Models; import javax.mvc.Models;
import javax.ws.rs.GET; import javax.ws.rs.GET;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.Path; import javax.ws.rs.Path;
/** /**
@ -46,7 +51,7 @@ public class ImExportController {
@Inject @Inject
private ImportExportMonitor importExportMonitor; private ImportExportMonitor importExportMonitor;
@Inject @Inject
private Models models; private Models models;
@ -63,8 +68,27 @@ public class ImExportController {
@AuthorizationRequired @AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN) @RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
public String exportEntities() { 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"; 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; private ApplicationRepository applicationRepository;
@Override @Override
protected Class<CcmApplication> getEntityClass() { public Class<CcmApplication> getEntityClass() {
return CcmApplication.class; return CcmApplication.class;
} }

View File

@ -1,7 +1,9 @@
<!DOCTYPE html> <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" <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:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:h="http://xmlns.jcp.org/jsf/html" 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"> xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml"> <ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
@ -24,14 +26,32 @@
<div class="container"> <div class="container">
<h1>#{AdminMessages['imexport.export.label']}</h1> <h1>#{AdminMessages['imexport.export.label']}</h1>
<p>Exportable classes</p> <form action="#"
<ul> aria-describedby="export-help">
<c:forEach items="#{exportables}" var="exportable"> <p id="export-help">#{AdminMessages['imexport.export.help']}</p>
<li><code>${exportable}</code></li>
</c:forEach>
</ul>
<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> </div>
</ui:define> </ui:define>

View File

@ -2,7 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml" <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core" xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:h="http://xmlns.jcp.org/jsf/html" 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:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="imexport" /> <ui:param name="activePage" value="imexport" />
@ -17,7 +18,55 @@
<ui:define name="main"> <ui:define name="main">
<div class="container"> <div class="container">
<h1>#{AdminMessages['imexport.label']}</h1> <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> </div>
</ui:define> </ui:define>

View File

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

View File

@ -526,3 +526,13 @@ themes.table.actions.delete.cancel=Cancel
themes.table.actions.delete.confirm=Delete theme themes.table.actions.delete.confirm=Delete theme
themes.table.actions.delete.title=Confirm theme deletion themes.table.actions.delete.title=Confirm theme deletion
themes.table.actions.delete.message=Are you sure to delete the theme {0}? 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.confirm=Theme l\u00f6schen
themes.table.actions.delete.title=L\u00f6schen des Themes best\u00e4tigen 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? 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