2018-08-09 16:03:24 +02:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { ActivatedRoute } from '@angular/router';
|
|
|
|
import { OpenSlidesComponent } from '../../../openslides.component';
|
|
|
|
import { BaseComponent } from '../../../base.component';
|
|
|
|
import { Motion } from '../../../shared/models/motions/motion';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-motion-detail',
|
|
|
|
templateUrl: './motion-detail.component.html',
|
|
|
|
styleUrls: ['./motion-detail.component.scss']
|
|
|
|
})
|
|
|
|
export class MotionDetailComponent extends BaseComponent implements OnInit {
|
|
|
|
motion: Motion;
|
|
|
|
|
|
|
|
constructor(private route: ActivatedRoute) {
|
|
|
|
super();
|
|
|
|
this.route.params.subscribe(params => {
|
|
|
|
console.log(params.id);
|
|
|
|
|
|
|
|
// has the motion of the DataStore was initialized before.
|
|
|
|
// Otherwise we need to observe DS
|
|
|
|
this.motion = this.DS.get(Motion, params.id) as Motion;
|
|
|
|
|
|
|
|
// Observe motion to get the motion in the parameter and also get the changes
|
|
|
|
this.DS.getObservable().subscribe(newModel => {
|
|
|
|
if (newModel instanceof Motion) {
|
|
|
|
if (newModel.id === +params.id) {
|
|
|
|
this.motion = newModel as Motion;
|
|
|
|
console.log('this.motion = ', this.motion);
|
2018-08-14 12:55:45 +02:00
|
|
|
// console.log('motion state name: ', this.motion.stateName);
|
2018-08-09 16:03:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
console.log('(init)the motion: ', this.motion);
|
2018-08-14 12:55:45 +02:00
|
|
|
console.log('motion state name: ', this.motion.stateName);
|
2018-08-09 16:03:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
downloadSingleMotionButton() {
|
|
|
|
console.log('Download this motion');
|
|
|
|
}
|
|
|
|
}
|