Some bugfixing
parent
e8b9d5940b
commit
1abf3d96a1
|
|
@ -88,6 +88,8 @@ public abstract class AbstractMvcAuthoringStep implements MvcAuthoringStep {
|
|||
|
||||
private String documentPath;
|
||||
|
||||
private String stepPath;
|
||||
|
||||
/**
|
||||
* Inits the step. This method MUST be called by all resource methods (all
|
||||
* methods annotated with {@link Path} in an authoring step. This is
|
||||
|
|
@ -128,8 +130,29 @@ public abstract class AbstractMvcAuthoringStep implements MvcAuthoringStep {
|
|||
documentModel.setContentItem(document);
|
||||
|
||||
this.documentPath = itemManager.getItemPath(document);
|
||||
final Map<String, String> values = new HashMap<>();
|
||||
values.put(
|
||||
MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM,
|
||||
contentSection.getLabel()
|
||||
);
|
||||
values.put(
|
||||
MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME,
|
||||
documentPath
|
||||
);
|
||||
|
||||
stepPath = Optional
|
||||
.ofNullable(getStepClass().getAnnotation(Path.class))
|
||||
.map(Path::value)
|
||||
.map(
|
||||
path -> UriBuilder
|
||||
.fromPath(path)
|
||||
.buildFromMap(values)
|
||||
.toString()
|
||||
)
|
||||
.orElse("");
|
||||
|
||||
models.put("activeDocumentTab", "editTab");
|
||||
models.put("stepPath", stepPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -229,52 +252,7 @@ public abstract class AbstractMvcAuthoringStep implements MvcAuthoringStep {
|
|||
|
||||
@Override
|
||||
public String getStepPath() {
|
||||
final ContentSection section = Optional
|
||||
.ofNullable(contentSection)
|
||||
.orElseThrow(
|
||||
() -> new WebApplicationException(
|
||||
String.format(
|
||||
"Authoring Step %s was not initalized properly. "
|
||||
+ "Did you forget to call %s#init()?",
|
||||
getStepClass().getName(),
|
||||
AbstractMvcAuthoringStep.class.getName()
|
||||
)
|
||||
)
|
||||
);
|
||||
final String docPath = Optional
|
||||
.ofNullable(documentPath)
|
||||
.map(this::withoutLeadingSlash)
|
||||
.orElseThrow(
|
||||
() -> new WebApplicationException(
|
||||
String.format(
|
||||
"Authoring Step %s was not initalized properly. "
|
||||
+ "Did you forget to call %s#init()?",
|
||||
getStepClass().getName(),
|
||||
AbstractMvcAuthoringStep.class.getName()
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
final Map<String, String> values = new HashMap<>();
|
||||
values.put(
|
||||
MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM,
|
||||
section.getLabel()
|
||||
);
|
||||
values.put(
|
||||
MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME,
|
||||
docPath
|
||||
);
|
||||
|
||||
return Optional
|
||||
.ofNullable(getStepClass().getAnnotation(Path.class))
|
||||
.map(Path::value)
|
||||
.map(
|
||||
path -> UriBuilder
|
||||
.fromPath(path)
|
||||
.buildFromMap(values)
|
||||
.toString()
|
||||
)
|
||||
.orElse("");
|
||||
return stepPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -50,13 +50,15 @@ import javax.ws.rs.PathParam;
|
|||
|
||||
import org.librecms.ui.contentsections.documents.MvcAuthoringStepDef;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* Authoring step for editing the main text of an {@link Article}.
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@RequestScoped
|
||||
@Path(MvcAuthoringSteps.PATH_PREFIX + "text")
|
||||
@Path(MvcAuthoringSteps.PATH_PREFIX + "article-text")
|
||||
@Controller
|
||||
@Named("CmsArticleTextBodyStep")
|
||||
@MvcAuthoringStepDef(
|
||||
|
|
@ -88,6 +90,10 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
|
|||
@Inject
|
||||
private ItemPermissionChecker itemPermissionChecker;
|
||||
|
||||
private Map<String, String> textValues;
|
||||
|
||||
private List<String> unusedLocales;
|
||||
|
||||
@Override
|
||||
public Class<MvcArticleTextBodyStep> getStepClass() {
|
||||
return MvcArticleTextBodyStep.class;
|
||||
|
|
@ -111,6 +117,28 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
|
|||
}
|
||||
|
||||
if (itemPermissionChecker.canEditItem(getArticle())) {
|
||||
textValues = getArticle()
|
||||
.getText()
|
||||
.getValues()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
entry -> entry.getKey().toString(),
|
||||
entry -> entry.getValue()
|
||||
)
|
||||
);
|
||||
|
||||
final Set<Locale> locales = getArticle()
|
||||
.getText()
|
||||
.getAvailableLocales();
|
||||
unusedLocales = globalizationHelper
|
||||
.getAvailableLocales()
|
||||
.stream()
|
||||
.filter(locale -> !locales.contains(locale))
|
||||
.map(Locale::toString)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return "org/librecms/ui/contenttypes/article/article-text.xhtml";
|
||||
} else {
|
||||
return documentUi.showAccessDenied(
|
||||
|
|
@ -127,17 +155,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
|
|||
* @return The localized values of the main text.
|
||||
*/
|
||||
public Map<String, String> getTextValues() {
|
||||
return getArticle()
|
||||
.getText()
|
||||
.getValues()
|
||||
.entrySet()
|
||||
.stream()
|
||||
.collect(
|
||||
Collectors.toMap(
|
||||
entry -> entry.getKey().toString(),
|
||||
entry -> entry.getValue()
|
||||
)
|
||||
);
|
||||
return Collections.unmodifiableMap(textValues);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -146,15 +164,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
|
|||
* @return The locales for which the main text has not been defined yet.
|
||||
*/
|
||||
public List<String> getUnusedLocales() {
|
||||
final Set<Locale> locales = getArticle()
|
||||
.getText()
|
||||
.getAvailableLocales();
|
||||
return globalizationHelper
|
||||
.getAvailableLocales()
|
||||
.stream()
|
||||
.filter(locale -> !locales.contains(locale))
|
||||
.map(Locale::toString)
|
||||
.collect(Collectors.toList());
|
||||
return Collections.unmodifiableList(unusedLocales);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -257,7 +267,7 @@ public class MvcArticleTextBodyStep extends AbstractMvcAuthoringStep {
|
|||
@POST
|
||||
@Path("/@remove/{locale}")
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
public String remvoeTextValue(
|
||||
public String removeTextValue(
|
||||
@PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM)
|
||||
final String sectionIdentifier,
|
||||
@PathParam(MvcAuthoringSteps.DOCUMENT_PATH_PATH_PARAM_NAME)
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@
|
|||
method="post">
|
||||
<input name="returnUrl"
|
||||
type="hidden"
|
||||
value="#{CmsArticlePropertiesStep.stepPath}" />
|
||||
value="#{stepPath}" />
|
||||
|
||||
<button class="btn btn-primary"
|
||||
type="submit">
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
method="post">
|
||||
<input name="returnUrl"
|
||||
type="hidden"
|
||||
value="#{CmsArticlePropertiesStep.stepPath}" />
|
||||
value="#{stepPath}" />
|
||||
<button class="btn btn-secondary btn-sm"
|
||||
type="submit">
|
||||
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.release']}
|
||||
|
|
@ -75,7 +75,7 @@
|
|||
method="post">
|
||||
<input name="returnUrl"
|
||||
type="hidden"
|
||||
value="#{CmsArticlePropertiesStep.stepPath}" />
|
||||
value="#{stepPath}" />
|
||||
<button class="btn btn-secondary btn-sm"
|
||||
type="submit">
|
||||
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.finish']}
|
||||
|
|
@ -88,7 +88,7 @@
|
|||
method="post">
|
||||
<input name="returnUrl"
|
||||
type="hidden"
|
||||
value="#{CmsArticlePropertiesStep.stepPath}" />
|
||||
value="#{stepPath}" />
|
||||
<button class="btn btn-secondary btn-sm"
|
||||
type="submit">
|
||||
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.takeover']}
|
||||
|
|
@ -101,7 +101,7 @@
|
|||
method="post">
|
||||
<input name="returnUrl"
|
||||
type="hidden"
|
||||
value="#{CmsArticlePropertiesStep.stepPath}" />
|
||||
value="#{stepPath}" />
|
||||
<button class="btn btn-secondary btn-sm"
|
||||
type="submit">
|
||||
#{CmsAdminMessages['contentsection.document.authoring.workflow.active_task.lock']}
|
||||
|
|
|
|||
|
|
@ -6,21 +6,23 @@
|
|||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml">
|
||||
|
||||
<h2>#{CmsArticleMessageBundle['textstep.header']}</h2>
|
||||
<ui:define name="authoringStep">
|
||||
<h2>#{CmsArticleMessageBundle['textstep.header']}</h2>
|
||||
|
||||
<libreccm:localizedStringEditor
|
||||
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/text/@add"
|
||||
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/text/@edit"
|
||||
editorId="article-text-editor"
|
||||
hasUnusedLocales="#{!CmsArticleTextBodyStep.unusedLocales.isEmpty()}"
|
||||
headingLevel="3"
|
||||
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
|
||||
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/text/@remove"
|
||||
title="#{CmsArticleMessageBundle['text.editor.header']}"
|
||||
unusedLocales="#{CmsArticleTextBodyStep.unusedLocales}"
|
||||
useTextarea="true"
|
||||
values="#{CmsArticleTextBodyStep.textValues}"
|
||||
/>
|
||||
<libreccm:localizedStringEditor
|
||||
addMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@article-text/add"
|
||||
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}"
|
||||
useTextarea="true"
|
||||
values="#{CmsArticleTextBodyStep.textValues}"
|
||||
/>
|
||||
</ui:define>
|
||||
|
||||
</ui:composition>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in New Issue