CCM NG/ccm-cms: Adding and removing images
git-svn-id: https://svn.libreccm.org/ccm/ccm_ng@4900 8810af33-2d31-482b-a856-94f89814c4df
Former-commit-id: 5ac7e51438
pull/2/head
parent
e51a65857d
commit
4eb0e720d2
|
|
@ -85,7 +85,7 @@ class AssignedImagesTable extends Table {
|
|||
"cms.ui.authoring.assets.imagestep.assigned_images.properties_header",
|
||||
CmsConstants.CMS_BUNDLE))));
|
||||
columnModel.add(new TableColumn(
|
||||
COL_IMAGE_DATA,
|
||||
COL_CAPTION,
|
||||
new Label(new GlobalizedMessage(
|
||||
"cms.ui.authoring.assets.imagestep.assigned_images.caption_header",
|
||||
CmsConstants.CMS_BUNDLE))));
|
||||
|
|
@ -95,7 +95,7 @@ class AssignedImagesTable extends Table {
|
|||
"cms.ui.authoring.assets.imagestep.assigned_images.move_header",
|
||||
CmsConstants.CMS_BUNDLE))));
|
||||
columnModel.add(new TableColumn(
|
||||
COL_IMAGE_DATA,
|
||||
COL_REMOVE,
|
||||
new Label(new GlobalizedMessage(
|
||||
"cms.ui.authoring.assets.imagestep.assigned_images.remove_header",
|
||||
CmsConstants.CMS_BUNDLE))));
|
||||
|
|
@ -151,15 +151,14 @@ class AssignedImagesTable extends Table {
|
|||
.parseLong((String) event.getRowKey());
|
||||
|
||||
controller.moveAfter(selectedAttachment, destId);
|
||||
|
||||
}
|
||||
break;
|
||||
case COL_REMOVE:
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final ImageStepController controller = cdiUtil
|
||||
.findBean(ImageStepController.class);
|
||||
controller.deleteAttachment(moveAttachmentModel
|
||||
.getSelectedAttachment(state));
|
||||
controller.deleteAttachment(Long
|
||||
.parseLong((String) event.getRowKey()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ class AssignedImagesTableModel implements TableModel {
|
|||
switch (columnIndex) {
|
||||
case AssignedImagesTable.COL_PREVIEW:
|
||||
return String
|
||||
.format("%s/content-.sections/%s/images/"
|
||||
.format("%s/content-sections/%s/images/"
|
||||
+ "uuid-%s?width=150&height=100",
|
||||
CCMDispatcherServlet.getContextPath(),
|
||||
CMS.getContext().getContentSection().getLabel(),
|
||||
|
|
|
|||
|
|
@ -151,7 +151,15 @@ class AvailableImages extends BoxPanel {
|
|||
public void cellSelected(final TableActionEvent event)
|
||||
throws FormProcessException {
|
||||
|
||||
final long imageId = (long) event.getRowKey();
|
||||
final Object rowKey = event.getRowKey();
|
||||
final long imageId;
|
||||
if (rowKey instanceof Long) {
|
||||
imageId = (Long) event.getRowKey();
|
||||
} else if(rowKey instanceof String) {
|
||||
imageId = Long.parseLong((String) rowKey);
|
||||
} else {
|
||||
imageId = Long.parseLong(rowKey.toString());
|
||||
}
|
||||
|
||||
final CdiUtil cdiUtil = CdiUtil.createCdiUtil();
|
||||
final ImageStepController controller = cdiUtil
|
||||
|
|
|
|||
|
|
@ -257,6 +257,18 @@ class ImageStepController {
|
|||
entityManager.merge(toMove);
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected void deleteAttachment(final long attachmentId) {
|
||||
|
||||
final ItemAttachment<?> attachment = attachmentManager
|
||||
.findById(attachmentId)
|
||||
.orElseThrow(() -> new IllegalArgumentException(String
|
||||
.format("No ItemAttachment with ID %d in the database.",
|
||||
attachmentId)));
|
||||
|
||||
deleteAttachment(attachment);
|
||||
}
|
||||
|
||||
@Transactional(Transactional.TxType.REQUIRED)
|
||||
protected void deleteAttachment(final ItemAttachment<?> attachment) {
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ public class AssetRepository
|
|||
final Class<T> type) {
|
||||
|
||||
final TypedQuery<Asset> query = getEntityManager()
|
||||
.createNamedQuery("assetId", Asset.class)
|
||||
.createNamedQuery("Asset.findByIdAndType", Asset.class)
|
||||
.setParameter("assetId", assetId)
|
||||
.setParameter("type", type);
|
||||
setAuthorizationParameters(query);
|
||||
|
|
|
|||
|
|
@ -197,7 +197,12 @@ public class AttachmentListManager {
|
|||
item.getClass());
|
||||
|
||||
final List<AttachmentList> lists = draft.getAttachments();
|
||||
final long lastOrder = lists.get(lists.size() - 1).getOrder();
|
||||
final long lastOrder;
|
||||
if (lists.isEmpty()) {
|
||||
lastOrder = 0;
|
||||
} else {
|
||||
lastOrder = lists.get(lists.size() - 1).getOrder();
|
||||
}
|
||||
|
||||
final AttachmentList list = new AttachmentList();
|
||||
list.setItem(draft);
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ public class ItemAttachmentManager {
|
|||
|
||||
final TypedQuery<ItemAttachment> query = entityManager
|
||||
.createNamedQuery("ItemAttachment.findById", ItemAttachment.class);
|
||||
query.setParameter("attachmentId", attachmentId);
|
||||
try {
|
||||
return Optional.of(query.getSingleResult());
|
||||
} catch (NoResultException ex) {
|
||||
|
|
|
|||
|
|
@ -413,3 +413,4 @@ cms.ui.authoring.assets.imagestep.available_images.none=No images available
|
|||
cms.ui.authoring.assets.imagestep.available_images.title_header=Title
|
||||
cms.ui.authoring.assets.imagestep.available_images.add=Add
|
||||
cms.ui.authoring.assets.imagestep.assigned_images.title_header=Title
|
||||
cms.ui.authoring.assets.imagestep.assigned_images.remove=Remove
|
||||
|
|
|
|||
|
|
@ -410,3 +410,4 @@ cms.ui.authoring.assets.imagestep.available_images.none=Keine Bilder verf\u00fcg
|
|||
cms.ui.authoring.assets.imagestep.available_images.title_header=Titel
|
||||
cms.ui.authoring.assets.imagestep.available_images.add=Hinzuf\u00fcgen
|
||||
cms.ui.authoring.assets.imagestep.assigned_images.title_header=Titel
|
||||
cms.ui.authoring.assets.imagestep.assigned_images.remove=Entfernen
|
||||
|
|
|
|||
|
|
@ -369,3 +369,4 @@ cms.ui.authoring.assets.imagestep.available_images.none=No images available
|
|||
cms.ui.authoring.assets.imagestep.available_images.title_header=Title
|
||||
cms.ui.authoring.assets.imagestep.available_images.add=Add
|
||||
cms.ui.authoring.assets.imagestep.assigned_images.title_header=Title
|
||||
cms.ui.authoring.assets.imagestep.assigned_images.remove=Remove
|
||||
|
|
|
|||
Loading…
Reference in New Issue