diff --git a/src/Umbraco.Web.UI.Client/src/packages/packages/package-builder/workspace/workspace-package-builder.element.ts b/src/Umbraco.Web.UI.Client/src/packages/packages/package-builder/workspace/workspace-package-builder.element.ts index 6338dedfb3..280298c9f6 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/packages/package-builder/workspace/workspace-package-builder.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/packages/package-builder/workspace/workspace-package-builder.element.ts @@ -1,6 +1,7 @@ import { UmbDictionaryPickerContext } from '../../../dictionary/components/input-dictionary/input-dictionary.context.js'; import { UmbMediaPickerContext } from '../../../media/media/components/input-media/input-media.context.js'; import { UmbPackageRepository } from '../../package/repository/index.js'; +import { UmbPartialViewPickerContext } from '../../../templating/partial-views/components/input-partial-view/input-partial-view.context.js'; import { UmbScriptPickerContext } from '../../../templating/scripts/components/input-script/input-script.context.js'; import { UmbStylesheetPickerContext } from '../../../templating/stylesheets/components/stylesheet-input/stylesheet-input.context.js'; import { UmbTemplatePickerContext } from '../../../templating/templates/components/input-template/input-template.context.js'; @@ -189,10 +190,7 @@ export class UmbWorkspacePackageBuilderElement extends UmbLitElement { ${this.#renderTemplateSection()} ${this.#renderStylesheetsSection()} ${this.#renderScriptsSection()} - - ${this.#renderPartialViewSection()} - `; } @@ -417,10 +415,30 @@ export class UmbWorkspacePackageBuilderElement extends UmbLitElement { `; } + #onPartialViewsChange(event: { target: UmbInputEntityElement }) { + if (!this._package) return; + + this._package.partialViews = + event.target.selection?.map((path) => this.#serverFilePathUniqueSerializer.toServerPath(path) as string) ?? []; + this.requestUpdate('_package'); + } + #renderPartialViewSection() { - return html`
- -
`; + if (!this._package) return nothing; + return html` + +
+ 'icon-notepad'} + .pickerContext=${UmbPartialViewPickerContext} + .selection=${this._package.partialViews.map((path) => + this.#serverFilePathUniqueSerializer.toUnique(path), + ) ?? []} + @change=${this.#onPartialViewsChange}> + +
+
+ `; } static styles = [ diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/partial-view-picker/partial-view-picker-modal.token.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/partial-view-picker/partial-view-picker-modal.token.ts index b9e090cb88..cf2f080421 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/modals/partial-view-picker/partial-view-picker-modal.token.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/modals/partial-view-picker/partial-view-picker-modal.token.ts @@ -1,8 +1,9 @@ import { UMB_PARTIAL_VIEW_TREE_ALIAS } from '../../partial-views/tree/manifests.js'; -import { UmbModalToken, type UmbPickerModalValue, type UmbTreePickerModalData } from '@umbraco-cms/backoffice/modal'; -import type { UmbUniqueTreeItemModel } from '@umbraco-cms/backoffice/tree'; +import type { UmbPartialViewTreeItemModel } from '../../partial-views/tree/index.js'; +import { UmbModalToken } from '@umbraco-cms/backoffice/modal'; +import type { UmbPickerModalValue, UmbTreePickerModalData } from '@umbraco-cms/backoffice/modal'; -export type UmbPartialViewPickerModalData = UmbTreePickerModalData; +export type UmbPartialViewPickerModalData = UmbTreePickerModalData; export type UmbPartialViewPickerModalValue = UmbPickerModalValue; export const UMB_PARTIAL_VIEW_PICKER_MODAL = new UmbModalToken< @@ -13,6 +14,5 @@ export const UMB_PARTIAL_VIEW_PICKER_MODAL = new UmbModalToken< type: 'sidebar', size: 'small', }, - data: { treeAlias: UMB_PARTIAL_VIEW_TREE_ALIAS, hideTreeRoot: true }, }); diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/components/input-partial-view/input-partial-view.context.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/components/input-partial-view/input-partial-view.context.ts new file mode 100644 index 0000000000..adf347c26b --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/components/input-partial-view/input-partial-view.context.ts @@ -0,0 +1,13 @@ +import { UMB_PARTIAL_VIEW_ITEM_REPOSITORY_ALIAS } from '../../repository/item/index.js'; +import { UMB_PARTIAL_VIEW_PICKER_MODAL } from '../../../modals/partial-view-picker/partial-view-picker-modal.token.js'; +import type { UmbPartialViewItemModel } from '../../types.js'; +import { UmbPickerInputContext } from '@umbraco-cms/backoffice/picker-input'; +import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; + +export class UmbPartialViewPickerContext extends UmbPickerInputContext { + constructor(host: UmbControllerHost) { + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + super(host, UMB_PARTIAL_VIEW_ITEM_REPOSITORY_ALIAS, UMB_PARTIAL_VIEW_PICKER_MODAL); + } +}