Skip to content

Commit 2d2eea4

Browse files
Merge branch 'main' into 14/bugfix/calculate-user-start-nodes
2 parents c5d199f + 631a217 commit 2d2eea4

File tree

21 files changed

+206
-175
lines changed

21 files changed

+206
-175
lines changed

examples/sorter-with-nested-containers/sorter-dashboard.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
22
import { css, html, customElement, LitElement } from '@umbraco-cms/backoffice/external/lit';
33
import { UmbElementMixin } from '@umbraco-cms/backoffice/element-api';
4-
import type { ModelEntryType } from './sorter-group.js';
4+
import type { ExampleSorterGroup, ModelEntryType } from './sorter-group.js';
55

66
import './sorter-group.js';
77
@customElement('example-sorter-dashboard')
@@ -57,9 +57,16 @@ export class ExampleSorterDashboard extends UmbElementMixin(LitElement) {
5757
return html`
5858
<uui-box class="uui-text">
5959
<div class="outer-wrapper">
60-
<h5>Notice this example still only support single group of Sorter.</h5>
61-
<example-sorter-group .initialItems=${this.groupOneItems}></example-sorter-group>
62-
<example-sorter-group .initialItems=${this.groupTwoItems}></example-sorter-group>
60+
<example-sorter-group
61+
.value=${this.groupOneItems}
62+
@change=${(e: Event) => {
63+
this.groupOneItems = (e.target as ExampleSorterGroup).value;
64+
}}></example-sorter-group>
65+
<example-sorter-group
66+
.value=${this.groupTwoItems}
67+
@change=${(e: Event) => {
68+
this.groupTwoItems = (e.target as ExampleSorterGroup).value;
69+
}}></example-sorter-group>
6370
</div>
6471
</uui-box>
6572
`;

examples/sorter-with-nested-containers/sorter-group.ts

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,8 @@ export type ModelEntryType = {
1313

1414
@customElement('example-sorter-group')
1515
export class ExampleSorterGroup extends UmbElementMixin(LitElement) {
16-
@property({ type: Array, attribute: false })
17-
public get initialItems(): ModelEntryType[] {
18-
return this.items;
19-
}
20-
public set initialItems(value: ModelEntryType[]) {
21-
// Only want to set the model initially, cause any re-render should not set this again.
22-
if (this._items !== undefined) return;
23-
this.items = value;
24-
}
25-
26-
@property({ type: Array, attribute: false })
27-
public get items(): ModelEntryType[] {
28-
return this._items ?? [];
29-
}
30-
public set items(value: ModelEntryType[]) {
31-
const oldValue = this._items;
32-
this._items = value;
33-
this.#sorter.setModel(this._items);
34-
this.requestUpdate('items', oldValue);
35-
}
36-
private _items?: ModelEntryType[];
37-
16+
//
17+
// Sorter setup:
3818
#sorter = new UmbSorterController<ModelEntryType, ExampleSorterItem>(this, {
3919
getUniqueOfElement: (element) => {
4020
return element.name;
@@ -46,26 +26,45 @@ export class ExampleSorterGroup extends UmbElementMixin(LitElement) {
4626
itemSelector: 'example-sorter-item',
4727
containerSelector: '.sorter-container',
4828
onChange: ({ model }) => {
49-
const oldValue = this._items;
50-
this._items = model;
51-
this.requestUpdate('items', oldValue);
29+
const oldValue = this._value;
30+
this._value = model;
31+
this.requestUpdate('value', oldValue);
32+
// Fire an event for the parent to know that the model has changed.
33+
this.dispatchEvent(new CustomEvent('change'));
5234
},
5335
});
5436

37+
@property({ type: Array, attribute: false })
38+
public get value(): ModelEntryType[] {
39+
return this._value ?? [];
40+
}
41+
public set value(value: ModelEntryType[]) {
42+
const oldValue = this._value;
43+
this._value = value;
44+
this.#sorter.setModel(this._value);
45+
this.requestUpdate('value', oldValue);
46+
}
47+
private _value?: ModelEntryType[];
48+
5549
removeItem = (item: ModelEntryType) => {
56-
this.items = this.items.filter((r) => r.name !== item.name);
50+
this.value = this.value.filter((r) => r.name !== item.name);
5751
};
5852

5953
render() {
6054
return html`
6155
<div class="sorter-container">
6256
${repeat(
63-
this.items,
57+
this.value,
58+
// Note: ideally you have an unique identifier for each item, but for this example we use the `name` as identifier.
6459
(item) => item.name,
6560
(item) =>
6661
html`<example-sorter-item name=${item.name}>
6762
<button slot="action" @click=${() => this.removeItem(item)}>Delete</button>
68-
${item.children ? html`<example-sorter-group .initialItems=${item.children}></example-sorter-group>` : ''}
63+
<example-sorter-group
64+
.value=${item.children ?? []}
65+
@change=${(e: Event) => {
66+
item.children = (e.target as ExampleSorterGroup).value;
67+
}}></example-sorter-group>
6968
</example-sorter-item>`,
7069
)}
7170
</div>

package-lock.json

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
"@types/diff": "^5.2.1",
185185
"@types/dompurify": "^3.0.5",
186186
"@types/uuid": "^9.0.8",
187-
"@umbraco-ui/uui": "1.8.1",
187+
"@umbraco-ui/uui": "1.8.2",
188188
"@umbraco-ui/uui-css": "1.8.0",
189189
"base64-js": "^1.5.1",
190190
"diff": "^5.2.0",
@@ -265,4 +265,4 @@
265265
"access": "public",
266266
"registry": "https://registry.npmjs.org/"
267267
}
268-
}
268+
}

src/assets/lang/da-dk.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ export default {
538538
selectContentType: 'Vælg indholdstype',
539539
selectMediaStartNode: 'Vælg startnode for mediearkivet',
540540
selectMember: 'Vælg medlem',
541+
selectMembers: 'Vælg medlemmer',
541542
selectMemberGroup: 'Vælg medlemsgruppe',
542543
selectMemberType: 'Vælg medlemstype',
543544
selectNode: 'Vælg node',
@@ -762,6 +763,7 @@ export default {
762763
deleted: 'Slettet',
763764
deleting: 'Sletter...',
764765
design: 'Design',
766+
details: 'Detaljer',
765767
dictionary: 'Ordbog',
766768
dimensions: 'Dimensioner',
767769
discard: 'Kassér',
@@ -808,6 +810,7 @@ export default {
808810
message: 'Besked',
809811
move: 'Flyt',
810812
name: 'Navn',
813+
never: 'Aldrig',
811814
new: 'Ny',
812815
next: 'Næste',
813816
no: 'Nej',
@@ -850,6 +853,7 @@ export default {
850853
submit: 'Indsend',
851854
type: 'Type',
852855
typeToSearch: 'Skriv for at søge...',
856+
unknown: 'Ukendt',
853857
unknownUser: 'Ukendt bruger',
854858
under: 'under',
855859
up: 'Op',

src/assets/lang/en-us.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ export default {
549549
selectContentType: 'Select content type',
550550
selectMediaStartNode: 'Select media start node',
551551
selectMember: 'Select member',
552+
selectMembers: 'Select members',
552553
selectMemberGroup: 'Select member group',
553554
selectMemberType: 'Select member type',
554555
selectNode: 'Select node',
@@ -821,6 +822,7 @@ export default {
821822
message: 'Message',
822823
move: 'Move',
823824
name: 'Name',
825+
never: 'Never',
824826
new: 'New',
825827
next: 'Next',
826828
no: 'No',
@@ -870,6 +872,7 @@ export default {
870872
type: 'Type',
871873
typeName: 'Type Name',
872874
typeToSearch: 'Type to search...',
875+
unknown: 'Unknown',
873876
unknownUser: 'Unknown user',
874877
under: 'under',
875878
up: 'Up',
@@ -1300,7 +1303,7 @@ export default {
13001303
packages: 'Packages',
13011304
marketplace: 'Marketplace',
13021305
settings: 'Settings',
1303-
translation: 'Translation',
1306+
translation: 'Dictionary',
13041307
users: 'Users',
13051308
},
13061309
help: {

0 commit comments

Comments
 (0)