Motion Workflow observing
This commit is contained in:
parent
f1da2689b9
commit
d26d131fa6
@ -37,6 +37,11 @@ export class Motion extends BaseModel {
|
|||||||
agenda_item_id: number;
|
agenda_item_id: number;
|
||||||
log_messages: MotionLog[];
|
log_messages: MotionLog[];
|
||||||
|
|
||||||
|
// read from config
|
||||||
|
workflow_id: number;
|
||||||
|
// by the config above
|
||||||
|
workflow: Workflow;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
id?: number,
|
id?: number,
|
||||||
identifier?: string,
|
identifier?: string,
|
||||||
@ -79,6 +84,33 @@ export class Motion extends BaseModel {
|
|||||||
this.polls = polls;
|
this.polls = polls;
|
||||||
this.agenda_item_id = agenda_item_id;
|
this.agenda_item_id = agenda_item_id;
|
||||||
this.log_messages = log_messages;
|
this.log_messages = log_messages;
|
||||||
|
|
||||||
|
this.initDataStoreValues();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sets the workflow_id and the workflow
|
||||||
|
*/
|
||||||
|
initDataStoreValues() {
|
||||||
|
const motionsWorkflowConfig = this.DS.filter(Config, config => config.key === 'motions_workflow')[0] as Config;
|
||||||
|
if (motionsWorkflowConfig) {
|
||||||
|
this.workflow_id = +motionsWorkflowConfig.value;
|
||||||
|
} else {
|
||||||
|
this.DS.getObservable().subscribe(newConfig => {
|
||||||
|
if (newConfig instanceof Config && newConfig.key === 'motions_workflow') {
|
||||||
|
this.workflow_id = +newConfig.value;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.workflow = this.DS.get(Workflow, this.workflow_id) as Workflow;
|
||||||
|
if (!this.workflow.id) {
|
||||||
|
this.DS.getObservable().subscribe(newModel => {
|
||||||
|
if (newModel instanceof Workflow && newModel.id === this.workflow_id) {
|
||||||
|
this.workflow = newModel;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -149,30 +181,18 @@ export class Motion extends BaseModel {
|
|||||||
this.category_id = newCategory.id;
|
this.category_id = newCategory.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the workflow
|
|
||||||
*
|
|
||||||
* TODO this is the default workflow, not yet the coresponding for the motion
|
|
||||||
*/
|
|
||||||
get workflow(): Workflow {
|
|
||||||
const motionsWorkflowConfig = this.DS.filter(Config, config => config.key === 'motions_workflow')[0] as Config;
|
|
||||||
//make sure this is a number
|
|
||||||
const workflowId = +motionsWorkflowConfig.value;
|
|
||||||
//get the workflow for our motion
|
|
||||||
const selectedWorkflow = this.DS.get(Workflow, workflowId) as Workflow;
|
|
||||||
return selectedWorkflow;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* return the workflow state
|
* return the workflow state
|
||||||
*
|
*
|
||||||
* Right now only the default workflow is assumed
|
* set the workflow via a component
|
||||||
* TODO: Motion workflow needs to be specific on the server
|
|
||||||
*/
|
*/
|
||||||
get state() {
|
get state() {
|
||||||
const workflow = this.workflow;
|
if (this.workflow && this.workflow.id) {
|
||||||
const state = workflow.state_by_id(this.state_id);
|
const state = this.workflow.state_by_id(this.state_id);
|
||||||
return state;
|
return state;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -182,25 +202,6 @@ export class Motion extends BaseModel {
|
|||||||
return this.workflow.states;
|
return this.workflow.states;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns possible "initial" states for a motion.
|
|
||||||
*
|
|
||||||
* Will filter "submitted"
|
|
||||||
*/
|
|
||||||
// get initial_states(): WorkflowState[] {
|
|
||||||
// const states = this.workflow.states;
|
|
||||||
|
|
||||||
// //find index of 'submitted'
|
|
||||||
// const submitted = states.findIndex(state => state.name === 'submitted');
|
|
||||||
|
|
||||||
// //if found a valid index, remove "submitted" from array
|
|
||||||
// if (typeof submitted === 'number' && submitted >= 0) {
|
|
||||||
// states.splice(submitted, 1);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return states;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the name of the recommendation.
|
* Returns the name of the recommendation.
|
||||||
*
|
*
|
||||||
@ -208,7 +209,6 @@ export class Motion extends BaseModel {
|
|||||||
* TODO: Motion workflow needs to be specific on the server
|
* TODO: Motion workflow needs to be specific on the server
|
||||||
*/
|
*/
|
||||||
get recommendation() {
|
get recommendation() {
|
||||||
// const stateName = this.workflow.getStateNameById(this.recommendation_id);
|
|
||||||
const state = this.workflow.state_by_id(this.recommendation_id);
|
const state = this.workflow.state_by_id(this.recommendation_id);
|
||||||
if (state) {
|
if (state) {
|
||||||
return state.recommendation_label;
|
return state.recommendation_label;
|
||||||
|
@ -113,7 +113,6 @@
|
|||||||
<h3 translate>Voting</h3>
|
<h3 translate>Voting</h3>
|
||||||
</div> -->
|
</div> -->
|
||||||
</form>
|
</form>
|
||||||
<!-- </div> -->
|
|
||||||
</mat-expansion-panel>
|
</mat-expansion-panel>
|
||||||
|
|
||||||
<!-- Personal Note -->
|
<!-- Personal Note -->
|
||||||
|
@ -27,16 +27,12 @@ export class MotionDetailComponent extends BaseComponent implements OnInit {
|
|||||||
this.route.params.subscribe(params => {
|
this.route.params.subscribe(params => {
|
||||||
// has the motion of the DataStore was initialized before.
|
// has the motion of the DataStore was initialized before.
|
||||||
this.motion = this.DS.get(Motion, params.id) as Motion;
|
this.motion = this.DS.get(Motion, params.id) as Motion;
|
||||||
if (this.motion) {
|
|
||||||
this.patchForm();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Observe motion to get the motion in the parameter and also get the changes
|
// Observe motion to get the motion in the parameter and also get the changes
|
||||||
this.DS.getObservable().subscribe(newModel => {
|
this.DS.getObservable().subscribe(newModel => {
|
||||||
if (newModel instanceof Motion) {
|
if (newModel instanceof Motion) {
|
||||||
if (newModel.id === +params.id) {
|
if (newModel.id === +params.id) {
|
||||||
this.motion = newModel as Motion;
|
this.motion = newModel as Motion;
|
||||||
this.patchForm();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -68,12 +64,16 @@ export class MotionDetailComponent extends BaseComponent implements OnInit {
|
|||||||
|
|
||||||
editMotionButton() {
|
editMotionButton() {
|
||||||
this.editMotion ? (this.editMotion = false) : (this.editMotion = true);
|
this.editMotion ? (this.editMotion = false) : (this.editMotion = true);
|
||||||
|
|
||||||
if (this.editMotion) {
|
if (this.editMotion) {
|
||||||
|
// switch to edit mode
|
||||||
|
this.patchForm();
|
||||||
this.metaInfoPanel.open();
|
this.metaInfoPanel.open();
|
||||||
this.contentPanel.open();
|
this.contentPanel.open();
|
||||||
|
} else {
|
||||||
|
// save button
|
||||||
|
this.saveMotion();
|
||||||
}
|
}
|
||||||
|
|
||||||
// console.log('this.motion.possible_states: ', this.motion.possible_states);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
<ng-container matColumnDef="state">
|
<ng-container matColumnDef="state">
|
||||||
<mat-header-cell *matHeaderCellDef mat-sort-header> State </mat-header-cell>
|
<mat-header-cell *matHeaderCellDef mat-sort-header> State </mat-header-cell>
|
||||||
<mat-cell *matCellDef="let motion">
|
<mat-cell *matCellDef="let motion">
|
||||||
<div *ngIf='motion.state.name !== "submitted"' class='innerTable'>
|
<div *ngIf='motion.state && motion.state.name !== "submitted"' class='innerTable'>
|
||||||
<fa-icon icon={{getStateIcon(motion.state)}}></fa-icon>
|
<fa-icon icon={{getStateIcon(motion.state)}}></fa-icon>
|
||||||
</div>
|
</div>
|
||||||
</mat-cell>
|
</mat-cell>
|
||||||
|
@ -64,7 +64,6 @@ export class StartComponent extends BaseComponent implements OnInit {
|
|||||||
if (welcomeTextConfig) {
|
if (welcomeTextConfig) {
|
||||||
this.welcomeText = welcomeTextConfig.value as string;
|
this.welcomeText = welcomeTextConfig.value as string;
|
||||||
}
|
}
|
||||||
console.log(this.DS.filter(Config, config => config.key === 'general_event_welcome_title'));
|
|
||||||
|
|
||||||
// observe title and text in DS
|
// observe title and text in DS
|
||||||
this.DS.getObservable().subscribe(newModel => {
|
this.DS.getObservable().subscribe(newModel => {
|
||||||
|
Loading…
Reference in New Issue
Block a user