|
|
@ -21,13 +21,6 @@ const MODE_WIZARD = 'Wizard'; |
|
|
const MODE_EDIT_TRIGGER = 'EditTrigger'; |
|
|
const MODE_EDIT_TRIGGER = 'EditTrigger'; |
|
|
const MODE_EDIT_ACTION = 'EditAction'; |
|
|
const MODE_EDIT_ACTION = 'EditAction'; |
|
|
|
|
|
|
|
|
const TITLES: ReadonlyArray<string> = [ |
|
|
|
|
|
'Step 1 of 4: Select Trigger', |
|
|
|
|
|
'Step 2 of 4: Configure Trigger', |
|
|
|
|
|
'Step 3 of 4: Select Action', |
|
|
|
|
|
'Step 4 of 4: Configure Action' |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
@Component({ |
|
|
selector: 'sqx-rule-wizard', |
|
|
selector: 'sqx-rule-wizard', |
|
|
styleUrls: ['./rule-wizard.component.scss'], |
|
|
styleUrls: ['./rule-wizard.component.scss'], |
|
|
@ -53,21 +46,21 @@ export class RuleWizardComponent implements AfterViewInit, OnInit { |
|
|
public mode = MODE_WIZARD; |
|
|
public mode = MODE_WIZARD; |
|
|
|
|
|
|
|
|
public actionForm = new Form<FormGroup, any>(new FormGroup({})); |
|
|
public actionForm = new Form<FormGroup, any>(new FormGroup({})); |
|
|
public actionType: string; |
|
|
|
|
|
public action: any = {}; |
|
|
public action: any = {}; |
|
|
|
|
|
|
|
|
public triggerForm = new Form<FormGroup, any>(new FormGroup({})); |
|
|
public triggerForm = new Form<FormGroup, any>(new FormGroup({})); |
|
|
public triggerType: string; |
|
|
|
|
|
public trigger: any = {}; |
|
|
public trigger: any = {}; |
|
|
|
|
|
|
|
|
public titles = TITLES; |
|
|
public get isWizard() { |
|
|
|
|
|
return this.mode === MODE_WIZARD; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public get actionElement() { |
|
|
public get actionElement() { |
|
|
return this.ruleActions[this.actionType]; |
|
|
return this.ruleActions[this.action.actionType]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public get triggerElement() { |
|
|
public get triggerElement() { |
|
|
return this.ruleTriggers[this.triggerType]; |
|
|
return this.ruleTriggers[this.trigger.triggerType]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public isEditable: boolean; |
|
|
public isEditable: boolean; |
|
|
@ -86,12 +79,10 @@ export class RuleWizardComponent implements AfterViewInit, OnInit { |
|
|
this.step = 4; |
|
|
this.step = 4; |
|
|
|
|
|
|
|
|
this.action = this.rule.action; |
|
|
this.action = this.rule.action; |
|
|
this.actionType = this.rule.actionType; |
|
|
|
|
|
} else if (this.mode === MODE_EDIT_TRIGGER) { |
|
|
} else if (this.mode === MODE_EDIT_TRIGGER) { |
|
|
this.step = 2; |
|
|
this.step = 2; |
|
|
|
|
|
|
|
|
this.trigger = this.rule.trigger; |
|
|
this.trigger = this.rule.trigger; |
|
|
this.triggerType = this.rule.triggerType; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -105,27 +96,33 @@ export class RuleWizardComponent implements AfterViewInit, OnInit { |
|
|
this.complete.emit(); |
|
|
this.complete.emit(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public go(step: number) { |
|
|
|
|
|
this.step = step; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public selectActionType(type: string) { |
|
|
|
|
|
this.action = { actionType: type }; |
|
|
|
|
|
this.actionForm = new Form<FormGroup, any>(new FormGroup({})); |
|
|
|
|
|
|
|
|
|
|
|
this.step++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public selectTriggerType(type: TriggerType) { |
|
|
public selectTriggerType(type: TriggerType) { |
|
|
this.triggerType = type; |
|
|
this.trigger = { triggerType: type }; |
|
|
|
|
|
this.triggerForm = new Form<FormGroup, any>(new FormGroup({})); |
|
|
|
|
|
|
|
|
if (type === 'Manual') { |
|
|
if (type === 'Manual') { |
|
|
this.trigger = { triggerType: type }; |
|
|
|
|
|
this.step += 2; |
|
|
this.step += 2; |
|
|
} else { |
|
|
} else { |
|
|
this.step++; |
|
|
this.step++; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public selectActionType(type: string) { |
|
|
|
|
|
this.actionType = type; |
|
|
|
|
|
this.step++; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public saveTrigger() { |
|
|
public saveTrigger() { |
|
|
const value = this.triggerForm.submit(); |
|
|
const value = this.triggerForm.submit(); |
|
|
|
|
|
|
|
|
if (value) { |
|
|
if (value) { |
|
|
this.trigger = { ...value, triggerType: this.triggerType }; |
|
|
this.trigger = { ...value, triggerType: this.trigger.triggerType }; |
|
|
|
|
|
|
|
|
if (this.mode === MODE_WIZARD) { |
|
|
if (this.mode === MODE_WIZARD) { |
|
|
this.step++; |
|
|
this.step++; |
|
|
@ -139,7 +136,7 @@ export class RuleWizardComponent implements AfterViewInit, OnInit { |
|
|
const value = this.actionForm.submit(); |
|
|
const value = this.actionForm.submit(); |
|
|
|
|
|
|
|
|
if (value) { |
|
|
if (value) { |
|
|
this.action = { ...value, actionType: this.actionType }; |
|
|
this.action = { ...value, actionType: this.action.actionType }; |
|
|
|
|
|
|
|
|
if (this.mode === MODE_WIZARD) { |
|
|
if (this.mode === MODE_WIZARD) { |
|
|
this.createRule(); |
|
|
this.createRule(); |
|
|
@ -155,11 +152,9 @@ export class RuleWizardComponent implements AfterViewInit, OnInit { |
|
|
this.rulesState.create(requestDto) |
|
|
this.rulesState.create(requestDto) |
|
|
.subscribe(() => { |
|
|
.subscribe(() => { |
|
|
this.emitComplete(); |
|
|
this.emitComplete(); |
|
|
|
|
|
|
|
|
this.actionForm.submitCompleted(); |
|
|
|
|
|
this.triggerForm.submitCompleted(); |
|
|
|
|
|
}, error => { |
|
|
}, error => { |
|
|
this.actionForm.submitFailed(error); |
|
|
this.actionForm.submitFailed(error); |
|
|
|
|
|
|
|
|
this.triggerForm.submitFailed(error); |
|
|
this.triggerForm.submitFailed(error); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|