This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
/
ktb-sequence-controls.component.ts
70 lines (62 loc) · 2.11 KB
/
ktb-sequence-controls.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { ChangeDetectorRef, Component, HostBinding, Input } from '@angular/core';
import { DataService } from '../../_services/data.service';
import { Sequence } from '../../_models/sequence';
import { SequenceStateControl } from '../../../../shared/interfaces/sequence';
import {
KtbConfirmationDialogComponent,
SequenceConfirmDialogData,
} from '../_dialogs/ktb-confirmation-dialog/ktb-confirmation-dialog.component';
import { MatDialog, MatDialogRef } from '@angular/material/dialog';
@Component({
selector: 'ktb-sequence-controls',
templateUrl: './ktb-sequence-controls.component.html',
})
export class KtbSequenceControlsComponent {
@HostBinding('class') cls = 'ktb-sequence-controls';
private _sequence?: Sequence;
private _smallButtons = false;
public confirmationDialogRef?: MatDialogRef<KtbConfirmationDialogComponent>;
@Input()
get sequence(): Sequence | undefined {
return this._sequence;
}
set sequence(sequence: Sequence | undefined) {
if (this._sequence !== sequence) {
this._sequence = sequence;
}
}
@Input()
get smallButtons(): boolean {
return this._smallButtons;
}
set smallButtons(value: boolean) {
if (this._smallButtons !== value) {
this._smallButtons = value;
}
}
constructor(
private _changeDetectorRef: ChangeDetectorRef,
private dataService: DataService,
public dialog: MatDialog
) {}
triggerResumeSequence(sequence: Sequence): void {
this.dataService.sendSequenceControl(sequence, SequenceStateControl.RESUME);
}
triggerPauseSequence(sequence: Sequence): void {
this.dataService.sendSequenceControl(sequence, SequenceStateControl.PAUSE);
}
triggerAbortSequence(sequence: Sequence): void {
const data: SequenceConfirmDialogData = {
sequence,
confirmCallback: (params: SequenceConfirmDialogData): void => {
this.abortSequence(params.sequence);
},
};
this.confirmationDialogRef = this.dialog.open(KtbConfirmationDialogComponent, {
data,
});
}
abortSequence(sequence: Sequence): void {
this.dataService.sendSequenceControl(sequence, SequenceStateControl.ABORT);
}
}