Skip to content

Commit 6045745

Browse files
madsrasmussenLottePitcherwarrenbuckleynhudinh0309nul800sebastiaan
authored
Block Type Configuration: filter search to only include element types (#19201)
* Incorrect forum and security urls when raising issue (#19080) * Add 'ManifestWithDynamicConditions' to ManifestHeaderApp so Header Apps can be conditionally shown/loaded (#19124) * V15 QA Added acceptance tests for bulk trash dialog (#19125) * Added tests for bulk trash content dialog * Updated tests for trash content dialog * Added tests for trash and bulk trash media dialog * Moved trash content tests into a folder * Bumped version * Make trash tests run in the pipeline * Make trash tests run in the pipeline * Fixed comments * Reverted npm command * readme shield for forum * Allow deselection of color picker property. (#19174) * V15 Added acceptance tests for tiptap statusbar (#19131) * Updated tests for tiptap RTE * Moved tests for titptap toolbar to another class * Added tests for titptap toolbar * Added tests for tiptap statusbar * Bumped version * Make tiptap tests run in the pipeline * Bumped version * Reverted npm command * build: restores some of the behavior from V13 in relation to StaticAssets (#19189) In v13, the StaticAssets build was only triggered based on the existence of either the output folder or a preserve.* marker file. Here, we also additionally check for the node_modules/.package-lock.json file before reinstalling npm dependencies. We also now only run `npm install` rather than `npm ci` to optimise the build. * filter search to only include element types * V16 QA update failing nightly tests (#19190) * Fixed tests * More updates for tests * Bumped version of testhelpers * Fixed notifications in tests * Last fixes * Revert "Merge branch 'v16/dev' into v16/hotfix/filter-element-type-search-for-block-types" This reverts commit 7b8b5c2, reversing changes made to 6d4ddb7. * disable not pickable search results * correct use of pickable filter --------- Co-authored-by: Lotte Pitcher <[email protected]> Co-authored-by: Warren Buckley <[email protected]> Co-authored-by: Nhu Dinh <[email protected]> Co-authored-by: Sebastiaan Janssen <[email protected]> Co-authored-by: Lotte Pitcher <[email protected]> Co-authored-by: Andy Butland <[email protected]> Co-authored-by: Jacob Overgaard <[email protected]> Co-authored-by: Andreas Zerbst <[email protected]> Co-authored-by: mole <[email protected]> Co-authored-by: Niels Lyngsø <[email protected]>
1 parent 479ea0c commit 6045745

File tree

8 files changed

+39
-11
lines changed

8 files changed

+39
-11
lines changed

src/Umbraco.Web.UI.Client/src/packages/block/block-type/components/input-block-type/input-block-type.element.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ export class UmbInputBlockTypeElement<
106106
presetAlias: 'element',
107107
},
108108
},
109+
// TODO: hide the queryParams and filter config under a "elementTypesOnly" field. [MR]
110+
search: {
111+
queryParams: {
112+
isElementType: true,
113+
},
114+
},
109115
pickableFilter: (docType) =>
110116
// Only pick elements:
111117
docType.isElement &&

src/Umbraco.Web.UI.Client/src/packages/core/picker/search/picker-search-result.element.ts

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { UMB_PICKER_CONTEXT } from '../picker.context.token.js';
22
import type { UmbPickerContext } from '../picker.context.js';
33
import type { ManifestPickerSearchResultItem } from './result-item/picker-search-result-item.extension.js';
4-
import { customElement, html, nothing, repeat, state } from '@umbraco-cms/backoffice/external/lit';
4+
import { customElement, html, nothing, property, repeat, state } from '@umbraco-cms/backoffice/external/lit';
55
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
66
import type { UmbSearchRequestArgs } from '@umbraco-cms/backoffice/search';
77
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';
88

9+
type PickableFilterMethodType<T extends UmbEntityModel = UmbEntityModel> = (item: T) => boolean;
10+
911
@customElement('umb-picker-search-result')
1012
export class UmbPickerSearchResultElement extends UmbLitElement {
1113
@state()
@@ -20,6 +22,9 @@ export class UmbPickerSearchResultElement extends UmbLitElement {
2022
@state()
2123
_isSearchable: boolean = false;
2224

25+
@property({ attribute: false })
26+
pickableFilter: PickableFilterMethodType = () => true;
27+
2328
#pickerContext?: UmbPickerContext;
2429

2530
constructor() {
@@ -30,10 +35,15 @@ export class UmbPickerSearchResultElement extends UmbLitElement {
3035
this.observe(
3136
this.#pickerContext?.search.searchable,
3237
(isSearchable) => (this._isSearchable = isSearchable ?? false),
38+
'obsSearchable',
39+
);
40+
this.observe(this.#pickerContext?.search.query, (query) => (this._query = query), 'obsQuery');
41+
this.observe(
42+
this.#pickerContext?.search.searching,
43+
(query) => (this._searching = query ?? false),
44+
'obsSearching',
3345
);
34-
this.observe(this.#pickerContext?.search.query, (query) => (this._query = query));
35-
this.observe(this.#pickerContext?.search.searching, (query) => (this._searching = query ?? false));
36-
this.observe(this.#pickerContext?.search.resultItems, (items) => (this._items = items ?? []));
46+
this.observe(this.#pickerContext?.search.resultItems, (items) => (this._items = items ?? []), 'obsResultItems');
3747
});
3848
}
3949

@@ -58,11 +68,15 @@ export class UmbPickerSearchResultElement extends UmbLitElement {
5868
}
5969

6070
#renderResultItem(item: UmbEntityModel) {
71+
console.log('pickableFilter', this.pickableFilter(item));
6172
return html`
6273
<umb-extension-with-api-slot
6374
type="pickerSearchResultItem"
6475
.filter=${(manifest: ManifestPickerSearchResultItem) => manifest.forEntityTypes.includes(item.entityType)}
65-
.elementProps=${{ item }}></umb-extension-with-api-slot>
76+
.elementProps=${{
77+
item,
78+
disabled: !this.pickableFilter(item),
79+
}}></umb-extension-with-api-slot>
6680
`;
6781
}
6882
}

src/Umbraco.Web.UI.Client/src/packages/core/picker/search/result-item/default/default-picker-search-result-item.element.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export class UmbDefaultPickerSearchResultItemElement extends UmbPickerSearchResu
1313
id=${item.unique}
1414
icon=${item.icon ?? 'icon-document'}
1515
select-only
16-
selectable
16+
?selectable=${!this.disabled}
1717
?selected=${this._isSelected}
18+
?disabled=${this.disabled}
1819
@deselected=${() => this.pickerContext?.selection.deselect(item.unique)}
1920
@selected=${() => this.pickerContext?.selection.select(item.unique)}>
2021
</umb-ref-item>

src/Umbraco.Web.UI.Client/src/packages/core/picker/search/result-item/picker-search-result-item-element-base.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ export abstract class UmbPickerSearchResultItemElementBase<ItemType extends UmbN
1818
return this.#item;
1919
}
2020

21+
@property({ type: Boolean })
22+
disabled?: boolean;
23+
2124
@state()
2225
_isSelected = false;
2326

@@ -49,8 +52,9 @@ export abstract class UmbPickerSearchResultItemElementBase<ItemType extends UmbN
4952
<umb-ref-item
5053
name=${item.name}
5154
select-only
52-
selectable
55+
?selectable=${!this.disabled}
5356
?selected=${this._isSelected}
57+
?disabled=${this.disabled}
5458
@deselected=${() => this.pickerContext?.selection.deselect(item.unique)}
5559
@selected=${() => this.pickerContext?.selection.select(item.unique)}>
5660
</umb-ref-item>

src/Umbraco.Web.UI.Client/src/packages/core/tree/tree-picker-modal/tree-picker-modal.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ export class UmbTreePickerModalElement<TreeItemType extends UmbTreeItemModelBase
159159
#renderSearch() {
160160
return html`
161161
<umb-picker-search-field></umb-picker-search-field>
162-
<umb-picker-search-result></umb-picker-search-result>
162+
<umb-picker-search-result .pickableFilter=${this.data?.pickableFilter}></umb-picker-search-result>
163163
`;
164164
}
165165

src/Umbraco.Web.UI.Client/src/packages/documents/document-types/picker/document-type-picker-search-result-item.element.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export class UmbDocumentTypePickerSearchResultItemElement extends UmbPickerSearc
1313
id=${item.unique}
1414
icon=${item.icon ?? 'icon-document'}
1515
select-only
16-
selectable
16+
?selectable=${!this.disabled}
1717
?selected=${this._isSelected}
18+
?disabled=${this.disabled}
1819
@deselected=${() => this.pickerContext?.selection.deselect(item.unique)}
1920
@selected=${() => this.pickerContext?.selection.select(item.unique)}>
2021
${when(

src/Umbraco.Web.UI.Client/src/packages/documents/documents/picker/document-picker-search-result-item.element.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export class UmbDocumentPickerSearchResultItemElement extends UmbPickerSearchRes
1313
id=${item.unique}
1414
icon=${item.documentType.icon ?? 'icon-document'}
1515
select-only
16-
selectable
16+
?selectable=${!this.disabled}
1717
?selected=${this._isSelected}
18+
?disabled=${this.disabled}
1819
@deselected=${() => this.pickerContext?.selection.deselect(item.unique)}
1920
@selected=${() => this.pickerContext?.selection.select(item.unique)}>
2021
</umb-ref-item>

src/Umbraco.Web.UI.Client/src/packages/members/member/picker/member-picker-search-result-item.element.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ export class UmbMemberPickerSearchResultItemElement extends UmbPickerSearchResul
1313
id=${item.unique}
1414
icon=${item.memberType.icon ?? 'icon-user'}
1515
select-only
16-
selectable
16+
?selectable=${!this.disabled}
1717
?selected=${this._isSelected}
18+
?disabled=${this.disabled}
1819
@deselected=${() => this.pickerContext?.selection.deselect(item.unique)}
1920
@selected=${() => this.pickerContext?.selection.select(item.unique)}>
2021
</umb-ref-item>

0 commit comments

Comments
 (0)