Changed category label for motion views
This commit is contained in:
parent
a5e1646f3c
commit
295c69e3fb
@ -63,7 +63,8 @@ export class CategoryRepositoryService extends BaseRepository<ViewCategory, Cate
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected createViewModel(category: Category): ViewCategory {
|
protected createViewModel(category: Category): ViewCategory {
|
||||||
return new ViewCategory(category);
|
const parent = this.viewModelStoreService.get(ViewCategory, category.parent_id);
|
||||||
|
return new ViewCategory(category, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -48,24 +48,22 @@ export class ViewCategory extends BaseViewModel<Category> implements CategoryTit
|
|||||||
return this.category.level;
|
return this.category.level;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Where is this used? Try to avoid this.
|
|
||||||
*/
|
|
||||||
/*public set prefix(prefix: string) {
|
|
||||||
this._model.prefix = prefix;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* TODO: Where is this used? Try to avoid this.
|
|
||||||
*/
|
|
||||||
/*public set name(name: string) {
|
|
||||||
this._model.name = name;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
public get prefixedName(): string {
|
public get prefixedName(): string {
|
||||||
return this.prefix ? this.prefix + ' - ' + this.name : this.name;
|
return this.prefix ? this.prefix + ' - ' + this.name : this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns the name with all parents in brackets: "<Cat> (<CatParent>, <CatParentParent>)"
|
||||||
|
*/
|
||||||
|
public get prefixedNameWithParents(): string {
|
||||||
|
const parents = this.collectParents();
|
||||||
|
let name = this.prefixedName;
|
||||||
|
if (parents.length) {
|
||||||
|
name += ' (' + parents.map(parent => parent.prefixedName).join(', ') + ')';
|
||||||
|
}
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
public constructor(category: Category, parent?: ViewCategory) {
|
public constructor(category: Category, parent?: ViewCategory) {
|
||||||
super(Category.COLLECTIONSTRING, category);
|
super(Category.COLLECTIONSTRING, category);
|
||||||
this._parent = parent;
|
this._parent = parent;
|
||||||
@ -79,6 +77,21 @@ export class ViewCategory extends BaseViewModel<Category> implements CategoryTit
|
|||||||
return '/motions/category';
|
return '/motions/category';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @returns an array with all parents. The ordering is the direct parent
|
||||||
|
* is in front of the array and the "highest" parent the last entry. Returns
|
||||||
|
* an empty array if the category does not have any parents.
|
||||||
|
*/
|
||||||
|
public collectParents(): ViewCategory[] {
|
||||||
|
if (this.parent) {
|
||||||
|
const parents = this.parent.collectParents();
|
||||||
|
parents.unshift(this.parent);
|
||||||
|
return parents;
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the local objects if required
|
* Updates the local objects if required
|
||||||
* @param update
|
* @param update
|
||||||
|
@ -322,7 +322,7 @@
|
|||||||
(click)="setCategory(category.id)"
|
(click)="setCategory(category.id)"
|
||||||
>
|
>
|
||||||
<mat-icon *ngIf="motion.category_id === category.id">check</mat-icon>
|
<mat-icon *ngIf="motion.category_id === category.id">check</mat-icon>
|
||||||
{{ category }}
|
{{ category.prefixedNameWithParents }}
|
||||||
</button>
|
</button>
|
||||||
</mat-menu>
|
</mat-menu>
|
||||||
<mat-basic-chip
|
<mat-basic-chip
|
||||||
@ -331,14 +331,14 @@
|
|||||||
class="grey"
|
class="grey"
|
||||||
disableRipple
|
disableRipple
|
||||||
>
|
>
|
||||||
{{ motion.category || '–' }}
|
{{ motion.category.prefixedNameWithParents || '–' }}
|
||||||
</mat-basic-chip>
|
</mat-basic-chip>
|
||||||
<mat-basic-chip
|
<mat-basic-chip
|
||||||
*ngIf="!perms.isAllowed('change_metadata', motion) && motion.category"
|
*ngIf="!perms.isAllowed('change_metadata', motion) && motion.category"
|
||||||
class="grey"
|
class="grey"
|
||||||
disableRipple
|
disableRipple
|
||||||
>
|
>
|
||||||
{{ motion.category }}
|
{{ motion.category.prefixedNameWithParents }}
|
||||||
</mat-basic-chip>
|
</mat-basic-chip>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@
|
|||||||
<div class="fill">
|
<div class="fill">
|
||||||
<div class="innerTable state-column">
|
<div class="innerTable state-column">
|
||||||
<div class="ellipsis-overflow" *ngIf="motion.category">
|
<div class="ellipsis-overflow" *ngIf="motion.category">
|
||||||
<os-icon-container icon="device_hub">{{ motion.category }}</os-icon-container>
|
<os-icon-container icon="device_hub">{{ motion.category.prefixedNameWithParents }}</os-icon-container>
|
||||||
</div>
|
</div>
|
||||||
<div class="ellipsis-overflow spacer-top-5" *ngIf="motion.motion_block">
|
<div class="ellipsis-overflow spacer-top-5" *ngIf="motion.motion_block">
|
||||||
<os-icon-container icon="widgets">{{
|
<os-icon-container icon="widgets">{{
|
||||||
@ -153,7 +153,7 @@
|
|||||||
<div class="column-state innerTable">
|
<div class="column-state innerTable">
|
||||||
<!-- Category -->
|
<!-- Category -->
|
||||||
<div class="ellipsis-overflow" *ngIf="motion.category">
|
<div class="ellipsis-overflow" *ngIf="motion.category">
|
||||||
<os-icon-container icon="device_hub">{{ motion.category }}</os-icon-container>
|
<os-icon-container icon="device_hub">{{ motion.category.prefixedNameWithParents }}</os-icon-container>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Motion Block -->
|
<!-- Motion Block -->
|
||||||
|
Loading…
Reference in New Issue
Block a user