update document name

This commit is contained in:
Niels Lyngsø
2023-06-07 15:20:20 +02:00
parent ab3e8cee6e
commit 5e43c373e4
6 changed files with 19 additions and 12 deletions

View File

@@ -5,6 +5,7 @@
"Backoffice",
"combobox",
"Elementable",
"Niels",
"pickable",
"templating",
"umbraco",

View File

@@ -7,12 +7,12 @@ export class UmbVariantId {
public readonly segment: string | null = null;
constructor(variantData: { culture?: string | null; segment?: string | null }) {
this.culture = variantData.culture || null;
this.segment = variantData.segment || null;
this.culture = (variantData.culture === 'invariant' ? null : variantData.culture) ?? null;
this.segment = variantData.segment ?? null;
}
public compare(obj: { culture?: string | null; segment?: string | null }): boolean {
return this.culture === (obj.culture || null) && this.segment === (obj.segment || null);
return this.equal(new UmbVariantId(obj));
}
public equal(variantId: UmbVariantId): boolean {

View File

@@ -53,7 +53,7 @@ export class UmbWorkspaceVariantContext {
this._observeVariant();
});
this.index.subscribe(() => {
new UmbObserverController(host, this.#index, () => {
this._observeVariant();
});
}

View File

@@ -164,17 +164,18 @@ export class UmbDocumentRepository
const { error } = await this.#detailDataSource.insert(item);
if (!error) {
// TODO: we currently don't use the detail store for anything.
// Consider to look up the data before fetching from the server
this.#store?.append(item);
// TODO: Update tree store with the new item? or ask tree to request the new item?
// TODO: Revisit this call, as we should be able to update tree on client.
await this.requestRootTreeItems();
const notification = { data: { message: `Document created` } };
this.#notificationContext?.peek('positive', notification);
}
const result = await this.requestRootTreeItems();
console.log("requested root tree items", result);
// TODO: we currently don't use the detail store for anything.
// Consider to look up the data before fetching from the server
this.#store?.append(item);
// TODO: Update tree store with the new item? or ask tree to request the new item?
return { error };
}
@@ -195,6 +196,9 @@ export class UmbDocumentRepository
//this.#treeStore?.updateItem(item.id, { name: item.name });// Port data to tree store.
// TODO: would be nice to align the stores on methods/methodNames.
// TODO: Revisit this call, as we should be able to update tree on client.
await this.requestRootTreeItems();
const notification = { data: { message: `Document saved` } };
this.#notificationContext?.peek('positive', notification);
}

View File

@@ -118,12 +118,14 @@ export class UmbDocumentWorkspaceContext
}
setName(name: string, variantId?: UmbVariantId) {
console.log("setname", name, variantId)
const oldVariants = this.#draft.getValue()?.variants || [];
const variants = partialUpdateFrozenArray(
oldVariants,
{ name },
variantId ? (x) => variantId.compare(x) : () => true
);
console.log(variants);
this.#draft.update({ variants });
}

View File

@@ -42,7 +42,7 @@ export class UmbTagRepository {
if (data) {
// TODO: allow to append an array of items to the store
// TODO: append culture? "Invariant" if null.
// TODO: Lone: append culture? "Invariant" if null. Niels: Actually, as of my current stand point, I think we should aim for invariant to be the value of ´null´.
data.items.forEach((x) => this.#tagStore?.append(x));
}