Adds amendment filter types to motion list

Adds the possibility to filter if a motion has amendments or is an amendment
This commit is contained in:
Sean Engelhardt 2019-09-25 15:51:15 +02:00
parent 534f2d1835
commit 82fe7eea4b
2 changed files with 48 additions and 1 deletions

View File

@ -40,6 +40,11 @@ export enum ChangeRecoMode {
ModifiedFinal = 'modified_final_version' ModifiedFinal = 'modified_final_version'
} }
export enum AmendmentType {
Amendment = 1,
Parent
}
export const verboseChangeRecoMode = { export const verboseChangeRecoMode = {
original: 'Original version', original: 'Original version',
changed: 'Changed version', changed: 'Changed version',
@ -340,6 +345,34 @@ export class ViewMotion extends BaseViewModelWithAgendaItemAndListOfSpeakers<Mot
this._diffLines = value; 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 * Get the number of the first diff line, in case a motion is an amendment
*/ */

View File

@ -17,7 +17,7 @@ import {
OsFilterOptions OsFilterOptions
} from 'app/core/ui-services/base-filter-list.service'; } from 'app/core/ui-services/base-filter-list.service';
import { ConfigService } from 'app/core/ui-services/config.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 * 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 = [ public personalNoteFilterOptions = [
{ {
property: 'star', property: 'star',
@ -226,9 +235,14 @@ export class MotionFilterListService extends BaseFilterListService<ViewMotion> {
filterDefinitions.push(this.hasSpeakerOptions); filterDefinitions.push(this.hasSpeakerOptions);
} }
if (this.showAmendmentsInMainTable) {
filterDefinitions.push(this.AmendmentFilterOption);
}
if (!this.operator.isAnonymous) { if (!this.operator.isAnonymous) {
filterDefinitions = filterDefinitions.concat(this.personalNoteFilterOptions); filterDefinitions = filterDefinitions.concat(this.personalNoteFilterOptions);
} }
return filterDefinitions; return filterDefinitions;
} }