rename update to updateItems
This commit is contained in:
@@ -22,7 +22,7 @@ export class UmbDataTypesStore extends UmbDataStoreBase<DataTypeDetails | Folder
|
||||
fetch(`/umbraco/backoffice/data-type/details/${key}`)
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
this.update(data);
|
||||
this.updateItems(data);
|
||||
});
|
||||
|
||||
return this.items.pipe(map((dataTypes) => dataTypes.find((dataType) => dataType.key === key) || null));
|
||||
@@ -45,7 +45,7 @@ export class UmbDataTypesStore extends UmbDataStoreBase<DataTypeDetails | Folder
|
||||
},
|
||||
});
|
||||
const json = await res.json();
|
||||
this.update(json);
|
||||
this.updateItems(json);
|
||||
} catch (error) {
|
||||
console.error('Save Data Type error', error);
|
||||
}
|
||||
@@ -72,7 +72,7 @@ export class UmbDataTypesStore extends UmbDataStoreBase<DataTypeDetails | Folder
|
||||
getTreeRoot(): Observable<Array<FolderTreeItem>> {
|
||||
DataTypeResource.getTreeDataTypeRoot({}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
@@ -92,7 +92,7 @@ export class UmbDataTypesStore extends UmbDataStoreBase<DataTypeDetails | Folder
|
||||
parentKey: key,
|
||||
}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
|
||||
@@ -16,7 +16,7 @@ export class UmbDocumentTypeStore extends UmbDataStoreBase<DocumentTypeDetails |
|
||||
fetch(`/umbraco/backoffice/document-type/${key}`)
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
this.update(data);
|
||||
this.updateItems(data);
|
||||
});
|
||||
|
||||
return this.items.pipe(
|
||||
@@ -35,7 +35,7 @@ export class UmbDocumentTypeStore extends UmbDataStoreBase<DocumentTypeDetails |
|
||||
},
|
||||
});
|
||||
const json = await res.json();
|
||||
this.update(json);
|
||||
this.updateItems(json);
|
||||
} catch (error) {
|
||||
console.error('Save Document Type error', error);
|
||||
}
|
||||
@@ -44,7 +44,7 @@ export class UmbDocumentTypeStore extends UmbDataStoreBase<DocumentTypeDetails |
|
||||
getTreeRoot(): Observable<Array<DocumentTypeTreeItem>> {
|
||||
DocumentTypeResource.getTreeDocumentTypeRoot({}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
@@ -64,7 +64,7 @@ export class UmbDocumentTypeStore extends UmbDataStoreBase<DocumentTypeDetails |
|
||||
parentKey: key,
|
||||
}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
|
||||
@@ -15,7 +15,7 @@ export class UmbDocumentStore extends UmbDataStoreBase<DocumentDetails | Documen
|
||||
fetch(`/umbraco/management/api/v1/document/details/${key}`)
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
this.update(data);
|
||||
this.updateItems(data);
|
||||
});
|
||||
|
||||
return this.items.pipe(map((documents) => documents.find((document) => document.key === key) || null));
|
||||
@@ -44,7 +44,7 @@ export class UmbDocumentStore extends UmbDataStoreBase<DocumentDetails | Documen
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data: Array<DocumentDetails>) => {
|
||||
this.update(data);
|
||||
this.updateItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,13 +60,13 @@ export class UmbDocumentStore extends UmbDataStoreBase<DocumentDetails | Documen
|
||||
},
|
||||
});
|
||||
const data = await res.json();
|
||||
this.update(data);
|
||||
this.updateItems(data);
|
||||
}
|
||||
|
||||
getTreeRoot(): Observable<Array<DocumentTreeItem>> {
|
||||
DocumentResource.getTreeDocumentRoot({}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
@@ -87,7 +87,7 @@ export class UmbDocumentStore extends UmbDataStoreBase<DocumentDetails | Documen
|
||||
parentKey: key,
|
||||
}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
@@ -109,7 +109,7 @@ export class UmbDocumentStore extends UmbDataStoreBase<DocumentDetails | Documen
|
||||
key: keys,
|
||||
}).then(
|
||||
(items) => {
|
||||
this.update(items);
|
||||
this.updateItems(items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
|
||||
@@ -13,7 +13,7 @@ export class UmbMediaTypeStore extends UmbDataStoreBase<MediaTypeDetails | Paged
|
||||
getTreeRoot(): Observable<Array<PagedFolderTreeItem>> {
|
||||
MediaTypeResource.getTreeMediaTypeRoot({}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
@@ -33,7 +33,7 @@ export class UmbMediaTypeStore extends UmbDataStoreBase<MediaTypeDetails | Paged
|
||||
parentKey: key,
|
||||
}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
|
||||
@@ -15,7 +15,7 @@ export class UmbMediaStore extends UmbDataStoreBase<MediaDetails | ContentTreeIt
|
||||
fetch(`/umbraco/management/api/v1/media/details/${key}`)
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
this.update(data);
|
||||
this.updateItems(data);
|
||||
});
|
||||
|
||||
return this.items.pipe(map((media) => media.find((media) => media.key === key) || null));
|
||||
@@ -44,7 +44,7 @@ export class UmbMediaStore extends UmbDataStoreBase<MediaDetails | ContentTreeIt
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data: Array<MediaDetails>) => {
|
||||
this.update(data);
|
||||
this.updateItems(data);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -60,13 +60,13 @@ export class UmbMediaStore extends UmbDataStoreBase<MediaDetails | ContentTreeIt
|
||||
},
|
||||
});
|
||||
const data = await res.json();
|
||||
this.update(data);
|
||||
this.updateItems(data);
|
||||
}
|
||||
|
||||
getTreeRoot(): Observable<Array<ContentTreeItem>> {
|
||||
MediaResource.getTreeMediaRoot({}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
@@ -87,7 +87,7 @@ export class UmbMediaStore extends UmbDataStoreBase<MediaDetails | ContentTreeIt
|
||||
parentKey: key,
|
||||
}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
|
||||
@@ -13,7 +13,7 @@ export class UmbMemberGroupStore extends UmbDataStoreBase<MemberGroupDetails | E
|
||||
getTreeRoot(): Observable<Array<EntityTreeItem>> {
|
||||
MemberGroupResource.getTreeMemberGroupRoot({}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
|
||||
@@ -13,7 +13,7 @@ export class UmbMemberTypeStore extends UmbDataStoreBase<MemberTypeDetails | Ent
|
||||
getTreeRoot(): Observable<Array<EntityTreeItem>> {
|
||||
MemberTypeResource.getTreeMemberTypeRoot({}).then(
|
||||
(res) => {
|
||||
this.update(res.items);
|
||||
this.updateItems(res.items);
|
||||
},
|
||||
(e) => {
|
||||
if (e instanceof ApiError) {
|
||||
|
||||
@@ -7,7 +7,7 @@ export interface UmbDataStoreIdentifiers {
|
||||
|
||||
export interface UmbDataStore<T> {
|
||||
readonly items: Observable<Array<T>>;
|
||||
update(items: Array<T>): void;
|
||||
updateItems(items: Array<T>): void;
|
||||
getTreeRoot?(): Observable<Array<T>>;
|
||||
getTreeItemChildren?(key: string): Observable<Array<T>>;
|
||||
}
|
||||
@@ -36,7 +36,7 @@ export class UmbDataStoreBase<T extends UmbDataStoreIdentifiers> implements UmbD
|
||||
* @param {keyof T} [compareKey='key']
|
||||
* @memberof UmbDataStoreBase
|
||||
*/
|
||||
public update(updatedItems: Array<T>, compareKey: keyof T = 'key'): void {
|
||||
public updateItems(updatedItems: Array<T>, compareKey: keyof T = 'key'): void {
|
||||
const storedItems = this._items.getValue();
|
||||
const updated: T[] = [...storedItems];
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export class UmbUserGroupStore extends UmbDataStoreBase<UserGroupDetails> {
|
||||
fetch(`/umbraco/backoffice/user-groups/list/items`)
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
this.update(data.items);
|
||||
this.updateItems(data.items);
|
||||
});
|
||||
|
||||
return this.items;
|
||||
|
||||
@@ -19,7 +19,7 @@ export class UmbUserStore extends UmbDataStoreBase<UserDetails> {
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
this._totalUsers.next(data.total);
|
||||
this.update(data.items);
|
||||
this.updateItems(data.items);
|
||||
});
|
||||
|
||||
return this.items;
|
||||
@@ -37,7 +37,7 @@ export class UmbUserStore extends UmbDataStoreBase<UserDetails> {
|
||||
fetch(`/umbraco/backoffice/users/${key}`)
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
this.update([data]);
|
||||
this.updateItems([data]);
|
||||
});
|
||||
|
||||
return this.items.pipe(
|
||||
@@ -62,7 +62,7 @@ export class UmbUserStore extends UmbDataStoreBase<UserDetails> {
|
||||
user.status = 'enabled';
|
||||
});
|
||||
|
||||
this.update(storedUsers);
|
||||
this.updateItems(storedUsers);
|
||||
} catch (error) {
|
||||
console.error('Enable Users failed', error);
|
||||
}
|
||||
@@ -85,7 +85,7 @@ export class UmbUserStore extends UmbDataStoreBase<UserDetails> {
|
||||
user.status = 'disabled';
|
||||
});
|
||||
|
||||
this.update(storedUsers);
|
||||
this.updateItems(storedUsers);
|
||||
} catch (error) {
|
||||
console.error('Disable Users failed', error);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ export class UmbUserStore extends UmbDataStoreBase<UserDetails> {
|
||||
},
|
||||
});
|
||||
const json = await res.json();
|
||||
this.update(json);
|
||||
this.updateItems(json);
|
||||
} catch (error) {
|
||||
console.error('Save Data Type error', error);
|
||||
}
|
||||
@@ -136,7 +136,7 @@ export class UmbUserStore extends UmbDataStoreBase<UserDetails> {
|
||||
},
|
||||
});
|
||||
const json = (await res.json()) as UserDetails[];
|
||||
this.update(json);
|
||||
this.updateItems(json);
|
||||
return json[0];
|
||||
} catch (error) {
|
||||
console.error('Invite user error', error);
|
||||
|
||||
Reference in New Issue
Block a user