Implement missing update behaviour for users

This commit is contained in:
FinnStutzenstein 2019-02-12 10:49:11 +01:00
parent 2e80cc34a0
commit 99d751dbaf
2 changed files with 7 additions and 14 deletions

View File

@ -125,6 +125,7 @@ export class ViewItem extends BaseViewModel {
public updateDependencies(update: BaseViewModel): boolean { public updateDependencies(update: BaseViewModel): boolean {
if ( if (
update &&
update.collectionString === this.item.content_object.collection && update.collectionString === this.item.content_object.collection &&
update.id === this.item.content_object.id update.id === this.item.content_object.id
) { ) {

View File

@ -206,21 +206,13 @@ export class ViewUser extends BaseProjectableViewModel implements Searchable {
return this.full_name; return this.full_name;
}; };
/**
* TODO: Implement
*/
public replaceGroup(newGroup: ViewGroup): void {}
public updateDependencies(update: BaseViewModel): void { public updateDependencies(update: BaseViewModel): void {
if (update instanceof ViewGroup) { if (update instanceof ViewGroup && this.user.groups_id.includes(update.id)) {
this.updateGroup(update); const groupIndex = this.groups.findIndex(group => group.id === update.id);
} if (groupIndex < 0) {
} this.groups.push(update);
} else {
public updateGroup(group: ViewGroup): void { this.groups[groupIndex] = update;
if (this.user && this.user.groups_id) {
if (this.user.containsGroupId(group.id)) {
this.replaceGroup(group);
} }
} }
} }