Authoring steps are shown

pull/10/head
Jens Pelzetter 2021-04-27 21:14:30 +02:00
parent 68f973cf15
commit e010e5a653
5 changed files with 145 additions and 112 deletions

View File

@ -37,6 +37,10 @@ public class CmsMessages {
private SortedMap<String, String> messages; private SortedMap<String, String> messages;
public CmsMessages() {
this.messages = new TreeMap<>();
}
public Map<String, String> getMessages() { public Map<String, String> getMessages() {
return Collections.unmodifiableSortedMap(messages); return Collections.unmodifiableSortedMap(messages);
} }

View File

@ -23,6 +23,7 @@ import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemManager; import org.librecms.contentsection.ContentItemManager;
import org.librecms.contentsection.ContentItemRepository; import org.librecms.contentsection.ContentItemRepository;
import org.librecms.contentsection.ContentSection; import org.librecms.contentsection.ContentSection;
import org.librecms.ui.contentsections.ContentSectionModel;
import org.librecms.ui.contentsections.ContentSectionsUi; import org.librecms.ui.contentsections.ContentSectionsUi;
import java.util.Objects; import java.util.Objects;
@ -48,12 +49,18 @@ public class MvcAuthoringStepService {
@Inject @Inject
private ContentItemRepository itemRepo; private ContentItemRepository itemRepo;
@Inject
private ContentSectionModel sectionModel;
@Inject @Inject
private ContentSectionsUi sectionsUi; private ContentSectionsUi sectionsUi;
@Inject @Inject
private GlobalizationHelper globalizationHelper; private GlobalizationHelper globalizationHelper;
@Inject
private SelectedDocumentModel documentModel;
private ContentSection section; private ContentSection section;
private ContentItem document; private ContentItem document;
@ -141,6 +148,7 @@ public class MvcAuthoringStepService {
sectionIdentifier) sectionIdentifier)
) )
); );
sectionModel.setSection(section);
document = itemRepo document = itemRepo
.findByPath(section, documentPath) .findByPath(section, documentPath)
@ -155,6 +163,7 @@ public class MvcAuthoringStepService {
) )
) )
); );
documentModel.setContentItem(document);
this.documentPath = itemManager.getItemPath(document); this.documentPath = itemManager.getItemPath(document);
} }
@ -185,7 +194,7 @@ public class MvcAuthoringStepService {
) )
.replace( .replace(
String.format("{%s}", String.format("{%s}",
MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME
), ),
documentPath documentPath
) )
@ -232,7 +241,7 @@ public class MvcAuthoringStepService {
) )
.replace( .replace(
String.format("{%s}", String.format("{%s}",
MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME
), ),
documentPath documentPath
) )

View File

@ -32,6 +32,8 @@ import org.librecms.ui.contentsections.documents.MvcAuthoringStep;
import org.librecms.ui.contentsections.documents.MvcAuthoringStepService; import org.librecms.ui.contentsections.documents.MvcAuthoringStepService;
import org.librecms.ui.contentsections.documents.MvcAuthoringSteps; import org.librecms.ui.contentsections.documents.MvcAuthoringSteps;
import java.util.Collections;
import javax.enterprise.context.RequestScoped; import javax.enterprise.context.RequestScoped;
import javax.inject.Inject; import javax.inject.Inject;
import javax.ws.rs.Path; import javax.ws.rs.Path;
@ -52,7 +54,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
/** /**
* Authoring step for editing the basic properties of an a {@link Article}. * Authoring step for editing the basic properties of an a {@link Article}.
* *
@ -109,6 +110,14 @@ public class MvcArticlePropertiesStep {
@Inject @Inject
private MvcAuthoringStepService stepService; private MvcAuthoringStepService stepService;
private Map<String, String> titleValues;
private List<String> unusedTitleLocales;
private Map<String, String> descriptionValues;
private List<String> unusedDescriptionLocales;
@GET @GET
@Path("/") @Path("/")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
@ -127,6 +136,56 @@ public class MvcArticlePropertiesStep {
} }
if (itemPermissionChecker.canEditItem(stepService.getDocument())) { if (itemPermissionChecker.canEditItem(stepService.getDocument())) {
titleValues = stepService
.getDocument()
.getTitle()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
entry -> entry.getValue()
)
);
final Set<Locale> titleLocales = stepService
.getDocument()
.getTitle()
.getAvailableLocales();
unusedTitleLocales = globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !titleLocales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList());
descriptionValues = stepService
.getDocument()
.getDescription()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
entry -> entry.getValue()
)
);
final Set<Locale> descriptionLocales = stepService
.getDocument()
.getDescription()
.getAvailableLocales();
unusedDescriptionLocales = globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !descriptionLocales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList());
return "org/librecms/ui/contenttypes/article/article-basic-properties.xhtml"; return "org/librecms/ui/contenttypes/article/article-basic-properties.xhtml";
} else { } else {
return documentUi.showAccessDenied( return documentUi.showAccessDenied(
@ -135,6 +194,7 @@ public class MvcArticlePropertiesStep {
articleMessageBundle.getMessage("article.edit.denied") articleMessageBundle.getMessage("article.edit.denied")
); );
} }
} }
/** /**
@ -199,18 +259,7 @@ public class MvcArticlePropertiesStep {
* @return The values of the localized title of the article. * @return The values of the localized title of the article.
*/ */
public Map<String, String> getTitleValues() { public Map<String, String> getTitleValues() {
return stepService return Collections.unmodifiableMap(titleValues);
.getDocument()
.getTitle()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
entry -> entry.getValue()
)
);
} }
/** /**
@ -219,16 +268,7 @@ public class MvcArticlePropertiesStep {
* @return The locales for which no localized title has been defined yet. * @return The locales for which no localized title has been defined yet.
*/ */
public List<String> getUnusedTitleLocales() { public List<String> getUnusedTitleLocales() {
final Set<Locale> titleLocales = stepService return Collections.unmodifiableList(unusedTitleLocales);
.getDocument()
.getTitle()
.getAvailableLocales();
return globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !titleLocales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList());
} }
/** /**
@ -367,16 +407,7 @@ public class MvcArticlePropertiesStep {
* yet. * yet.
*/ */
public List<String> getUnusedDescriptionLocales() { public List<String> getUnusedDescriptionLocales() {
final Set<Locale> descriptionLocales = stepService return Collections.unmodifiableList(unusedDescriptionLocales);
.getDocument()
.getDescription()
.getAvailableLocales();
return globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !descriptionLocales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList());
} }
/** /**
@ -385,18 +416,7 @@ public class MvcArticlePropertiesStep {
* @return The values of the localized description of the article. * @return The values of the localized description of the article.
*/ */
public Map<String, String> getDescriptionValues() { public Map<String, String> getDescriptionValues() {
return stepService return Collections.unmodifiableMap(descriptionValues);
.getDocument()
.getDescription()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
entry -> entry.getValue()
)
);
} }
/** /**
@ -492,7 +512,7 @@ public class MvcArticlePropertiesStep {
* *
* @param sectionIdentifier * @param sectionIdentifier
* @param documentPath * @param documentPath
* @param localeParam The locale to remove. * @param localeParam The locale to remove.
* *
* @return A redirect to this authoring step. * @return A redirect to this authoring step.
*/ */
@ -500,13 +520,13 @@ public class MvcArticlePropertiesStep {
@Path("/title/@remove/{locale}") @Path("/title/@remove/{locale}")
@Transactional(Transactional.TxType.REQUIRED) @Transactional(Transactional.TxType.REQUIRED)
public String removeDescription( public String removeDescription(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier, final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME) @PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath, final String documentPath,
@PathParam("locale") final String localeParam @PathParam("locale") final String localeParam
) { ) {
try { try {
stepService.setSectionAndDocument(sectionIdentifier, documentPath); stepService.setSectionAndDocument(sectionIdentifier, documentPath);
} catch (ContentSectionNotFoundException ex) { } catch (ContentSectionNotFoundException ex) {
return ex.showErrorMessage(); return ex.showErrorMessage();
@ -515,11 +535,11 @@ public class MvcArticlePropertiesStep {
} }
if (itemPermissionChecker.canEditItem(stepService.getDocument())) { if (itemPermissionChecker.canEditItem(stepService.getDocument())) {
final Locale locale = new Locale(localeParam); final Locale locale = new Locale(localeParam);
stepService.getDocument().getDescription().removeValue(locale); stepService.getDocument().getDescription().removeValue(locale);
itemRepo.save(stepService.getDocument()); itemRepo.save(stepService.getDocument());
return stepService.buildRedirectPathForStep(getClass()); return stepService.buildRedirectPathForStep(getClass());
} else { } else {
return documentUi.showAccessDenied( return documentUi.showAccessDenied(
stepService.getContentSection(), stepService.getContentSection(),

View File

@ -1,12 +1,10 @@
<!DOCTYPE html [<!ENTITY times '&#215;'>]> <!DOCTYPE html [<!ENTITY times '&#215;'>]>
<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: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/librecms/ui/contentsection/contentsection.xhtml"> <ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/contentsection.xhtml">
<ui:define name="documentMain"> <ui:define name="main">
<div class="row"> <div class="row">
<ul class="nav nav-tabs"> <ul class="nav nav-tabs">
@ -90,8 +88,8 @@
type="button"> type="button">
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.lock']}: } #{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.lock']}: }
</button> </button>
</c:otherwise>
</form> </form>
</c:when>
</c:choose> </c:choose>
</p> </p>
@ -100,7 +98,7 @@
<ul class="list-group"> <ul class="list-group">
<c:forEach items="#{CmsSelectedDocumentModel.authoringStepsList}" <c:forEach items="#{CmsSelectedDocumentModel.authoringStepsList}"
var="step"> var="step">
<li aria-current="#{step.path == authoringStep ? 'true' : ''} <li aria-current="#{step.path == authoringStep ? 'true' : ''}"
class="list-group-item #{step.path == authoringStep ? 'active' : ''}"> class="list-group-item #{step.path == authoringStep ? 'active' : ''}">
<a class="list-group-item-action" <a class="list-group-item-action"
href="#{mvc.basePath}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/#{step.path}"> href="#{mvc.basePath}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/#{step.path}">
@ -110,14 +108,14 @@
</c:forEach> </c:forEach>
<c:if test="#{!CmsSelectedDocumentModel.excludeDefaultAuthoringSteps}"> <c:if test="#{!CmsSelectedDocumentModel.excludeDefaultAuthoringSteps}">
<li aria-current="#{'categorize' == authoringStep ? 'true' : ''} <li aria-current="#{'categorize' == authoringStep ? 'true' : ''}"
class="list-group-item #{'categorize' == authoringStep ? 'active' : ''}"> class="list-group-item #{'categorize' == authoringStep ? 'active' : ''}">
<a class="list-group-item-action" <a class="list-group-item-action"
href="#{mvc.basePath}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/categorize"> href="#{mvc.basePath}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/categorize">
#{CmsAdminMessages['contentsection.document.authoring.steps.categorize.label']} #{CmsAdminMessages['contentsection.document.authoring.steps.categorize.label']}
</a> </a>
</li> </li>
<li aria-current="#{'relatedInfo' == authoringStep ? 'true' : ''} <li aria-current="#{'relatedInfo' == authoringStep ? 'true' : ''}"
class="list-group-item #{'relatedInfo' == authoringStep ? 'active' : ''}"> class="list-group-item #{'relatedInfo' == authoringStep ? 'active' : ''}">
<a class="list-group-item-action" <a class="list-group-item-action"
href="#{mvc.basePath}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/relatedInfo"> href="#{mvc.basePath}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/relatedInfo">
@ -126,7 +124,7 @@
</li> </li>
</c:if> </c:if>
<li aria-current="#{'publish' == authoringStep ? 'true' : ''} <li aria-current="#{'publish' == authoringStep ? 'true' : ''}"
class="list-group-item #{'publish' == authoringStep ? 'active' : ''}"> class="list-group-item #{'publish' == authoringStep ? 'active' : ''}">
<a class="list-group-item-action" <a class="list-group-item-action"
href="#{mvc.basePath}/documents/#{CmsSelectedDocumentModel.itemPath}/@publish"> href="#{mvc.basePath}/documents/#{CmsSelectedDocumentModel.itemPath}/@publish">

View File

@ -6,62 +6,64 @@
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml"> <ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml">
<h2>#{CmsArticleMessageBundle['basicproperties.name.header']}</h2> <ui:define name="authoringStep">
<h2>#{CmsArticleMessageBundle['basicproperties.name.header']}</h2>
<div class="d-flex"> <div class="d-flex">
<pre> <pre>
#{CmsArticlePropertiesStep.name} #{CmsArticlePropertiesStep.name}
</pre> </pre>
<button class="btn btn-primary" <button class="btn btn-primary"
data-toggle="modal" data-toggle="modal"
data-target="name-edit-dialog" data-target="name-edit-dialog"
type="button"> type="button">
<bootstrap:svgIcon icon="pen" /> <bootstrap:svgIcon icon="pen" />
<span class="sr-only"> <span class="sr-only">
#{CmsArticleMessageBundle['basicproperties.name.edit']} #{CmsArticleMessageBundle['basicproperties.name.edit']}
</span> </span>
</button> </button>
<div aria-hidden="true" <div aria-hidden="true"
aria-labelledby="name-edit-dialog-title" aria-labelledby="name-edit-dialog-title"
class="modal fade" class="modal fade"
id="name-edit-dialog" id="name-edit-dialog"
tabindex="-1"> tabindex="-1">
<div class="modal-dialog"> <div class="modal-dialog">
<form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/name" <form action="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/name"
class="modal-content" class="modal-content"
method="post"> method="post">
</form> </form>
</div>
</div> </div>
</div> </div>
</div>
<libreccm:localizedStringEditor <libreccm:localizedStringEditor
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/title/@add" addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/title/@add"
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/title/@edit" editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/title/@edit"
editorId="title-editor" editorId="title-editor"
hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}" hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}"
headingLevel="3" headingLevel="3"
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}" objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/title/@remove" removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/title/@remove"
title="#{CmsArticleMessageBundle['basicproperties.title.header']}" title="#{CmsArticleMessageBundle['basicproperties.title.header']}"
unusedLocales="#{CmsArticlePropertiesStep.unusedTitleLocales}" unusedLocales="#{CmsArticlePropertiesStep.unusedTitleLocales}"
values="#{CmsArticlePropertiesStep.titleValues}" values="#{CmsArticlePropertiesStep.titleValues}"
/> />
<libreccm:localizedStringEditor <libreccm:localizedStringEditor
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/description/@add" addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/description/@add"
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/description/@edit" editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/description/@edit"
editorId="description-editor" editorId="description-editor"
hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}" hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}"
headingLevel="3" headingLevel="3"
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}" objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/description/@remove" removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/description/@remove"
title="#{CmsArticleMessageBundle['basicproperties.description.header']}" title="#{CmsArticleMessageBundle['basicproperties.description.header']}"
unusedLocales="#{CmsArticlePropertiesStep.unusedTitleLocales}" unusedLocales="#{CmsArticlePropertiesStep.unusedTitleLocales}"
values="#{CmsArticlePropertiesStep.descriptionValues}" values="#{CmsArticlePropertiesStep.descriptionValues}"
useTextarea="true" useTextarea="true"
/> />
</ui:define>
</ui:composition> </ui:composition>
</html> </html>