From 91329a8338f400ab5c5e3b90ee79d23efe257a2c Mon Sep 17 00:00:00 2001 From: Sean Engelhardt Date: Tue, 3 Sep 2019 15:11:54 +0200 Subject: [PATCH] Add sort service for amendments Adds the posibility to sort amendments by the parents identifier and line number. Patches the amendment model by their diff lines in runtime --- .../core-services/relation-manager.service.ts | 15 +++++- client/src/app/core/definitions/relations.ts | 5 ++ .../motions/motion-repository.service.ts | 48 ++++++++++++------- .../ui-services/base-filter-list.service.ts | 2 - .../ui-services/base-sort-list.service.ts | 41 +++++++++++----- .../sort-filter-bar.component.ts | 5 +- .../services/assignment-sort-list.service.ts | 16 ++++++- .../services/mediafiles-sort-list.service.ts | 16 ++++++- .../app/site/motions/models/view-motion.ts | 27 +++++++++++ .../amendment-list.component.html | 3 +- .../amendment-list.component.ts | 46 ++++-------------- .../amendment-sort-list.service.spec.ts | 12 +++++ .../services/amendment-sort-list.service.ts | 47 ++++++++++++++++++ .../services/motion-block-sort.service.ts | 16 ++++++- .../services/motion-sort-list.service.ts | 17 +++++-- .../users/services/user-sort-list.service.ts | 16 ++++++- 16 files changed, 245 insertions(+), 87 deletions(-) create mode 100644 client/src/app/site/motions/services/amendment-sort-list.service.spec.ts create mode 100644 client/src/app/site/motions/services/amendment-sort-list.service.ts diff --git a/client/src/app/core/core-services/relation-manager.service.ts b/client/src/app/core/core-services/relation-manager.service.ts index b7bdeb210..4bc4f1f54 100644 --- a/client/src/app/core/core-services/relation-manager.service.ts +++ b/client/src/app/core/core-services/relation-manager.service.ts @@ -82,12 +82,18 @@ export class RelationManagerService { ); viewModel['_' + relation.ownKey] = foreignViewModels; this.sortByRelation(relation, viewModel); + if (relation.afterSetRelation) { + relation.afterSetRelation(viewModel, foreignViewModels); + } } else if (relation.type === 'M2O') { const foreignViewModel = this.viewModelStoreService.get( relation.foreignViewModel, model[relation.ownIdKey] ); viewModel['_' + relation.ownKey] = foreignViewModel; + if (relation.afterSetRelation) { + relation.afterSetRelation(viewModel, foreignViewModel); + } } } else if (isReverseRelationDefinition(relation) && !initialLoading) { if (relation.type === 'M2M') { @@ -203,12 +209,19 @@ export class RelationManagerService { ) { const foreignViewModel = this.viewModelStoreService.get(collection, changedId); this.setForeingViewModelInOwnViewModelArray(foreignViewModel, ownViewModel, relation.ownKey); + if (relation.afterDependencyChange) { + relation.afterDependencyChange(ownViewModel, foreignViewModel); + } return true; } } else if (relation.type === 'M2O') { if (ownViewModel[relation.ownIdKey] === changedId) { // Check, if this is the matching foreign view model. - ownViewModel['_' + relation.ownKey] = this.viewModelStoreService.get(collection, changedId); + const foreignViewModel = this.viewModelStoreService.get(collection, changedId); + ownViewModel['_' + relation.ownKey] = foreignViewModel; + if (relation.afterDependencyChange) { + relation.afterDependencyChange(ownViewModel, foreignViewModel); + } return true; } } diff --git a/client/src/app/core/definitions/relations.ts b/client/src/app/core/definitions/relations.ts index c2adffe35..32666c4c2 100644 --- a/client/src/app/core/definitions/relations.ts +++ b/client/src/app/core/definitions/relations.ts @@ -39,6 +39,8 @@ interface BaseNormalRelationDefinition extends B * the model and view model. E.g. `category_id` in a motion. */ ownIdKey: string; + + afterDependencyChange?: (ownViewModel: BaseViewModel, foreignViewModel: BaseViewModel) => void; } /** @@ -56,16 +58,19 @@ interface NormalM2MRelationDefinition extends BaseNormalRelationDefinition, BaseOrderedRelation { type: 'M2M'; + afterSetRelation?: (ownViewModel: BaseViewModel, foreignViewModels: BaseViewModel[]) => void; } interface NormalO2MRelationDefinition extends BaseNormalRelationDefinition, BaseOrderedRelation { type: 'O2M'; + afterSetRelation?: (ownViewModel: BaseViewModel, foreignViewModels: BaseViewModel[]) => void; } interface NormalM2ORelationDefinition extends BaseNormalRelationDefinition { type: 'M2O'; + afterSetRelation?: (ownViewModel: BaseViewModel, foreignViewModel: BaseViewModel | null) => void; } export type NormalRelationDefinition = diff --git a/client/src/app/core/repositories/motions/motion-repository.service.ts b/client/src/app/core/repositories/motions/motion-repository.service.ts index 63141942d..5010945af 100644 --- a/client/src/app/core/repositories/motions/motion-repository.service.ts +++ b/client/src/app/core/repositories/motions/motion-repository.service.ts @@ -133,12 +133,6 @@ const MotionRelations: RelationDefinition[] = [ ownKey: 'tags', foreignViewModel: ViewTag }, - { - type: 'M2O', - ownIdKey: 'parent_id', - ownKey: 'parent', - foreignViewModel: ViewMotion - }, { type: 'M2M', ownIdKey: 'change_recommendations_id', @@ -171,6 +165,11 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo */ protected sortProperty: SortProperty; + /** + * Line length of a motion + */ + private motionLineLength: number; + /** * Creates a MotionRepository * @@ -206,10 +205,15 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo this.sortProperty = conf; this.setConfigSortFn(); }); + + config.get('motions_line_length').subscribe(lineLength => { + this.motionLineLength = lineLength; + }); } /** * Adds the personal note custom relation to the relation definitions. + * Also adds the parent relation here to get access to methods in this repo. */ protected groupRelationsByCollections(): void { this.relationDefinitions.push({ @@ -228,6 +232,22 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo return true; } }); + this.relationDefinitions.push({ + type: 'M2O', + ownIdKey: 'parent_id', + ownKey: 'parent', + foreignViewModel: ViewMotion, + afterSetRelation: (motion: ViewMotion, foreignViewModel: ViewMotion | null) => { + if (foreignViewModel) { + motion.diffLines = this.getAmendmentParagraphs(motion, this.motionLineLength, false); + } + }, + afterDependencyChange: (motion: ViewMotion, parent: ViewMotion) => { + if (motion.parent) { + motion.diffLines = this.getAmendmentParagraphs(motion, this.motionLineLength, false); + } + } + }); super.groupRelationsByCollections(); } @@ -284,8 +304,10 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo protected createViewModelWithTitles(model: Motion, initialLoading: boolean): ViewMotion { const viewModel = super.createViewModelWithTitles(model, initialLoading); + viewModel.getIdentifierOrTitle = () => this.getIdentifierOrTitle(viewModel); viewModel.getProjectorTitle = () => this.getAgendaSlideTitle(viewModel); + return viewModel; } @@ -639,16 +661,6 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo return range.to; } - /** - * Given an amendment, this returns the motion affected by this amendments - * - * @param {ViewMotion} amendment - * @returns {ViewMotion} - */ - public getAmendmentBaseMotion(amendment: ViewMotion): ViewMotion { - return this.getViewModel(amendment.parent_id); - } - /** * Splits a motion into paragraphs, optionally adding line numbers * @@ -700,7 +712,7 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo lineLength: number, includeUnchanged: boolean ): DiffLinesInParagraph[] { - const motion = this.getAmendmentBaseMotion(amendment); + const motion = amendment.parent; const baseParagraphs = this.getTextParagraphs(motion, true, lineLength); return amendment.amendment_paragraphs @@ -744,7 +756,7 @@ export class MotionRepositoryService extends BaseIsAgendaItemAndListOfSpeakersCo * @returns {ViewMotionAmendedParagraph[]} */ public getAmendmentAmendedParagraphs(amendment: ViewMotion, lineLength: number): ViewMotionAmendedParagraph[] { - const motion = this.getAmendmentBaseMotion(amendment); + const motion = amendment.parent; const baseParagraphs = this.getTextParagraphs(motion, true, lineLength); return amendment.amendment_paragraphs diff --git a/client/src/app/core/ui-services/base-filter-list.service.ts b/client/src/app/core/ui-services/base-filter-list.service.ts index 5b76b1447..5caf3c8f0 100644 --- a/client/src/app/core/ui-services/base-filter-list.service.ts +++ b/client/src/app/core/ui-services/base-filter-list.service.ts @@ -243,8 +243,6 @@ export abstract class BaseFilterListService { if (storedFilter && storedFilter.length && newDefinitions && newDefinitions.length) { for (const newDef of newDefinitions) { - console.log('set filter'); - // for some weird angular bugs, newDef can actually be undefined if (newDef) { let count = 0; diff --git a/client/src/app/core/ui-services/base-sort-list.service.ts b/client/src/app/core/ui-services/base-sort-list.service.ts index 9dda0c490..6f798a62f 100644 --- a/client/src/app/core/ui-services/base-sort-list.service.ts +++ b/client/src/app/core/ui-services/base-sort-list.service.ts @@ -55,6 +55,11 @@ export abstract class BaseSortListService { */ private sortDefinition: OsSortingDefinition; + /** + * The key to access stored valued + */ + protected abstract readonly storageKey: string; + /** * The sorting function according to current settings. */ @@ -105,13 +110,15 @@ export abstract class BaseSortListService { * @returns wether sorting is active or not */ public get isActive(): boolean { - return this.sortDefinition && this.sortOptions.length > 0; + return this.sortOptions && this.sortOptions.length > 0; } - /** - * Enforce children to implement sortOptions - */ - public abstract sortOptions: OsSortingOption[]; + public get sortOptions(): OsSortingOption[] { + const sortOptions = this.getSortOptions(); + if (sortOptions && sortOptions.length) { + return sortOptions; + } + } /** * Constructor. @@ -121,12 +128,16 @@ export abstract class BaseSortListService { * @param store to save and load sorting preferences */ public constructor( - protected name: string, protected translate: TranslateService, private store: StorageService, private OSStatus: OpenSlidesStatusService ) {} + /** + * Enforce children to implement a function that returns their sorting options + */ + protected abstract getSortOptions(): OsSortingOption[]; + /** * Enforce children to implement a method that returns the fault sorting */ @@ -148,7 +159,7 @@ export abstract class BaseSortListService { if (this.OSStatus.isInHistoryMode) { this.sortDefinition = null; } else { - this.sortDefinition = await this.store.get | null>('sorting_' + this.name); + this.sortDefinition = await this.store.get | null>('sorting_' + this.storageKey); } if (this.sortDefinition && this.sortDefinition.sortProperty) { @@ -183,11 +194,15 @@ export abstract class BaseSortListService { * @param option * @returns the name of the sorting icon, fit to material icon ligatures */ - public getSortIcon(option: OsSortingOption): string { - if (this.sortProperty !== option.property) { - return ''; + public getSortIcon(option: OsSortingOption): string | null { + if (this.sortDefinition) { + if (this.sortProperty && this.sortProperty !== option.property) { + return ''; + } + return this.ascending ? 'arrow_upward' : 'arrow_downward'; + } else { + return null; } - return this.ascending ? 'arrow_upward' : 'arrow_downward'; } /** @@ -210,7 +225,7 @@ export abstract class BaseSortListService { private updateSortDefinitions(): void { this.updateSortedData(); if (!this.OSStatus.isInHistoryMode) { - this.store.set('sorting_' + this.name, this.sortDefinition); + this.store.set('sorting_' + this.storageKey, this.sortDefinition); } } @@ -227,7 +242,7 @@ export abstract class BaseSortListService { * every time the sorting (property, ascending/descending) or the language changes */ protected updateSortedData(): void { - if (this.inputData) { + if (this.inputData && this.sortDefinition) { const property = this.sortProperty as string; const intl = new Intl.Collator(this.translate.currentLang, { diff --git a/client/src/app/shared/components/sort-filter-bar/sort-filter-bar.component.ts b/client/src/app/shared/components/sort-filter-bar/sort-filter-bar.component.ts index 0a5092b14..03c87e340 100644 --- a/client/src/app/shared/components/sort-filter-bar/sort-filter-bar.component.ts +++ b/client/src/app/shared/components/sort-filter-bar/sort-filter-bar.component.ts @@ -208,8 +208,9 @@ export class SortFilterBarComponent { * Retrieves the currently active icon for an option. * @param option */ - public getSortIcon(option: OsSortingOption): string { - return this.sortService.getSortIcon(option); + public getSortIcon(option: OsSortingOption): string | null { + const icon = this.sortService.getSortIcon(option); + return icon ? icon : null; } /** diff --git a/client/src/app/site/assignments/services/assignment-sort-list.service.ts b/client/src/app/site/assignments/services/assignment-sort-list.service.ts index 7a7f14d8c..95c38d34d 100644 --- a/client/src/app/site/assignments/services/assignment-sort-list.service.ts +++ b/client/src/app/site/assignments/services/assignment-sort-list.service.ts @@ -14,10 +14,15 @@ import { ViewAssignment } from '../models/view-assignment'; providedIn: 'root' }) export class AssignmentSortListService extends BaseSortListService { + /** + * set the storage key name + */ + protected storageKey = 'AssignmentList'; + /** * Define the sort options */ - public sortOptions: OsSortingOption[] = [ + private assignmentSortOptions: OsSortingOption[] = [ { property: 'title', label: 'Name' }, { property: 'phase', label: 'Phase' }, { property: 'candidateAmount', label: 'Number of candidates' }, @@ -31,7 +36,14 @@ export class AssignmentSortListService extends BaseSortListService[] { + return this.assignmentSortOptions; } /** diff --git a/client/src/app/site/mediafiles/services/mediafiles-sort-list.service.ts b/client/src/app/site/mediafiles/services/mediafiles-sort-list.service.ts index f199b87d3..3426dd02f 100644 --- a/client/src/app/site/mediafiles/services/mediafiles-sort-list.service.ts +++ b/client/src/app/site/mediafiles/services/mediafiles-sort-list.service.ts @@ -14,7 +14,12 @@ import { ViewMediafile } from '../models/view-mediafile'; providedIn: 'root' }) export class MediafilesSortListService extends BaseSortListService { - public sortOptions: OsSortingOption[] = [ + /** + * set the storage key name + */ + protected storageKey = 'MediafileList'; + + private mediafilesSortOptions: OsSortingOption[] = [ { property: 'title' }, { property: 'type', @@ -33,7 +38,14 @@ export class MediafilesSortListService extends BaseSortListService[] { + return this.mediafilesSortOptions; } /** diff --git a/client/src/app/site/motions/models/view-motion.ts b/client/src/app/site/motions/models/view-motion.ts index ba6bb8456..219862c03 100644 --- a/client/src/app/site/motions/models/view-motion.ts +++ b/client/src/app/site/motions/models/view-motion.ts @@ -1,5 +1,6 @@ import { _ } from 'app/core/translate/translation-marker'; import { ConfigService } from 'app/core/ui-services/config.service'; +import { DiffLinesInParagraph } from 'app/core/ui-services/diff.service'; import { SearchProperty, SearchRepresentation } from 'app/core/ui-services/search.service'; import { Motion, MotionComment } from 'app/shared/models/motions/motion'; import { PersonalNoteContent } from 'app/shared/models/users/personal-note'; @@ -76,6 +77,7 @@ export class ViewMotion extends BaseViewModelWithAgendaItemAndListOfSpeakers string; diff --git a/client/src/app/site/motions/modules/amendment-list/amendment-list.component.html b/client/src/app/site/motions/modules/amendment-list/amendment-list.component.html index 7027a8849..783cb2b5a 100644 --- a/client/src/app/site/motions/modules/amendment-list/amendment-list.component.html +++ b/client/src/app/site/motions/modules/amendment-list/amendment-list.component.html @@ -18,7 +18,7 @@
+
diff --git a/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts b/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts index 06da9bd26..5e670914b 100644 --- a/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts +++ b/client/src/app/site/motions/modules/amendment-list/amendment-list.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, OnInit } from '@angular/core'; +import { ChangeDetectionStrategy, Component, OnInit, ViewEncapsulation } from '@angular/core'; import { MatDialog, MatSnackBar } from '@angular/material'; import { DomSanitizer, SafeHtml, Title } from '@angular/platform-browser'; import { ActivatedRoute } from '@angular/router'; @@ -7,10 +7,9 @@ import { TranslateService } from '@ngx-translate/core'; import { PblColumnDefinition } from '@pebula/ngrid'; import { AmendmentFilterListService } from '../../services/amendment-filter-list.service'; +import { AmendmentSortListService } from '../../services/amendment-sort-list.service'; import { StorageService } from 'app/core/core-services/storage.service'; import { MotionRepositoryService } from 'app/core/repositories/motions/motion-repository.service'; -import { ConfigService } from 'app/core/ui-services/config.service'; -import { DiffLinesInParagraph } from 'app/core/ui-services/diff.service'; import { LinenumberingService } from 'app/core/ui-services/linenumbering.service'; import { ItemVisibilityChoices } from 'app/shared/models/agenda/item'; import { largeDialogSettings } from 'app/shared/utils/dialog-settings'; @@ -27,7 +26,8 @@ import { ViewMotion } from '../../models/view-motion'; selector: 'os-amendment-list', templateUrl: './amendment-list.component.html', styleUrls: ['./amendment-list.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush + changeDetection: ChangeDetectionStrategy.OnPush, + encapsulation: ViewEncapsulation.None }) export class AmendmentListComponent extends BaseListViewComponent implements OnInit { /** @@ -40,11 +40,6 @@ export class AmendmentListComponent extends BaseListViewComponent im */ public itemVisibility = ItemVisibilityChoices; - /** - * To hold the motions line length - */ - private motionLineLength: number; - /** * Column defintiion */ @@ -88,9 +83,9 @@ export class AmendmentListComponent extends BaseListViewComponent im route: ActivatedRoute, public motionRepo: MotionRepositoryService, public motionSortService: MotionSortListService, + public amendmentSortService: AmendmentSortListService, public amendmentFilterService: AmendmentFilterListService, private sanitizer: DomSanitizer, - private configService: ConfigService, private dialog: MatDialog, private motionExport: MotionExportService, private linenumberingService: LinenumberingService @@ -106,32 +101,7 @@ export class AmendmentListComponent extends BaseListViewComponent im } } - /** - * Observe the line length - */ - public ngOnInit(): void { - this.configService.get('motions_line_length').subscribe(lineLength => { - this.motionLineLength = lineLength; - }); - - if (!!this.parentMotionId) { - // this.amendmentFilterService.clearAllFilters(); - } - } - - /** - * Helper function to get amendment paragraphs of a given motion - * - * @param amendment the get the paragraphs from - * @returns DiffLinesInParagraph-List - */ - private getDiffLines(amendment: ViewMotion): DiffLinesInParagraph[] { - if (amendment.isParagraphBasedAmendment()) { - return this.motionRepo.getAmendmentParagraphs(amendment, this.motionLineLength, false); - } else { - return null; - } - } + public ngOnInit(): void {} /** * Extract the lines of the amendments @@ -141,7 +111,7 @@ export class AmendmentListComponent extends BaseListViewComponent im * @return The lines of the amendment */ public getChangeLines(amendment: ViewMotion): string { - const diffLines = this.getDiffLines(amendment); + const diffLines = amendment.diffLines; if (!!diffLines) { return diffLines @@ -163,7 +133,7 @@ export class AmendmentListComponent extends BaseListViewComponent im * @returns the amendments as string, if they are multiple they gonna be separated by `[...]` */ public getAmendmentSummary(amendment: ViewMotion): string { - const diffLines = this.getDiffLines(amendment); + const diffLines = amendment.diffLines; if (!!diffLines) { return diffLines .map(diffLine => { diff --git a/client/src/app/site/motions/services/amendment-sort-list.service.spec.ts b/client/src/app/site/motions/services/amendment-sort-list.service.spec.ts new file mode 100644 index 000000000..261e06081 --- /dev/null +++ b/client/src/app/site/motions/services/amendment-sort-list.service.spec.ts @@ -0,0 +1,12 @@ +import { TestBed } from '@angular/core/testing'; + +import { AmendmentSortListService } from './amendment-sort-list.service'; + +describe('AmendmentSortListService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: AmendmentSortListService = TestBed.get(AmendmentSortListService); + expect(service).toBeTruthy(); + }); +}); diff --git a/client/src/app/site/motions/services/amendment-sort-list.service.ts b/client/src/app/site/motions/services/amendment-sort-list.service.ts new file mode 100644 index 000000000..66a0c572f --- /dev/null +++ b/client/src/app/site/motions/services/amendment-sort-list.service.ts @@ -0,0 +1,47 @@ +import { Injectable } from '@angular/core'; + +import { TranslateService } from '@ngx-translate/core'; + +import { OpenSlidesStatusService } from 'app/core/core-services/openslides-status.service'; +import { StorageService } from 'app/core/core-services/storage.service'; +import { OsSortingDefinition, OsSortingOption } from 'app/core/ui-services/base-sort-list.service'; +import { ConfigService } from 'app/core/ui-services/config.service'; +import { MotionSortListService } from './motion-sort-list.service'; +import { ViewMotion } from '../models/view-motion'; + +@Injectable({ + providedIn: 'root' +}) +export class AmendmentSortListService extends MotionSortListService { + /** + * set the storage key name + */ + protected storageKey = 'AmendmentList'; + + private amendmentSortOptions: OsSortingOption[] = [ + { + property: 'parentAndLineNumber', + label: 'Main motion and line number' + } + ]; + + public constructor( + translate: TranslateService, + store: StorageService, + OSStatus: OpenSlidesStatusService, + config: ConfigService + ) { + super(translate, store, OSStatus, config); + } + + protected getSortOptions(): OsSortingOption[] { + return this.amendmentSortOptions.concat(super.getSortOptions()); + } + + protected async getDefaultDefinition(): Promise> { + return { + sortProperty: 'parentAndLineNumber', + sortAscending: true + }; + } +} diff --git a/client/src/app/site/motions/services/motion-block-sort.service.ts b/client/src/app/site/motions/services/motion-block-sort.service.ts index 4d3baec4d..aff2aceb7 100644 --- a/client/src/app/site/motions/services/motion-block-sort.service.ts +++ b/client/src/app/site/motions/services/motion-block-sort.service.ts @@ -11,7 +11,12 @@ import { ViewMotionBlock } from '../models/view-motion-block'; providedIn: 'root' }) export class MotionBlockSortService extends BaseSortListService { - public sortOptions: OsSortingOption[] = [ + /** + * set the storage key name + */ + protected storageKey = 'MotionBlockList'; + + private MotionBlockSortOptions: OsSortingOption[] = [ { property: 'title' }, { property: 'motions', @@ -25,7 +30,14 @@ export class MotionBlockSortService extends BaseSortListService ]; public constructor(translate: TranslateService, store: StorageService, OSStatus: OpenSlidesStatusService) { - super('Motion block', translate, store, OSStatus); + super(translate, store, OSStatus); + } + + /** + * @override + */ + protected getSortOptions(): OsSortingOption[] { + return this.MotionBlockSortOptions; } protected async getDefaultDefinition(): Promise> { diff --git a/client/src/app/site/motions/services/motion-sort-list.service.ts b/client/src/app/site/motions/services/motion-sort-list.service.ts index 84eb85b05..e4804f53c 100644 --- a/client/src/app/site/motions/services/motion-sort-list.service.ts +++ b/client/src/app/site/motions/services/motion-sort-list.service.ts @@ -17,6 +17,11 @@ import { ViewMotion } from '../models/view-motion'; providedIn: 'root' }) export class MotionSortListService extends BaseSortListService { + /** + * set the storage key name + */ + protected storageKey = 'MotionList'; + /** * Hold the default motion sorting */ @@ -30,7 +35,7 @@ export class MotionSortListService extends BaseSortListService { /** * Define the sort options */ - public sortOptions: OsSortingOption[] = [ + protected motionSortOptions: OsSortingOption[] = [ { property: 'weight', label: 'Call list' }, { property: 'identifier' }, { property: 'title' }, @@ -53,11 +58,11 @@ export class MotionSortListService extends BaseSortListService { translate: TranslateService, store: StorageService, OSStatus: OpenSlidesStatusService, - private config: ConfigService + config: ConfigService ) { - super('Motion', translate, store, OSStatus); + super(translate, store, OSStatus); - this.config.get('motions_motions_sorting').subscribe(defSortProp => { + config.get('motions_motions_sorting').subscribe(defSortProp => { if (defSortProp) { this.defaultMotionSorting = defSortProp; this.defaultSortingLoaded.resolve(); @@ -65,6 +70,10 @@ export class MotionSortListService extends BaseSortListService { }); } + protected getSortOptions(): OsSortingOption[] { + return this.motionSortOptions; + } + /** * Required by parent * diff --git a/client/src/app/site/users/services/user-sort-list.service.ts b/client/src/app/site/users/services/user-sort-list.service.ts index 63a69700d..b78a966be 100644 --- a/client/src/app/site/users/services/user-sort-list.service.ts +++ b/client/src/app/site/users/services/user-sort-list.service.ts @@ -14,10 +14,15 @@ import { ViewUser } from '../models/view-user'; providedIn: 'root' }) export class UserSortListService extends BaseSortListService { + /** + * set the storage key name + */ + protected storageKey = 'UserList'; + /** * Define the sort options */ - public sortOptions: OsSortingOption[] = [ + private userSortOptions: OsSortingOption[] = [ { property: 'first_name', label: 'Given name' }, { property: 'last_name', label: 'Surname' }, { property: 'is_present', label: 'Presence' }, @@ -36,7 +41,14 @@ export class UserSortListService extends BaseSortListService { * @param store requires by parent */ public constructor(translate: TranslateService, store: StorageService, OSStatus: OpenSlidesStatusService) { - super('User', translate, store, OSStatus); + super(translate, store, OSStatus); + } + + /** + * @override + */ + protected getSortOptions(): OsSortingOption[] { + return this.userSortOptions; } /**