delete now works
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user