2019-02-21 12:34:13 +01:00
|
|
|
import { Component } from '@angular/core';
|
|
|
|
|
|
|
|
import { BaseSlideComponent } from 'app/slides/base-slide-component';
|
2019-02-26 14:43:51 +01:00
|
|
|
import {
|
|
|
|
MotionBlockSlideData,
|
|
|
|
MotionBlockSlideMotionRepresentation,
|
|
|
|
MotionTitleInformation
|
|
|
|
} from './motion-block-slide-data';
|
2019-02-21 12:34:13 +01:00
|
|
|
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';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'os-motion-block-slide',
|
|
|
|
templateUrl: './motion-block-slide.component.html',
|
|
|
|
styleUrls: ['./motion-block-slide.component.scss']
|
|
|
|
})
|
|
|
|
export class MotionBlockSlideComponent extends BaseSlideComponent<MotionBlockSlideData> {
|
|
|
|
public constructor(private motionRepo: MotionRepositoryService, private translate: TranslateService) {
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2019-02-26 14:43:51 +01:00
|
|
|
public getMotionTitle(motion: MotionTitleInformation): string {
|
|
|
|
return this.motionRepo.getTitle(motion);
|
2019-02-21 12:34:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public getStateCssColor(motion: MotionBlockSlideMotionRepresentation): string {
|
|
|
|
return StateCssClassMapping[motion.recommendation.css_class] || '';
|
|
|
|
}
|
|
|
|
|
2019-02-21 15:06:14 +01:00
|
|
|
public getRecommendationLabel(motion: MotionBlockSlideMotionRepresentation): string {
|
2019-02-21 12:34:13 +01:00
|
|
|
let recommendation = this.translate.instant(motion.recommendation.name);
|
|
|
|
if (motion.recommendation_extension) {
|
2019-02-26 14:43:51 +01:00
|
|
|
const extension = motion.recommendation_extension.replace(/\[motion:(\d+)\]/g, (match, id) => {
|
|
|
|
const titleInformation = this.data.data.referenced_motions[id];
|
|
|
|
if (titleInformation) {
|
|
|
|
return this.motionRepo.getIdentifierOrTitle(titleInformation);
|
|
|
|
} else {
|
|
|
|
return this.translate.instant('<unknown motion>');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
recommendation += ' ' + extension;
|
2019-02-21 12:34:13 +01:00
|
|
|
}
|
|
|
|
return recommendation;
|
|
|
|
}
|
|
|
|
}
|