From 2f0816b7eeee296b35a7986f24eeee0327ce660e Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 16 Apr 2024 16:19:48 +0200 Subject: [PATCH 1/4] remove guid --- .../components/input-document/input-document.element.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/components/input-document/input-document.element.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/components/input-document/input-document.element.ts index 6e8055da88..d80c9524ed 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/documents/components/input-document/input-document.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/documents/components/input-document/input-document.element.ts @@ -191,7 +191,7 @@ export class UmbInputDocumentElement extends UUIFormControlMixin(UmbLitElement, const name = item.variants[0]?.name; return html` - + ${this.#renderIcon(item)} ${this.#renderIsTrashed(item)} ${this.#renderOpenButton(item)} From 264c25e57f40f4e3acd63562cd1b272414d92e11 Mon Sep 17 00:00:00 2001 From: leekelleher Date: Tue, 16 Apr 2024 17:30:17 +0100 Subject: [PATCH 2/4] Logviewer: removes the `decodeURIComponent` as the router-slot `query()` function already handles URL decoding. --- .../log-viewer/workspace/logviewer-workspace.context.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/log-viewer/workspace/logviewer-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/packages/log-viewer/workspace/logviewer-workspace.context.ts index 1040248603..c7f99582a3 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/log-viewer/workspace/logviewer-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/log-viewer/workspace/logviewer-workspace.context.ts @@ -124,11 +124,7 @@ export class UmbLogViewerWorkspaceContext extends UmbControllerBase implements U onChangeState = () => { const searchQuery = query(); - let sanitizedQuery = ''; - if (searchQuery.lq) { - sanitizedQuery = decodeURIComponent(searchQuery.lq); - } - this.setFilterExpression(sanitizedQuery); + this.setFilterExpression(searchQuery.lq); let validLogLevels: LogLevelModel[] = []; if (searchQuery.loglevels) { From 5e1e3ab894e5699ae63f37d6154d1ef84c5b6128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Tue, 16 Apr 2024 20:31:32 +0200 Subject: [PATCH 3/4] fix delete --- .../structure/content-type-structure-manager.class.ts | 2 +- .../views/design/content-type-design-editor.element.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts index 41cefe4ad9..69e432a5ef 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts @@ -391,7 +391,7 @@ export class UmbContentTypeStructureManager< throw new Error('Could not find the Content Type to remove container from'); } const frozenContainers = contentType.containers ?? []; - const containers = frozenContainers.filter((x) => x.id !== containerId || x.parent?.id !== containerId); + const containers = frozenContainers.filter((x) => x.id !== containerId && x.parent?.id !== containerId); const frozenProperties = contentType.properties ?? []; const properties = frozenProperties.filter((x) => x.container?.id !== containerId); diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor.element.ts index e3bcdb1266..015212cef9 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor.element.ts @@ -228,7 +228,7 @@ export class UmbContentTypeDesignEditorElement extends UmbLitElement implements this._routes = routes; } - async #requestRemoveTab(tab: UmbPropertyTypeContainerModel | undefined) { + async #requestDeleteTab(tab: UmbPropertyTypeContainerModel | undefined) { // TODO: Localize this: const modalData: UmbConfirmModalData = { headline: 'Delete tab', @@ -248,9 +248,9 @@ export class UmbContentTypeDesignEditorElement extends UmbLitElement implements await umbConfirmModal(this, modalData); - this.#remove(tab?.id); + this.#deleteTab(tab?.id); } - #remove(tabId?: string) { + #deleteTab(tabId?: string) { if (!tabId) return; this.#workspaceContext?.structure.removeContainer(null, tabId); // TODO: We should only navigate away if it was the last tab and if it was the active one... [NL] @@ -495,7 +495,7 @@ export class UmbContentTypeDesignEditorElement extends UmbLitElement implements @click=${(e: MouseEvent) => { e.stopPropagation(); e.preventDefault(); - this.#requestRemoveTab(tab); + this.#requestDeleteTab(tab); }} compact> From 166d10fc9a508be819065544ca1e7c8939cce69f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Tue, 16 Apr 2024 21:31:42 +0200 Subject: [PATCH 4/4] correct code for inheritance detection --- .../property-type-settings-modal.element.ts | 6 +++ ...nt-type-property-structure-helper.class.ts | 7 +++ .../content-type-structure-manager.class.ts | 12 +++++ ...t-type-design-editor-properties.element.ts | 3 -- ...ent-type-design-editor-property.element.ts | 46 +++++++++---------- 5 files changed, 46 insertions(+), 28 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/modals/property-type-settings/property-type-settings-modal.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/modals/property-type-settings/property-type-settings-modal.element.ts index 0b0149ec97..ff53f2f34e 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/modals/property-type-settings/property-type-settings-modal.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/modals/property-type-settings/property-type-settings-modal.element.ts @@ -65,6 +65,12 @@ export class UmbPropertyTypeSettingsModalElement extends UmbModalBaseElement< this.consumeContext(UMB_CONTENT_TYPE_WORKSPACE_CONTEXT, (instance) => { if (!this.data?.contentTypeId) return; + if (instance.getUnique() !== this.data.contentTypeId) { + // We can currently only edit properties that are part of a content type workspace, which has to be present outside of the modal. [NL] + throw new Error( + 'The content type workspace context does not match the content type id of the property type settings modal.', + ); + } this.observe(instance.variesByCulture, (variesByCulture) => (this._contentTypeVariesByCulture = variesByCulture)); this.observe(instance.variesBySegment, (variesBySegment) => (this._contentTypeVariesBySegment = variesBySegment)); diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-property-structure-helper.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-property-structure-helper.class.ts index aa8107da68..44726957bb 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-property-structure-helper.class.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-property-structure-helper.class.ts @@ -178,6 +178,13 @@ export class UmbContentTypePropertyStructureHelper x?.properties.some((y) => y.id === propertyId)); } + async contentTypeOfProperty(propertyId: UmbPropertyTypeId) { + await this.#init; + if (!this.#structure) return; + + return this.#structure.contentTypeOfProperty(propertyId); + } + // TODO: consider moving this to another class, to separate 'viewer' from 'manipulator': /** Manipulate methods: */ diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts index 69e432a5ef..59a98256d4 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/structure/content-type-structure-manager.class.ts @@ -19,6 +19,8 @@ import { import { incrementString } from '@umbraco-cms/backoffice/utils'; import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; +type UmbPropertyTypeId = UmbPropertyTypeModel['id']; + /** * Manages a structure of a Content Type and its properties and containers. * This loads and merges the structures of the Content Type and its inherited and composed Content Types. @@ -192,6 +194,10 @@ export class UmbContentTypeStructureManager< return this.#contentTypes.getValue().find((y) => y.unique === this.#ownerContentTypeUnique); } + getOwnerContentTypeUnique() { + return this.#ownerContentTypeUnique; + } + updateOwnerContentType(entry: Partial) { this.#contentTypes.updateOne(this.#ownerContentTypeUnique, entry); } @@ -670,6 +676,12 @@ export class UmbContentTypeStructureManager< }); } + contentTypeOfProperty(propertyId: UmbPropertyTypeId) { + return this.#contentTypes.asObservablePart((contentTypes) => + contentTypes.find((contentType) => contentType.properties.some((p) => p.id === propertyId)), + ); + } + private _reset() { this.#contentTypeObservers.forEach((observer) => observer.destroy()); this.#contentTypeObservers = []; diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-properties.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-properties.element.ts index 9e726ba35b..06e96bfb28 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-properties.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-properties.element.ts @@ -208,10 +208,7 @@ export class UmbContentTypeDesignEditorPropertiesElement extends UmbLitElement { return html` diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-property.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-property.element.ts index 75e6a688d9..389040c68b 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-property.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/content-type/workspace/views/design/content-type-design-editor-property.element.ts @@ -58,28 +58,21 @@ export class UmbContentTypeDesignEditorPropertyElement extends UmbLitElement { } private _property?: UmbPropertyTypeModel | UmbPropertyTypeScaffoldModel | undefined; - /** - * Inherited, Determines if the property is part of the main content type thats being edited. - * If true, then the property is inherited from another content type, not a part of the main content type. - * @type {boolean} - * @attr - * @default undefined - */ - @property({ type: Boolean }) - public inherited?: boolean; - @property({ type: Boolean, reflect: true, attribute: 'sort-mode-active' }) public sortModeActive = false; - @property({ type: String, attribute: 'owner-content-type-id' }) - public ownerContentTypeId?: string; - - @property({ type: String, attribute: 'owner-content-type-name' }) - public ownerContentTypeName?: string; - @property({ type: String, attribute: 'edit-content-type-path' }) public editContentTypePath?: string; + @state() + public _inherited?: boolean; + + @state() + public _inheritedContentTypeId?: string; + + @state() + public _inheritedContentTypeName?: string; + @state() protected _modalRoute?: string; @@ -96,7 +89,7 @@ export class UmbContentTypeDesignEditorPropertyElement extends UmbLitElement { this.#settingsModal = new UmbModalRouteRegistrationController(this, UMB_PROPERTY_TYPE_SETTINGS_MODAL) .addUniquePaths(['propertyId']) .onSetup(() => { - const id = this.ownerContentTypeId; + const id = this._inheritedContentTypeId; if (id === undefined) return false; const propertyData = this.property; if (propertyData === undefined) return false; @@ -114,9 +107,12 @@ export class UmbContentTypeDesignEditorPropertyElement extends UmbLitElement { if (this._propertyStructureHelper && this._property) { // We can first match with something if we have a name [NL] this.observe( - await this._propertyStructureHelper!.isOwnerProperty(this._property.id), - (isOwned) => { - this.inherited = !isOwned; + await this._propertyStructureHelper!.contentTypeOfProperty(this._property.id), + (contentType) => { + this._inherited = + this._propertyStructureHelper?.getStructureManager()?.getOwnerContentTypeUnique() !== contentType?.unique; + this._inheritedContentTypeId = contentType?.unique; + this._inheritedContentTypeName = contentType?.name; }, 'observeIsOwnerProperty', ); @@ -196,7 +192,7 @@ export class UmbContentTypeDesignEditorPropertyElement extends UmbLitElement { render() { // TODO: Only show alias on label if user has access to DocumentType within settings: [NL] - return this.inherited ? this.renderInheritedProperty() : this.renderEditableProperty(); + return this._inherited ? this.renderInheritedProperty() : this.renderEditableProperty(); } renderInheritedProperty() { @@ -217,8 +213,8 @@ export class UmbContentTypeDesignEditorPropertyElement extends UmbLitElement { ${this.localize.term('contentTypeEditor_inheritedFrom')} - - ${this.ownerContentTypeName ?? '??'} + + ${this._inheritedContentTypeName ?? '??'} @@ -275,12 +271,12 @@ export class UmbContentTypeDesignEditorPropertyElement extends UmbLitElement { if (!this.property) return; return html`
- + ${this.property.name} (${this.property.alias})
this.#partialUpdate({ sortOrder: parseInt(e.target.value as string) ?? 0 } as UmbPropertyTypeModel)}