Merge pull request #4480 from FinnStutzenstein/sortMotionBlocksOnSlide
Sort motions on the motion block slide
This commit is contained in:
commit
5e7c604c4b
@ -2,7 +2,11 @@ import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { BaseSlideComponent } from 'app/slides/base-slide-component';
|
||||
import { MotionRepositoryService } from 'app/core/repositories/motions/motion-repository.service';
|
||||
import { MotionTitleInformation } from '../motion-block/motion-block-slide-data';
|
||||
|
||||
export interface MotionTitleInformation {
|
||||
title: string;
|
||||
identifier?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format for referenced motions: A mapping of motion ids to their title information.
|
||||
|
@ -1,9 +1,4 @@
|
||||
import { ReferencedMotions } from '../base/base-motion-slide';
|
||||
|
||||
export interface MotionTitleInformation {
|
||||
title: string;
|
||||
identifier?: string;
|
||||
}
|
||||
import { ReferencedMotions, MotionTitleInformation } from '../base/base-motion-slide';
|
||||
|
||||
export interface MotionBlockSlideMotionRepresentation extends MotionTitleInformation {
|
||||
recommendation?: {
|
||||
|
@ -1,14 +1,12 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { Component, Input } from '@angular/core';
|
||||
|
||||
import {
|
||||
MotionBlockSlideData,
|
||||
MotionBlockSlideMotionRepresentation,
|
||||
MotionTitleInformation
|
||||
} from './motion-block-slide-data';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
|
||||
import { MotionBlockSlideData, MotionBlockSlideMotionRepresentation } from './motion-block-slide-data';
|
||||
import { MotionRepositoryService } from 'app/core/repositories/motions/motion-repository.service';
|
||||
import { StateCssClassMapping } from 'app/site/motions/models/view-workflow';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { BaseMotionSlideComponent } from '../base/base-motion-slide';
|
||||
import { BaseMotionSlideComponent, MotionTitleInformation } from '../base/base-motion-slide';
|
||||
import { SlideData } from 'app/core/core-services/projector-data.service';
|
||||
|
||||
@Component({
|
||||
selector: 'os-motion-block-slide',
|
||||
@ -16,14 +14,49 @@ import { BaseMotionSlideComponent } from '../base/base-motion-slide';
|
||||
styleUrls: ['./motion-block-slide.component.scss']
|
||||
})
|
||||
export class MotionBlockSlideComponent extends BaseMotionSlideComponent<MotionBlockSlideData> {
|
||||
public constructor(translate: TranslateService, motionRepo: MotionRepositoryService) {
|
||||
super(translate, motionRepo);
|
||||
/**
|
||||
* For sorting motion blocks by their displayed title
|
||||
*/
|
||||
private languageCollator: Intl.Collator;
|
||||
|
||||
private _data: SlideData<MotionBlockSlideData>;
|
||||
|
||||
/**
|
||||
* Sort the motions given.
|
||||
*/
|
||||
@Input()
|
||||
public set data(data: SlideData<MotionBlockSlideData>) {
|
||||
if (data && data.data.motions) {
|
||||
data.data.motions = data.data.motions.sort((a, b) =>
|
||||
this.languageCollator.compare(this.getMotionIdentifier(a), this.getMotionIdentifier(b))
|
||||
);
|
||||
}
|
||||
this._data = data;
|
||||
}
|
||||
|
||||
public get data(): SlideData<MotionBlockSlideData> {
|
||||
return this._data;
|
||||
}
|
||||
|
||||
public constructor(translate: TranslateService, motionRepo: MotionRepositoryService) {
|
||||
super(translate, motionRepo);
|
||||
this.languageCollator = new Intl.Collator(this.translate.currentLang);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the title of the given motion.
|
||||
*/
|
||||
public getMotionTitle(motion: MotionTitleInformation): string {
|
||||
return this.motionRepo.getTitle(motion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @returns the identifier (of title if identifier not availabe) of the given motion.
|
||||
*/
|
||||
public getMotionIdentifier(motion: MotionTitleInformation): string {
|
||||
return this.motionRepo.getIdentifierOrTitle(motion);
|
||||
}
|
||||
|
||||
public getStateCssColor(motion: MotionBlockSlideMotionRepresentation): string {
|
||||
return StateCssClassMapping[motion.recommendation.css_class] || '';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user