Editing localized basic properties of an article

pull/10/head
Jens Pelzetter 2021-04-29 20:52:47 +02:00
parent e36d9eb924
commit 0baaefa543
4 changed files with 198 additions and 82 deletions

View File

@ -286,9 +286,53 @@ 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)
@ -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)
);
}
}

View File

@ -44,25 +44,25 @@
</button>
</div>
<div class="modal-body">
<bootstrap:formGroupText
help="#{CmsArticleMessageBundle['basicproperties.name.help']}"
inputId="name"
label="#{CmsArticleMessageBundle['basicproperties.name.label']}"
name="name"
pattern="^([a-zA-Z0-9_-]*)$"
required="true"
value="#{CmsArticlePropertiesStep.name}"/>
<bootstrap:formGroupText
help="#{CmsArticleMessageBundle['basicproperties.name.help']}"
inputId="name"
label="#{CmsArticleMessageBundle['basicproperties.name.label']}"
name="name"
pattern="^([a-zA-Z0-9_-]*)$"
required="true"
value="#{CmsArticlePropertiesStep.name}"/>
</div>
<div class="modal-footer">
<button class="btn btn-warning"
data-dismiss="modal"
type="button">
#{CmsArticleMessageBundle['basicproperties.name.edit.close']}
</button>
<button class="btn btn-success"
type="submit">
#{CmsArticleMessageBundle['basicproperties.name.edit.submit']}
</button>
<button class="btn btn-warning"
data-dismiss="modal"
type="button">
#{CmsArticleMessageBundle['basicproperties.name.edit.close']}
</button>
<button class="btn btn-success"
type="submit">
#{CmsArticleMessageBundle['basicproperties.name.edit.submit']}
</button>
</div>
</form>
</div>
@ -70,28 +70,67 @@
<libreccm:localizedStringEditor
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/title/@add"
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/title/@edit"
addButtonLabel="#{CmsArticleMessageBundle['basicproperties.title.add']}"
addDialogCancelLabel="#{CmsArticleMessageBundle['basicproperties.title.add.cancel']}"
addDialogLocaleSelectHelp="#{CmsArticleMessageBundle['basicproperties.title.add.locale.help']}"
addDialogLocaleSelectLabel="#{CmsArticleMessageBundle['basicproperties.title.add.locale.label']}"
addDialogSubmitLabel="#{CmsArticleMessageBundle['basicproperties.title.add.submit']}"
addDialogTitle="#{CmsArticleMessageBundle['basicproperties.title.add.header']}"
addDialogValueHelp="#{CmsArticleMessageBundle['basicproperties.title.add.value.help']}"
addDialogValueLabel="#{CmsArticleMessageBundle['basicproperties.title.add.value.label']}"
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/title/@add"
editButtonLabel="#{CmsArticleMessageBundle['basicproperties.title.edit']}"
editDialogCancelLabel="#{CmsArticleMessageBundle['basicproperties.title.edit.cancel']}"
editDialogSubmitLabel="#{CmsArticleMessageBundle['basicproperties.title.edit.submit']}"
editDialogTitle="#{CmsArticleMessageBundle['basicproperties.title.edit.header']}"
editDialogValueHelp="#{CmsArticleMessageBundle['basicproperties.title.edit.value.help']}"
editDialogValueLabel="#{CmsArticleMessageBundle['basicproperties.title.edit.value.label']}"
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/title/@edit"
editorId="title-editor"
hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}"
headingLevel="3"
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/title/@remove"
removeButtonLabel="#{CmsArticleMessageBundle['basicproperties.title.remove']}"
removeDialogCancelLabel="#{CmsArticleMessageBundle['basicproperties.title.remove.cancel']}"
removeDialogSubmitLabel="#{CmsArticleMessageBundle['basicproperties.title.remove.submit']}"
removeDialogText="#{CmsArticleMessageBundle['basicproperties.title.remove.text']}"
removeDialogTitle="#{CmsArticleMessageBundle['basicproperties.title.remove.header']}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/title/@remove"
title="#{CmsArticleMessageBundle['basicproperties.title.header']}"
unusedLocales="#{CmsArticlePropertiesStep.unusedTitleLocales}"
values="#{CmsArticlePropertiesStep.titleValues}"
/>
<libreccm:localizedStringEditor
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/description/@add"
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/description/@edit"
addButtonLabel="#{CmsArticleMessageBundle['basicproperties.description.add']}"
addDialogCancelLabel="#{CmsArticleMessageBundle['basicproperties.description.add.cancel']}"
addDialogLocaleSelectHelp="#{CmsArticleMessageBundle['basicproperties.description.add.locale.help']}"
addDialogLocaleSelectLabel="#{CmsArticleMessageBundle['basicproperties.description.add.locale.label']}"
addDialogSubmitLabel="#{CmsArticleMessageBundle['basicproperties.description.add.submit']}"
addDialogTitle="#{CmsArticleMessageBundle['basicproperties.description.add.header']}"
addDialogValueHelp="#{CmsArticleMessageBundle['basicproperties.description.add.value.help']}"
addDialogValueLabel="#{CmsArticleMessageBundle['basicproperties.description.add.value.label']}"
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/description/@add"
editButtonLabel="#{CmsArticleMessageBundle['basicproperties.description.edit']}"
editDialogCancelLabel="#{CmsArticleMessageBundle['basicproperties.description.edit.cancel']}"
editDialogSubmitLabel="#{CmsArticleMessageBundle['basicproperties.description.edit.submit']}"
editDialogTitle="#{CmsArticleMessageBundle['basicproperties.description.edit.header']}"
editDialogValueHelp="#{CmsArticleMessageBundle['basicproperties.description.edit.value.help']}"
editDialogValueLabel="#{CmsArticleMessageBundle['basicproperties.description.edit.value.label']}"
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/description/@edit"
editorId="description-editor"
hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}"
hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedDescriptionLocales.isEmpty()}"
headingLevel="3"
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/description/@remove"
removeButtonLabel="#{CmsArticleMessageBundle['basicproperties.description.remove']}"
removeDialogCancelLabel="#{CmsArticleMessageBundle['basicproperties.description.remove.cancel']}"
removeDialogSubmitLabel="#{CmsArticleMessageBundle['basicproperties.description.remove.submit']}"
removeDialogText="#{CmsArticleMessageBundle['basicproperties.description.remove.text']}"
removeDialogTitle="#{CmsArticleMessageBundle['basicproperties.description.remove.header']}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents#{CmsSelectedDocumentModel.itemPath}/@article-basicproperties/description/@remove"
title="#{CmsArticleMessageBundle['basicproperties.description.header']}"
unusedLocales="#{CmsArticlePropertiesStep.unusedTitleLocales}"
unusedLocales="#{CmsArticlePropertiesStep.unusedDescriptionLocales}"
values="#{CmsArticlePropertiesStep.descriptionValues}"
useTextarea="true"
/>

View File

@ -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

View File

@ -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