Skip to content

Commit 1f050ff

Browse files
committed
single item mode
1 parent f8af105 commit 1f050ff

File tree

4 files changed

+42
-32
lines changed

4 files changed

+42
-32
lines changed

src/packages/block/block-grid/workspace/views/block-grid-type-workspace-view-advanced.element.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,6 @@ export class UmbBlockGridTypeWorkspaceViewAdvancedElement extends UmbLitElement
88
override render() {
99
return html`
1010
<uui-box headline="Advanced">
11-
<umb-property
12-
label="Custom view"
13-
alias="view"
14-
property-editor-ui-alias="Umb.PropertyEditorUi.StaticFilePicker"></umb-property>
15-
<umb-property
16-
label="Custom stylesheet"
17-
alias="stylesheet"
18-
property-editor-ui-alias="Umb.PropertyEditorUi.StaticFilePicker"></umb-property>
1911
<umb-property
2012
label="Overlay size"
2113
alias="editorSize"
@@ -41,7 +33,13 @@ export class UmbBlockGridTypeWorkspaceViewAdvancedElement extends UmbLitElement
4133
<umb-property
4234
label="Thumbnail"
4335
alias="thumbnail"
44-
property-editor-ui-alias="Umb.PropertyEditorUi.StaticFilePicker"></umb-property>
36+
property-editor-ui-alias="Umb.PropertyEditorUi.StaticFilePicker"
37+
.config=${[
38+
{
39+
alias: 'singleItemMode',
40+
value: true,
41+
},
42+
]}></umb-property>
4543
</uui-box>
4644
`;
4745
}

src/packages/block/block-list/workspace/views/block-list-type-workspace-view.element.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,6 @@ export class UmbBlockListTypeWorkspaceViewSettingsElement extends UmbLitElement
1212
label="Label"
1313
alias="label"
1414
property-editor-ui-alias="Umb.PropertyEditorUi.TextBox"></umb-property>
15-
<!--<umb-property
16-
label="Custom view"
17-
alias="view"
18-
property-editor-ui-alias="Umb.PropertyEditorUi.StaticFilePicker"></umb-property>
19-
<umb-property
20-
label="Custom stylesheet"
21-
alias="stylesheet"
22-
property-editor-ui-alias="Umb.PropertyEditorUi.StaticFilePicker"></umb-property>-->
2315
<umb-property
2416
label="Overlay size"
2517
alias="editorSize"
@@ -67,9 +59,15 @@ export class UmbBlockListTypeWorkspaceViewSettingsElement extends UmbLitElement
6759
alias="iconColor"
6860
property-editor-ui-alias="Umb.PropertyEditorUi.TextBox"></umb-property>
6961
<umb-property
70-
label="Custom stylesheet"
71-
alias="stylesheet"
72-
property-editor-ui-alias="Umb.PropertyEditorUi.StaticFilePicker"></umb-property>
62+
label="Thumbnail"
63+
alias="thumbnail"
64+
property-editor-ui-alias="Umb.PropertyEditorUi.StaticFilePicker"
65+
.config=${[
66+
{
67+
alias: 'singleItemMode',
68+
value: true,
69+
},
70+
]}></umb-property>
7371
</uui-box>
7472
<uui-box headline="Advanced">
7573
<umb-property

src/packages/block/block-rte/workspace/views/block-rte-type-workspace-view.element.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,15 @@ export class UmbBlockRteTypeWorkspaceViewSettingsElement extends UmbLitElement i
6363
alias="iconColor"
6464
property-editor-ui-alias="Umb.PropertyEditorUi.TextBox"></umb-property>
6565
<umb-property
66-
label="Custom stylesheet"
67-
alias="stylesheet"
68-
property-editor-ui-alias="Umb.PropertyEditorUi.StaticFilePicker"></umb-property>
66+
label="Thumbnail"
67+
alias="thumbnail"
68+
property-editor-ui-alias="Umb.PropertyEditorUi.StaticFilePicker"
69+
.config=${[
70+
{
71+
alias: 'singleItemMode',
72+
value: true,
73+
},
74+
]}></umb-property>
6975
</uui-box>
7076
`;
7177
}

src/packages/static-file/property-editors/static-file-picker/property-editor-ui-static-file-picker.element.ts

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,21 @@ import '../../components/input-static-file/index.js';
1111

1212
@customElement('umb-property-editor-ui-static-file-picker')
1313
export class UmbPropertyEditorUIStaticFilePickerElement extends UmbLitElement implements UmbPropertyEditorUiElement {
14-
private _value: Array<string> = [];
14+
private _singleItemMode = false;
1515

16-
@property({ type: Array })
17-
public set value(value: Array<string>) {
18-
this._value = value || [];
16+
@state()
17+
private _value?: string | Array<string>;
18+
19+
@property({ attribute: false })
20+
public set value(value: string | Array<string> | undefined) {
21+
this._value = value;
1922
}
20-
public get value(): Array<string> {
23+
public get value() {
2124
return this._value;
2225
}
2326

2427
public set config(config: UmbPropertyEditorConfigCollection | undefined) {
28+
this._singleItemMode = config?.getValueByAlias<boolean>('singleItemMode') ?? false;
2529
const validationLimit = config?.getValueByAlias<UmbNumberRangeValueType>('validationLimit');
2630

2731
this._limitMin = validationLimit?.min;
@@ -34,18 +38,22 @@ export class UmbPropertyEditorUIStaticFilePickerElement extends UmbLitElement im
3438
private _limitMax?: number;
3539

3640
private _onChange(event: CustomEvent) {
37-
this.value = (event.target as UmbInputStaticFileElement).selection;
41+
if (this._singleItemMode) {
42+
this.value = (event.target as UmbInputStaticFileElement).selection[0];
43+
} else {
44+
this.value = (event.target as UmbInputStaticFileElement).selection;
45+
}
3846
this.dispatchEvent(new UmbPropertyValueChangeEvent());
3947
}
4048

4149
// TODO: Implement mandatory?
4250
override render() {
4351
return html`
4452
<umb-input-static-file
45-
@change=${this._onChange}
46-
.selection=${this._value}
53+
.selection=${this._value ? (Array.isArray(this._value) ? this._value : [this._value]) : []}
4754
.min=${this._limitMin ?? 0}
48-
.max=${this._limitMax ?? Infinity}></umb-input-static-file>
55+
.max=${this._limitMax ?? Infinity}
56+
@change=${this._onChange}></umb-input-static-file>
4957
`;
5058
}
5159
}

0 commit comments

Comments
 (0)