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