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);
} }

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()
)
);
} }
/** /**

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,6 +6,7 @@
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">
<ui:define name="authoringStep">
<h2>#{CmsArticleMessageBundle['basicproperties.name.header']}</h2> <h2>#{CmsArticleMessageBundle['basicproperties.name.header']}</h2>
<div class="d-flex"> <div class="d-flex">
@ -62,6 +63,7 @@
values="#{CmsArticlePropertiesStep.descriptionValues}" values="#{CmsArticlePropertiesStep.descriptionValues}"
useTextarea="true" useTextarea="true"
/> />
</ui:define>
</ui:composition> </ui:composition>
</html> </html>