1 /*******************************************************************************
2 * Copyright (c) 2017 ZTE Corporation.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * and the Apache License 2.0 which both accompany this distribution,
6 * and are available at http://www.eclipse.org/legal/epl-v10.html
7 * and http://www.apache.org/licenses/LICENSE-2.0
10 * ZTE - initial API and implementation and/or initial documentation
11 *******************************************************************************/
12 import { Component, Input, OnInit } from '@angular/core';
13 import { Subscription } from 'rxjs/Subscription';
15 import { ValueSource } from '../../../model/value-source.enum';
16 import { Parameter } from '../../../model/workflow/parameter';
17 import { StartEvent } from '../../../model/workflow/start-event';
18 import { BroadcastService } from '../../../services/broadcast.service';
19 import { WorkflowUtil } from '../../../util/workflow-util';
20 import { TranslateService } from '@ngx-translate/core';
23 selector: 'wfm-start-event',
24 styleUrls: ['./start-event.component.css'],
25 templateUrl: 'start-event.component.html',
27 export class StartEventComponent implements OnInit {
28 @Input() public node: StartEvent;
29 public sources: ValueSource[] = [ValueSource.string];
31 constructor(private translate: TranslateService) { }
35 public create(): void {
36 let parameter = new Parameter('', '', ValueSource[ValueSource.string]);
37 this.node.parameters.push(parameter);
40 public delete(index: number): void {
41 this.node.parameters.splice(index, 1);
44 public checkKey(newName: string, index: number): void {
45 this.node.parameters[index].name = newName;
46 this.node.parameters.forEach(parameter => {
47 parameter.errorMsg = '';
50 this.translate.get('WORKFLOW.MSG.VARIABLE_EMPTY').subscribe((res: string) => {
51 this.node.parameters[index].errorMsg = res;
54 this.node.parameters.forEach((parameter, i) => {
55 if (i + 1 < this.node.parameters.length) {
56 for (let j = i + 1; j < this.node.parameters.length; j++) {
57 let element = this.node.parameters[j];
58 if (element.name && parameter.name === element.name) {
59 this.translate.get('WORKFLOW.MSG.VARIABLE_SAME').subscribe((res: string) => {
60 parameter.errorMsg = res;
61 element.errorMsg = res;