Fixed inconsistiency of canEdit usage in authoring steps

pull/10/head
Jens Pelzetter 2021-12-09 21:02:57 +01:00
parent 5bafec04a3
commit eef4210785
11 changed files with 430 additions and 439 deletions

View File

@ -133,6 +133,7 @@ public abstract class AbstractMvcAuthoringStep implements MvcAuthoringStep {
)
);
documentModel.setContentItem(document);
documentModel.setCanEdit(getCanEdit());
documentPath = itemManager.getItemPath(document);
final Map<String, String> values = new HashMap<>();

View File

@ -45,7 +45,6 @@ import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.Path;
import javax.ws.rs.core.UriBuilder;
/**
@ -140,6 +139,11 @@ public class SelectedDocumentModel {
*/
private boolean excludeDefaultAuthoringSteps;
/**
* Can the current user edit the document.
*/
private boolean canEdit;
/**
* The workflow assigned to the current content item.
*/
@ -186,6 +190,14 @@ public class SelectedDocumentModel {
return excludeDefaultAuthoringSteps;
}
public boolean getCanEdit() {
return canEdit;
}
public void setCanEdit(final boolean canEdit) {
this.canEdit = canEdit;
}
public String getWorkflowName() {
return workflowName;
}

View File

@ -127,8 +127,6 @@ public class MvcArticlePropertiesStep extends AbstractMvcAuthoringStep {
articlePropertiesStepModel.setName(getDocument().getDisplayName());
articlePropertiesStepModel.setCanEdit(getCanEdit());
final Set<Locale> titleLocales = getDocument()
.getTitle()
.getAvailableLocales();

View File

@ -37,8 +37,6 @@ public class MvcArticlePropertiesStepModel {
private String name;
private boolean canEdit;
private Map<String, String> titleValues;
private List<String> unusedTitleLocales;
@ -55,14 +53,6 @@ public class MvcArticlePropertiesStepModel {
this.name = name;
}
public boolean getCanEdit() {
return canEdit;
}
public void setCanEdit(final boolean canEdit) {
this.canEdit = canEdit;
}
public Map<String, String> getTitleValues() {
return Collections.unmodifiableMap(titleValues);
}

View File

@ -222,7 +222,7 @@
</c:otherwise>
</c:choose>
<div class="cms-editor-messages"></div>
<c:if test="#{cc.attrs.hasUnusedLocales}">
<c:if test="#{cc.attrs.hasUnusedLocales and cc.attrs.canEdit}">
<div class="mb-2">
<div class="text-right">
<button

View File

@ -17,6 +17,7 @@
<div class="d-flex mb-3">
<span class="mr-2">#{CmsDefaultStepsMessageBundle['categorization.system.assigned.to']}</span>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<button class="btn btn-primary"
data-target="#edit-categorization-#{tree.domainKey}"
data-toggle="modal"
@ -26,7 +27,9 @@
#{CmsDefaultStepsMessageBundle['categorization.system.assigned.edit']}
</span>
</button>
</c:if>
</div>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<div aria-labelledby="edit-categorization-#{tree.domainKey}-title"
aria-hidden="true"
class="modal fade"
@ -74,6 +77,7 @@
</form>
</div>
</div>
</c:if>
<c:choose>
<c:when test="#{tree.root.assigned or tree.root.subCategoryAssigned}">
@ -91,7 +95,6 @@
</c:otherwise>
</c:choose>
</c:forEach>
</ui:define>

View File

@ -22,6 +22,7 @@
#{CmsDefaultStepsMessageBundle['media.sortmedia.errors.save']}
</div>
</template>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<div class="text-right">
<button class="btn btn-primary"
data-toggle="modal"
@ -87,7 +88,9 @@
</form>
</div>
</div>
</c:if>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<div>
<button class="btn btn-secondary media-save-order-button"
disabled="disabled"
@ -104,6 +107,7 @@
<span>#{CmsDefaultStepsMessageBundle['media.medialists.order.save']}</span>
</button>
</div>
</c:if>
<div id="messages"></div>
<ul class="cms-media-lists mt-3 list-group"
data-baseUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@media-service/save-order">
@ -114,28 +118,30 @@
<div class="d-flex justify-content-between">
<div>#{list.name}</div>
<div class="cms-medialist-buttons d-flex">
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<button class="btn btn-secondary cms-sort-handle mr-2"
type="button">
<bootstrap:svgIcon icon="arrows-move" />
<span class="sr-only">#{CmsDefaultStepsMessageBundle['media.medialists.move.button']}"</span>
</button>
</c:if>
<button class="btn btn-secondary mx-2"
data-toggle="modal"
data-target="#media-list-#{list.name}-info"
data-target="#media-list-#{list.uuid}-info"
type="button">
<bootstrap:svgIcon icon="info-circle" />
<span class="sr-only">#{CmsDefaultStepsMessageBundle['media.medialists.info.button']}"</span>
</button>
<div aria-hidden="true"
aria-labelledby="medialist-#{list.name}-info-title"
aria-labelledby="medialist-#{list.uuid}-info-title"
class="modal fade"
id="media-list-#{list.name}-info"
id="media-list-#{list.uuid}-info"
tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title"
id="medialist-#{list.name}-info-title">
id="medialist-#{list.uuid}-info-title">
#{CmsDefaultStepsMessageBundle.getMessage('media.medialists.info.dialog.title', [list.name])}
</h3>
<button
@ -164,6 +170,7 @@
</div>
</div>
</div>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<a class="btn btn-primary mx-2"
href="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@media/medialists/#{list.name}/@details">
<bootstrap:svgIcon icon="pen" />
@ -193,6 +200,7 @@
contentSection="#{CmsMediaStep.sectionName}"
formParamName="mediaIdentifier"
/>
</c:if>
</div>
</div>
<ul class="cms-medias mt-3 list-group"
@ -234,11 +242,13 @@
<span class="cms-media-label">#{media.title}</span>
</div>
<div class="cms-media-buttons d-flex">
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<button class="btn btn-secondary cms-sort-handle mr-2"
type="button">
<bootstrap:svgIcon icon="arrows-move" />
<span class="sr-only">#{CmsDefaultStepsMessageBundle['media.medialists.media.move.button']}"</span>
</button>
</c:if>
<button class="btn btn-secondary mx-2"
data-toggle="modal"
data-target="#media-#{media.uuid}-info-dialog"
@ -286,6 +296,7 @@
</div>
</div>
</div>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<libreccm:deleteDialog
actionTarget="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@media/medialists/#{list.name}/media/#{media.uuid}/@remove"
buttonLabelClass="sr-only"
@ -297,6 +308,7 @@
dialogTitle="#{CmsDefaultStepsMessageBundle['media.medialists.media.remove.title']}"
message="#{CmsDefaultStepsMessageBundle.getMessage('media.medialists.media.remove.message', [list.name, media.title])}"
/>
</c:if>
</div>
</li>
</c:forEach>
@ -305,6 +317,7 @@
</c:forEach>
</ul>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<div>
<button class="btn btn-secondary media-save-order-button"
disabled="disabled"
@ -321,6 +334,7 @@
<span>#{CmsDefaultStepsMessageBundle['media.medialists.order.save']}</span>
</button>
</div>
</c:if>
</ui:define>
</ui:composition>

View File

@ -22,6 +22,7 @@
#{CmsDefaultStepsMessageBundle['relatedinfo.sortattachments.errors.save']}
</div>
</template>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<div class="text-right">
<button class="btn btn-primary"
data-toggle="modal"
@ -87,7 +88,9 @@
</form>
</div>
</div>
</c:if>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<div>
<button class="btn btn-secondary attachments-save-order-button"
disabled="disabled"
@ -104,6 +107,7 @@
<span>#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.order.save']}</span>
</button>
</div>
</c:if>
<div id="messages"></div>
<ul class="cms-attachment-lists mt-3 list-group"
data-baseUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@relatedinfo-service/save-order">
@ -114,28 +118,30 @@
<div class="d-flex justify-content-between">
<div>#{list.name}</div>
<div class="cms-attachmentlist-buttons d-flex">
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<button class="btn btn-secondary cms-sort-handle mr-2"
type="button">
<bootstrap:svgIcon icon="arrows-move" />
<span class="sr-only">#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.move.button']}"</span>
</button>
</c:if>
<button class="btn btn-secondary mx-2"
data-toggle="modal"
data-target="#attachment-list-#{list.name}-info"
data-target="#attachment-list-#{list.uuid}-info"
type="button">
<bootstrap:svgIcon icon="info-circle" />
<span class="sr-only">#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.info.button']}"</span>
</button>
<div aria-hidden="true"
aria-labelledby="attachmentlist-#{list.name}-info-title"
aria-labelledby="attachmentlist-#{list.uuid}-info-title"
class="modal fade"
id="attachment-list-#{list.name}-info"
id="attachment-list-#{list.uuid}-info"
tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title"
id="attachmentlist-#{list.name}-info-title">
id="attachmentlist-#{list.uuid}-info-title">
#{CmsDefaultStepsMessageBundle.getMessage('relatedinfo.attachmentlists.info.dialog.title', [list.name])}
</h3>
<button
@ -164,6 +170,7 @@
</div>
</div>
</div>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<a class="btn btn-primary mx-2"
href="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@relatedinfo/attachmentlists/#{list.name}/@details">
<bootstrap:svgIcon icon="pen" />
@ -199,6 +206,7 @@
contentSection="#{CmsRelatedInfoStep.sectionName}"
formParamName="assetIdentifier"
/>
</c:if>
</div>
</div>
<ul class="cms-attachments mt-3 list-group"
@ -222,11 +230,13 @@
<span class="cms-attachment-label">#{attachment.title}</span>
</div>
<div class="cms-attachment-buttons d-flex">
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<button class="btn btn-secondary cms-sort-handle mr-2"
type="button">
<bootstrap:svgIcon icon="arrows-move" />
<span class="sr-only">#{CmsDefaultStepsMessageBundle['relatedinfo.attachments.move.button']}"</span>
</button>
</c:if>
<button class="btn btn-secondary mx-2"
data-toggle="modal"
data-target="#attachment-#{attachment.uuid}-info-dialog"
@ -274,6 +284,7 @@
</div>
</div>
</div>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<c:if test="#{attachment.assetType.equals(CmsRelatedInfoStep.relatedLinkType)}">
<a class="btn btn-primary mx-2"
href="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@relatedinfo/attachmentlists/#{list.name}/links/#{attachment.assetUuid}/@details"
@ -293,6 +304,7 @@
dialogTitle="#{CmsDefaultStepsMessageBundle['relatedinfo.attachment.remove.title']}"
message="#{CmsDefaultStepsMessageBundle.getMessage('relatedinfo.attachment.remove.message', [list.name, attachment.title])}"
/>
</c:if>
</div>
</li>
</c:forEach>
@ -301,6 +313,7 @@
</c:forEach>
</ul>
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<div>
<button class="btn btn-secondary attachments-save-order-button"
disabled="disabled"
@ -317,6 +330,7 @@
<span>#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.order.save']}</span>
</button>
</div>
</c:if>
</ui:define>

View File

@ -15,7 +15,7 @@
<h3>#{CmsArticleMessageBundle.getMessage('basicproperties.name.header')}</h3>
<div class="d-flex">
<pre class="mr-2">#{CmsArticlePropertiesStep.name}</pre>
<c:if test="#{CmsArticlePropertiesStep.canEdit}">
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<button class="btn btn-primary btn-sm"
data-toggle="modal"
data-target="#name-edit-dialog"
@ -28,7 +28,7 @@
</c:if>
</div>
<c:if test="#{CmsArticlePropertiesStep.canEdit}">
<c:if test="#{CmsSelectedDocumentModel.canEdit}">
<div aria-hidden="true"
aria-labelledby="name-edit-dialog-title"
class="modal fade"
@ -98,7 +98,7 @@
hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}"
headingLevel="3"
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
readOnly="#{!CmsArticlePropertiesStep.canEdit}"
readOnly="#{!CmsSelectedDocumentModel.canEdit}"
removeButtonLabel="#{CmsArticleMessageBundle['basicproperties.title.remove']}"
removeDialogCancelLabel="#{CmsArticleMessageBundle['basicproperties.title.remove.cancel']}"
removeDialogSubmitLabel="#{CmsArticleMessageBundle['basicproperties.title.remove.submit']}"
@ -132,7 +132,7 @@
hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedDescriptionLocales.isEmpty()}"
headingLevel="3"
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
readOnly="#{!CmsArticlePropertiesStep.canEdit}"
readOnly="#{!CmsSelectedDocumentModel.canEdit}"
removeButtonLabel="#{CmsArticleMessageBundle['basicproperties.description.remove']}"
removeDialogCancelLabel="#{CmsArticleMessageBundle['basicproperties.description.remove.cancel']}"
removeDialogSubmitLabel="#{CmsArticleMessageBundle['basicproperties.description.remove.submit']}"

View File

@ -1,42 +0,0 @@
<!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:librecms="http://xmlns.jcp.org/jsf/composite/components/librecms"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml">
<ui:param name="authoringStep"
value="/libreccm/@contentsections/info/documents/test-article/@article-text" />
<ui:define name="authoringStep">
<h2>#{CmsArticleMessageBundle['textstep.header']}</h2>
<librecms:cmsEditor addButtonLabel="#{CmsArticleMessageBundle['text.editor.add_variant']}"
addDialogLocaleSelectHelp="#{CmsAdminMessages['text.editor.add.locale.help']}"
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-text/add"
editDialogValueHelp="#{CmsAdminMessages['text.editor.edit.value.help']}"
editDialogValueLabel="#{CmsAdminMessages['text.editor.edit.value.label']}"
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-text/edit"
editorId="article-text-editor"
hasUnusedLocales="#{!CmsArticleTextBodyStep.unusedLocales.isEmpty()}"
headingLevel="3"
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-text/remove"
title="#{CmsArticleMessageBundle['text.editor.header']}"
unusedLocales="#{CmsArticleTextBodyStep.unusedLocales}"
variantUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-text-resources/variants"
variants="#{CmsArticleTextBodyStep.variants}"
wordCountUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-text-resources/variants/wordcount"
/>
</ui:define>
<ui:define name="scripts">
<script src="#{request.contextPath}/assets/@content-sections/cms-editor.js"></script>
</ui:define>
</ui:composition>
</html>

View File

@ -17,6 +17,7 @@
addButtonLabel="#{CmsArticleMessageBundle['text.editor.add_variant']}"
addDialogLocaleSelectHelp="#{CmsAdminMessages['text.editor.add.locale.help']}"
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-text/add"
canEdit="#{CmsSelectedDocumentModel.canEdit}"
editorPageUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-text/edit"
hasUnusedLocales="#{!CmsArticleTextBodyStep.unusedLocales.isEmpty()}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-text/remove"