summaryrefslogtreecommitdiffstats
path: root/sdc-workflow-designer-ui/src/app/components/parameter
diff options
context:
space:
mode:
authorLvbo163 <lv.bo163@zte.com.cn>2017-09-06 17:31:15 +0800
committerLvbo163 <lv.bo163@zte.com.cn>2017-09-06 17:31:15 +0800
commitb8932e8304ed077912949890c3ec47a087be7ddd (patch)
tree7ac38d7bed907a3ca60e26c307bda953051a114a /sdc-workflow-designer-ui/src/app/components/parameter
parent15f0e4fa63bb1fd533091d9ab85d3612752c2d27 (diff)
paramters can quote input parameter of start event
rest task input parameters can quote input parameters of start event Issue-ID: SDC-122 Change-Id: I0cda0f1967514ac90e377b2f054ddf2cef011694 Signed-off-by: Lvbo163 <lv.bo163@zte.com.cn>
Diffstat (limited to 'sdc-workflow-designer-ui/src/app/components/parameter')
-rw-r--r--sdc-workflow-designer-ui/src/app/components/parameter/parameter.component.html9
-rw-r--r--sdc-workflow-designer-ui/src/app/components/parameter/parameter.component.ts54
2 files changed, 59 insertions, 4 deletions
diff --git a/sdc-workflow-designer-ui/src/app/components/parameter/parameter.component.html b/sdc-workflow-designer-ui/src/app/components/parameter/parameter.component.html
index da7dfb1d..229c5afb 100644
--- a/sdc-workflow-designer-ui/src/app/components/parameter/parameter.component.html
+++ b/sdc-workflow-designer-ui/src/app/components/parameter/parameter.component.html
@@ -20,9 +20,16 @@
<div [ngClass]="valueGroupClass">
<div [ngSwitch]="param.valueSource">
<input *ngSwitchCase="sourceEnum[sourceEnum.String]" [ngClass]="valueClass" class="form-control"
- type="text" [ngModel]="param.value" (ngModelChange)="modelChange($event)">
+ type="text" [ngModel]="param.value" (ngModelChange)="valueChange($event)">
<!-- TODO add plan and Top parameters -->
+ <tree-select *ngSwitchCase="sourceEnum[sourceEnum.Plan]" name="simpleSelect" [items]="planOptions"
+ childrenField="children" #simpleSelect="ngModel" [ngClass]="valueClass" class="tree-select-class"
+ [ngModel]="planValue" (ngModelChange)="valueChange($event)"></tree-select>
</div>
+ <select *ngIf="showValueSource" class="form-control col-md-3" type="text" [ngModel]="param.valueSource"
+ (ngModelChange)="valueSourceChange($event)">
+ <option *ngFor="let sourceType of valueSource" value="{{sourceEnum[sourceType]}}">{{sourceEnum[sourceType]}}</option>
+ </select>
</div>
<div *ngIf="canDelete" class="col-md-2">
<button type="button" class="btn oes-red-bg pull-right" (click)="deleteParam()">
diff --git a/sdc-workflow-designer-ui/src/app/components/parameter/parameter.component.ts b/sdc-workflow-designer-ui/src/app/components/parameter/parameter.component.ts
index f42caf66..2cd5a0fd 100644
--- a/sdc-workflow-designer-ui/src/app/components/parameter/parameter.component.ts
+++ b/sdc-workflow-designer-ui/src/app/components/parameter/parameter.component.ts
@@ -15,6 +15,7 @@ import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { ValueSource } from '../../model/value-source.enum';
import { Parameter } from '../../model/workflow/parameter';
import { DataAccessService } from "../../services/data-access/data-access.service";
+import { PlanTreeviewItem } from "../../model/plan-treeview-item";
/**
* this component contains in property component if the corresponding node has parameter properties
@@ -30,6 +31,7 @@ export class ParameterComponent implements OnInit {
@Input() public canEditName: boolean;
@Input() public showLabel = true;
@Input() public canDelete: boolean;
+ @Input() public planItems: PlanTreeviewItem[];
@Output() public paramChange = new EventEmitter<Parameter>();
@Output() delete: EventEmitter<Parameter> = new EventEmitter<Parameter>();
@@ -37,10 +39,13 @@ export class ParameterComponent implements OnInit {
public valueGroupClass;
public valueClass;
public showValueSource: boolean = true;
+ public planValue: any = {};
+ public planOptions = [];
constructor(private dataAccessService: DataAccessService) { }
public ngOnInit(): void {
+ console.log(this.planItems);
if (1 === this.valueSource.length) {
this.showValueSource = false;
}
@@ -53,15 +58,58 @@ export class ParameterComponent implements OnInit {
'col-md-7': this.canDelete,
'col-md-9': !this.canDelete
};
+
+ // trans plan options to tree view items.
+ this.initPlanTreeviewItems(this.planItems);
+ if (ValueSource[ValueSource.Plan] === this.param.valueSource) {
+ this.planValue = { id: this.param.value };
+ }
}
public deleteParam(): void {
this.delete.emit();
}
- public modelChange(value: any) {
- this.param.value = value;
- this.paramChange.emit(this.param)
+ public valueSourceChange(valueSource: string) {
+ this.param.valueSource = valueSource;
+ this.valueChange(null);
+ }
+
+ public valueChange(value: any) {
+ if (ValueSource[ValueSource.Plan] === this.param.valueSource) {
+ if (value !== null && 'object' === typeof (value)) {
+ this.planValue = value;
+ } else {
+ this.planValue = {};
+ }
+ this.param.value = this.planValue.id;
+ } else {
+ this.param.value = value;
+ }
+ this.paramChange.emit(this.param);
+ }
+
+ private initPlanTreeviewItems(planTreeviewItems: PlanTreeviewItem[]): void {
+ this.planOptions = this.getTreeviewChild(planTreeviewItems);
+ }
+
+ private getTreeviewChild(planTreeviewItems: PlanTreeviewItem[]): any[] {
+ let treeviewItems = [];
+ if (undefined == planTreeviewItems || 0 === planTreeviewItems.length) {
+ // todo: debug check if it need [] or undefined.
+ return treeviewItems;
+ }
+ planTreeviewItems.forEach(item => {
+ const treeviewItem = {
+ id: item.value,
+ name: item.name,
+ disabled: false,
+ // !item.canSelect,
+ children: this.getTreeviewChild(item.children)
+ };
+ treeviewItems.push(treeviewItem);
+ });
+ return treeviewItems;
}
}