|
1 |
| -import type { UmbDropzoneElement } from '../../dropzone/dropzone.element.js'; |
2 |
| -import { type UmbMediaItemModel, UmbMediaItemRepository, UmbMediaUrlRepository } from '../../repository/index.js'; |
| 1 | +import { UmbMediaItemRepository, UmbMediaUrlRepository } from '../../repository/index.js'; |
3 | 2 | import { UmbMediaTreeRepository } from '../../tree/media-tree.repository.js';
|
4 | 3 | import { UMB_MEDIA_ROOT_ENTITY_TYPE } from '../../entity.js';
|
| 4 | +import type { UmbDropzoneElement } from '../../dropzone/dropzone.element.js'; |
| 5 | +import type { UmbMediaItemModel } from '../../repository/index.js'; |
5 | 6 | import type { UmbMediaCardItemModel, UmbMediaPathModel } from './types.js';
|
6 | 7 | import type { UmbMediaPickerFolderPathElement } from './components/media-picker-folder-path.element.js';
|
7 | 8 | import type { UmbMediaPickerModalData, UmbMediaPickerModalValue } from './media-picker-modal.token.js';
|
8 |
| -import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal'; |
9 |
| -import { UmbImagingRepository } from '@umbraco-cms/backoffice/imaging'; |
10 | 9 | import { css, html, customElement, state, repeat, ifDefined, query } from '@umbraco-cms/backoffice/external/lit';
|
11 |
| -import type { UUIInputEvent } from '@umbraco-cms/backoffice/external/uui'; |
| 10 | +import { debounce } from '@umbraco-cms/backoffice/utils'; |
12 | 11 | import { ImageCropModeModel } from '@umbraco-cms/backoffice/external/backend-api';
|
| 12 | +import { UmbImagingRepository } from '@umbraco-cms/backoffice/imaging'; |
| 13 | +import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal'; |
13 | 14 | import { UMB_CONTENT_PROPERTY_CONTEXT } from '@umbraco-cms/backoffice/content';
|
| 15 | +import type { UUIInputEvent } from '@umbraco-cms/backoffice/external/uui'; |
14 | 16 |
|
15 | 17 | const root: UmbMediaPathModel = { name: 'Media', unique: null, entityType: UMB_MEDIA_ROOT_ENTITY_TYPE };
|
16 | 18 |
|
@@ -154,9 +156,13 @@ export class UmbMediaPickerModalElement extends UmbModalBaseElement<
|
154 | 156 | this._mediaFilteredList = await this.#mapMediaUrls(data.filter((found) => found.isTrashed === false));
|
155 | 157 | }
|
156 | 158 |
|
| 159 | + #debouncedSearch = debounce(() => { |
| 160 | + this.#filterMediaItems(); |
| 161 | + }, 500); |
| 162 | + |
157 | 163 | #onSearch(e: UUIInputEvent) {
|
158 | 164 | this._searchQuery = (e.target.value as string).toLocaleLowerCase();
|
159 |
| - this.#filterMediaItems(); |
| 165 | + this.#debouncedSearch(); |
160 | 166 | }
|
161 | 167 |
|
162 | 168 | #onPathChange(e: CustomEvent) {
|
@@ -203,23 +209,25 @@ export class UmbMediaPickerModalElement extends UmbModalBaseElement<
|
203 | 209 | #renderToolbar() {
|
204 | 210 | /**<umb-media-picker-create-item .node=${this._currentMediaEntity.unique}></umb-media-picker-create-item>
|
205 | 211 | * We cannot route to a workspace without the media picker modal is a routeable. Using regular upload button for now... */
|
206 |
| - return html`<div id="toolbar"> |
207 |
| - <div id="search"> |
208 |
| - <uui-input |
209 |
| - label=${this.localize.term('general_search')} |
210 |
| - placeholder=${this.localize.term('placeholders_search')} |
211 |
| - @change=${this.#onSearch}> |
212 |
| - <uui-icon slot="prepend" name="icon-search"></uui-icon> |
213 |
| - </uui-input> |
214 |
| - <uui-checkbox |
215 |
| - @change=${() => (this._searchOnlyThisFolder = !this._searchOnlyThisFolder)} |
216 |
| - label=${this.localize.term('general_excludeFromSubFolders')}></uui-checkbox> |
| 212 | + return html` |
| 213 | + <div id="toolbar"> |
| 214 | + <div id="search"> |
| 215 | + <uui-input |
| 216 | + label=${this.localize.term('general_search')} |
| 217 | + placeholder=${this.localize.term('placeholders_search')} |
| 218 | + @input=${this.#onSearch}> |
| 219 | + <uui-icon slot="prepend" name="icon-search"></uui-icon> |
| 220 | + </uui-input> |
| 221 | + <uui-checkbox |
| 222 | + @change=${() => (this._searchOnlyThisFolder = !this._searchOnlyThisFolder)} |
| 223 | + label=${this.localize.term('general_excludeFromSubFolders')}></uui-checkbox> |
| 224 | + </div> |
| 225 | + <uui-button |
| 226 | + @click=${() => this._dropzone.browse()} |
| 227 | + label=${this.localize.term('general_upload')} |
| 228 | + look="primary"></uui-button> |
217 | 229 | </div>
|
218 |
| - <uui-button |
219 |
| - @click=${() => this._dropzone.browse()} |
220 |
| - label=${this.localize.term('general_upload')} |
221 |
| - look="primary"></uui-button> |
222 |
| - </div> `; |
| 230 | + `; |
223 | 231 | }
|
224 | 232 |
|
225 | 233 | #renderCard(item: UmbMediaCardItemModel) {
|
|
0 commit comments