This commit is contained in:
Niels Lyngsø
2024-03-14 12:53:02 +01:00
parent 834442ce33
commit 0e8a247c78
2 changed files with 2 additions and 42 deletions

View File

@@ -102,7 +102,6 @@ export class UmbContentTypeContainerStructureHelper<T extends UmbContentTypeMode
this.#structure.containerById(this._containerId),
(container) => {
if (container) {
console.log('Container update', container.name);
this._containerName = container.name ?? '';
this._containerType = container.type;
if (container.parent) {
@@ -227,7 +226,6 @@ export class UmbContentTypeContainerStructureHelper<T extends UmbContentTypeMode
// This only works cause we are dealing with a single level of containers in this Helper, if we had more levels we would need to be more clever about the parent as well. [NL]
merged = merged.filter((x, i, cons) => i === cons.findIndex((y) => y.name === x.name && y.type === x.type));
this.#mergedContainers.setValue(merged);
console.log('merge', containers, ' > ', merged);
};
/**

View File

@@ -20,7 +20,6 @@ import type { UmbConfirmModalData } from '@umbraco-cms/backoffice/modal';
import { UMB_MODAL_MANAGER_CONTEXT, umbConfirmModal } from '@umbraco-cms/backoffice/modal';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { UmbSorterController } from '@umbraco-cms/backoffice/sorter';
import './content-type-design-editor-tab.element.js';
@customElement('umb-content-type-design-editor')
export class UmbContentTypeDesignEditorElement extends UmbLitElement implements UmbWorkspaceViewElement {
@@ -124,9 +123,6 @@ export class UmbContentTypeDesignEditorElement extends UmbLitElement implements
this._tabsStructureHelper.setIsRoot(true);
this.observe(this._tabsStructureHelper.mergedContainers, (tabs) => {
this._tabs = tabs;
this._tabs.forEach((tab) => {
this.#updateCachedTabElementId(tab.name ?? '', tab.id);
});
this.#sorter.setModel(tabs);
this._createRoutes();
});
@@ -158,37 +154,6 @@ export class UmbContentTypeDesignEditorElement extends UmbLitElement implements
);
}
#routeElementCache = new Map<string, UmbContentTypeDesignEditorTabElement>();
#getCacheOrImportTabElement(tabName: string) {
const found = this.#routeElementCache.get(tabName);
if (found) {
return found;
}
const element = document.createElement(
'umb-content-type-design-editor-tab',
) as UmbContentTypeDesignEditorTabElement;
this.#routeElementCache.set(tabName, element);
return element;
}
#updateCachedTabElementId(tabName: string, containerId: string | null) {
const found = this.#routeElementCache.get(tabName);
if (found) {
found.containerId = containerId;
}
}
#updateCachedTabElementName(tabName: string, newTabName: string) {
// change key for map entry:
const found = this.#routeElementCache.get(tabName);
if (found) {
this.#routeElementCache.set(newTabName, found);
this.#routeElementCache.delete(tabName);
}
}
private _createRoutes() {
// TODO: How about storing a set of elements based on tab ids? to prevent re-initializing the element when renaming..[NL]
if (!this.#workspaceContext || !this._tabs || this._hasRootGroups === undefined) return;
@@ -205,7 +170,7 @@ export class UmbContentTypeDesignEditorElement extends UmbLitElement implements
}
routes.push({
path: `tab/${encodeFolderName(tabName).toString()}`,
component: () => this.#getCacheOrImportTabElement(tabName),
component: () => import('./content-type-design-editor-tab.element.js'),
setup: (component) => {
// Or just cache the current view here, and use it if the same is begin requested?. [NL]
//(component as UmbContentTypeDesignEditorTabElement).tabName = tabName;
@@ -217,8 +182,7 @@ export class UmbContentTypeDesignEditorElement extends UmbLitElement implements
routes.push({
path: 'root',
component: () =>
document.createElement('umb-content-type-design-editor-tab') as UmbContentTypeDesignEditorTabElement,
component: () => import('./content-type-design-editor-tab.element.js'),
setup: (component) => {
//(component as UmbContentTypeDesignEditorTabElement).noTabName = true;
(component as UmbContentTypeDesignEditorTabElement).containerId = null;
@@ -332,8 +296,6 @@ export class UmbContentTypeDesignEditorElement extends UmbLitElement implements
(event.target as HTMLInputElement).value = newName;
}
this.#updateCachedTabElementName(tab.name ?? '', newName);
this._tabsStructureHelper.partialUpdateContainer(tab.id!, {
name: newName,
});