@umbraco-cms/backoffice 14.0.0--preview007-02546fcd → 14.0.0--preview007-dd76e4de

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { UmbLitElement } from '../../../../../core/lit-element/index.js';
2
1
  import './document-type-workspace-view-edit-property.element.js';
3
2
  import type { UmbDocumentTypeDetailModel } from '../../../types.js';
3
+ import { UmbLitElement } from '../../../../../core/lit-element/index.js';
4
4
  import type { UmbPropertyContainerTypes, UmbPropertyTypeModel } from '../../../../../core/content-type/index.js';
5
5
  import { UmbContentTypePropertyStructureHelper } from '../../../../../core/content-type/index.js';
6
6
  export declare class UmbDocumentTypeWorkspaceViewEditPropertiesElement extends UmbLitElement {
@@ -9,9 +9,15 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13
+ if (kind === "m") throw new TypeError("Private method is not writable");
14
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
15
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
+ };
12
18
  var _UmbDocumentTypeWorkspaceViewEditPropertiesElement_instances, _UmbDocumentTypeWorkspaceViewEditPropertiesElement_model, _UmbDocumentTypeWorkspaceViewEditPropertiesElement_sorter, _UmbDocumentTypeWorkspaceViewEditPropertiesElement_addProperty;
13
- import { UmbLitElement } from '../../../../../core/lit-element/index.js';
14
19
  import './document-type-workspace-view-edit-property.element.js';
20
+ import { UmbLitElement } from '../../../../../core/lit-element/index.js';
15
21
  import { css, html, customElement, property, state, repeat, ifDefined } from '../../../../../../external/lit/index.js';
16
22
  import { UmbTextStyles } from '../../../../../../shared/style/index.js';
17
23
  import { UmbContentTypePropertyStructureHelper } from '../../../../../core/content-type/index.js';
@@ -54,27 +60,52 @@ let UmbDocumentTypeWorkspaceViewEditPropertiesElement = class UmbDocumentTypeWor
54
60
  },
55
61
  identifier: 'document-type-property-sorter',
56
62
  itemSelector: 'umb-document-type-workspace-view-edit-property',
57
- disabledItemSelector: '[inherited]',
63
+ //disabledItemSelector: '[inherited]',
58
64
  //TODO: Set the property list (sorter wrapper) to inherited, if its inherited
59
65
  // This is because we don't want to move local properties into an inherited group container.
60
66
  // Or maybe we do, but we still need to check if the group exists locally, if not, then it needs to be created before we move a property into it.
61
67
  // TODO: Fix bug where a local property turn into an inherited when moved to a new group container.
62
68
  containerSelector: '#property-list',
63
69
  onChange: ({ item, model }) => {
64
- const isInNewContainer = model.find((entry) => entry?.container?.id !== this._containerId && this._containerId);
65
- if (isInNewContainer) {
66
- model.forEach((entry, index) => {
67
- entry.id === item.id
68
- ? this._propertyStructureHelper.partialUpdateProperty(entry.id, {
69
- sortOrder: index,
70
- container: { id: this._containerId },
71
- })
72
- : this._propertyStructureHelper.partialUpdateProperty(entry.id, { sortOrder: index });
70
+ __classPrivateFieldSet(this, _UmbDocumentTypeWorkspaceViewEditPropertiesElement_model, model, "f");
71
+ this._propertyStructure = model;
72
+ },
73
+ onEnd: ({ item }) => {
74
+ /** Explanation: If the item is the first in list, we compare it to the item behind it to set a sortOrder.
75
+ * If it's not the first in list, we will compare to the item in before it, and check the following item to see if it caused overlapping sortOrder, then update
76
+ * the overlap if true, which may cause another overlap, so we loop through them till no more overlaps...
77
+ */
78
+ const model = __classPrivateFieldGet(this, _UmbDocumentTypeWorkspaceViewEditPropertiesElement_model, "f");
79
+ const newIndex = model.findIndex((entry) => entry.id === item.id);
80
+ // Doesn't exist in model
81
+ if (newIndex === -1)
82
+ return;
83
+ // First in list
84
+ if (newIndex === 0 && model.length > 1) {
85
+ this._propertyStructureHelper.partialUpdateProperty(item.id, {
86
+ sortOrder: model[1].sortOrder - 1,
87
+ container: this._containerId ? { id: this._containerId } : null,
73
88
  });
89
+ return;
74
90
  }
75
- else {
76
- model.forEach((entry, index) => {
77
- this._propertyStructureHelper.partialUpdateProperty(entry.id, { sortOrder: index });
91
+ // Not first in list
92
+ if (newIndex > 0 && model.length > 1) {
93
+ const prevItemSortOrder = model[newIndex - 1].sortOrder;
94
+ let weight = 1;
95
+ this._propertyStructureHelper.partialUpdateProperty(item.id, {
96
+ sortOrder: prevItemSortOrder + weight,
97
+ container: this._containerId ? { id: this._containerId } : null,
98
+ });
99
+ // Check for overlaps
100
+ model.some((entry, index) => {
101
+ if (index <= newIndex)
102
+ return;
103
+ if (entry.sortOrder === prevItemSortOrder + weight) {
104
+ weight++;
105
+ this._propertyStructureHelper.partialUpdateProperty(entry.id, { sortOrder: prevItemSortOrder + weight });
106
+ }
107
+ // Break the loop
108
+ return true;
78
109
  });
79
110
  }
80
111
  },
@@ -101,6 +132,12 @@ let UmbDocumentTypeWorkspaceViewEditPropertiesElement = class UmbDocumentTypeWor
101
132
  });
102
133
  this.observe(this._propertyStructureHelper.propertyStructure, (propertyStructure) => {
103
134
  this._propertyStructure = propertyStructure;
135
+ if (this._sortModeActive) {
136
+ __classPrivateFieldGet(this, _UmbDocumentTypeWorkspaceViewEditPropertiesElement_sorter, "f").setModel(this._propertyStructure);
137
+ }
138
+ else {
139
+ __classPrivateFieldGet(this, _UmbDocumentTypeWorkspaceViewEditPropertiesElement_sorter, "f").setModel([]);
140
+ }
104
141
  });
105
142
  // Note: Route for adding a new property
106
143
  new UmbModalRouteRegistrationController(this, UMB_PROPERTY_SETTINGS_MODAL)
@@ -443,7 +443,10 @@ UmbDocumentTypeWorkspacePropertyElement.styles = [
443
443
  }
444
444
 
445
445
  :host([drag-placeholder]) {
446
- opacity: 0.2;
446
+ opacity: 0.5;
447
+ }
448
+ :host([drag-placeholder]) uui-input {
449
+ visibility: hidden;
447
450
  }
448
451
  `,
449
452
  ];
@@ -9,7 +9,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _UmbDocumentTypeWorkspaceViewEditTabElement_instances, _UmbDocumentTypeWorkspaceViewEditTabElement_sorter, _UmbDocumentTypeWorkspaceViewEditTabElement_onAddGroup, _UmbDocumentTypeWorkspaceViewEditTabElement_renderHeader, _UmbDocumentTypeWorkspaceViewEditTabElement_renderInputGroupName, _UmbDocumentTypeWorkspaceViewEditTabElement_renderAddGroupButton;
12
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13
+ if (kind === "m") throw new TypeError("Private method is not writable");
14
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
15
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
+ };
18
+ var _UmbDocumentTypeWorkspaceViewEditTabElement_instances, _UmbDocumentTypeWorkspaceViewEditTabElement_model, _UmbDocumentTypeWorkspaceViewEditTabElement_sorter, _UmbDocumentTypeWorkspaceViewEditTabElement_onAddGroup, _UmbDocumentTypeWorkspaceViewEditTabElement_renderHeader, _UmbDocumentTypeWorkspaceViewEditTabElement_renderInputGroupName, _UmbDocumentTypeWorkspaceViewEditTabElement_renderAddGroupButton;
13
19
  import { UmbLitElement } from '../../../../../core/lit-element/index.js';
14
20
  import { css, html, customElement, property, state, repeat, ifDefined } from '../../../../../../external/lit/index.js';
15
21
  import { UmbTextStyles } from '../../../../../../shared/style/index.js';
@@ -51,6 +57,7 @@ let UmbDocumentTypeWorkspaceViewEditTabElement = class UmbDocumentTypeWorkspaceV
51
57
  constructor() {
52
58
  super();
53
59
  _UmbDocumentTypeWorkspaceViewEditTabElement_instances.add(this);
60
+ _UmbDocumentTypeWorkspaceViewEditTabElement_model.set(this, []);
54
61
  _UmbDocumentTypeWorkspaceViewEditTabElement_sorter.set(this, new UmbSorterController(this, {
55
62
  getUniqueOfElement: (element) => element.querySelector('umb-document-type-workspace-view-edit-properties').getAttribute('container-id'),
56
63
  getUniqueOfModel: (modelEntry) => modelEntry.id,
@@ -58,9 +65,41 @@ let UmbDocumentTypeWorkspaceViewEditTabElement = class UmbDocumentTypeWorkspaceV
58
65
  itemSelector: '.container-handle',
59
66
  containerSelector: '.container-list',
60
67
  onChange: ({ model }) => {
61
- model.forEach((modelItem, index) => {
62
- this._groupStructureHelper.partialUpdateContainer(modelItem.id, { sortOrder: index });
63
- });
68
+ this._groups = model;
69
+ __classPrivateFieldSet(this, _UmbDocumentTypeWorkspaceViewEditTabElement_model, model, "f");
70
+ },
71
+ onEnd: ({ item }) => {
72
+ /** Explanation: If the item is the first in list, we compare it to the item behind it to set a sortOrder.
73
+ * If it's not the first in list, we will compare to the item in before it, and check the following item to see if it caused overlapping sortOrder, then update
74
+ * the overlap if true, which may cause another overlap, so we loop through them till no more overlaps...
75
+ */
76
+ const model = __classPrivateFieldGet(this, _UmbDocumentTypeWorkspaceViewEditTabElement_model, "f");
77
+ const newIndex = model.findIndex((entry) => entry.id === item.id);
78
+ // Doesn't exist in model
79
+ if (newIndex === -1)
80
+ return;
81
+ // First in list
82
+ if (newIndex === 0 && model.length > 1) {
83
+ this._groupStructureHelper.partialUpdateContainer(item.id, { sortOrder: model[1].sortOrder - 1 });
84
+ return;
85
+ }
86
+ // Not first in list
87
+ if (newIndex > 0 && model.length > 1) {
88
+ const prevItemSortOrder = model[newIndex - 1].sortOrder;
89
+ let weight = 1;
90
+ this._groupStructureHelper.partialUpdateContainer(item.id, { sortOrder: prevItemSortOrder + weight });
91
+ // Check for overlaps
92
+ model.some((entry, index) => {
93
+ if (index <= newIndex)
94
+ return;
95
+ if (entry.sortOrder === prevItemSortOrder + weight) {
96
+ weight++;
97
+ this._groupStructureHelper.partialUpdateContainer(entry.id, { sortOrder: prevItemSortOrder + weight });
98
+ }
99
+ // Break the loop
100
+ return true;
101
+ });
102
+ }
64
103
  },
65
104
  }));
66
105
  this._groupStructureHelper = new UmbContentTypeContainerStructureHelper(this);
@@ -84,6 +123,12 @@ let UmbDocumentTypeWorkspaceViewEditTabElement = class UmbDocumentTypeWorkspaceV
84
123
  });
85
124
  this.observe(this._groupStructureHelper.containers, (groups) => {
86
125
  this._groups = groups;
126
+ if (this._sortModeActive) {
127
+ __classPrivateFieldGet(this, _UmbDocumentTypeWorkspaceViewEditTabElement_sorter, "f").setModel(this._groups);
128
+ }
129
+ else {
130
+ __classPrivateFieldGet(this, _UmbDocumentTypeWorkspaceViewEditTabElement_sorter, "f").setModel([]);
131
+ }
87
132
  this.requestUpdate('_groups');
88
133
  });
89
134
  this.observe(this._groupStructureHelper.hasProperties, (hasProperties) => {
@@ -111,7 +156,7 @@ let UmbDocumentTypeWorkspaceViewEditTabElement = class UmbDocumentTypeWorkspaceV
111
156
  `
112
157
  : ''}
113
158
  <div class="container-list" ?sort-mode-active=${this._sortModeActive}>
114
- ${repeat(this._groups, (group) => group.id ?? '' + group.name, (group) => html `<uui-box class="container-handle">
159
+ ${repeat(this._groups, (group) => group.id + '' + group.name + group.sortOrder, (group) => html `<uui-box class="container-handle">
115
160
  ${__classPrivateFieldGet(this, _UmbDocumentTypeWorkspaceViewEditTabElement_instances, "m", _UmbDocumentTypeWorkspaceViewEditTabElement_renderHeader).call(this, group)}
116
161
  <umb-document-type-workspace-view-edit-properties
117
162
  container-id=${ifDefined(group.id)}
@@ -124,6 +169,7 @@ let UmbDocumentTypeWorkspaceViewEditTabElement = class UmbDocumentTypeWorkspaceV
124
169
  `;
125
170
  }
126
171
  };
172
+ _UmbDocumentTypeWorkspaceViewEditTabElement_model = new WeakMap();
127
173
  _UmbDocumentTypeWorkspaceViewEditTabElement_sorter = new WeakMap();
128
174
  _UmbDocumentTypeWorkspaceViewEditTabElement_onAddGroup = new WeakMap();
129
175
  _UmbDocumentTypeWorkspaceViewEditTabElement_instances = new WeakSet();
@@ -138,11 +184,9 @@ _UmbDocumentTypeWorkspaceViewEditTabElement_renderHeader = function _UmbDocument
138
184
  <uui-input
139
185
  type="number"
140
186
  label=${this.localize.term('sort_sortOrder')}
141
- @change=${(e) => {
142
- this._groupStructureHelper.partialUpdateContainer(group.id, {
143
- sortOrder: parseInt(e.target.value) || 0,
144
- });
145
- }}
187
+ @change=${(e) => this._groupStructureHelper.partialUpdateContainer(group.id, {
188
+ sortOrder: parseInt(e.target.value) || 0,
189
+ })}
146
190
  .value=${group.sortOrder || 0}
147
191
  ?disabled=${inherited}></uui-input>
148
192
  </div> `;
@@ -178,7 +222,11 @@ UmbDocumentTypeWorkspaceViewEditTabElement.styles = [
178
222
  UmbTextStyles,
179
223
  css `
180
224
  [drag-placeholder] {
181
- opacity: 0.2;
225
+ opacity: 0.5;
226
+ }
227
+
228
+ [drag-placeholder] > * {
229
+ visibility: hidden;
182
230
  }
183
231
 
184
232
  #add {
@@ -9,7 +9,13 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _UmbDocumentTypeWorkspaceViewEditElement_instances, _UmbDocumentTypeWorkspaceViewEditElement_sorter, _UmbDocumentTypeWorkspaceViewEditElement_changeMode, _UmbDocumentTypeWorkspaceViewEditElement_requestRemoveTab, _UmbDocumentTypeWorkspaceViewEditElement_remove, _UmbDocumentTypeWorkspaceViewEditElement_addTab, _UmbDocumentTypeWorkspaceViewEditElement_focusInput, _UmbDocumentTypeWorkspaceViewEditElement_tabNameChanged, _UmbDocumentTypeWorkspaceViewEditElement_openCompositionModal, _UmbDocumentTypeWorkspaceViewEditElement_changeOrderNumber;
12
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
13
+ if (kind === "m") throw new TypeError("Private method is not writable");
14
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
15
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
16
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
17
+ };
18
+ var _UmbDocumentTypeWorkspaceViewEditElement_instances, _UmbDocumentTypeWorkspaceViewEditElement_model, _UmbDocumentTypeWorkspaceViewEditElement_sorter, _UmbDocumentTypeWorkspaceViewEditElement_changeMode, _UmbDocumentTypeWorkspaceViewEditElement_requestRemoveTab, _UmbDocumentTypeWorkspaceViewEditElement_remove, _UmbDocumentTypeWorkspaceViewEditElement_addTab, _UmbDocumentTypeWorkspaceViewEditElement_focusInput, _UmbDocumentTypeWorkspaceViewEditElement_tabNameChanged, _UmbDocumentTypeWorkspaceViewEditElement_openCompositionModal, _UmbDocumentTypeWorkspaceViewEditElement_changeOrderNumber;
13
19
  import { UMB_COMPOSITION_PICKER_MODAL } from '../../../modals/index.js';
14
20
  import { css, html, customElement, state, repeat, nothing, ifDefined } from '../../../../../../external/lit/index.js';
15
21
  import { UmbContentTypeContainerStructureHelper } from '../../../../../core/content-type/index.js';
@@ -24,6 +30,7 @@ let UmbDocumentTypeWorkspaceViewEditElement = class UmbDocumentTypeWorkspaceView
24
30
  constructor() {
25
31
  super();
26
32
  _UmbDocumentTypeWorkspaceViewEditElement_instances.add(this);
33
+ _UmbDocumentTypeWorkspaceViewEditElement_model.set(this, []);
27
34
  _UmbDocumentTypeWorkspaceViewEditElement_sorter.set(this, new UmbSorterController(this, {
28
35
  getUniqueOfElement: (element) => element.getAttribute('data-umb-tabs-id'),
29
36
  getUniqueOfModel: (modelEntry) => modelEntry.id,
@@ -33,9 +40,41 @@ let UmbDocumentTypeWorkspaceViewEditElement = class UmbDocumentTypeWorkspaceView
33
40
  disabledItemSelector: '#root-tab',
34
41
  resolveVerticalDirection: () => false,
35
42
  onChange: ({ model }) => {
36
- model.forEach((modelItem, index) => {
37
- this._tabsStructureHelper.partialUpdateContainer(modelItem.id, { sortOrder: index });
38
- });
43
+ __classPrivateFieldSet(this, _UmbDocumentTypeWorkspaceViewEditElement_model, model, "f");
44
+ this._tabs = model;
45
+ },
46
+ onEnd: ({ item }) => {
47
+ /** Explanation: If the item is the first in list, we compare it to the item behind it to set a sortOrder.
48
+ * If it's not the first in list, we will compare to the item in before it, and check the following item to see if it caused overlapping sortOrder, then update
49
+ * the overlap if true, which may cause another overlap, so we loop through them till no more overlaps...
50
+ */
51
+ const model = __classPrivateFieldGet(this, _UmbDocumentTypeWorkspaceViewEditElement_model, "f");
52
+ const newIndex = model.findIndex((entry) => entry.id === item.id);
53
+ // Doesn't exist in model
54
+ if (newIndex === -1)
55
+ return;
56
+ // First in list
57
+ if (newIndex === 0 && model.length > 1) {
58
+ this._tabsStructureHelper.partialUpdateContainer(item.id, { sortOrder: model[1].sortOrder - 1 });
59
+ return;
60
+ }
61
+ // Not first in list
62
+ if (newIndex > 0 && model.length > 1) {
63
+ const prevItemSortOrder = model[newIndex - 1].sortOrder;
64
+ let weight = 1;
65
+ this._tabsStructureHelper.partialUpdateContainer(item.id, { sortOrder: prevItemSortOrder + weight });
66
+ // Check for overlaps
67
+ model.some((entry, index) => {
68
+ if (index <= newIndex)
69
+ return;
70
+ if (entry.sortOrder === prevItemSortOrder + weight) {
71
+ weight++;
72
+ this._tabsStructureHelper.partialUpdateContainer(entry.id, { sortOrder: prevItemSortOrder + weight });
73
+ }
74
+ // Break the loop
75
+ return true;
76
+ });
77
+ }
39
78
  },
40
79
  }));
41
80
  //private _hasRootProperties = false;
@@ -49,6 +88,12 @@ let UmbDocumentTypeWorkspaceViewEditElement = class UmbDocumentTypeWorkspaceView
49
88
  this._tabsStructureHelper.setContainerChildType('Tab');
50
89
  this.observe(this._tabsStructureHelper.containers, (tabs) => {
51
90
  this._tabs = tabs;
91
+ if (this._sortModeActive) {
92
+ __classPrivateFieldGet(this, _UmbDocumentTypeWorkspaceViewEditElement_sorter, "f").setModel(tabs);
93
+ }
94
+ else {
95
+ __classPrivateFieldGet(this, _UmbDocumentTypeWorkspaceViewEditElement_sorter, "f").setModel([]);
96
+ }
52
97
  this._createRoutes();
53
98
  });
54
99
  // _hasRootProperties can be gotten via _tabsStructureHelper.hasProperties. But we do not support root properties currently.
@@ -260,6 +305,7 @@ let UmbDocumentTypeWorkspaceViewEditElement = class UmbDocumentTypeWorkspaceView
260
305
  </uui-button>`;
261
306
  }
262
307
  };
308
+ _UmbDocumentTypeWorkspaceViewEditElement_model = new WeakMap();
263
309
  _UmbDocumentTypeWorkspaceViewEditElement_sorter = new WeakMap();
264
310
  _UmbDocumentTypeWorkspaceViewEditElement_instances = new WeakSet();
265
311
  _UmbDocumentTypeWorkspaceViewEditElement_changeMode = function _UmbDocumentTypeWorkspaceViewEditElement_changeMode() {
@@ -367,7 +413,11 @@ UmbDocumentTypeWorkspaceViewEditElement.styles = [
367
413
  }
368
414
 
369
415
  [drag-placeholder] {
370
- opacity: 0.2;
416
+ opacity: 0.5;
417
+ }
418
+
419
+ [drag-placeholder] uui-input {
420
+ visibility: hidden;
371
421
  }
372
422
 
373
423
  /* TODO: This should be replaced with a general workspace bar — naming is hard */