diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/FileDetailsModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/FileDetailsModel.java new file mode 100644 index 000000000..e0c45150f --- /dev/null +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/FileDetailsModel.java @@ -0,0 +1,88 @@ +/* + * Copyright (C) 2021 LibreCCM Foundation. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + */ +package org.librecms.ui.contentsections.documents.relatedinfo; + +import javax.enterprise.context.RequestScoped; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("CmsFileDetailsModel") +public class FileDetailsModel { + + private String baseUrl; + + /** + * The identifier of the {@link AttachmentList} of the link. + */ + private String listIdentifier; + + /** + * The UUID of the link. + */ + private String uuid; + + private String name; + + private String sectionName; + + public String getBaseUrl() { + return baseUrl; + } + + public void setBaseUrl(final String baseUrl) { + this.baseUrl = baseUrl; + } + + public String getListIdentifier() { + return listIdentifier; + } + + public void setListIdentifier(final String listIdentifier) { + this.listIdentifier = listIdentifier; + } + + public String getUuid() { + return uuid; + } + + public void setUuid(final String uuid) { + this.uuid = uuid; + } + + public String getName() { + return name; + } + + public void setName(final String name) { + this.name = name; + } + + public String getSectionName() { + return sectionName; + } + + public void setSectionName(final String sectionName) { + this.sectionName = sectionName; + } + +} diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStep.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStep.java index f9ffc887c..bf5cc1301 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStep.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStep.java @@ -27,6 +27,7 @@ import org.libreccm.security.PermissionChecker; import org.libreccm.ui.BaseUrl; import org.librecms.assets.AssetTypesManager; import org.librecms.assets.Bookmark; +import org.librecms.assets.FileAsset; import org.librecms.assets.RelatedLink; import org.librecms.contentsection.Asset; import org.librecms.contentsection.AssetManager; @@ -116,6 +117,9 @@ public class RelatedInfoStep extends AbstractMvcAuthoringStep { @Inject private AssetTypesManager assetTypesManager; + @Inject + private BaseUrl baseUrl; + /** * Model for the details view of an {@link AttachmentList}. */ @@ -143,6 +147,9 @@ public class RelatedInfoStep extends AbstractMvcAuthoringStep { @Context private HttpServletRequest request; + @Inject + private FileDetailsModel fileDetailsModel; + /** * Model for the details view of an internal {@link RelatedLink}. */ @@ -206,6 +213,11 @@ public class RelatedInfoStep extends AbstractMvcAuthoringStep { .map(this::buildAttachmentListDto) .collect(Collectors.toList()) ); + relatedInfoStepModel.setFileAssetPickerBaseUrl( + baseUrl.getBaseUrl(request) + ); + + relatedInfoStepModel.setSectionName(getContentSection().getLabel()); } @GET @@ -888,7 +900,7 @@ public class RelatedInfoStep extends AbstractMvcAuthoringStep { * @return A redirect to the list of attachment lists and attachments. */ @POST - @Path("/attachmentlists/{attachmentListIdentifier}/attachments") + @Path("/attachmentlists/{attachmentListIdentifier}/attachments/@create") @Transactional(Transactional.TxType.REQUIRED) public String createAttachment( @PathParam(MvcAuthoringSteps.SECTION_IDENTIFIER_PATH_PARAM) @@ -1387,7 +1399,8 @@ public class RelatedInfoStep extends AbstractMvcAuthoringStep { final Optional bookmarkResult; final Identifier bookmarkIdentifer = identifierParser - .parseIdentifier(targetBookmarkIdentifier); + .parseIdentifier(targetBookmarkIdentifier + ); switch (bookmarkIdentifer.getType()) { case ID: bookmarkResult = assetRepo @@ -1442,7 +1455,7 @@ public class RelatedInfoStep extends AbstractMvcAuthoringStep { assetRepo.save(link); return buildRedirectPathForStep( - String.format( + String.format( "/attachmentlists/%s/links/%s/@details", list.getName(), link.getUuid() diff --git a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStepModel.java b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStepModel.java index b369a7a4e..f9e9db48b 100644 --- a/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStepModel.java +++ b/ccm-cms/src/main/java/org/librecms/ui/contentsections/documents/relatedinfo/RelatedInfoStepModel.java @@ -18,6 +18,9 @@ */ package org.librecms.ui.contentsections.documents.relatedinfo; +import org.librecms.assets.FileAsset; +import org.librecms.contentsection.AttachmentList; + import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -32,10 +35,14 @@ import javax.inject.Named; @RequestScoped @Named("CmsRelatedInfoStep") public class RelatedInfoStepModel { - - private List attachmentsLists; - - /** + + private List attachmentsLists; + + private String fileAssetPickerBaseUrl; + + private String sectionName; + + /** * Gets the {@link AttachmentList}s of the current content item and converts * them to {@link AttachmentListDto}s to make data about the lists available * in the views. @@ -45,11 +52,39 @@ public class RelatedInfoStepModel { public List getAttachmentLists() { return Collections.unmodifiableList(attachmentsLists); } - + + public List getAttachmentsLists() { + return attachmentsLists; + } + + public void setAttachmentsLists(List attachmentsLists) { + this.attachmentsLists = attachmentsLists; + } + protected void setAttachmentLists( final List attachmentLists ) { this.attachmentsLists = new ArrayList<>(attachmentLists); } - + + public String getFileAssetType() { + return FileAsset.class.getName(); + } + + public String getFileAssetPickerBaseUrl() { + return fileAssetPickerBaseUrl; + } + + public void setFileAssetPickerBaseUrl(final String fileAssetPickerBaseUrl) { + this.fileAssetPickerBaseUrl = fileAssetPickerBaseUrl; + } + + public String getSectionName() { + return sectionName; + } + + public void setSectionName(final String sectionName) { + this.sectionName = sectionName; + } + } diff --git a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml index 52dd356e4..399d1c4d8 100644 --- a/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml +++ b/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/documents/relatedinfo.xhtml @@ -1,6 +1,7 @@ ]> @@ -420,18 +421,31 @@ #{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.edit.button']}" - + + + - #{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.link.add.label']} + #{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.link.add.label']}