Add manual cd for workflow detail
This commit is contained in:
parent
876dd1f7d6
commit
dd272c823f
@ -1,4 +1,4 @@
|
|||||||
import { Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, OnInit, TemplateRef, ViewChild } from '@angular/core';
|
||||||
import { MatCheckboxChange } from '@angular/material/checkbox';
|
import { MatCheckboxChange } from '@angular/material/checkbox';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
import { MatDialog } from '@angular/material/dialog';
|
||||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
@ -8,6 +8,7 @@ import { ActivatedRoute } from '@angular/router';
|
|||||||
|
|
||||||
import { TranslateService } from '@ngx-translate/core';
|
import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Observable } from 'rxjs';
|
import { Observable } from 'rxjs';
|
||||||
|
import { map } from 'rxjs/operators';
|
||||||
|
|
||||||
import { StateRepositoryService } from 'app/core/repositories/motions/state-repository.service';
|
import { StateRepositoryService } from 'app/core/repositories/motions/state-repository.service';
|
||||||
import { WorkflowRepositoryService } from 'app/core/repositories/motions/workflow-repository.service';
|
import { WorkflowRepositoryService } from 'app/core/repositories/motions/workflow-repository.service';
|
||||||
@ -68,7 +69,8 @@ interface Restriction {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'os-workflow-detail',
|
selector: 'os-workflow-detail',
|
||||||
templateUrl: './workflow-detail.component.html',
|
templateUrl: './workflow-detail.component.html',
|
||||||
styleUrls: ['./workflow-detail.component.scss']
|
styleUrls: ['./workflow-detail.component.scss'],
|
||||||
|
changeDetection: ChangeDetectionStrategy.OnPush
|
||||||
})
|
})
|
||||||
export class WorkflowDetailComponent extends BaseViewComponent implements OnInit {
|
export class WorkflowDetailComponent extends BaseViewComponent implements OnInit {
|
||||||
/**
|
/**
|
||||||
@ -157,7 +159,8 @@ export class WorkflowDetailComponent extends BaseViewComponent implements OnInit
|
|||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
private workflowRepo: WorkflowRepositoryService,
|
private workflowRepo: WorkflowRepositoryService,
|
||||||
private stateRepo: StateRepositoryService,
|
private stateRepo: StateRepositoryService,
|
||||||
private route: ActivatedRoute
|
private route: ActivatedRoute,
|
||||||
|
private cd: ChangeDetectorRef
|
||||||
) {
|
) {
|
||||||
super(title, translate, matSnackBar);
|
super(title, translate, matSnackBar);
|
||||||
}
|
}
|
||||||
@ -168,14 +171,26 @@ export class WorkflowDetailComponent extends BaseViewComponent implements OnInit
|
|||||||
* Observe the parameters of the URL and loads the specified workflow
|
* Observe the parameters of the URL and loads the specified workflow
|
||||||
*/
|
*/
|
||||||
public ngOnInit(): void {
|
public ngOnInit(): void {
|
||||||
this.route.params.subscribe(params => {
|
const paramsId = parseInt(this.route.snapshot.paramMap.get('id'), 10);
|
||||||
if (params) {
|
|
||||||
this.workflowRepo.getViewModelObservable(params.id).subscribe(newWorkflow => {
|
this.subscriptions.push(
|
||||||
|
this.workflowRepo.getViewModelObservable(paramsId).subscribe(newWorkflow => {
|
||||||
|
if (newWorkflow) {
|
||||||
this.workflow = newWorkflow;
|
this.workflow = newWorkflow;
|
||||||
this.updateRowDef();
|
this.updateRowDef();
|
||||||
});
|
this.cd.markForCheck();
|
||||||
}
|
}
|
||||||
});
|
}),
|
||||||
|
|
||||||
|
this.stateRepo
|
||||||
|
.getViewModelListObservable()
|
||||||
|
.pipe(map(states => states.filter(state => this.workflow.states_id.includes(state.id))))
|
||||||
|
.subscribe(states => {
|
||||||
|
if (states) {
|
||||||
|
this.cd.markForCheck();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -187,6 +202,7 @@ export class WorkflowDetailComponent extends BaseViewComponent implements OnInit
|
|||||||
public onClickStateName(state: ViewState): void {
|
public onClickStateName(state: ViewState): void {
|
||||||
this.openEditDialog(state.name, 'Rename state', '', true).subscribe(result => {
|
this.openEditDialog(state.name, 'Rename state', '', true).subscribe(result => {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
this.cd.detectChanges();
|
||||||
if (result.action === 'update') {
|
if (result.action === 'update') {
|
||||||
this.stateRepo.update({ name: result.value }, state).then(() => {}, this.raiseError);
|
this.stateRepo.update({ name: result.value }, state).then(() => {}, this.raiseError);
|
||||||
} else if (result.action === 'delete') {
|
} else if (result.action === 'delete') {
|
||||||
|
Loading…
Reference in New Issue
Block a user