Fixed remaining links in @admin

Former-commit-id: 573af19c5f
pull/10/head
Jens Pelzetter 2021-01-14 20:14:52 +01:00
parent 840365ff0e
commit 7ba904f3f1
15 changed files with 85 additions and 62 deletions

View File

@ -47,6 +47,11 @@ public class ContentSectionApplicationController
@Inject
private ContentSectionRepository sectionRepository;
@Override
public String getControllerLink() {
return "applications/content-sections";
}
@GET
@Path("/")
@AuthorizationRequired

View File

@ -28,4 +28,6 @@ public interface ApplicationController {
String getApplication();
String getControllerLink();
}

View File

@ -32,6 +32,8 @@ import java.util.Map;
import java.util.stream.Collectors;
import javax.enterprise.context.RequestScoped;
import javax.enterprise.inject.Any;
import javax.enterprise.inject.Instance;
import javax.inject.Inject;
import javax.mvc.Controller;
import javax.mvc.Models;
@ -49,6 +51,10 @@ import javax.ws.rs.Path;
@Path("/applications")
public class ApplicationsController {
@Inject
@Any
private Instance<ApplicationController> applicationControllers;
@Inject
private ApplicationManager appManager;
@ -115,17 +121,24 @@ public class ApplicationsController {
final Class<? extends ApplicationController> controllerClass
= applicationType.applicationController();
if (!DefaultApplicationController.class.isAssignableFrom(
controllerClass
)) {
item.setControllerLink(
String.format(
"%s#getApplication",
controllerClass.getSimpleName())
);
final Instance<? extends ApplicationController> controllerInstance
= applicationControllers.select(controllerClass);
if (hasControllerLink(controllerClass, controllerInstance)) {
final ApplicationController controller = controllerInstance.get();
item.setControllerLink(controller.getControllerLink());
}
return item;
}
private boolean hasControllerLink(
final Class<? extends ApplicationController> controllerClass,
final Instance<? extends ApplicationController> controllerInstance
) {
return !DefaultApplicationController.class
.isAssignableFrom(controllerClass)
&& controllerInstance.isResolvable();
}
}

View File

@ -40,4 +40,9 @@ public class DefaultApplicationController implements ApplicationController {
return "";
}
@Override
public String getControllerLink() {
return "application";
}
}

View File

@ -448,7 +448,7 @@ public class CategoriesController {
* @return Redirect to the details page of the category.
*/
@POST
@Path("/{identifier}/title/{locale}/edit")
@Path("/{identifier}/title/edit/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String editTitle(
@ -505,7 +505,7 @@ public class CategoriesController {
* @return Redirect to the details page of the category.
*/
@POST
@Path("/{identifier}/title/{locale}/remove")
@Path("/{identifier}/title/remove/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String removeTitle(
@ -621,7 +621,7 @@ public class CategoriesController {
* @return Redirect to the details page of the category.
*/
@POST
@Path("/{identifier}/description/{locale}/edit")
@Path("/{identifier}/description/edit/{locale}")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@ -679,7 +679,7 @@ public class CategoriesController {
* @return Redirect to the details page of the category.
*/
@POST
@Path("/{identifier}/description/{locale}/remove")
@Path("/{identifier}/description/remove/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String removeDescription(

View File

@ -354,7 +354,7 @@ public class CategorySystemsController {
* @return Redirect to the details page of the category system.
*/
@POST
@Path("/{identifier}/title/${locale}/edit")
@Path("/{identifier}/title/edit/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String editTitle(
@ -414,18 +414,18 @@ public class CategorySystemsController {
*
* @param categorySystemIdentifier Identifier of the category system.
* @param localeParam The locale of the title.
* @param confirmed Has the deletion been confirmed?
*
* @return Redirect to the details page of the category system.
*/
@POST
@Path("/{identifier}/title/${locale}/remove")
@Path("/{identifier}/title/remove/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String removeTitle(
@PathParam("identifier") final String categorySystemIdentifier,
@PathParam("locale") final String localeParam,
@FormParam("confirmed")
final String confirmed
@FormParam("confirmed") final String confirmed
) {
final Identifier identifier = identifierParser.parseIdentifier(
@ -553,7 +553,7 @@ public class CategorySystemsController {
*/
@POST
@Path(
"categorysystems/{identifier}/description/${locale}/edit"
"categorysystems/{identifier}/description/edit/{locale}"
)
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
@ -619,7 +619,7 @@ public class CategorySystemsController {
*/
@POST
@Path(
"categorysystems/{identifier}/description/${locale}/remove")
"categorysystems/{identifier}/description/remove/{locale}")
@AuthorizationRequired
@Transactional(Transactional.TxType.REQUIRED)
public String removeDescription(
@ -770,7 +770,7 @@ public class CategorySystemsController {
*
* @param categorySystemIdentifier Identifier of teh category system.
* @param applicationUuid UUID of the owner to remove.
* @param confirmed Was the deletion confirmed by the user?
* @param confirmed Was the deletion confirmed by the user?
*
* @return Redirect to the details page of the category system.
*/

View File

@ -6,7 +6,7 @@
<cc:interface shortDescription="A editor component for localized strings.">
<cc:attribute name="addMethod"
required="true"
shortDescription="Name of the endpoiint to which the POST request from the add form is send. The URL must contain a path parameter named identifier. Two values are submitted: locale and value."
shortDescription="URL of the endpoint for adding localized string values."
type="String" />
<cc:attribute name="addButtonLabel"
default="Add"
@ -76,7 +76,7 @@
type="String" />
<cc:attribute name="editMethod"
required="true"
shortDescription="Name of the endpoiint to which the POST request from the edit form is send. The URL must contain a path parameter named identifier, and a path parameter named locale. The new value is submitted as form parameter with the name value."
shortDescription="URL of the endpoint for editing/updating a value. The value of the locale to update is added after the provided URL, eg. /de for updating the german value."
type="String" />
<cc:attribute name="hasUnusedLocales"
required="true"
@ -127,7 +127,7 @@
type="String" />
<cc:attribute name="removeMethod"
required="true"
shortDescription="Name of the endpoint to which the POST request from the remove form is send. The URL must contain a path parameter named identifier, and a path parameter named locale."
shortDescription="URL of the endpoint for remvoving a value. The locale of the value to remove is added to the end of the URL. Eg. /de for removing the value for the locale de."
type="String" />
<cc:attribute name="tableActionsHeading"
default="Actions"
@ -207,7 +207,7 @@
id="#{cc.attrs.editorId}-dialog"
tabindex="-1">
<div class="modal-dialog">
<form action="#{mvc.uri(cc.attrs.addMethod, { 'identifier': cc.attrs.objectIdentifier})}"
<form action="#{cc.attrs.addMethod}"
class="modal-content"
method="post">
<div class="modal-header">
@ -346,7 +346,7 @@
tabindex="-1">
<div class="modal-dialog">
<form accept-charset="UTF-8"
action="#{mvc.uri(cc.attrs.editMethod, { 'identifier': cc.attrs.objectIdentifier, 'locale': entry.key })}"
action="#{cc.attrs.editMethod}/#{entry.key}"
class="modal-content"
method="post">
<div class="modal-header">
@ -444,7 +444,7 @@
id="#{cc.attrs.editorId}-#{entry.key}-remove-dialog"
tabindex="-1">
<div class="modal-dialog">
<form action="#{mvc.uri(cc.attrs.removeMethod, {'identifier': cc.attrs.objectIdentifier, 'locale': entry.key})}"
<form action="#{cc.attrs.removeMethod}/#{entry.key}"
class="modal-content"
method="post">
<div class="modal-header">

View File

@ -24,7 +24,7 @@
<h2>
<c:choose>
<c:when test="#{type.controllerLink != null}">
<a href="#{mvc.uri(type.controllerLink)}">#{type.title}</a>
<a href="#{mvc.basePath}/#{type.controllerLink}">#{type.title}</a>
</c:when>
<c:otherwise>
<span>#{type.title}</span>

View File

@ -110,7 +110,7 @@
</a>
</div>
<libreccm:localizedStringEditor addMethod="CategoriesController#addTitle"
<libreccm:localizedStringEditor addMethod="#{mvc.basePath}/categorymanager/categories/#{CategoryDetailsModel.identifier}/title/add"
addButtonLabel="#{AdminMessages['categories.details.title.add']}"
addDialogCancelLabel="#{AdminMessages['categories.details.title.add.dialog.close']}"
addDialogLocaleSelectHelp="#{AdminMessages['categories.details.title.add.dialog.locale.help']}"
@ -125,7 +125,7 @@
editDialogTitle="#{AdminMessages['categories.details.title.table.actions.edit.dialog.title']}"
editDialogValueHelp="#{AdminMessages['categories.details.title.edit.dialog.value.help']}"
editDialogValueLabel="#{AdminMessages['categories.details.title.edit.dialog.value.label']}"
editMethod="CategoriesController#editTitle"
editMethod="#{mvc.basePath}/categorymanager/categories/#{CategoryDetailsModel.identifier}/title/edit"
editorId="category-title"
emptyText="#{AdminMessages['categories.details.title.none']}"
hasUnusedLocales="#{CategoryDetailsModel.hasUnusedTitleLocales()}"
@ -143,7 +143,7 @@
unusedLocales="#{CategoryDetailsModel.unusedTitleLocales}"
values="#{CategoryDetailsModel.title}" />
<libreccm:localizedStringEditor addMethod="CategoriesController#addDescription"
<libreccm:localizedStringEditor addMethod="#{mvc.basePath}/categorymanager/categories/#{CategoryDetailsModel.identifier}/description/add"
addButtonLabel="#{AdminMessages['categories.details.description.add']}"
addDialogCancelLabel="#{AdminMessages['categories.details.description.add.dialog.close']}"
addDialogLocaleSelectHelp="#{AdminMessages['categories.details.description.add.dialog.locale.help']}"
@ -158,7 +158,7 @@
editDialogTitle="#{AdminMessages['categories.details.description.table.actions.edit.dialog.title']}"
editDialogValueHelp="#{AdminMessages['categories.details.description.edit.dialog.value.help']}"
editDialogValueLabel="#{AdminMessages['categories.details.description.edit.dialog.value.label']}"
editMethod="CategoriesController#editDescription"
editMethod="#{mvc.basePath}/categorymanager/categories/#{CategoryDetailsModel.identifier}/description/edit"
editorId="category-description"
emptyText="#{AdminMessages['categories.details.description.none']}"
hasUnusedLocales="#{CategoryDetailsModel.hasUnusedDescriptionLocales()}"
@ -168,7 +168,7 @@
removeDialogSubmitLabel="#{AdminMessages['categories.details.description.remove.dialog.submit']}"
removeDialogText="#{AdminMessages['categories.details.description.remove.dialog.message']}"
removeDialogTitle="#{AdminMessages['categories.details.description.table.actions.remove.dialog.title']}"
removeMethod="CategoriesController#removeDescription"
removeMethod="#{mvc.basePath}/categorymanager/categories/#{CategoryDetailsModel.identifier}/description/remove"
tableActionsHeading="#{AdminMessages['categories.details.description.table.headings.actions']}"
tableLocaleHeading="#{AdminMessages['categories.details.description.table.headings.locale']}"
tableValueHeading="#{AdminMessages['categories.details.description.table.headings.value']}"

View File

@ -86,7 +86,7 @@
</a>
</div>
<libreccm:localizedStringEditor addMethod="CategorySystemsController#addTitle"
<libreccm:localizedStringEditor addMethod="#{mvc.basePath}/categorymanager/categorysystems/#{CategorySystemDetailsModel.identifier}/title/add"
addButtonLabel="#{AdminMessages['categorysystems.details.title.add']}"
addDialogCancelLabel="#{AdminMessages['categorysystems.details.title.add.dialog.close']}"
addDialogLocaleSelectHelp="#{AdminMessages['categorysystems.details.title.add.dialog.locale.help']}"
@ -101,7 +101,7 @@
editDialogTitle="#{AdminMessages['categorysystems.details.title.table.actions.edit.dialog.title']}"
editDialogValueHelp="#{AdminMessages['categorysystems.details.title.edit.dialog.value.help']}"
editDialogValueLabel="#{AdminMessages['categorysystems.details.title.edit.dialog.value.label']}"
editMethod="CategorySystemsController#editTitle"
editMethod="#{mvc.basePath}/categorymanager/categorysystems/#{CategorySystemDetailsModel.identifier}/title/edit"
editorId="categorysystem-title"
emptyText="#{AdminMessages['categorysystems.details.title.none']}"
hasUnusedLocales="#{CategorySystemDetailsModel.hasUnusedTitleLocales()}"
@ -111,7 +111,7 @@
removeDialogSubmitLabel="#{AdminMessages['categorysystems.details.title.remove.dialog.submit']}"
removeDialogText="#{AdminMessages['categorysystems.details.title.remove.dialog.message']}"
removeDialogTitle="#{AdminMessages['categorysystems.details.title.table.actions.remove.dialog.title']}"
removeMethod="CategorySystemsController#removeTitle"
removeMethod="#{mvc.basePath}/categorymanager/categorysystems/#{CategorySystemDetailsModel.identifier}/title/remove"
tableActionsHeading="#{AdminMessages['categorysystems.details.title.table.headings.actions']}"
tableLocaleHeading="#{AdminMessages['categorysystems.details.title.table.headings.locale']}"
tableValueHeading="#{AdminMessages['categorysystems.details.title.table.headings.value']}"
@ -119,7 +119,7 @@
unusedLocales="#{CategorySystemDetailsModel.unusedTitleLocales}"
values="#{CategorySystemDetailsModel.title}" />
<libreccm:localizedStringEditor addMethod="CategorySystemsController#addDescription"
<libreccm:localizedStringEditor addMethod="#{mvc.basePath}/categorymanager/categorysystems/#{CategorySystemDetailsModel.identifier}/description/add"
addButtonLabel="#{AdminMessages['categorysystems.details.description.add']}"
addDialogCancelLabel="#{AdminMessages['categorysystems.details.description.add.dialog.close']}"
addDialogLocaleSelectHelp="#{AdminMessages['categorysystems.details.description.add.dialog.locale.help']}"
@ -134,7 +134,7 @@
editDialogTitle="#{AdminMessages['categorysystems.details.description.table.actions.edit.dialog.title']}"
editDialogValueHelp="#{AdminMessages['categorysystems.details.description.edit.dialog.value.help']}"
editDialogValueLabel="#{AdminMessages['categorysystems.details.description.edit.dialog.value.label']}"
editMethod="CategorySystemsController#editDescription"
editMethod="#{mvc.basePath}/categorymanager/categorysystems/#{CategorySystemDetailsModel.identifier}/description/edit"
editorId="categorysystem-description"
emptyText="#{AdminMessages['categorysystems.details.description.none']}"
hasUnusedLocales="#{CategorySystemDetailsModel.hasUnusedDescriptionLocales()}"
@ -144,7 +144,7 @@
removeDialogSubmitLabel="#{AdminMessages['categorysystems.details.description.remove.dialog.submit']}"
removeDialogText="#{AdminMessages['categorysystems.details.description.remove.dialog.message']}"
removeDialogTitle="#{AdminMessages['categorysystems.details.description.table.actions.remove.dialog.title']}"
removeMethod="CategorySystemsController#removeDescription"
removeMethod="#{mvc.basePath}/categorymanager/categorysystems/#{CategorySystemDetailsModel.identifier}/description/remove"
tableActionsHeading="#{AdminMessages['categorysystems.details.description.table.headings.actions']}"
tableLocaleHeading="#{AdminMessages['categorysystems.details.description.table.headings.locale']}"
tableValueHeading="#{AdminMessages['categorysystems.details.description.table.headings.value']}"

View File

@ -12,7 +12,7 @@
<ui:define name="breadcrumb">
<li class="breadcrumb-item">
<a href="#{mvc.uri('ImExportController#getImExportDashboard')}">
<a href="#{mvc.basePath}/imexport">
#{AdminMessages['imexport.label']}
</a>
</li>
@ -26,7 +26,7 @@
<div class="container">
<h1>#{AdminMessages['imexport.export.label']}</h1>
<form action="#{mvc.uri('ImExportController#exportEntities')}"
<form action="#{mvc.basePath}/imexport/export"
aria-describedby="export-help"
method="post">
<p id="export-help">#{AdminMessages['imexport.export.help']}</p>
@ -53,7 +53,7 @@
required="treu" />
<a class="btn btn-warning"
href="#{mvc.uri('ImExportController#getImExportDashboard')}">
href="#{mvc.basePath}/imexport">
#{AdminMessages['imexport.export.cancel']}
</a>
<button class="btn btn-success" type="submit">

View File

@ -1,9 +1,8 @@
<!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"
xmlns:xlink="http://www.w3.org/1999/xlink">
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
<ui:param name="activePage" value="imexport" />
@ -23,16 +22,12 @@
<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>
<bootstrap:svgIcon icon="download" />
<div class="card-body"
id="import-card-body">
<h2 class="card-title">
<a class="stretched-link"
href="#{mvc.uri('ImExportController#importEntities')}">
href="#{mvc.basePath}/imexport/import">
#{AdminMessages['import.label']}
</a>
</h2>
@ -47,16 +42,12 @@
<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>
<bootstrap:svgIcon icon="download" />
<div class="card-body"
id="export-card-body">
<h2 class="card-title">
<a class="stretched-link"
href="#{mvc.uri('ImExportController#exportEntities')}">
href="#{mvc.basePath}/imexport/export">
#{AdminMessages['export.label']}
</a>
</h2>

View File

@ -12,7 +12,7 @@
<ui:define name="breadcrumb">
<li class="breadcrumb-item">
<a href="#{mvc.uri('ImExportController#getImExportDashboard')}">
<a href="#{mvc.basePath}/imexport">
#{AdminMessages['imexport.label']}
</a>
</li>
@ -26,7 +26,7 @@
<div class="container">
<h1>#{AdminMessages['imexport.import.label']}</h1>
<form action="#{mvc.uri('ImExportController#importEntities')}"
<form action="#{mvc.basePath}/imexport/import"
aria-described="import-help"
method="post">
<p id="import-help">#{AdminMessages['imexport.import.help']}</p>
@ -37,7 +37,7 @@
name="archive"
options="#{importArchives}" />
<a class="btn btn-warning"
href="#{mvc.uri('ImExportController#getImExportDashboard')}">
href="#{mvc.basePath}/imexport">
#{AdminMessages['imexport.import.cancel']}
</a>
<button class="btn btn-success" type="submit">

View File

@ -65,6 +65,11 @@ public class ShortcutsApplicationController implements ApplicationController {
return "org/libreccm/ui/admin/applications/shortcuts/shortcuts.xhtml";
}
@Override
public String getControllerLink() {
return "applications/shortcuts";
}
@POST
@Path("/add")
@AuthorizationRequired

View File

@ -13,7 +13,9 @@
<ui:define name="breadcrumb">
<li class="breadcrumb-item">
#{AdminMessages['applications.label']}
<a href="#{mvc.basePath}/applications">
#{AdminMessages['applications.label']}
</a>
</li>
<li class="breadcrumb-item active">
#{ShortcutAdminMessages['application_title']}
@ -25,7 +27,7 @@
<h1>#{ShortcutAdminMessages['application_title']}</h1>
<div class="mb-2">
<bootstrap:modalForm actionTarget="#{mvc.uri('ShortcutsApplicationController#addShortcut')}"
<bootstrap:modalForm actionTarget="#{mvc.basePath}/applications/shortcuts/add"
buttonIcon="plus-circle"
buttonText="#{ShortcutAdminMessages['shortcuts.ui.admin.add_shortcut']}"
buttonTextClass="text-right"
@ -69,7 +71,7 @@
<td>#{shortcut.urlKey}</td>
<td>#{shortcut.redirect}</td>
<td>
<bootstrap:modalForm actionTarget="#{mvc.uri('ShortcutsApplicationController#updateShortcut', { 'shortcutId': shortcut.shortcutId })}"
<bootstrap:modalForm actionTarget="#{mvc.basePath}/applications/shortcuts/#{shortcut.shortcutId}/edit"
buttonIcon="pen"
buttonText="#{ShortcutAdminMessages['shortcuts.ui.admin.shortcuts_table.edit']}"
buttonTextClass="text-center"
@ -102,7 +104,7 @@
</bootstrap:modalForm>
</td>
<td>
<libreccm:deleteDialog actionTarget="#{mvc.uri('ShortcutsApplicationController#removeShortcut', { 'shortcutId': shortcut.shortcutId })}"
<libreccm:deleteDialog actionTarget="#{mvc.basePath}/applications/shortcuts/#{shortcut.shortcutId}/remove"
buttonText="#{ShortcutAdminMessages['shortcuts.ui.admin.shortcuts_table.delete']}"
cancelLabel="#{ShortcutAdminMessages['shortcuts.ui.admin.delete_dialog.cancel']}"
confirmLabel="#{ShortcutAdminMessages['shortcuts.ui.admin.delete_dialog.confirm']}"