diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/mpa/MpaSectionModel.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/mpa/MpaSectionModel.java index 58eafaeed..9b8575feb 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/mpa/MpaSectionModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/mpa/MpaSectionModel.java @@ -18,6 +18,8 @@ */ package org.librecms.ui.contenttypes.mpa; +import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -38,6 +40,8 @@ public class MpaSectionModel { private String articleTitle; private long sectionId; + + private String sectionTitle; private boolean pageBreak; @@ -49,7 +53,7 @@ public class MpaSectionModel { private List unusedTitleLocales; - private Map textValues; + private List textValues; private Map truncatedTextValues; @@ -70,6 +74,14 @@ public class MpaSectionModel { protected void setSectionId(final long sectionId) { this.sectionId = sectionId; } + + public String getSectionTitle() { + return sectionTitle; + } + + protected void setSectionTitle(final String sectionTitle) { + this.sectionTitle = sectionTitle; + } public boolean isPageBreak() { return pageBreak; @@ -115,12 +127,12 @@ public class MpaSectionModel { return !unusedTitleLocales.isEmpty(); } - public Map getTextValues() { - return Collections.unmodifiableMap(textValues); + public List getTextValues() { + return Collections.unmodifiableList(textValues); } - protected void setTextValues(final Map textValues) { - this.textValues = new HashMap<>(textValues); + protected void setTextValues(final List textValues) { + this.textValues = new ArrayList<>(textValues); } public Map getTruncatedTextValues() { diff --git a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/mpa/MvcMpaSectionsStep.java b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/mpa/MvcMpaSectionsStep.java index 69487ecb9..645607e00 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contenttypes/mpa/MvcMpaSectionsStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contenttypes/mpa/MvcMpaSectionsStep.java @@ -27,6 +27,7 @@ import org.librecms.contenttypes.MultiPartArticleSectionRepository; import org.librecms.ui.contentsections.ContentSectionNotFoundException; import org.librecms.ui.contentsections.ItemPermissionChecker; import org.librecms.ui.contentsections.documents.AbstractMvcAuthoringStep; +import org.librecms.ui.contentsections.documents.CmsEditorLocaleVariantRow; import org.librecms.ui.contentsections.documents.DocumentNotFoundException; import org.librecms.ui.contentsections.documents.DocumentUi; import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef; @@ -38,6 +39,7 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.Set; +import java.util.StringTokenizer; import java.util.stream.Collectors; import javax.enterprise.context.RequestScoped; @@ -91,6 +93,7 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { @Inject private MpaSectionsStepModel mpaSectionsStepModel; + @Inject private MpaSectionModel mpaSectionModel; @@ -338,7 +341,9 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { section.getTitle().putValue(locale, value); sectionRepo.save(section); - return buildRedirectPathForStep(); + return String.format( + "%s/%d", buildRedirectPathForStep(), section.getSectionId() + ); } else { return documentUi.showAccessDenied( getContentSection(), @@ -349,7 +354,7 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { } @POST - @Path("/{sectionId}/title/@remove") + @Path("/{sectionId}/title/@remove/{locale}") @Transactional(Transactional.TxType.REQUIRED) public String removeTitleValue( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @@ -358,7 +363,7 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { final String documentPath, @PathParam("sectionId") final String sectionIdParam, - @FormParam("locale") + @PathParam("locale") final String localeParam ) { try { @@ -385,7 +390,9 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { section.getTitle().removeValue(locale); sectionRepo.save(section); - return buildRedirectPathForStep(); + return String.format( + "%s/%d", buildRedirectPathForStep(), section.getSectionId() + ); } else { return documentUi.showAccessDenied( getContentSection(), @@ -440,7 +447,9 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { section.getText().putValue(locale, value); sectionRepo.save(section); - return buildRedirectPathForStep(); + return String.format( + "%s/%d", buildRedirectPathForStep(), section.getSectionId() + ); } else { return documentUi.showAccessDenied( getContentSection(), @@ -512,7 +521,9 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { section.getText().putValue(locale, value); sectionRepo.save(section); - return buildRedirectPathForStep(); + return String.format( + "%s/%d", buildRedirectPathForStep(), section.getSectionId() + ); } else { return documentUi.showAccessDenied( getContentSection(), @@ -559,7 +570,9 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { section.getText().removeValue(locale); sectionRepo.save(section); - return buildRedirectPathForStep(); + return String.format( + "%s/%d", buildRedirectPathForStep(), section.getSectionId() + ); } else { return documentUi.showAccessDenied( getContentSection(), @@ -601,10 +614,12 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { } final MultiPartArticleSection section = result.get(); - section.setPageBreak(Boolean.parseBoolean(pageBreakParam)); + section.setPageBreak(pageBreakParam != null); sectionRepo.save(section); - return buildRedirectPathForStep(); + return String.format( + "%s/%d", buildRedirectPathForStep(), section.getSectionId() + ); } else { return documentUi.showAccessDenied( getContentSection(), @@ -718,18 +733,19 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { mpaSectionModel.setPageBreak(section.isPageBreak()); mpaSectionModel.setRank(section.getRank()); mpaSectionModel.setSectionId(section.getSectionId()); + mpaSectionModel.setSectionTitle( + globalizationHelper.getValueFromLocalizedString( + section.getTitle() + ) + ); mpaSectionModel.setTextValues( section .getText() .getValues() .entrySet() .stream() - .collect( - Collectors.toMap( - entry -> entry.getKey().toString(), - Map.Entry::getValue - ) - ) + .map(this::buildVariantRow) + .collect(Collectors.toList()) ); mpaSectionModel.setTitleValues( section @@ -805,4 +821,14 @@ public class MvcMpaSectionsStep extends AbstractMvcAuthoringStep { return showStep(sectionIdentifier, documentPath); } + private CmsEditorLocaleVariantRow buildVariantRow( + final Map.Entry variant + ) { + final CmsEditorLocaleVariantRow row = new CmsEditorLocaleVariantRow(); + row.setLocale(variant.getKey().toString()); + row.setWordCount(new StringTokenizer(variant.getValue()).countTokens()); + + return row; + } + } diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/mpa/mpa-section-text.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/mpa/mpa-section-text.xhtml index 7b2e91b28..25b1ee578 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/mpa/mpa-section-text.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/mpa/mpa-section-text.xhtml @@ -16,11 +16,11 @@

#{CmsMpaMessageBundle.getMessage('sectionstep.textstep.header.edit',[CmsMpaSectionStep.articleTitle, CmsMpaSectionStep.titleValues.get(CmsMpaSectionStep.selectedLocale) , CmsMpaSectionStep.selectedLocale])}

- +
- - - #{CmsMpaMessageBundle['sectionstep.back']} - -

#{CmsMpaMessageBundle.getMessage('sectionstep.header', CmsMpaSectionStep.articleTitle, CmsMpaSectionStep.titleValues.get(CmsMpaSectionStep.selectedLocale))}

- - - -

#{CmsMpaMessageBundle['sectionsection.pagebreak.title']}

- - - #{CmsMpaMessageBundle['sectionsection.pagebreak.yes']} - - - #{CmsMpaMessageBundle['sectionsection.pagebreak.no']} - - - + + + #{CmsMpaMessageBundle['sectionstep.back']} +
- - - - +

#{CmsMpaMessageBundle['sectionstep.header']}

+ +
+
#{CmsMpaMessageBundle['sectionstep.current_article']}
+
#{CmsMpaSectionStep.articleTitle}
+
#{CmsMpaMessageBundle['sectionstep.current_section']}
+
#{CmsMpaSectionStep.sectionTitle}
+
+ + + +

#{CmsMpaMessageBundle['sectionsection.pagebreak.title']}

+
+ + + #{CmsMpaMessageBundle['sectionsection.pagebreak.yes']} + + + #{CmsMpaMessageBundle['sectionsection.pagebreak.no']} + + + +
+ + + + + + diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/mpa/mpa-sections.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/mpa/mpa-sections.xhtml index 17ec47324..b533dca41 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/mpa/mpa-sections.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contenttypes/mpa/mpa-sections.xhtml @@ -117,7 +117,7 @@

- +
@@ -143,10 +143,6 @@ iconClass="text-success" /> #{CmsMpaMessageBundle['sectionsstep.sections.section.pagebreak.yes']} - - #{CmsMpaMessageBundle['sectionsstep.sections.section.pagebreak.no']} - - diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/MpaStepsBundle.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/MpaStepsBundle.properties index 16cd3429c..dd2fb243e 100644 --- a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/MpaStepsBundle.properties +++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/MpaStepsBundle.properties @@ -97,7 +97,7 @@ sectionsstep.sections.section.remove.dialog.confirm=Remove section sectionsstep.sections.section.remove.dialog.title=Confirm removal of section sectionsstep.sections.section.remove.dialog.message=Are you sure to remove the following section? sectionstep.back=Back -sectionstep.header=Edit section {1} of multipart article {0} +sectionstep.header=Edit section of a multipart article sectionstep.title.label=Title sectionsection.pagebreak.title=Page break after section? sectionsection.pagebreak.yes=Yes @@ -116,3 +116,25 @@ authoringsteps.sections.label=Sections sectionsstep.sections.empty=This multipart article has no sections yet. sectionsstep.error.initial_locale_missing=Initial locale is missing. sectionsstep.error.title_missing=Title for the new section is missing. +sectionstep.current_article=Selection multipart article +sectionstep.current_section=Selected section +sectionstep.title.add.label=Add localized title +sectionstep.title.add.cancel=Cancel +sectionstep.title.add.locale.help=The locale of the new localized title. +sectionstep.title.add.locale.label=Locale +sectionstep.title.add.submit=Add localized title +sectionstep.title.add.dialog_title=Add localized title +sectionstep.title.add.value.help=The localized title. +sectionstep.title.add.value.label=Title +sectionstep.title.edit.label=Edit +sectionstep.title.edit.dialog.cancel=Cancel +sectionstep.title.edit.dialog.submit=Save +sectionstep.title.edit.dialog.title=Edit localized title +sectionstep.title.edit.dialog.value.help=The localized title. +sectionstep.title.edit.dialog.value.label=Title +sectionstep.title.empty=No localized title yet. +sectionstep.title.edit.remove.label=Remove +sectionstep.title.edit.remove.dialog.cancel=Cancel +sectionstep.title.edit.remove.dialog.submit=Remove localized title +sectionstep.title.edit.remove.dialog.text=Are you sure to remove to this localized title? +sectionstep.title.edit.remove.dialog.title=Remove localized title diff --git a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/MpaStepsBundle_de.properties b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/MpaStepsBundle_de.properties index 4bc46fd94..09f3b7758 100644 --- a/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/MpaStepsBundle_de.properties +++ b/ccm-cms/src/main/resources/org/librecms/ui/contenttypes/MpaStepsBundle_de.properties @@ -97,7 +97,7 @@ sectionsstep.sections.section.remove.dialog.confirm=Abschnitt entfernen sectionsstep.sections.section.remove.dialog.title=Entfernen des Abschnitts best\u00e4tigen sectionsstep.sections.section.remove.dialog.message=Sind Sie sicher, dass Sie den folgenden Abschnitt entfernen wollen? sectionstep.back=Zur\u00fcck -sectionstep.header=Abschnitt {1} des mehrteiligen Artikels {0} bearbeiten +sectionstep.header=Einen Abschnitt eines mehrteiligen Artikels bearbeiten sectionstep.title.label=Titel sectionsection.pagebreak.title=Seitenumbruch nach Abschnitt? sectionsection.pagebreak.yes=Ja @@ -116,3 +116,25 @@ authoringsteps.sections.label=Abschnitte sectionsstep.sections.empty=Diese mehrteilige Artikel hat noch keine Abschnitte. sectionsstep.error.initial_locale_missing=Es wurde keine initiale Sprache f\u00fcr den neuen Abschnitt angegeben. sectionsstep.error.title_missing=Der Titel f\u00fcr den neuen Abschnitt wurde nicht angegeben. +sectionstep.current_article=Ausgew\u00e4hlter mehrteiliger Artikel +sectionstep.current_section=Ausgew\u00e4hlter Abschnitt +sectionstep.title.add.label=Lokalisierten Titel hinzuf\u00fcgen +sectionstep.title.add.cancel=Abbrechen +sectionstep.title.add.locale.help=Die Sprache des neuen lokalisierten Titels. +sectionstep.title.add.locale.label=Sprache +sectionstep.title.add.submit=Lokalisierten Titel hinzuf\u00fcgen +sectionstep.title.add.dialog_title=Lokalisierten Titel hinzuf\u00fcgen +sectionstep.title.add.value.help=Der lokalisierte Titel +sectionstep.title.add.value.label=Titel +sectionstep.title.edit.label=Bearbeiten +sectionstep.title.edit.dialog.cancel=Abbrechen +sectionstep.title.edit.dialog.submit=Speichern +sectionstep.title.edit.dialog.title=Lokalisierten Titel bearbeiten +sectionstep.title.edit.dialog.value.help=Der lokalisierte Titel. +sectionstep.title.edit.dialog.value.label=Titel +sectionstep.title.empty=Es wurden noch keine lokalisierten Titel hinzugef\u00fcgt. +sectionstep.title.edit.remove.label=Entfernen +sectionstep.title.edit.remove.dialog.cancel=Abbrechen +sectionstep.title.edit.remove.dialog.submit=Lokalisierten Titel entfernen +sectionstep.title.edit.remove.dialog.text=Sind Sie sicher, dass Sie diesen lokaliserten Titel entfernen wollen? +sectionstep.title.edit.remove.dialog.title=Lokalisierten Titel entfernen
#{CmsMpaMessageBundle['sectionsstep.sections.section.title']} @@ -160,12 +156,14 @@