CCM NG/ccm-cms: RelatedInfo step now works
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4990 8810af33-2d31-482b-a856-94f89814c4dfccm-docs
parent
a7c70290c4
commit
7f893066d2
|
|
@ -20,7 +20,6 @@ package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
||||||
|
|
||||||
import com.arsdigita.bebop.Form;
|
import com.arsdigita.bebop.Form;
|
||||||
import com.arsdigita.bebop.FormProcessException;
|
import com.arsdigita.bebop.FormProcessException;
|
||||||
import com.arsdigita.bebop.Page;
|
|
||||||
import com.arsdigita.bebop.PageState;
|
import com.arsdigita.bebop.PageState;
|
||||||
import com.arsdigita.bebop.SaveCancelSection;
|
import com.arsdigita.bebop.SaveCancelSection;
|
||||||
import com.arsdigita.bebop.event.FormInitListener;
|
import com.arsdigita.bebop.event.FormInitListener;
|
||||||
|
|
@ -79,14 +78,14 @@ class RelatedInfoAttachAssetForm
|
||||||
super.addProcessListener(this);
|
super.addProcessListener(this);
|
||||||
super.addSubmissionListener(this);
|
super.addSubmissionListener(this);
|
||||||
}
|
}
|
||||||
|
//
|
||||||
@Override
|
// @Override
|
||||||
public void register(final Page page) {
|
// public void register(final Page page) {
|
||||||
super.register(page);
|
// super.register(page);
|
||||||
|
//
|
||||||
page.addComponentStateParam(this, itemSelectionModel.getStateParameter());
|
// page.addComponentStateParam(this, itemSelectionModel.getStateParameter());
|
||||||
page.addComponentStateParam(this, listSelectionModel.getStateParameter());
|
// page.addComponentStateParam(this, listSelectionModel.getStateParameter());
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(final FormSectionEvent event) throws FormProcessException {
|
public void init(final FormSectionEvent event) throws FormProcessException {
|
||||||
|
|
@ -110,32 +109,36 @@ class RelatedInfoAttachAssetForm
|
||||||
final Object value = searchWidget.getValue(state);
|
final Object value = searchWidget.getValue(state);
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||||
final ItemAttachmentManager attachmentManager = cdiUtil
|
// final ItemAttachmentManager attachmentManager = cdiUtil
|
||||||
.findBean(ItemAttachmentManager.class);
|
// .findBean(ItemAttachmentManager.class);
|
||||||
final AssetRepository assetRepo = cdiUtil
|
// final AssetRepository assetRepo = cdiUtil
|
||||||
.findBean(AssetRepository.class);
|
// .findBean(AssetRepository.class);
|
||||||
final Asset asset = assetRepo
|
// final Asset asset = assetRepo
|
||||||
.findById((long) value)
|
// .findById((long) value)
|
||||||
.orElseThrow(() -> new UnexpectedErrorException(String
|
// .orElseThrow(() -> new UnexpectedErrorException(String
|
||||||
.format("No Asset with ID %d in the database.", value)));
|
// .format("No Asset with ID %d in the database.", value)));
|
||||||
|
|
||||||
final AttachmentList list = listSelectionModel
|
final AttachmentList list = listSelectionModel
|
||||||
.getSelectedAttachmentList(state);
|
.getSelectedAttachmentList(state);
|
||||||
|
|
||||||
attachmentManager.attachAsset(asset, list);
|
// attachmentManager.attachAsset(asset, list);
|
||||||
|
final RelatedInfoStepController controller = cdiUtil
|
||||||
|
.findBean(RelatedInfoStepController.class);
|
||||||
|
controller.attachAsset(list, (long) value);
|
||||||
}
|
}
|
||||||
|
|
||||||
relatedInfoStep.showAttachmentListTable(state);
|
relatedInfoStep.showAttachmentsTable(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void submitted(final FormSectionEvent event) throws
|
public void submitted(final FormSectionEvent event)
|
||||||
FormProcessException {
|
throws FormProcessException {
|
||||||
|
|
||||||
final PageState state = event.getPageState();
|
final PageState state = event.getPageState();
|
||||||
|
|
||||||
listSelectionModel.clearSelection(state);
|
if (saveCancelSection.getCancelButton().isSelected(state)) {
|
||||||
relatedInfoStep.showAttachmentListTable(state);
|
relatedInfoStep.showAttachmentsTable(state);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -211,6 +211,11 @@ public class RelatedInfoStep extends ResettableContainer {
|
||||||
page.addComponentStateParam(this,
|
page.addComponentStateParam(this,
|
||||||
moveAttachmentModel.getStateParameter());
|
moveAttachmentModel.getStateParameter());
|
||||||
|
|
||||||
|
// page.addGlobalStateParam(selectedListModel.getStateParameter());
|
||||||
|
// page.addGlobalStateParam(moveListModel.getStateParameter());
|
||||||
|
// page.addGlobalStateParam(selectedAttachmentModel.getStateParameter());
|
||||||
|
// page.addGlobalStateParam(moveAttachmentModel.getStateParameter());
|
||||||
|
|
||||||
page.setVisibleDefault(listTable, true);
|
page.setVisibleDefault(listTable, true);
|
||||||
page.setVisibleDefault(listForm, false);
|
page.setVisibleDefault(listForm, false);
|
||||||
page.setVisibleDefault(addListLink, true);
|
page.setVisibleDefault(addListLink, true);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,10 @@ package com.arsdigita.cms.ui.authoring.assets.relatedinfo;
|
||||||
import com.arsdigita.kernel.KernelConfig;
|
import com.arsdigita.kernel.KernelConfig;
|
||||||
|
|
||||||
import org.libreccm.configuration.ConfigurationManager;
|
import org.libreccm.configuration.ConfigurationManager;
|
||||||
|
import org.libreccm.core.UnexpectedErrorException;
|
||||||
import org.librecms.assets.RelatedLink;
|
import org.librecms.assets.RelatedLink;
|
||||||
|
import org.librecms.contentsection.Asset;
|
||||||
|
import org.librecms.contentsection.AssetRepository;
|
||||||
import org.librecms.contentsection.AttachmentList;
|
import org.librecms.contentsection.AttachmentList;
|
||||||
import org.librecms.contentsection.AttachmentListManager;
|
import org.librecms.contentsection.AttachmentListManager;
|
||||||
import org.librecms.contentsection.ContentItem;
|
import org.librecms.contentsection.ContentItem;
|
||||||
|
|
@ -47,6 +50,9 @@ import javax.transaction.Transactional;
|
||||||
@RequestScoped
|
@RequestScoped
|
||||||
class RelatedInfoStepController {
|
class RelatedInfoStepController {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private AssetRepository assetRepo;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AttachmentListManager attachmentListManager;
|
private AttachmentListManager attachmentListManager;
|
||||||
|
|
||||||
|
|
@ -299,6 +305,24 @@ class RelatedInfoStepController {
|
||||||
itemAttachmentManager.attachAsset(link, attachmentList);
|
itemAttachmentManager.attachAsset(link, attachmentList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(Transactional.TxType.REQUIRED)
|
||||||
|
protected void attachAsset(final AttachmentList attachmentList,
|
||||||
|
final long assetId) {
|
||||||
|
|
||||||
|
final Asset asset = assetRepo
|
||||||
|
.findById(assetId)
|
||||||
|
.orElseThrow(() -> new UnexpectedErrorException(String
|
||||||
|
.format("No Asset with ID %d in the database.", assetId)));
|
||||||
|
|
||||||
|
final AttachmentList list = attachmentListManager
|
||||||
|
.getAttachmentList(attachmentList.getListId())
|
||||||
|
.orElseThrow(() -> new UnexpectedErrorException(String
|
||||||
|
.format("No AttachmentList with ID %d in the database.",
|
||||||
|
attachmentList.getListId())));
|
||||||
|
|
||||||
|
itemAttachmentManager.attachAsset(asset, list);
|
||||||
|
}
|
||||||
|
|
||||||
private AttachmentListTableRow buildAttachmentListTableRow(
|
private AttachmentListTableRow buildAttachmentListTableRow(
|
||||||
final AttachmentList attachmentList,
|
final AttachmentList attachmentList,
|
||||||
final Locale selectedLocale) {
|
final Locale selectedLocale) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue