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;
public CmsMessages() {
this.messages = new TreeMap<>();
}
public Map<String, String> getMessages() {
return Collections.unmodifiableSortedMap(messages);
}

View File

@ -23,6 +23,7 @@ import org.librecms.contentsection.ContentItem;
import org.librecms.contentsection.ContentItemManager;
import org.librecms.contentsection.ContentItemRepository;
import org.librecms.contentsection.ContentSection;
import org.librecms.ui.contentsections.ContentSectionModel;
import org.librecms.ui.contentsections.ContentSectionsUi;
import java.util.Objects;
@ -48,12 +49,18 @@ public class MvcAuthoringStepService {
@Inject
private ContentItemRepository itemRepo;
@Inject
private ContentSectionModel sectionModel;
@Inject
private ContentSectionsUi sectionsUi;
@Inject
private GlobalizationHelper globalizationHelper;
@Inject
private SelectedDocumentModel documentModel;
private ContentSection section;
private ContentItem document;
@ -141,6 +148,7 @@ public class MvcAuthoringStepService {
sectionIdentifier)
)
);
sectionModel.setSection(section);
document = itemRepo
.findByPath(section, documentPath)
@ -155,6 +163,7 @@ public class MvcAuthoringStepService {
)
)
);
documentModel.setContentItem(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.MvcAuthoringSteps;
import java.util.Collections;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.ws.rs.Path;
@ -52,7 +54,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PathParam;
/**
* Authoring step for editing the basic properties of an a {@link Article}.
*
@ -109,6 +110,14 @@ public class MvcArticlePropertiesStep {
@Inject
private MvcAuthoringStepService stepService;
private Map<String, String> titleValues;
private List<String> unusedTitleLocales;
private Map<String, String> descriptionValues;
private List<String> unusedDescriptionLocales;
@GET
@Path("/")
@Transactional(Transactional.TxType.REQUIRED)
@ -127,6 +136,56 @@ public class MvcArticlePropertiesStep {
}
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";
} else {
return documentUi.showAccessDenied(
@ -135,6 +194,7 @@ public class MvcArticlePropertiesStep {
articleMessageBundle.getMessage("article.edit.denied")
);
}
}
/**
@ -199,18 +259,7 @@ public class MvcArticlePropertiesStep {
* @return The values of the localized title of the article.
*/
public Map<String, String> getTitleValues() {
return stepService
.getDocument()
.getTitle()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
entry -> entry.getValue()
)
);
return Collections.unmodifiableMap(titleValues);
}
/**
@ -219,16 +268,7 @@ public class MvcArticlePropertiesStep {
* @return The locales for which no localized title has been defined yet.
*/
public List<String> getUnusedTitleLocales() {
final Set<Locale> titleLocales = stepService
.getDocument()
.getTitle()
.getAvailableLocales();
return globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !titleLocales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList());
return Collections.unmodifiableList(unusedTitleLocales);
}
/**
@ -367,16 +407,7 @@ public class MvcArticlePropertiesStep {
* yet.
*/
public List<String> getUnusedDescriptionLocales() {
final Set<Locale> descriptionLocales = stepService
.getDocument()
.getDescription()
.getAvailableLocales();
return globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !descriptionLocales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList());
return Collections.unmodifiableList(unusedDescriptionLocales);
}
/**
@ -385,18 +416,7 @@ public class MvcArticlePropertiesStep {
* @return The values of the localized description of the article.
*/
public Map<String, String> getDescriptionValues() {
return stepService
.getDocument()
.getDescription()
.getValues()
.entrySet()
.stream()
.collect(
Collectors.toMap(
entry -> entry.getKey().toString(),
entry -> entry.getValue()
)
);
return Collections.unmodifiableMap(descriptionValues);
}
/**

View File

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

View File

@ -6,6 +6,7 @@
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml">
<ui:define name="authoringStep">
<h2>#{CmsArticleMessageBundle['basicproperties.name.header']}</h2>
<div class="d-flex">
@ -62,6 +63,7 @@
values="#{CmsArticlePropertiesStep.descriptionValues}"
useTextarea="true"
/>
</ui:define>
</ui:composition>
</html>