Implemented adding file attachments (not tested yet)
parent
16bdc50f0e
commit
9a9e5dc767
|
|
@ -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 <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
@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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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<Bookmark> 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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -33,9 +36,13 @@ import javax.inject.Named;
|
|||
@Named("CmsRelatedInfoStep")
|
||||
public class RelatedInfoStepModel {
|
||||
|
||||
private List<AttachmentListDto> attachmentsLists;
|
||||
private List<AttachmentListDto> 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.
|
||||
|
|
@ -46,10 +53,38 @@ public class RelatedInfoStepModel {
|
|||
return Collections.unmodifiableList(attachmentsLists);
|
||||
}
|
||||
|
||||
public List<AttachmentListDto> getAttachmentsLists() {
|
||||
return attachmentsLists;
|
||||
}
|
||||
|
||||
public void setAttachmentsLists(List<AttachmentListDto> attachmentsLists) {
|
||||
this.attachmentsLists = attachmentsLists;
|
||||
}
|
||||
|
||||
protected void setAttachmentLists(
|
||||
final List<AttachmentListDto> 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
<!DOCTYPE html [<!ENTITY times '×'>]>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||
xmlns:bootstrap="http://xmlns.jcp.org/jsf/composite/components/bootstrap"
|
||||
xmlns:librecms="http://xmlns.jcp.org/jsf/composite/components/librecms"
|
||||
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||
<ui:composition template="/WEB-INF/views/org/librecms/ui/contentsection/documents/authoringstep.xhtml">
|
||||
|
|
@ -420,18 +421,31 @@
|
|||
<bootstrap:svgIcon icon="pen" />
|
||||
<span class="sr-only">#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.edit.button']}"</span>
|
||||
</a>
|
||||
<button class="btn btn-primary"
|
||||
data-target="#attachmentlist-#{list.name}-add-attachment-dialog"
|
||||
data-toggle="modal"
|
||||
type="button">
|
||||
<bootstrap:svgIcon icon="file-earmark-plus" />
|
||||
<span class="sr-only">#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.attachment.add.label']}</span>
|
||||
</button>
|
||||
<librecms:assetPickerButton
|
||||
assetPickerId="attach-file-picker"
|
||||
buttonIcon="file-earmark-plus"
|
||||
buttonText="#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.attachment.add.label']}"
|
||||
/>
|
||||
<librecms:assetPicker
|
||||
actionUrl="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@relatedinfo/attachmentlists/#{list.name}/attachments/@create"
|
||||
assetType="#{CmsRelatedInfoStep.fileAssetType}"
|
||||
assetPickerId="attach-file-picker"
|
||||
baseUrl="#{CmsRelatedInfoStep.fileAssetPickerBaseUrl}"
|
||||
contentSection="#{CmsRelatedInfoStep.sectionName}"
|
||||
formParamName="assetUuid"
|
||||
/>
|
||||
<!-- <button class="btn btn-primary"
|
||||
data-target="#attachmentlist-#{list.name}-add-attachment-dialog"
|
||||
data-toggle="modal"
|
||||
type="button">
|
||||
<bootstrap:svgIcon icon="file-earmark-plus" />
|
||||
<span class="sr-only">#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.attachment.add.label']}</span>
|
||||
</button>-->
|
||||
<a class="btn btn-primary"
|
||||
href="#{mvc.basePath}/#{ContentSectionModel.sectionName}/documents/#{CmsSelectedDocumentModel.itemPath}/@relatedinfo/attachmentlists/#{list.name}/links/@create"
|
||||
type="button">
|
||||
<bootstrap:svgIcon icon="bookmark-plus" />
|
||||
<span>#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.link.add.label']}</span>
|
||||
<span class="sr-only">#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.link.add.label']}</span>
|
||||
</a>
|
||||
<button class="btn btn-danger"
|
||||
type="button">
|
||||
|
|
|
|||
Loading…
Reference in New Issue