Authoring Step for text body

pull/10/head
Jens Pelzetter 2021-03-22 20:35:29 +01:00
parent b584b895d6
commit 6070c6aae1
3 changed files with 47 additions and 2 deletions

View File

@ -21,16 +21,18 @@ import javax.ws.rs.Path;
import org.librecms.ui.contentsections.documents.MvcAuthoringStep; import org.librecms.ui.contentsections.documents.MvcAuthoringStep;
import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import javax.ws.rs.FormParam; import javax.ws.rs.FormParam;
import javax.ws.rs.POST; import javax.ws.rs.POST;
import javax.ws.rs.PathParam; import javax.ws.rs.PathParam;
import static org.librecms.ui.contenttypes.MvcArticlePropertiesStep.PATH_FRAGMENT;
/** /**
* *
@ -40,9 +42,10 @@ import static org.librecms.ui.contenttypes.MvcArticlePropertiesStep.PATH_FRAGMEN
@Controller @Controller
@Path("/") @Path("/")
@AuthoringStepPathFragment(MvcArticleTextBodyStep.PATH_FRAGMENT) @AuthoringStepPathFragment(MvcArticleTextBodyStep.PATH_FRAGMENT)
@Named("CmsArticleTextBodyStep")
public class MvcArticleTextBodyStep implements MvcAuthoringStep { public class MvcArticleTextBodyStep implements MvcAuthoringStep {
static final String PATH_FRAGMENT = "basicproperties"; static final String PATH_FRAGMENT = "text";
@Inject @Inject
private ContentItemRepository itemRepo; private ContentItemRepository itemRepo;
@ -147,6 +150,18 @@ public class MvcArticleTextBodyStep implements MvcAuthoringStep {
) )
); );
} }
public List<String> getUnusedLocales() {
final Set<Locale> locales = document
.getText()
.getAvailableLocales();
return globalizationHelper
.getAvailableLocales()
.stream()
.filter(locale -> !locales.contains(locale))
.map(Locale::toString)
.collect(Collectors.toList());
}
@POST @POST
@Path("/@add") @Path("/@add")

View File

@ -41,6 +41,7 @@
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/title/@edit" editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/title/@edit"
editorId="title-editor" editorId="title-editor"
hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}" hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}"
headingLevel="3"
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}" objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/title/@remove" removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/title/@remove"
title="#{CmsArticleMessageBundle['basicproperties.title.header']}" title="#{CmsArticleMessageBundle['basicproperties.title.header']}"
@ -53,11 +54,13 @@
editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/description/@edit" editMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/description/@edit"
editorId="description-editor" editorId="description-editor"
hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}" hasUnusedLocales="#{!CmsArticlePropertiesStep.unusedTitleLocales.isEmpty()}"
headingLevel="3"
objectIdentifier="#{CmsSelectedDocumentModel.itemPath}" objectIdentifier="#{CmsSelectedDocumentModel.itemPath}"
removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/description/@remove" removeMethod="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@authoringsteps/basicproperties/description/@remove"
title="#{CmsArticleMessageBundle['basicproperties.description.header']}" title="#{CmsArticleMessageBundle['basicproperties.description.header']}"
unusedLocales="#{CmsArticlePropertiesStep.unusedTitleLocales}" unusedLocales="#{CmsArticlePropertiesStep.unusedTitleLocales}"
values="#{CmsArticlePropertiesStep.descriptionValues}" values="#{CmsArticlePropertiesStep.descriptionValues}"
useTextarea="true"
/> />
</ui:composition> </ui:composition>

View File

@ -0,0 +1,27 @@
<!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/documents/authoringstep.xhtml">
<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}"
/>
</ui:composition>
</html>