Merge pull request #5056 from tsiegleauq/amendment-filter-for-motion-list

Adds amendment filter types to motion list
This commit is contained in:
Emanuel Schütze 2019-09-25 17:01:18 +02:00 committed by GitHub
commit f0dd88ddb8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 48 additions and 1 deletions

View File

@ -40,6 +40,11 @@ export enum ChangeRecoMode {
ModifiedFinal = 'modified_final_version'
}
export enum AmendmentType {
Amendment = 1,
Parent
}
export const verboseChangeRecoMode = {
original: 'Original version',
changed: 'Changed version',
@ -340,6 +345,34 @@ export class ViewMotion extends BaseViewModelWithAgendaItemAndListOfSpeakers<Mot
this._diffLines = value;
}
/**
* Determine if a motion has a parent at all
*/
public get hasParent(): boolean {
return !!this.parent_id;
}
/**
* Determine if a motion has amenments
*/
public get hasAmendments(): boolean {
return !!this.amendments && !!this.amendments.length;
}
/**
* Determine if the motion has parents, is a parent of neither
*/
public get amendmentType(): number {
if (this.hasAmendments) {
return AmendmentType.Parent;
} else if (this.hasParent) {
return AmendmentType.Amendment;
} else {
// not any amendment
return 0;
}
}
/**
* Get the number of the first diff line, in case a motion is an amendment
*/

View File

@ -17,7 +17,7 @@ import {
OsFilterOptions
} from 'app/core/ui-services/base-filter-list.service';
import { ConfigService } from 'app/core/ui-services/config.service';
import { ViewMotion } from '../models/view-motion';
import { AmendmentType, ViewMotion } from '../models/view-motion';
/**
* Filter description to easier parse dynamically occurring workflows
@ -97,6 +97,15 @@ export class MotionFilterListService extends BaseFilterListService<ViewMotion> {
]
};
public AmendmentFilterOption: OsFilter = {
property: 'amendmentType',
label: 'Amendment',
options: [
{ condition: AmendmentType.Amendment, label: this.translate.instant('Is amendment') },
{ condition: AmendmentType.Parent, label: this.translate.instant('Has amendment') }
]
};
public personalNoteFilterOptions = [
{
property: 'star',
@ -226,9 +235,14 @@ export class MotionFilterListService extends BaseFilterListService<ViewMotion> {
filterDefinitions.push(this.hasSpeakerOptions);
}
if (this.showAmendmentsInMainTable) {
filterDefinitions.push(this.AmendmentFilterOption);
}
if (!this.operator.isAnonymous) {
filterDefinitions = filterDefinitions.concat(this.personalNoteFilterOptions);
}
return filterDefinitions;
}