From 0baaefa543f22a302f9deefb1d4a9563a3755dd5 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Thu, 29 Apr 2021 20:52:47 +0200 Subject: [PATCH] Editing localized basic properties of an article --- .../MvcArticlePropertiesStep.java | 115 +++++++++--------- .../article/article-basic-properties.xhtml | 89 ++++++++++---- .../ui/contenttypes/ArticleBundle.properties | 38 ++++++ .../contenttypes/ArticleBundle_de.properties | 38 ++++++ 4 files changed, 198 insertions(+), 82 deletions(-) diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/MvcArticlePropertiesStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/MvcArticlePropertiesStep.java index e2b78ab83..14b2710e6 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/MvcArticlePropertiesStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/MvcArticlePropertiesStep.java @@ -286,13 +286,57 @@ public class MvcArticlePropertiesStep { * @return A redirect to this authoring step. */ @POST - @Path("/title/@edit/{locale}") + @Path("/title/@add") @Transactional(Transactional.TxType.REQUIRED) public String addTitle( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) final String sectionIdentifier, @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) final String documentPath, + @FormParam("locale") final String localeParam, + @FormParam("value") final String value + ) { + try { + stepService.setSectionAndDocument(sectionIdentifier, documentPath); + } catch (ContentSectionNotFoundException ex) { + return ex.showErrorMessage(); + } catch (DocumentNotFoundException ex) { + return ex.showErrorMessage(); + } + + if (itemPermissionChecker.canEditItem(stepService.getDocument())) { + final Locale locale = new Locale(localeParam); + stepService.getDocument().getTitle().addValue(locale, value); + itemRepo.save(stepService.getDocument()); + + return stepService.buildRedirectPathForStep(MvcArticlePropertiesStep.class); + } else { + return documentUi.showAccessDenied( + stepService.getContentSection(), + stepService.getDocument(), + stepService.getLabel(MvcArticlePropertiesStep.class) + ); + } + } + + /** + * Updates a localized title of the article. + * + * @param sectionIdentifier + * @param documentPath + * @param localeParam The locale to update. + * @param value The updated title value. + * + * @return A redirect to this authoring step. + */ + @POST + @Path("/title/@edit/{locale}") + @Transactional(Transactional.TxType.REQUIRED) + public String editTitle( + @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) + final String sectionIdentifier, + @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) + final String documentPath, @PathParam("locale") final String localeParam, @FormParam("value") final String value ) { @@ -309,55 +353,12 @@ public class MvcArticlePropertiesStep { stepService.getDocument().getTitle().addValue(locale, value); itemRepo.save(stepService.getDocument()); - return stepService.buildRedirectPathForStep(getClass()); + return stepService.buildRedirectPathForStep(MvcArticlePropertiesStep.class); } else { return documentUi.showAccessDenied( stepService.getContentSection(), stepService.getDocument(), - stepService.getLabel(getClass()) - ); - } - } - - /** - * Updates a localized title of the article. - * - * @param sectionIdentifier - * @param documentPath - * @param localeParam The locale to update. - * @param value The updated title value. - * - * @return A redirect to this authoring step. - */ - @POST - @Path("/title/@edit/{locale}") - @Transactional(Transactional.TxType.REQUIRED) - public String editTitle( - final String sectionIdentifier, - @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) - final String documentPath, - @PathParam("locale") final String localeParam, - @FormParam("value") final String value - ) { - try { - stepService.setSectionAndDocument(sectionIdentifier, documentPath); - } catch (ContentSectionNotFoundException ex) { - return ex.showErrorMessage(); - } catch (DocumentNotFoundException ex) { - return ex.showErrorMessage(); - } - - if (itemPermissionChecker.canEditItem(stepService.getDocument())) { - final Locale locale = new Locale(localeParam); - stepService.getDocument().getTitle().removeValue(locale); - itemRepo.save(stepService.getDocument()); - - return stepService.buildRedirectPathForStep(getClass()); - } else { - return documentUi.showAccessDenied( - stepService.getContentSection(), - stepService.getDocument(), - stepService.getLabel(getClass()) + stepService.getLabel(MvcArticlePropertiesStep.class) ); } } @@ -394,12 +395,12 @@ public class MvcArticlePropertiesStep { stepService.getDocument().getTitle().removeValue(locale); itemRepo.save(stepService.getDocument()); - return stepService.buildRedirectPathForStep(getClass()); + return stepService.buildRedirectPathForStep(MvcArticlePropertiesStep.class); } else { return documentUi.showAccessDenied( stepService.getContentSection(), stepService.getDocument(), - stepService.getLabel(getClass()) + stepService.getLabel(MvcArticlePropertiesStep.class) ); } } @@ -434,7 +435,7 @@ public class MvcArticlePropertiesStep { * @return A redirect to this authoring step. */ @POST - @Path("/title/@add") + @Path("/description/@add") @Transactional(Transactional.TxType.REQUIRED) public String addDescription( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @@ -457,12 +458,12 @@ public class MvcArticlePropertiesStep { stepService.getDocument().getDescription().addValue(locale, value); itemRepo.save(stepService.getDocument()); - return stepService.buildRedirectPathForStep(getClass()); + return stepService.buildRedirectPathForStep(MvcArticlePropertiesStep.class); } else { return documentUi.showAccessDenied( stepService.getContentSection(), stepService.getDocument(), - stepService.getLabel(getClass()) + stepService.getLabel(MvcArticlePropertiesStep.class) ); } } @@ -478,7 +479,7 @@ public class MvcArticlePropertiesStep { * @return A redirect to this authoring step. */ @POST - @Path("/title/@edit/{locale}") + @Path("/description/@edit/{locale}") @Transactional(Transactional.TxType.REQUIRED) public String editDescription( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @@ -501,12 +502,12 @@ public class MvcArticlePropertiesStep { stepService.getDocument().getDescription().addValue(locale, value); itemRepo.save(stepService.getDocument()); - return stepService.buildRedirectPathForStep(getClass()); + return stepService.buildRedirectPathForStep(MvcArticlePropertiesStep.class); } else { return documentUi.showAccessDenied( stepService.getContentSection(), stepService.getDocument(), - stepService.getLabel(getClass()) + stepService.getLabel(MvcArticlePropertiesStep.class) ); } } @@ -521,7 +522,7 @@ public class MvcArticlePropertiesStep { * @return A redirect to this authoring step. */ @POST - @Path("/title/@remove/{locale}") + @Path("/description/@remove/{locale}") @Transactional(Transactional.TxType.REQUIRED) public String removeDescription( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @@ -543,12 +544,12 @@ public class MvcArticlePropertiesStep { stepService.getDocument().getDescription().removeValue(locale); itemRepo.save(stepService.getDocument()); - return stepService.buildRedirectPathForStep(getClass()); + return stepService.buildRedirectPathForStep(MvcArticlePropertiesStep.class); } else { return documentUi.showAccessDenied( stepService.getContentSection(), stepService.getDocument(), - stepService.getLabel(getClass()) + stepService.getLabel(MvcArticlePropertiesStep.class) ); } } diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/article/article-basic-properties.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/article/article-basic-properties.xhtml index 075f7b50a..5cd590c5d 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/article/article-basic-properties.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/article/article-basic-properties.xhtml @@ -44,25 +44,25 @@ @@ -70,28 +70,67 @@ diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/ArticleBundle.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/ArticleBundle.properties index 82fac82e2..ccd794d5a 100644 --- a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/ArticleBundle.properties +++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/ArticleBundle.properties @@ -37,3 +37,41 @@ basicproperties.header=Basic Properties of Article {0} basicproperties.name.edit.title=Edit name basicproperties.name.edit.close=Cancel basicproperties.name.edit.submit=Save +basicproperties.title.add=Add localized title +basicproperties.title.add.cancel=Cancel +basicproperties.title.add.locale.help=The locale of the new localized title. +basicproperties.title.add.locale.label=Title +basicproperties.title.add.submit=Add title value +basicproperties.title.add.header=Add localized title +basicproperties.title.add.value.help=The new localized title. +basicproperties.title.add.value.label=Localized title +basicproperties.title.edit=Edit +basicproperties.title.edit.cancel=Cancel +basicproperties.title.edit.submit=Save +basicproperties.title.edit.header=Edit localized title +basicproperties.title.edit.value.help=The localized title. +basicproperties.title.edit.value.label=Localized title +basicproperties.title.remove=Remove +basicproperties.title.remove.cancel=Cancel +basicproperties.title.remove.submit=Remove localized title +basicproperties.title.remove.text=Are your sure to remove the localized title for the following locale: +basicproperties.title.remove.header=Remove localized title +basicproperties.description.add=Add localized summary +basicproperties.description.add.cancel=Cancel +basicproperties.description.add.locale.help=The locale of the new localized summary. +basicproperties.description.add.locale.label=Locale +basicproperties.description.add.submit=Add localized summary +basicproperties.description.add.header=Add localized summary +basicproperties.description.add.value.help=The new localized summary. +basicproperties.description.add.value.label=Localized summary +basicproperties.description.edit=Edit +basicproperties.description.edit.cancel=Cancel +basicproperties.description.edit.submit=Save +basicproperties.description.edit.header=Edit localized summary +basicproperties.description.edit.value.help=The localized summary. +basicproperties.description.edit.value.label=Localized summary +basicproperties.description.remove=Remove +basicproperties.description.remove.cancel=Cancel +basicproperties.description.remove.submit=Remove localized summary +basicproperties.description.remove.text=Are you sure to remove the localized summary for this following locale? +basicproperties.description.remove.header=Remove localized summary diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/ArticleBundle_de.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/ArticleBundle_de.properties index 1fbb79da5..3127af404 100644 --- a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/ArticleBundle_de.properties +++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/ArticleBundle_de.properties @@ -37,3 +37,41 @@ basicproperties.header=Basiseigenschaften des Artikels {0} basicproperties.name.edit.title=Name bearbeiten basicproperties.name.edit.close=Abbrechen basicproperties.name.edit.submit=Speichern +basicproperties.title.add=Lokalisierten Titel hinzuf\u00fcgen +basicproperties.title.add.cancel=Abbrechen +basicproperties.title.add.locale.help=The locale of the new localized title. +basicproperties.title.add.locale.label=Titel +basicproperties.title.add.submit=Titel hinzuf\u00fcgen +basicproperties.title.add.header=Lokalisierten Titel hinzuf\u00fcgen +basicproperties.title.add.value.help=Der neue lokalisierte Titel. +basicproperties.title.add.value.label=Lokalisierter Titel +basicproperties.title.edit=Bearbeiten +basicproperties.title.edit.cancel=Abbrechen +basicproperties.title.edit.submit=Speichern +basicproperties.title.edit.header=Lokalisierten Titel bearbeiten +basicproperties.title.edit.value.help=Der lokalisierte Titel. +basicproperties.title.edit.value.label=Lokalisierter Titel +basicproperties.title.remove=Entfernen +basicproperties.title.remove.cancel=Abbrechen +basicproperties.title.remove.submit=Lokalisierten Titel entfernen +basicproperties.title.remove.text=Sind Sie sicher, dass Sie den lokalisierten Titel f\u00fcr folgende Sprachen l\u00f6schen wollen? +basicproperties.title.remove.header=Lokalisierten Titel entfernen +basicproperties.description.add=Lokalisierte Zusammenfassung hinzuf\u00fcgen +basicproperties.description.add.cancel=Abbrechen +basicproperties.description.add.locale.help=Die Sprache der neuen lokalisierten Zusammenfassung. +basicproperties.description.add.locale.label=Sprache +basicproperties.description.add.submit=Lokaliserte Zusammenfassung hinzuf\u00fcgen +basicproperties.description.add.header=Lokalisierte Zusammenfassung hinzuf\u00fcgen +basicproperties.description.add.value.help=Die neue lokalisierte Beschreibung. +basicproperties.description.add.value.label=Lokalisierte Zusammenfassung +basicproperties.description.edit=Bearbeiten +basicproperties.description.edit.cancel=Abbrechen +basicproperties.description.edit.submit=Speichern +basicproperties.description.edit.header=Lokalisierte Zusammenfassung bearbeiten +basicproperties.description.edit.value.help=Die lokalisierte Zusammenfassung. +basicproperties.description.edit.value.label=Lokalisierte Beschreibung +basicproperties.description.remove=Entfernen +basicproperties.description.remove.cancel=Abbrechen +basicproperties.description.remove.submit=Lokalisierte Zusammenfassung entfernen +basicproperties.description.remove.text=Sind Sie sicher, dass Sie die lokalisierte Zusammenfassung f\u00fcr die folgende Sprach entfernen wollen? +basicproperties.description.remove.header=Lokalisierte Zusammenfassung entfernen