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);
}
@ -185,7 +194,7 @@ public class MvcAuthoringStepService {
)
.replace(
String.format("{%s}",
MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME
MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME
),
documentPath
)
@ -232,7 +241,7 @@ public class MvcAuthoringStepService {
)
.replace(
String.format("{%s}",
MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME
MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME
),
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.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);
}
/**
@ -492,7 +512,7 @@ public class MvcArticlePropertiesStep {
*
* @param sectionIdentifier
* @param documentPath
* @param localeParam The locale to remove.
* @param localeParam The locale to remove.
*
* @return A redirect to this authoring step.
*/
@ -500,13 +520,13 @@ public class MvcArticlePropertiesStep {
@Path("/title/@remove/{locale}")
@Transactional(Transactional.TxType.REQUIRED)
public String removeDescription(
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
final String sectionIdentifier,
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
final String documentPath,
@PathParam("locale") final String localeParam
) {
try {
try {
stepService.setSectionAndDocument(sectionIdentifier, documentPath);
} catch (ContentSectionNotFoundException ex) {
return ex.showErrorMessage();
@ -515,11 +535,11 @@ public class MvcArticlePropertiesStep {
}
if (itemPermissionChecker.canEditItem(stepService.getDocument())) {
final Locale locale = new Locale(localeParam);
stepService.getDocument().getDescription().removeValue(locale);
itemRepo.save(stepService.getDocument());
final Locale locale = new Locale(localeParam);
stepService.getDocument().getDescription().removeValue(locale);
itemRepo.save(stepService.getDocument());
return stepService.buildRedirectPathForStep(getClass());
return stepService.buildRedirectPathForStep(getClass());
} else {
return documentUi.showAccessDenied(
stepService.getContentSection(),

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