delete now works

This commit is contained in:
Jesper Møller Jensen
2022-10-05 12:00:40 +02:00
parent 86afcdce15
commit fd64ef526e
3 changed files with 12 additions and 4 deletions

View File

@@ -116,7 +116,8 @@ export class UmbEditorViewUsersUserDetailsElement extends UmbContextConsumerMixi
if (!this._user || !this._userStore) return;
this._userStore.deleteUsers([this._user.key]);
// history.back(); //TODO Should redirect to users section
history.pushState(null, '', '/section/users/view/users/overview');
}
private renderLeftColumn() {

View File

@@ -21,6 +21,13 @@ export class UmbDataStoreBase<T extends UmbDataStoreIdentifiers> implements UmbD
protected _items: BehaviorSubject<Array<T>> = new BehaviorSubject(<Array<T>>[]);
public readonly items: Observable<Array<T>> = this._items.asObservable();
public delete(deletedKeys: Array<string>): void {
const remainingItems = this._items
.getValue()
.filter((item) => item.key && deletedKeys.includes(item.key) === false);
this._items.next(remainingItems);
}
/**
* @description - Update the store with new items. Existing items are updated, new items are added. Existing items are matched by the compareKey.
* @param {Array<T>} updatedItems

View File

@@ -107,9 +107,9 @@ export class UmbUserStore extends UmbDataStoreBase<UserDetails> {
'Content-Type': 'application/json',
},
});
const json = await res.json();
this.update(json);
this._entityStore.update(json);
const deletedKeys = await res.json();
this.delete(deletedKeys);
this._entityStore.delete(deletedKeys);
} catch (error) {
console.error('Delete Users failed', error);
}