RelatedInfo step save sort works now, cleanup

pull/10/head
Jens Pelzetter 2021-07-31 15:05:56 +02:00
parent 7eaba5ee31
commit 0b2f844e49
14 changed files with 1043 additions and 946 deletions

View File

@ -114,11 +114,11 @@ class RelatedInfoStepController {
.sorted((list1, list2) -> list1.compareTo(list2)) .sorted((list1, list2) -> list1.compareTo(list2))
.collect(Collectors.toList()); .collect(Collectors.toList());
toMove.setOrder(0); toMove.setListOrder(0);
lists lists
.stream() .stream()
.filter(current -> !current.equals(toMove)) .filter(current -> !current.equals(toMove))
.forEach(current -> current.setOrder(current.getOrder() + 1)); .forEach(current -> current.setListOrder(current.getListOrder() + 1));
lists.forEach(entityManager::merge); lists.forEach(entityManager::merge);
} }
@ -207,11 +207,11 @@ class RelatedInfoStepController {
final int afterIndex = lists.indexOf(after); final int afterIndex = lists.indexOf(after);
for (int i = afterIndex + 1; i < lists.size(); i++) { for (int i = afterIndex + 1; i < lists.size(); i++) {
final AttachmentList current = lists.get(i); final AttachmentList current = lists.get(i);
current.setOrder(current.getOrder() + 1); current.setListOrder(current.getListOrder() + 1);
entityManager.merge(current); entityManager.merge(current);
} }
toMove.setOrder(afterIndex + 1); toMove.setListOrder(afterIndex + 1);
entityManager.merge(toMove); entityManager.merge(toMove);
} }

View File

@ -85,7 +85,7 @@ import static org.librecms.CmsConstants.DB_SCHEMA;
query = "SELECT l FROM AttachmentList l " query = "SELECT l FROM AttachmentList l "
+ "WHERE l.name = :name " + "WHERE l.name = :name "
+ "AND l.item = :item " + "AND l.item = :item "
+ "ORDER BY l.order") + "ORDER BY l.listOrder")
}) })
public class AttachmentList implements Comparable<AttachmentList>, public class AttachmentList implements Comparable<AttachmentList>,
Identifiable, Identifiable,
@ -121,11 +121,11 @@ public class AttachmentList implements Comparable<AttachmentList>,
private String name; private String name;
/** /**
* A order index for ordering multiple attachment lists with the same * A listOrder index for ordering multiple attachment lists with the same
* {@link #name}. {@link #name}.
*/ */
@Column(name = "LIST_ORDER") @Column(name = "LIST_ORDER")
private long order; private long listOrder;
/** /**
* The localised title of the list. * The localised title of the list.
@ -201,12 +201,12 @@ public class AttachmentList implements Comparable<AttachmentList>,
this.name = name; this.name = name;
} }
public long getOrder() { public long getListOrder() {
return order; return listOrder;
} }
public void setOrder(final long order) { public void setListOrder(final long listOrder) {
this.order = order; this.listOrder = listOrder;
} }
public LocalizedString getTitle() { public LocalizedString getTitle() {
@ -254,7 +254,7 @@ public class AttachmentList implements Comparable<AttachmentList>,
final int nameCompare = name.compareTo(other.getName()); final int nameCompare = name.compareTo(other.getName());
if (nameCompare == 0) { if (nameCompare == 0) {
return Long.compare(order, other.getOrder()); return Long.compare(listOrder, other.getListOrder());
} else { } else {
return nameCompare; return nameCompare;
} }
@ -266,7 +266,7 @@ public class AttachmentList implements Comparable<AttachmentList>,
hash = 29 * hash + (int) (listId ^ (listId >>> 32)); hash = 29 * hash + (int) (listId ^ (listId >>> 32));
hash = 29 * hash + Objects.hashCode(uuid); hash = 29 * hash + Objects.hashCode(uuid);
hash = 29 * hash + Objects.hashCode(name); hash = 29 * hash + Objects.hashCode(name);
hash = 29 * hash + (int) (order ^ (order >>> 32)); hash = 29 * hash + (int) (listOrder ^ (listOrder >>> 32));
hash = 29 * hash + Objects.hashCode(title); hash = 29 * hash + Objects.hashCode(title);
hash = 29 * hash + Objects.hashCode(description); hash = 29 * hash + Objects.hashCode(description);
hash = 29 * hash + Objects.hashCode(attachments); hash = 29 * hash + Objects.hashCode(attachments);
@ -299,7 +299,7 @@ public class AttachmentList implements Comparable<AttachmentList>,
System.out.println("uuid is not equal"); System.out.println("uuid is not equal");
return false; return false;
} }
if (order != other.getOrder()) { if (listOrder != other.getListOrder()) {
return false; return false;
} }
if (!Objects.equals(name, other.getName())) { if (!Objects.equals(name, other.getName())) {
@ -344,7 +344,7 @@ public class AttachmentList implements Comparable<AttachmentList>,
listId, listId,
uuid, uuid,
name, name,
order, listOrder,
Objects.toString(title), Objects.toString(title),
Objects.toString(description), Objects.toString(description),
Objects.toString(attachments), Objects.toString(attachments),

View File

@ -70,7 +70,7 @@ public class AttachmentListManager {
*/ */
private void normalizeOrder(final List<AttachmentList> lists) { private void normalizeOrder(final List<AttachmentList> lists) {
for (int i = 0; i < lists.size(); i++) { for (int i = 0; i < lists.size(); i++) {
lists.get(i).setOrder(i); lists.get(i).setListOrder(i);
entityManager.merge(lists.get(i)); entityManager.merge(lists.get(i));
} }
} }
@ -201,14 +201,14 @@ public class AttachmentListManager {
if (lists.isEmpty()) { if (lists.isEmpty()) {
lastOrder = 0; lastOrder = 0;
} else { } else {
lastOrder = lists.get(lists.size() - 1).getOrder(); lastOrder = lists.get(lists.size() - 1).getListOrder();
} }
final AttachmentList list = new AttachmentList(); final AttachmentList list = new AttachmentList();
list.setItem(draft); list.setItem(draft);
list.setName(name); list.setName(name);
list.setUuid(UUID.randomUUID().toString()); list.setUuid(UUID.randomUUID().toString());
list.setOrder(lastOrder + 1); list.setListOrder(lastOrder + 1);
draft.addAttachmentList(list); draft.addAttachmentList(list);
@ -270,10 +270,10 @@ public class AttachmentListManager {
list.setItem(draft); list.setItem(draft);
list.setName(name); list.setName(name);
list.setUuid(UUID.randomUUID().toString()); list.setUuid(UUID.randomUUID().toString());
list.setOrder(listPos); list.setListOrder(listPos);
for (long i = listPos; i < lists.size(); i++) { for (long i = listPos; i < lists.size(); i++) {
lists.get((int) i).setOrder(i + 1); lists.get((int) i).setListOrder(i + 1);
entityManager.merge(lists.get((int) i)); entityManager.merge(lists.get((int) i));
} }
@ -336,21 +336,21 @@ public class AttachmentListManager {
.getAttachments(); .getAttachments();
final Optional<AttachmentList> list1 = lists.stream() final Optional<AttachmentList> list1 = lists.stream()
.filter(list -> list.getOrder() == attachmentList.getOrder()) .filter(list -> list.getListOrder() == attachmentList.getListOrder())
.findFirst(); .findFirst();
final Optional<AttachmentList> list2 = lists.stream() final Optional<AttachmentList> list2 = lists.stream()
.filter(list -> list.getOrder() >= attachmentList.getOrder() + 1) .filter(list -> list.getListOrder() >= attachmentList.getListOrder() + 1)
.findFirst(); .findFirst();
if (!list2.isPresent()) { if (!list2.isPresent()) {
return; return;
} }
final long order1 = list1.get().getOrder(); final long order1 = list1.get().getListOrder();
final long order2 = list2.get().getOrder(); final long order2 = list2.get().getListOrder();
list1.get().setOrder(order2); list1.get().setListOrder(order2);
list2.get().setOrder(order1); list2.get().setListOrder(order1);
entityManager.merge(list1.get()); entityManager.merge(list1.get());
entityManager.merge(list2.get()); entityManager.merge(list2.get());
@ -374,10 +374,10 @@ public class AttachmentListManager {
.getAttachments(); .getAttachments();
final Optional<AttachmentList> list1 = lists.stream() final Optional<AttachmentList> list1 = lists.stream()
.filter(list -> list.getOrder() == attachmentList.getOrder()) .filter(list -> list.getListOrder() == attachmentList.getListOrder())
.findFirst(); .findFirst();
final List<AttachmentList> lower = lists.stream() final List<AttachmentList> lower = lists.stream()
.filter(list -> list.getOrder() <= attachmentList.getOrder() - 1) .filter(list -> list.getListOrder() <= attachmentList.getListOrder() - 1)
.collect(Collectors.toList()); .collect(Collectors.toList());
Collections.sort(lower); Collections.sort(lower);
@ -392,11 +392,11 @@ public class AttachmentListManager {
return; return;
} }
final long order1 = list1.get().getOrder(); final long order1 = list1.get().getListOrder();
final long order2 = list2.get().getOrder(); final long order2 = list2.get().getListOrder();
list1.get().setOrder(order2); list1.get().setListOrder(order2);
list2.get().setOrder(order1); list2.get().setListOrder(order1);
entityManager.merge(list1.get()); entityManager.merge(list1.get());
entityManager.merge(list2.get()); entityManager.merge(list2.get());

View File

@ -65,7 +65,6 @@ import javax.persistence.OrderBy;
import javax.xml.bind.annotation.XmlElement; import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper; import javax.xml.bind.annotation.XmlElementWrapper;
/** /**
* Base type for all content item types. Specifies some common properties. * Base type for all content item types. Specifies some common properties.
* *
@ -94,8 +93,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " ) " + " ) "
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " )") + " )"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByUuid", name = "ContentItem.findByUuid",
query query
@ -114,8 +112,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " ) " + " ) "
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " )") + " )"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByType", name = "ContentItem.findByType",
query query
@ -134,8 +131,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " ) " + " ) "
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " )") + " )"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByIdAndType", name = "ContentItem.findByIdAndType",
query query
@ -155,8 +151,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " ) " + " ) "
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " )") + " )"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByUuidAndType", name = "ContentItem.findByUuidAndType",
query query
@ -176,8 +171,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " ) " + " ) "
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " )") + " )"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByContentSection", name = "ContentItem.findByContentSection",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -197,8 +191,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ ")") + ")"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByContentSectionAndVersion", name = "ContentItem.findByContentSectionAndVersion",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -219,8 +212,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ ")") + ")"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByNameAndContentSection", name = "ContentItem.findByNameAndContentSection",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -241,8 +233,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ ")") + ")"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByNameAndContentSectionAndVersion", name = "ContentItem.findByNameAndContentSectionAndVersion",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -264,9 +255,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ ")") + ")"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByTypeAndContentSection", name = "ContentItem.findByTypeAndContentSection",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -287,8 +276,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ ")") + ")"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByTypeAndContentSectionAndVersion", name = "ContentItem.findByTypeAndContentSectionAndVersion",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -311,9 +299,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ ")" + ")"
) ),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByNameAndTypeAndContentSection", name = "ContentItem.findByNameAndTypeAndContentSection",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -335,8 +321,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ ")") + ")"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByNameAndTypeAndContentSectionAndVersion", name = "ContentItem.findByNameAndTypeAndContentSectionAndVersion",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -359,8 +344,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ ")") + ")"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByFolder", name = "ContentItem.findByFolder",
@ -382,8 +366,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " )") + " )"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.countItemsInFolder", name = "ContentItem.countItemsInFolder",
query query
@ -404,8 +387,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " )") + " )"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findByNameInFolder", name = "ContentItem.findByNameInFolder",
query query
@ -428,8 +410,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " )") + " )"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.countByNameInFolder", name = "ContentItem.countByNameInFolder",
query = "SELECT COUNT(DISTINCT i)" query = "SELECT COUNT(DISTINCT i)"
@ -451,8 +432,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " )") + " )"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.filterByFolderAndName", name = "ContentItem.filterByFolderAndName",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -474,8 +454,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " ) " + " ) "
+ "ORDER BY i.displayName") + "ORDER BY i.displayName"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.countFilterByFolderAndName", name = "ContentItem.countFilterByFolderAndName",
query = "SELECT COUNT(DISTINCT i) FROM ContentItem i " query = "SELECT COUNT(DISTINCT i) FROM ContentItem i "
@ -496,8 +475,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " )" + " )"
) ),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.filterByFolderAndType", name = "ContentItem.filterByFolderAndType",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -519,8 +497,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " ) " + " ) "
+ "ORDER BY i.displayName") + "ORDER BY i.displayName"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.filterByFolderAndTypeAndName", name = "ContentItem.filterByFolderAndTypeAndName",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -543,15 +520,13 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ " )" + " )"
+ " OR true = :isSystemUser OR true = :isAdmin" + " OR true = :isSystemUser OR true = :isAdmin"
+ " ) " + " ) "
+ "ORDER BY i.displayName") + "ORDER BY i.displayName"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.hasLiveVersion", name = "ContentItem.hasLiveVersion",
query = "SELECT (CASE WHEN COUNT(i) > 0 THEN true ELSE false END) " query = "SELECT (CASE WHEN COUNT(i) > 0 THEN true ELSE false END) "
+ "FROM ContentItem i " + "FROM ContentItem i "
+ "WHERE i.itemUuid = :uuid " + "WHERE i.itemUuid = :uuid "
+ "AND i.version = org.librecms.contentsection.ContentItemVersion.LIVE") + "AND i.version = org.librecms.contentsection.ContentItemVersion.LIVE"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findDraftVersion", name = "ContentItem.findDraftVersion",
query query
@ -563,8 +538,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ "AND " + "AND "
+ "((p.grantee IN :roles " + "((p.grantee IN :roles "
+ "AND p.grantedPrivilege = '" + ItemPrivileges.PREVIEW + "' " + "AND p.grantedPrivilege = '" + ItemPrivileges.PREVIEW + "' "
+ ") OR true = :isSystemUser OR true = :isAdmin)") + ") OR true = :isSystemUser OR true = :isAdmin)"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findLiveVersion", name = "ContentItem.findLiveVersion",
query query
@ -579,8 +553,7 @@ import javax.xml.bind.annotation.XmlElementWrapper;
+ "'" + "'"
+ ItemPrivileges.VIEW_PUBLISHED + ItemPrivileges.VIEW_PUBLISHED
+ "' " + "' "
+ ") OR true = :isSystemUser OR true = :isAdmin)") + ") OR true = :isSystemUser OR true = :isAdmin)"),
,
@NamedQuery( @NamedQuery(
name = "ContentItem.findItemWithWorkflow", name = "ContentItem.findItemWithWorkflow",
query = "SELECT DISTINCT i " query = "SELECT DISTINCT i "
@ -697,7 +670,7 @@ public class ContentItem extends CcmObject implements Serializable, Exportable {
private String ancestors; private String ancestors;
@OneToMany(mappedBy = "item", fetch = FetchType.LAZY) @OneToMany(mappedBy = "item", fetch = FetchType.LAZY)
@OrderBy("order ASC") @OrderBy("list_order ASC")
@XmlElementWrapper(name = "attachments", namespace = CMS_XML_NS) @XmlElementWrapper(name = "attachments", namespace = CMS_XML_NS)
@JsonIgnore @JsonIgnore
private List<AttachmentList> attachments; private List<AttachmentList> attachments;
@ -850,7 +823,6 @@ public class ContentItem extends CcmObject implements Serializable, Exportable {
} }
public List<AttachmentList> getAttachments() { public List<AttachmentList> getAttachments() {
Collections.sort(attachments);
return Collections.unmodifiableList(attachments); return Collections.unmodifiableList(attachments);
} }

View File

@ -680,7 +680,7 @@ public class ContentItemManager {
.getDescription()); .getDescription());
targetList.setItem(target); targetList.setItem(target);
targetList.setName(sourceList.getName()); targetList.setName(sourceList.getName());
targetList.setOrder(sourceList.getOrder()); targetList.setListOrder(sourceList.getListOrder());
copyLocalizedString(sourceList.getTitle(), targetList.getTitle()); copyLocalizedString(sourceList.getTitle(), targetList.getTitle());
targetList.setUuid(UUID.randomUUID().toString()); targetList.setUuid(UUID.randomUUID().toString());
@ -1116,7 +1116,7 @@ public class ContentItemManager {
targetList.setName(sourceList.getName()); targetList.setName(sourceList.getName());
copyLocalizedString(sourceList.getTitle(), copyLocalizedString(sourceList.getTitle(),
targetList.getTitle()); targetList.getTitle());
targetList.setOrder(sourceList.getOrder()); targetList.setListOrder(sourceList.getListOrder());
targetList.setUuid(UUID.randomUUID().toString()); targetList.setUuid(UUID.randomUUID().toString());
} else { } else {
targetList = liveItem.getAttachments().get(i); targetList = liveItem.getAttachments().get(i);

View File

@ -164,7 +164,7 @@ public abstract class AbstractContentItemRenderer implements Serializable {
* "listId": {@link AttachmentList#getListId()} * "listId": {@link AttachmentList#getListId()}
* "uuid": {@link AttachmentList#getUuid()} * "uuid": {@link AttachmentList#getUuid()}
* "name": {@link AttachmentList#getName()} * "name": {@link AttachmentList#getName()}
* "order": {@link AttachmentList#getOrder()} * "order": {@link AttachmentList#getListOrder()}
* "title": {@link AttachmentList#getTitle()} * "title": {@link AttachmentList#getTitle()}
* "description": {@link AttachmentList#getDescription()} * "description": {@link AttachmentList#getDescription()}
* "attachments": {@link AttachmentList#getAttachments()} * "attachments": {@link AttachmentList#getAttachments()}
@ -189,7 +189,7 @@ public abstract class AbstractContentItemRenderer implements Serializable {
result.put("listId", attachmentList.getListId()); result.put("listId", attachmentList.getListId());
result.put("uuid", attachmentList.getUuid()); result.put("uuid", attachmentList.getUuid());
result.put("name", attachmentList.getName()); result.put("name", attachmentList.getName());
result.put("order", attachmentList.getOrder()); result.put("order", attachmentList.getListOrder());
result.put("title", attachmentList.getTitle().getValue(language)); result.put("title", attachmentList.getTitle().getValue(language));
result.put("description", result.put("description",
attachmentList.getDescription().getValue(language)); attachmentList.getDescription().getValue(language));

View File

@ -2141,7 +2141,7 @@ public class RelatedInfoStep extends AbstractMvcAuthoringStep {
); );
dto.setListId(attachmentList.getListId()); dto.setListId(attachmentList.getListId());
dto.setName(attachmentList.getName()); dto.setName(attachmentList.getName());
dto.setOrder(attachmentList.getOrder()); dto.setOrder(attachmentList.getListOrder());
dto.setTitle( dto.setTitle(
globalizationHelper globalizationHelper
.getValueFromLocalizedString( .getValueFromLocalizedString(

View File

@ -55,7 +55,7 @@ public class RelatedInfoStepModel {
} }
public List<AttachmentListDto> getAttachmentsLists() { public List<AttachmentListDto> getAttachmentsLists() {
return attachmentsLists; return Collections.unmodifiableList(attachmentsLists);
} }
public void setAttachmentsLists(List<AttachmentListDto> attachmentsLists) { public void setAttachmentsLists(List<AttachmentListDto> attachmentsLists) {

View File

@ -0,0 +1 @@
/home/jensp/pwi/libreccm/git/libreccm/ccm-cms/src/main/resources/WEB-INF/views/org/librecms/ui/contentsection/assets/edit-contactable.xhtml

View File

@ -88,7 +88,15 @@
<button class="btn btn-secondary save-order-button" <button class="btn btn-secondary save-order-button"
disabled="disabled" disabled="disabled"
type="button"> type="button">
<span class="save-icon">
<bootstrap:svgIcon icon="save" /> <bootstrap:svgIcon icon="save" />
</span>
<span class="save-spinner d-none">
<span aria-hidden="true"
class="spinner-border spinner-border-sm"
role="status"></span>
<span class="sr-only">#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.order.save.inprogress']}</span>
</span>
<span>#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.order.save']}</span> <span>#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.order.save']}</span>
</button> </button>
</div> </div>
@ -293,7 +301,15 @@
<button class="btn btn-secondary save-order-button" <button class="btn btn-secondary save-order-button"
disabled="disabled" disabled="disabled"
type="button"> type="button">
<span class="save-icon">
<bootstrap:svgIcon icon="save" /> <bootstrap:svgIcon icon="save" />
</span>
<span class="save-spinner d-none">
<span aria-hidden="true"
class="spinner-border spinner-border-sm"
role="status"></span>
<span class="sr-only">#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.order.save.inprogress']}</span>
</span>
<span>#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.order.save']}</span> <span>#{CmsDefaultStepsMessageBundle['relatedinfo.attachmentlists.order.save']}</span>
</button> </button>
</div> </div>

View File

@ -238,3 +238,4 @@ relatedinfo.attachments.info.dialog.title=Attachment {1} of list {0}
relatedinfo.attachments.info.dialog.close=Close relatedinfo.attachments.info.dialog.close=Close
relatedinfo.attachments.info.dialog.title.label=Title relatedinfo.attachments.info.dialog.title.label=Title
relatedinfo.attachments.info.dialog.type.label=Type relatedinfo.attachments.info.dialog.type.label=Type
relatedinfo.attachmentlists.order.save.inprogress=Saving...

View File

@ -238,3 +238,4 @@ relatedinfo.attachments.info.dialog.title=Anhang {1} der List {0}
relatedinfo.attachments.info.dialog.close=Schlie\u00dfen relatedinfo.attachments.info.dialog.close=Schlie\u00dfen
relatedinfo.attachments.info.dialog.title.label=Titel relatedinfo.attachments.info.dialog.title.label=Titel
relatedinfo.attachments.info.dialog.type.label=Typ relatedinfo.attachments.info.dialog.type.label=Typ
relatedinfo.attachmentlists.order.save.inprogress=Speichere...

View File

@ -149,6 +149,17 @@ function saveOrder() {
"data-baseUrl attribute on cms-attachment-lists container is missing or empty." "data-baseUrl attribute on cms-attachment-lists container is missing or empty."
); );
} }
const saveOrderButtons = document.querySelectorAll(".save-order-button");
for (let i = 0; i < saveOrderButtons.length; i++) {
const saveOrderButton: HTMLButtonElement = saveOrderButtons[i] as HTMLButtonElement;
saveOrderButton.disabled = true;
const saveIcon = saveOrderButton.querySelector(".save-icon");
const spinner = saveOrderButton.querySelector(".save-spinner");
saveIcon?.classList.toggle("d-none");
spinner?.classList.toggle("d-none");
}
const headers = new Headers(); const headers = new Headers();
headers.append("Content-Type", "application/json"); headers.append("Content-Type", "application/json");
fetch(baseUrl, { fetch(baseUrl, {
@ -159,15 +170,30 @@ function saveOrder() {
}) })
.then(response => { .then(response => {
if (response.ok) { if (response.ok) {
const saveOrderButtons = // const saveOrderButtons =
document.querySelectorAll("save-order-button"); // document.querySelectorAll(".save-order-button");
for (let i = 0; i < saveOrderButtons.length; i++) { for (let i = 0; i < saveOrderButtons.length; i++) {
const saveOrderButton: HTMLButtonElement = saveOrderButtons[ const saveOrderButton: HTMLButtonElement = saveOrderButtons[
i i
] as HTMLButtonElement; ] as HTMLButtonElement;
saveOrderButton.disabled = true; // saveOrderButton.disabled = true;
const saveIcon = saveOrderButton.querySelector(".save-icon");
const spinner = saveOrderButton.querySelector(".save-spinner");
saveIcon?.classList.toggle("d-none");
spinner?.classList.toggle("d-none");
} }
} else { } else {
showSaveError();
for (let i = 0; i < saveOrderButtons.length; i++) {
const saveOrderButton: HTMLButtonElement = saveOrderButtons[
i
] as HTMLButtonElement;
saveOrderButton.disabled = false;
const saveIcon = saveOrderButton.querySelector(".save-icon");
const spinner = saveOrderButton.querySelector(".save-spinner");
saveIcon?.classList.toggle("d-none");
spinner?.classList.toggle("d-none");
}
throw Error( throw Error(
`Failed to save attachments order. Response status: ${response.status}, statusText: ${response.statusText}` `Failed to save attachments order. Response status: ${response.status}, statusText: ${response.statusText}`
); );
@ -175,6 +201,16 @@ function saveOrder() {
}) })
.catch(error => { .catch(error => {
showSaveError(); showSaveError();
for (let i = 0; i < saveOrderButtons.length; i++) {
const saveOrderButton: HTMLButtonElement = saveOrderButtons[
i
] as HTMLButtonElement;
saveOrderButton.disabled = false;
const saveIcon = saveOrderButton.querySelector(".save-icon");
const spinner = saveOrderButton.querySelector(".save-spinner");
saveIcon?.classList.toggle("d-none");
spinner?.classList.toggle("d-none");
}
throw new Error(`Failed to save attachments order: ${error}`); throw new Error(`Failed to save attachments order: ${error}`);
}); });
} }