update URL as tab name changes

This commit is contained in:
Niels Lyngsø
2023-04-13 11:23:44 +02:00
parent 9dec24ce5d
commit 1bd02328cc
3 changed files with 15 additions and 4 deletions

View File

@@ -147,7 +147,7 @@ export class UmbDocumentTypeWorkspaceViewEditElement extends UmbLitElement {
// TODO: make better url folder name:
const path = this._routerPath + '/tab/' + encodeURI(tab.name || '');
return html`<uui-tab label=${tab.name!} .active=${path === this._activePath} href=${path}>
${path === this._activePath
${path === this._activePath && this._tabsStructureHelper.isOwnerContainer(tab.id!)
? html` <uui-input
label="Tab name"
look="placeholder"
@@ -155,11 +155,12 @@ export class UmbDocumentTypeWorkspaceViewEditElement extends UmbLitElement {
placeholder="Enter a name"
@change=${(e: InputEvent) => {
const newName = (e.target as HTMLInputElement).value;
// Update the current URL, so we are still on this specific tab:
window.history.replaceState(null, '', this._routerPath + '/tab/' + encodeURI(newName));
this._tabsStructureHelper.partialUpdateContainer(tab.id, {
name: newName,
});
// Update the current URL, so we are still on this specific tab:
window.history.replaceState(null, '', this._routerPath + '/tab/' + encodeURI(newName));
}}>
<!-- todo only if its part of root: -->
<uui-button

View File

@@ -18,6 +18,7 @@ export class UmbWorkspaceContainerStructureHelper {
private _ownerKey?: string;
// Containers defined in data might be more than actual containers to display as we merge them by name.
// Owner containers are the containers defining the total of this container(Multiple containers with the same name and type)
private _ownerContainers: PropertyTypeContainerResponseModelBaseModel[] = [];
// State containing the merged containers (only one pr. name):
@@ -151,6 +152,15 @@ export class UmbWorkspaceContainerStructureHelper {
});
};
/**
* Returns true if the container is an owner container.
*/
isOwnerContainer(groupId?: string) {
if (!this.#workspaceContext || !groupId) return;
return this._ownerContainers.find((x) => x.id === groupId) !== undefined;
}
/** Manipulate methods: */
async addContainer(ownerId?: string, sortOrder?: number) {

View File

@@ -221,7 +221,7 @@ export class UmbWorkspacePropertyStructureManager<R extends UmbDocumentTypeRepos
async updateProperty(
documentTypeId: string | null,
propertyId: string,
partialUpdate: Partial<DocumentTypePropertyTypeResponseModel>
partialUpdate: Partial<PropertyTypeResponseModelBaseModel>
) {
await this.#init;
documentTypeId = documentTypeId ?? this.#rootDocumentTypeId!;