@umbraco-cms/backoffice 14.0.0--preview007-02546fcd → 14.0.0--preview007-477ee42e

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 */
@@ -79,14 +79,17 @@ let UmbTemplatingInsertMenuElement = class UmbTemplatingInsertMenuElement extend
79
79
  render() {
80
80
  return html `
81
81
  <uui-button-group>
82
- <uui-button look="secondary" @click=${__classPrivateFieldGet(this, _UmbTemplatingInsertMenuElement_openChooseTypeModal, "f")} label="Choose value to insert">
83
- <uui-icon name="icon-add"></uui-icon>Insert
82
+ <uui-button
83
+ look="secondary"
84
+ @click=${__classPrivateFieldGet(this, _UmbTemplatingInsertMenuElement_openChooseTypeModal, "f")}
85
+ label=${this.localize.term('template_insertDesc')}>
86
+ <uui-icon name="icon-add"></uui-icon> ${this.localize.term('template_insert')}
84
87
  </uui-button>
85
88
  <umb-dropdown look="secondary" compact placement="bottom-end" id="insert-button" label="open insert menu">
86
89
  <uui-menu-item
87
90
  class="insert-menu-item"
88
- label="Dictionary item"
89
- title="Dictionary item"
91
+ label=${this.localize.term('template_insertDictionaryItem')}
92
+ title=${this.localize.term('template_insertDictionaryItem')}
90
93
  @click=${__classPrivateFieldGet(this, _UmbTemplatingInsertMenuElement_instances, "m", _UmbTemplatingInsertMenuElement_openInsertDictionaryItemModal)}>
91
94
  </uui-menu-item>
92
95
  </umb-dropdown>
@@ -112,6 +115,7 @@ _UmbTemplatingInsertMenuElement_openInsertDictionaryItemModal = function _UmbTem
112
115
  __classPrivateFieldSet(this, _UmbTemplatingInsertMenuElement_openModal, this._modalContext?.open(UMB_DICTIONARY_ITEM_PICKER_MODAL, {
113
116
  data: {
114
117
  pickableFilter: (item) => item.id !== null,
118
+ hideTreeRoot: true,
115
119
  },
116
120
  }), "f");
117
121
  __classPrivateFieldGet(this, _UmbTemplatingInsertMenuElement_openModal, "f")?.onSubmit().then((value) => {
@@ -41,17 +41,14 @@ let UmbChooseInsertTypeModalElement = class UmbChooseInsertTypeModalElement exte
41
41
  <umb-body-layout headline="Insert">
42
42
  <div id="main">
43
43
  <uui-box>
44
- <uui-button @click=${__classPrivateFieldGet(this, _UmbChooseInsertTypeModalElement_instances, "m", _UmbChooseInsertTypeModalElement_openInsertDictionaryItemModal)} look="placeholder" label="Insert Dictionary item"
45
- ><h3>Dictionary item</h3>
46
- <p>
47
- A dictionary item is a placeholder for a translatable piece of text, which makes it easy to create
48
- designs for multilingual websites.
49
- </p></uui-button
50
- >
44
+ <uui-button @click=${__classPrivateFieldGet(this, _UmbChooseInsertTypeModalElement_instances, "m", _UmbChooseInsertTypeModalElement_openInsertDictionaryItemModal)} look="placeholder" label="Insert Dictionary item">
45
+ <h3>${this.localize.term('template_insertDictionaryItem')}</h3>
46
+ <p>${this.localize.term('template_insertDictionaryItemDesc')}</p>
47
+ </uui-button>
51
48
  </uui-box>
52
49
  </div>
53
50
  <div slot="actions">
54
- <uui-button @click=${this._close} look="secondary" label="Close">Close</uui-button>
51
+ <uui-button @click=${this._close} look="secondary" label=${this.localize.term('general_close')}></uui-button>
55
52
  </div>
56
53
  </umb-body-layout>
57
54
  `;
@@ -75,6 +72,7 @@ _UmbChooseInsertTypeModalElement_openInsertDictionaryItemModal = function _UmbCh
75
72
  __classPrivateFieldSet(this, _UmbChooseInsertTypeModalElement_openModal, this._modalContext?.open(UMB_DICTIONARY_ITEM_PICKER_MODAL, {
76
73
  data: {
77
74
  pickableFilter: (item) => item.id !== null,
75
+ hideTreeRoot: true,
78
76
  },
79
77
  }), "f");
80
78
  __classPrivateFieldGet(this, _UmbChooseInsertTypeModalElement_openModal, "f")?.onSubmit().then((dictionaryItemPickerModalValue) => {
@@ -87,12 +85,9 @@ _UmbChooseInsertTypeModalElement_openInsertDictionaryItemModal = function _UmbCh
87
85
  _UmbChooseInsertTypeModalElement_renderInsertPartialViewButton = function _UmbChooseInsertTypeModalElement_renderInsertPartialViewButton() {
88
86
  return html `${this.data?.hidePartialViews
89
87
  ? ''
90
- : html `<uui-button @click=${__classPrivateFieldGet(this, _UmbChooseInsertTypeModalElement_instances, "m", _UmbChooseInsertTypeModalElement_openInsertPartialViewSidebar)} look="placeholder" label="Insert value"
91
- ><h3>Partial view</h3>
92
- <p>
93
- A partial view is a separate template file which can be rendered inside another template, it's great for
94
- reusing markup or for separating complex templates into separate files.
95
- </p></uui-button
88
+ : html `<uui-button @click=${__classPrivateFieldGet(this, _UmbChooseInsertTypeModalElement_instances, "m", _UmbChooseInsertTypeModalElement_openInsertPartialViewSidebar)} look="placeholder" label="Insert value">
89
+ <h3>${this.localize.term('template_insertPartialView')}</h3>
90
+ <p>${this.localize.term('template_insertPartialViewDesc')}</p></uui-button
96
91
  >`}`;
97
92
  };
98
93
  UmbChooseInsertTypeModalElement.styles = [
@@ -21,7 +21,7 @@ export declare class UmbTemplateServerDataSource implements UmbDetailDataSource<
21
21
  * @return { CreateTemplateRequestModel }
22
22
  * @memberof UmbTemplateServerDataSource
23
23
  */
24
- createScaffold(parentUnique: string | null): Promise<{
24
+ createScaffold(parentUnique: string | null, preset?: Partial<UmbTemplateDetailModel>): Promise<{
25
25
  data: UmbTemplateDetailModel;
26
26
  }>;
27
27
  /**
@@ -36,15 +36,16 @@ export class UmbTemplateServerDataSource {
36
36
  * @return { CreateTemplateRequestModel }
37
37
  * @memberof UmbTemplateServerDataSource
38
38
  */
39
- async createScaffold(parentUnique) {
39
+ async createScaffold(parentUnique, preset) {
40
+ const scaffold = '@using Umbraco.Cms.Web.Common.PublishedModels;\n@inherits Umbraco.Cms.Web.Common.Views.UmbracoViewPage\n@{\n\tLayout = null;\n}';
40
41
  const data = {
41
42
  entityType: UMB_TEMPLATE_ENTITY_TYPE,
42
43
  unique: UmbId.new(),
43
44
  parentUnique,
44
- name: '',
45
- alias: '',
46
- content: '',
47
- masterTemplate: null,
45
+ name: preset?.name ?? '',
46
+ alias: preset?.alias ?? '',
47
+ content: preset?.content ?? scaffold,
48
+ masterTemplate: preset?.masterTemplate ?? null,
48
49
  };
49
50
  return { data };
50
51
  }
@@ -89,16 +89,16 @@ let UmbTemplateWorkspaceEditorElement = class UmbTemplateWorkspaceEditorElement
89
89
  <uui-button
90
90
  look="secondary"
91
91
  id="query-builder-button"
92
- label="Query builder"
92
+ label=${this.localize.term('template_queryBuilder')}
93
93
  @click=${__classPrivateFieldGet(this, _UmbTemplateWorkspaceEditorElement_instances, "m", _UmbTemplateWorkspaceEditorElement_openQueryBuilder)}>
94
- <uui-icon name="icon-wand"></uui-icon>Query builder
94
+ <uui-icon name="icon-wand"></uui-icon> ${this.localize.term('template_queryBuilder')}
95
95
  </uui-button>
96
96
  <uui-button
97
97
  look="secondary"
98
98
  id="sections-button"
99
- label="Query builder"
99
+ label=${this.localize.term('template_insertSections')}
100
100
  @click=${__classPrivateFieldGet(this, _UmbTemplateWorkspaceEditorElement_instances, "m", _UmbTemplateWorkspaceEditorElement_openInsertSectionModal)}>
101
- <uui-icon name="icon-indent"></uui-icon>Sections
101
+ <uui-icon name="icon-indent"></uui-icon> ${this.localize.term('template_insertSections')}
102
102
  </uui-button>
103
103
  </div>
104
104
  </div>
@@ -153,6 +153,7 @@ _UmbTemplateWorkspaceEditorElement_openMasterTemplatePicker = function _UmbTempl
153
153
  pickableFilter: (item) => {
154
154
  return item.unique !== null && item.unique !== __classPrivateFieldGet(this, _UmbTemplateWorkspaceEditorElement_templateWorkspaceContext, "f")?.getEntityId();
155
155
  },
156
+ hideTreeRoot: true,
156
157
  },
157
158
  value: {
158
159
  selection: [__classPrivateFieldGet(this, _UmbTemplateWorkspaceEditorElement_masterTemplateUnique, "f")],
@@ -179,15 +180,15 @@ _UmbTemplateWorkspaceEditorElement_renderMasterTemplatePicker = function _UmbTem
179
180
  @click=${__classPrivateFieldGet(this, _UmbTemplateWorkspaceEditorElement_instances, "m", _UmbTemplateWorkspaceEditorElement_openMasterTemplatePicker)}
180
181
  look="secondary"
181
182
  id="master-template-button"
182
- label="Change Master template"
183
- >${this._masterTemplateName
184
- ? `Master template: ${this._masterTemplateName}`
185
- : 'Set master template'}</uui-button
186
- >
183
+ label=${this.localize.term('template_mastertemplate')}>
184
+ ${this._masterTemplateName
185
+ ? `${this.localize.term('template_mastertemplate')}: ${this._masterTemplateName}`
186
+ : this.localize.term('template_noMaster')}
187
+ </uui-button>
187
188
  ${this._masterTemplateName
188
- ? html ` <uui-button look="secondary" id="save-button" label="Remove master template" compact
189
- ><uui-icon name="icon-delete" @click=${__classPrivateFieldGet(this, _UmbTemplateWorkspaceEditorElement_instances, "m", _UmbTemplateWorkspaceEditorElement_resetMasterTemplate)}></uui-icon
190
- ></uui-button>`
189
+ ? html ` <uui-button look="secondary" id="save-button" label=${this.localize.term('actions_remove')} compact>
190
+ <uui-icon name="icon-delete" @click=${__classPrivateFieldGet(this, _UmbTemplateWorkspaceEditorElement_instances, "m", _UmbTemplateWorkspaceEditorElement_resetMasterTemplate)}></uui-icon>
191
+ </uui-button>`
191
192
  : nothing}
192
193
  </uui-button-group>
193
194
  `;
@@ -28,7 +28,7 @@ export declare class UmbTemplateWorkspaceContext extends UmbEditableWorkspaceCon
28
28
  getHasLayoutBlock(): boolean;
29
29
  load(unique: string): Promise<void>;
30
30
  setMasterTemplate(id: string | null): Promise<UmbTemplateItemModel | null>;
31
- create(parentUnique: string | null): Promise<void>;
31
+ create(parentUnique: string | null, preset?: Partial<UmbTemplateDetailModel>): Promise<void>;
32
32
  save(): Promise<void>;
33
33
  destroy(): void;
34
34
  }
@@ -97,16 +97,15 @@ ${currentContent}`;
97
97
  }
98
98
  return null;
99
99
  }
100
- async create(parentUnique) {
101
- const { data } = await this.detailRepository.createScaffold(parentUnique);
100
+ async create(parentUnique, preset) {
101
+ const { data } = await this.detailRepository.createScaffold(parentUnique, preset);
102
102
  if (!data)
103
103
  return;
104
104
  this.setIsNew(true);
105
105
  __classPrivateFieldGet(this, _UmbTemplateWorkspaceContext_data, "f").setValue(data);
106
- /*
107
- if (!parentUnique) return;
106
+ if (!parentUnique)
107
+ return;
108
108
  await this.setMasterTemplate(parentUnique);
109
- */
110
109
  }
111
110
  async save() {
112
111
  if (!__classPrivateFieldGet(this, _UmbTemplateWorkspaceContext_data, "f").value)