Merge pull request #4786 from GabrielInTheWorld/FinnStutzenstein/categoryNameWithParents
Labelling of subcategories
This commit is contained in:
commit
c7088a4b73
@ -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
|
||||||
|
@ -321,7 +321,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
|
||||||
@ -330,14 +330,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 -->
|
||||||
|
@ -128,7 +128,7 @@ export class MotionPdfCatalogService {
|
|||||||
|
|
||||||
if (categories && categories.length) {
|
if (categories && categories.length) {
|
||||||
const catTocBody = [];
|
const catTocBody = [];
|
||||||
for (const category of categories) {
|
for (const category of categories.sort((a, b) => a.weight - b.weight)) {
|
||||||
// push the name of the category
|
// push the name of the category
|
||||||
// make a table for correct alignment
|
// make a table for correct alignment
|
||||||
catTocBody.push({
|
catTocBody.push({
|
||||||
@ -136,7 +136,7 @@ export class MotionPdfCatalogService {
|
|||||||
body: [
|
body: [
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
text: category.prefix ? category.prefix + ' - ' + category.name : category.name,
|
text: category.prefixedNameWithParents,
|
||||||
style: 'tocCategoryTitle'
|
style: 'tocCategoryTitle'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -271,9 +271,7 @@ export class MotionPdfService {
|
|||||||
style: 'boldText'
|
style: 'boldText'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: motion.category.prefix
|
text: motion.category.prefixedNameWithParents
|
||||||
? `${motion.category.prefix} - ${motion.category.name}`
|
|
||||||
: `${motion.category.name}`
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user