@umbraco-cms/backoffice 14.0.0--preview004-e6d96d04 → 14.0.0--preview004-b8e797f1

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.
@@ -8,12 +8,40 @@ import { css, html, nothing, repeat, customElement, property, state } from '../.
8
8
  import { FormControlMixin } from '../../../../external/uui/index.js';
9
9
  import { UmbChangeEvent } from '../../event/index.js';
10
10
  import { UmbLitElement } from '../../../../shared/lit-element/index.js';
11
+ import { UmbSorterController } from '../../sorter/index.js';
12
+ const SORTER_CONFIG = {
13
+ compareElementToModel: (element, model) => {
14
+ return element.getAttribute('data-sort-entry-id') === model.value;
15
+ },
16
+ querySelectModelToElement: (container, modelEntry) => {
17
+ return container.querySelector('data-sort-entry-id=[' + modelEntry.value + ']');
18
+ },
19
+ identifier: 'Umb.SorterIdentifier.ColorEditor',
20
+ itemSelector: 'umb-input-multiple-text-string-item',
21
+ containerSelector: '#sorter-wrapper',
22
+ };
11
23
  /**
12
24
  * @element umb-input-multiple-text-string
13
25
  */
14
26
  let UmbInputMultipleTextStringElement = class UmbInputMultipleTextStringElement extends FormControlMixin(UmbLitElement) {
27
+ #prevalueSorter;
15
28
  constructor() {
16
29
  super();
30
+ this.#prevalueSorter = new UmbSorterController(this, {
31
+ ...SORTER_CONFIG,
32
+ performItemInsert: (args) => {
33
+ const frozenArray = [...this.items];
34
+ const indexToMove = frozenArray.findIndex((x) => x.value === args.item.value);
35
+ frozenArray.splice(indexToMove, 1);
36
+ frozenArray.splice(args.newIndex, 0, args.item);
37
+ this.items = frozenArray;
38
+ this.dispatchEvent(new UmbChangeEvent());
39
+ return true;
40
+ },
41
+ performItemRemove: (args) => {
42
+ return true;
43
+ },
44
+ });
17
45
  /**
18
46
  * Min validation message.
19
47
  * @type {boolean}
@@ -63,6 +91,7 @@ let UmbInputMultipleTextStringElement = class UmbInputMultipleTextStringElement
63
91
  // TODO: when we have a way to overwrite the missing value validator we can remove this
64
92
  this.value = items?.length > 0 ? 'some value' : '';
65
93
  this._items = items ?? [];
94
+ this.#prevalueSorter.setModel(this.items);
66
95
  }
67
96
  // TODO: Some inputs might not have a value that is either FormDataEntryValue or FormData.
68
97
  // How do we handle this?
@@ -104,13 +133,15 @@ let UmbInputMultipleTextStringElement = class UmbInputMultipleTextStringElement
104
133
  return undefined;
105
134
  }
106
135
  render() {
107
- return html ` ${this.#renderItems()} ${this.#renderAddButton()} `;
136
+ return html `<div id="sorter-wrapper">${this.#renderItems()}</div>
137
+ ${this.#renderAddButton()} `;
108
138
  }
109
139
  #renderItems() {
110
140
  return html `
111
141
  ${repeat(this._items, (item, index) => index, (item, index) => html ` <umb-input-multiple-text-string-item
112
142
  value=${item.value}
113
143
  name="item-${index}"
144
+ data-sort-entry-id=${item.value}
114
145
  @input=${(event) => this.#onInput(event, index)}
115
146
  @delete="${(event) => this.#deleteItem(event, index)}"
116
147
  ?disabled=${this.disabled}
@@ -137,6 +168,18 @@ let UmbInputMultipleTextStringElement = class UmbInputMultipleTextStringElement
137
168
  #action {
138
169
  display: block;
139
170
  }
171
+
172
+ .--umb-sorter-placeholder {
173
+ position: relative;
174
+ visibility: hidden;
175
+ }
176
+ .--umb-sorter-placeholder::after {
177
+ content: '';
178
+ position: absolute;
179
+ inset: 0px;
180
+ border-radius: var(--uui-border-radius);
181
+ border: 1px dashed var(--uui-color-divider-emphasis);
182
+ }
140
183
  `,
141
184
  ]; }
142
185
  };
@@ -1,7 +1,7 @@
1
1
  export const manifest = {
2
2
  type: 'propertyEditorSchema',
3
3
  name: 'Checkbox List',
4
- alias: 'Umbraco.CheckBoxList',
4
+ alias: 'Umbraco.CheckboxList',
5
5
  meta: {
6
6
  defaultPropertyEditorUiAlias: 'Umb.PropertyEditorUi.CheckboxList',
7
7
  },
@@ -40,6 +40,7 @@ let UmbDictionaryWorkspaceEditorElement = class UmbDictionaryWorkspaceEditorElem
40
40
  <uui-icon name="icon-arrow-left"></uui-icon>
41
41
  </uui-button>
42
42
  <uui-input
43
+ placeholder=${this.localize.term('placeholders_entername')}
43
44
  .value=${this._name ?? ''}
44
45
  @input="${this.#handleInput}"
45
46
  label="${this.localize.term('general_dictionary')} ${this.localize.term('general_name')}"></uui-input>
@@ -12,7 +12,7 @@ export declare class UmbQueryBuilderFilterElement extends UmbLitElement {
12
12
  private _renderOperatorsDropdown;
13
13
  private _renderConstraintValueInput;
14
14
  render(): import("lit-html").TemplateResult<1>;
15
- static styles: import("@lit/reactive-element/css-tag").CSSResult[];
15
+ static styles: import("@lit/reactive-element/css-tag.js").CSSResult[];
16
16
  }
17
17
  export default UmbQueryBuilderFilterElement;
18
18
  declare global {
@@ -4,7 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { css, html, customElement, property, state } from '../../../../../external/lit/index.js';
7
+ import { localizeOperators, localizePropertyType } from './utils.js';
8
+ import { css, html, customElement, property, state, ifDefined, } from '../../../../../external/lit/index.js';
8
9
  import { UmbLitElement } from '../../../../../shared/lit-element/index.js';
9
10
  import { TemplateQueryPropertyTypeModel, } from '../../../../../external/backend-api/index.js';
10
11
  let UmbQueryBuilderFilterElement = class UmbQueryBuilderFilterElement extends UmbLitElement {
@@ -62,15 +63,18 @@ let UmbQueryBuilderFilterElement = class UmbQueryBuilderFilterElement extends Um
62
63
  }
63
64
  }
64
65
  _renderOperatorsDropdown() {
65
- return html `<umb-dropdown look="outline" id="operator-dropdown" label="choose operator">
66
+ if (!this.settings?.operators)
67
+ return;
68
+ const operators = localizeOperators(this.settings?.operators, this.currentPropertyType);
69
+ return html `<umb-dropdown look="outline" id="operator-dropdown" label="Choose operator">
66
70
  <span slot="label">${this.filter?.operator ?? ''}</span>
67
71
  <uui-combobox-list @change=${this.#setOperator} class="options-list">
68
- ${this.settings?.operators
72
+ ${operators
69
73
  ?.filter((operator) => this.currentPropertyType ? operator.applicableTypes?.includes(this.currentPropertyType) : true)
70
- .map((operator) => html `<uui-combobox-list-option .value=${operator.operator ?? ''}
71
- >${operator.operator}</uui-combobox-list-option
72
- >`)}</uui-combobox-list
73
- >
74
+ .map((operator) => html `<uui-combobox-list-option .value=${operator.operator ?? ''}>
75
+ <umb-localize .key=${operator.localizeKey}> ${operator.operator} </umb-localize>
76
+ </uui-combobox-list-option>`)}
77
+ </uui-combobox-list>
74
78
  </umb-dropdown>`;
75
79
  }
76
80
  _renderConstraintValueInput() {
@@ -86,23 +90,32 @@ let UmbQueryBuilderFilterElement = class UmbQueryBuilderFilterElement extends Um
86
90
  }
87
91
  }
88
92
  render() {
93
+ const properties = localizePropertyType(this.settings?.properties);
89
94
  return html `
90
95
  <span>${this.unremovable ? this.localize.term('template_where') : this.localize.term('template_and')}</span>
91
96
  <umb-dropdown look="outline" id="property-alias-dropdown" label="Property alias">
92
97
  <span slot="label">${this.filter?.propertyAlias ?? ''}</span>
93
98
  <uui-combobox-list @change=${this.#setPropertyAlias} class="options-list">
94
- ${this.settings?.properties?.map((property) => html `<uui-combobox-list-option tabindex="0" .value=${property.alias ?? ''}
95
- >${property.alias}</uui-combobox-list-option
96
- >`)}
99
+ ${properties?.map((property) => html `<uui-combobox-list-option tabindex="0" .value=${property.alias ?? ''}>
100
+ <umb-localize key=${ifDefined(property.localizeKey)}> ${property.alias}</umb-localize>
101
+ </uui-combobox-list-option>`)}
97
102
  </uui-combobox-list></umb-dropdown
98
103
  >
99
104
  ${this.filter?.propertyAlias ? this._renderOperatorsDropdown() : ''}
100
105
  ${this.filter?.operator ? this._renderConstraintValueInput() : ''}
101
106
  <uui-button-group>
102
- <uui-button title="Add filter" label="Add filter" compact @click=${this.#addFilter}>
107
+ <uui-button
108
+ title=${this.localize.term('general_add')}
109
+ label=${this.localize.term('general_add')}
110
+ compact
111
+ @click=${this.#addFilter}>
103
112
  <uui-icon name="icon-add"></uui-icon>
104
113
  </uui-button>
105
- <uui-button title="Remove filter" label="Remove filter" compact @click=${this.#removeOrReset}>
114
+ <uui-button
115
+ title=${this.localize.term('general_remove')}
116
+ label=${this.localize.term('general_remove')}
117
+ compact
118
+ @click=${this.#removeOrReset}>
106
119
  <uui-icon name="delete"></uui-icon>
107
120
  </uui-button>
108
121
  </uui-button-group>
@@ -5,7 +5,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { UmbTemplateRepository } from '../../repository/template.repository.js';
8
- import { css, html, customElement, state, query, queryAll } from '../../../../../external/lit/index.js';
8
+ import { localizePropertyType, localizeSort } from './utils.js';
9
+ import { css, html, customElement, state, query, queryAll, ifDefined } from '../../../../../external/lit/index.js';
9
10
  import { UmbModalBaseElement, UMB_DOCUMENT_PICKER_MODAL, UMB_MODAL_MANAGER_CONTEXT_TOKEN, } from '../../../../core/modal/index.js';
10
11
  import { UmbDocumentRepository } from '../../../../documents/documents/index.js';
11
12
  import './query-builder-filter.element.js';
@@ -144,24 +145,30 @@ let UmbChooseInsertTypeModalElement = class UmbChooseInsertTypeModalElement exte
144
145
  #updateFilters;
145
146
  #removeFilter;
146
147
  render() {
148
+ const properties = localizePropertyType(this._queryBuilderSettings?.properties);
149
+ const sort = localizeSort(this._queryRequest.sort);
147
150
  return html `
148
- <umb-body-layout headline="Query builder">
151
+ <umb-body-layout headline=${this.localize.term('template_queryBuilder')}>
149
152
  <div id="main">
150
153
  <uui-box>
151
154
  <div class="row">
152
- I want
155
+ <umb-localize key="template_iWant">I want</umb-localize>
153
156
  <umb-dropdown look="outline" id="content-type-dropdown" label="Choose content type">
154
- <span slot="label">${this._queryRequest?.contentTypeAlias ?? 'all content'}</span>
157
+ <span slot="label">
158
+ ${this._queryRequest?.contentTypeAlias ?? this.localize.term('template_allContent')}
159
+ </span>
155
160
  <uui-combobox-list @change=${this.#setContentType} class="options-list">
156
161
  <uui-combobox-list-option value="">all content</uui-combobox-list-option>
157
- ${this._queryBuilderSettings?.contentTypeAliases?.map((alias) => html `<uui-combobox-list-option .value=${alias}
158
- >content of type "${alias}"</uui-combobox-list-option
159
- >`)}
162
+ ${this._queryBuilderSettings?.contentTypeAliases?.map((alias) => html `<uui-combobox-list-option .value=${alias}>
163
+ <umb-localize key="template_contentOfType" .args=${[alias]}>
164
+ content of type "${alias}"
165
+ </umb-localize>
166
+ </uui-combobox-list-option>`)}
160
167
  </uui-combobox-list></umb-dropdown
161
168
  >
162
- from
163
- <uui-button look="outline" @click=${this.#openDocumentPicker} label="Choose root content"
164
- >${this._selectedRootContentName}
169
+ <umb-localize key="template_from">from</umb-localize>
170
+ <uui-button look="outline" @click=${this.#openDocumentPicker} label="Choose root content">
171
+ ${this._selectedRootContentName}
165
172
  </uui-button>
166
173
  </div>
167
174
  <div id="filter-container">
@@ -174,35 +181,45 @@ let UmbChooseInsertTypeModalElement = class UmbChooseInsertTypeModalElement exte
174
181
  @remove-filter=${this.#removeFilter}></umb-query-builder-filter>
175
182
  </div>
176
183
  <div class="row">
177
- ordered by
184
+ <umb-localize key="template_orderBy">order by</umb-localize>
178
185
  <umb-dropdown look="outline" id="sort-dropdown" label="Property alias">
179
186
  <span slot="label">${this._queryRequest.sort?.propertyAlias ?? ''}</span>
180
187
  <uui-combobox-list @change=${this.#setSortProperty} class="options-list">
181
- ${this._queryBuilderSettings?.properties?.map((property) => html `<uui-combobox-list-option .value=${property.alias ?? ''}
182
- >${property.alias}</uui-combobox-list-option
183
- >`)}
184
- </uui-combobox-list></umb-dropdown
185
- >
188
+ ${properties?.map((property) => html `<uui-combobox-list-option .value=${property.alias ?? ''}>
189
+ <umb-localize key=${ifDefined(property.localizeKey)}>${property.alias}</umb-localize>
190
+ </uui-combobox-list-option>`)}
191
+ </uui-combobox-list>
192
+ </umb-dropdown>
186
193
 
187
- ${this._queryRequest.sort?.propertyAlias
188
- ? html `<uui-button look="outline" @click=${this.#setSortDirection}
189
- >${this._queryRequest.sort.direction ?? this._defaultSortDirection}</uui-button
190
- >`
194
+ ${sort?.propertyAlias
195
+ ? html `<uui-button look="outline" @click=${this.#setSortDirection}>
196
+ <umb-localize key=${ifDefined(sort.localizeKey)}>
197
+ ${sort.direction ?? this._defaultSortDirection}
198
+ </umb-localize>
199
+ </uui-button>`
191
200
  : ''}
192
201
  </div>
193
202
  <div class="row">
194
- <span id="results-count"
195
- >${this._templateQuery?.resultCount ?? 0} items returned, in ${this._templateQuery?.executionTime ?? 0}
196
- ms</span
197
- >
203
+ <span id="results-count">
204
+ ${this._templateQuery?.resultCount ?? 0}
205
+ <umb-localize key="template_itemsReturned">items returned, in</umb-localize>
206
+ ${this._templateQuery?.executionTime ?? 0} ms
207
+ </span>
198
208
  </div>
199
209
  <umb-code-block language="C#" copy>${this._templateQuery?.queryExpression ?? ''}</umb-code-block>
200
210
  </uui-box>
201
211
  </div>
202
212
 
203
213
  <div slot="actions">
204
- <uui-button @click=${this.#close} look="secondary" label="Close">Close</uui-button>
205
- <uui-button @click=${this.#submit} look="primary" color="positive" label="Submit">Submit</uui-button>
214
+ <uui-button
215
+ @click=${this.#close}
216
+ look="secondary"
217
+ label=${this.localize.term('buttons_confirmActionCancel')}></uui-button>
218
+ <uui-button
219
+ @click=${this.#submit}
220
+ look="primary"
221
+ color="positive"
222
+ label=${this.localize.term('buttons_submitChanges')}></uui-button>
206
223
  </div>
207
224
  </umb-body-layout>
208
225
  `;
@@ -0,0 +1,14 @@
1
+ import { TemplateQueryExecuteSortModel, TemplateQueryOperatorModel, TemplateQueryPropertyPresentationModel, TemplateQueryPropertyTypeModel } from '../../../../../external/backend-api/index.js';
2
+ type TemplateOperatorModel = TemplateQueryOperatorModel & {
3
+ localizeKey?: string;
4
+ };
5
+ type TemplatePropertyModel = TemplateQueryPropertyPresentationModel & {
6
+ localizeKey?: string;
7
+ };
8
+ type TemplateSortModel = TemplateQueryExecuteSortModel & {
9
+ localizeKey?: string;
10
+ };
11
+ export declare function localizeOperators(operators: Array<TemplateQueryOperatorModel>, currentPropertyType: TemplateQueryPropertyTypeModel | null): Array<TemplateOperatorModel>;
12
+ export declare function localizePropertyType(propertyTypes?: Array<TemplateQueryPropertyPresentationModel>): TemplatePropertyModel[] | undefined;
13
+ export declare function localizeSort(sort?: TemplateQueryExecuteSortModel | null): TemplateSortModel | undefined;
14
+ export {};
@@ -0,0 +1,96 @@
1
+ import { OperatorModel, TemplateQueryPropertyTypeModel, UserOrderModel, } from '../../../../../external/backend-api/index.js';
2
+ export function localizeOperators(operators, currentPropertyType) {
3
+ switch (currentPropertyType) {
4
+ case TemplateQueryPropertyTypeModel.STRING:
5
+ return isString(operators);
6
+ case TemplateQueryPropertyTypeModel.INTEGER:
7
+ return isInteger(operators);
8
+ case TemplateQueryPropertyTypeModel.DATE_TIME:
9
+ return isDateTime(operators);
10
+ default:
11
+ return operators;
12
+ }
13
+ }
14
+ export function localizePropertyType(propertyTypes) {
15
+ if (!propertyTypes)
16
+ return;
17
+ return propertyTypes.map((propertyType) => {
18
+ switch (propertyType.alias) {
19
+ case UserOrderModel.NAME:
20
+ return { ...propertyType, localizeKey: 'template_name' };
21
+ case UserOrderModel.ID:
22
+ return { ...propertyType, localizeKey: 'template_id' };
23
+ case UserOrderModel.CREATE_DATE:
24
+ return { ...propertyType, localizeKey: 'template_createdDate' };
25
+ case UserOrderModel.UPDATE_DATE:
26
+ return { ...propertyType, localizeKey: 'template_lastUpdatedDate' };
27
+ default:
28
+ return propertyType;
29
+ }
30
+ });
31
+ }
32
+ export function localizeSort(sort) {
33
+ if (!sort?.direction)
34
+ return undefined;
35
+ switch (sort.direction) {
36
+ case 'ascending':
37
+ return { ...sort, localizeKey: 'template_ascending' };
38
+ case 'descending':
39
+ return { ...sort, localizeKey: 'template_descending' };
40
+ default:
41
+ return sort;
42
+ }
43
+ }
44
+ // Following code is for localization of operators (checks on property type);
45
+ function isString(operators) {
46
+ return operators.map((operator) => {
47
+ switch (operator.operator) {
48
+ case OperatorModel.EQUALS:
49
+ return { ...operator, localizeKey: 'template_is' };
50
+ case OperatorModel.NOT_EQUALS:
51
+ return { ...operator, localizeKey: 'template_isNot' };
52
+ case OperatorModel.CONTAINS:
53
+ return { ...operator, localizeKey: 'template_contains' };
54
+ case OperatorModel.NOT_CONTAINS:
55
+ return { ...operator, localizeKey: 'template_doesNotContain' };
56
+ default:
57
+ return operator;
58
+ }
59
+ });
60
+ }
61
+ function isInteger(operators) {
62
+ return operators.map((operator) => {
63
+ switch (operator.operator) {
64
+ case OperatorModel.EQUALS:
65
+ return { ...operator, localizeKey: 'template_equals' };
66
+ case OperatorModel.NOT_EQUALS:
67
+ return { ...operator, localizeKey: 'template_doesNotEqual' };
68
+ case OperatorModel.GREATER_THAN:
69
+ return { ...operator, localizeKey: 'template_greaterThan' };
70
+ case OperatorModel.GREATER_THAN_EQUAL_TO:
71
+ return { ...operator, localizeKey: 'template_greaterThanEqual' };
72
+ case OperatorModel.LESS_THAN:
73
+ return { ...operator, localizeKey: 'template_lessThan' };
74
+ case OperatorModel.LESS_THAN_EQUAL_TO:
75
+ return { ...operator, localizeKey: 'template_lessThanEqual' };
76
+ default:
77
+ return operator;
78
+ }
79
+ });
80
+ }
81
+ function isDateTime(operators) {
82
+ return operators.map((operator) => {
83
+ switch (operator.operator) {
84
+ case OperatorModel.GREATER_THAN:
85
+ return { ...operator, localizeKey: 'template_before' };
86
+ case OperatorModel.GREATER_THAN_EQUAL_TO:
87
+ return { ...operator, localizeKey: 'template_beforeIncDate' };
88
+ case OperatorModel.LESS_THAN:
89
+ return { ...operator, localizeKey: 'template_after' };
90
+ case OperatorModel.LESS_THAN_EQUAL_TO:
91
+ return { ...operator, localizeKey: 'template_afterIncDate' };
92
+ default:
93
+ return operator;
94
+ }
95
+ });
96
+ }
@@ -53,7 +53,7 @@ let UmbTemplateWorkspaceEditorElement = class UmbTemplateWorkspaceEditorElement
53
53
  });
54
54
  this.inputQuery$.pipe(debounceTime(250)).subscribe((nameInputValue) => {
55
55
  this.#templateWorkspaceContext?.setName(nameInputValue);
56
- if (this.#isNew && !this._alias)
56
+ if (this.#isNew)
57
57
  this.#templateWorkspaceContext?.setAlias(camelCase(nameInputValue));
58
58
  });
59
59
  });
@@ -64,6 +64,7 @@ let UmbTemplateWorkspaceEditorElement = class UmbTemplateWorkspaceEditorElement
64
64
  this.inputQuery$.next(value);
65
65
  }
66
66
  #onAliasInput(event) {
67
+ event.stopPropagation();
67
68
  const target = event.target;
68
69
  const value = target.value;
69
70
  this.#templateWorkspaceContext?.setAlias(value);
@@ -150,7 +151,7 @@ let UmbTemplateWorkspaceEditorElement = class UmbTemplateWorkspaceEditorElement
150
151
  .value=${this._name}
151
152
  @input=${this.#onNameInput}
152
153
  label="template name">
153
- <uui-input-lock slot="append" value=${ifDefined(this._alias)} @change=${this.#onAliasInput}></uui-input-lock>
154
+ <uui-input-lock slot="append" value=${ifDefined(this._alias)} @input=${this.#onAliasInput}></uui-input-lock>
154
155
  </uui-input>
155
156
 
156
157
  <uui-box>
@@ -120,6 +120,7 @@ ${currentContent}`;
120
120
  else {
121
121
  this.#treeRepository.requestRootTreeItems();
122
122
  }
123
+ this.setIsNew(false);
123
124
  return;
124
125
  }
125
126
  if (template?.id) {