Adds a 'tag' filter to motion lists
This commit is contained in:
parent
b05cd3af5a
commit
b5a6669359
@ -14,6 +14,7 @@ import { MotionCommentSectionRepositoryService } from 'app/core/repositories/mot
|
|||||||
import { ConfigService } from 'app/core/ui-services/config.service';
|
import { ConfigService } from 'app/core/ui-services/config.service';
|
||||||
import { ViewWorkflow } from '../models/view-workflow';
|
import { ViewWorkflow } from '../models/view-workflow';
|
||||||
import { OperatorService } from 'app/core/core-services/operator.service';
|
import { OperatorService } from 'app/core/core-services/operator.service';
|
||||||
|
import { TagRepositoryService } from 'app/core/repositories/tags/tag-repository.service';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@ -31,7 +32,8 @@ export class MotionFilterListService extends BaseFilterListService<Motion, ViewM
|
|||||||
this.categoryFilterOptions,
|
this.categoryFilterOptions,
|
||||||
this.motionBlockFilterOptions,
|
this.motionBlockFilterOptions,
|
||||||
this.recommendationFilterOptions,
|
this.recommendationFilterOptions,
|
||||||
this.motionCommentFilterOptions
|
this.motionCommentFilterOptions,
|
||||||
|
this.tagFilterOptions
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!this.operator.isAnonymous) {
|
if (!this.operator.isAnonymous) {
|
||||||
@ -87,6 +89,12 @@ export class MotionFilterListService extends BaseFilterListService<Motion, ViewM
|
|||||||
options: []
|
options: []
|
||||||
};
|
};
|
||||||
|
|
||||||
|
public tagFilterOptions: OsFilter = {
|
||||||
|
property: 'tags',
|
||||||
|
label: 'Tags',
|
||||||
|
options: []
|
||||||
|
};
|
||||||
|
|
||||||
public personalNoteFilterOptions = [
|
public personalNoteFilterOptions = [
|
||||||
{
|
{
|
||||||
property: 'star',
|
property: 'star',
|
||||||
@ -142,13 +150,15 @@ export class MotionFilterListService extends BaseFilterListService<Motion, ViewM
|
|||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
private config: ConfigService,
|
private config: ConfigService,
|
||||||
motionRepo: MotionRepositoryService,
|
motionRepo: MotionRepositoryService,
|
||||||
private operator: OperatorService
|
private operator: OperatorService,
|
||||||
|
private tagRepo: TagRepositoryService
|
||||||
) {
|
) {
|
||||||
super(store, motionRepo);
|
super(store, motionRepo);
|
||||||
this.subscribeWorkflows();
|
this.subscribeWorkflows();
|
||||||
this.subscribeCategories();
|
this.subscribeCategories();
|
||||||
this.subscribeMotionBlocks();
|
this.subscribeMotionBlocks();
|
||||||
this.subscribeComments();
|
this.subscribeComments();
|
||||||
|
this.subscribeTags();
|
||||||
|
|
||||||
this.operator.getUserObservable().subscribe(() => {
|
this.operator.getUserObservable().subscribe(() => {
|
||||||
this.updateFilterDefinitions(this.filterOptions);
|
this.updateFilterDefinitions(this.filterOptions);
|
||||||
@ -313,4 +323,26 @@ export class MotionFilterListService extends BaseFilterListService<Motion, ViewM
|
|||||||
this.updateFilterDefinitions(this.filterOptions);
|
this.updateFilterDefinitions(this.filterOptions);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Subscibes to changing Tags, and updates the filter accordingly
|
||||||
|
*/
|
||||||
|
private subscribeTags(): void {
|
||||||
|
this.tagRepo.getViewModelListObservable().subscribe(tags => {
|
||||||
|
const tagOptions: OsFilterOptions = tags.map(tag => ({
|
||||||
|
condition: tag.id,
|
||||||
|
label: tag.name,
|
||||||
|
isActive: false
|
||||||
|
}));
|
||||||
|
if (tags.length) {
|
||||||
|
tagOptions.push('-');
|
||||||
|
tagOptions.push({
|
||||||
|
label: this.translate.instant('No tags'),
|
||||||
|
condition: null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.tagFilterOptions.options = tagOptions;
|
||||||
|
this.updateFilterDefinitions(this.filterOptions);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user