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';
14 import { ScriptTask } from "../../../model/workflow/script-task";
15 import { NodeTypeService } from '../../../services/node-type.service';
18 selector: 'wfm-script-task',
19 templateUrl: 'script-task.component.html',
21 export class ScriptTaskComponent implements OnInit {
22 @Input() public node: ScriptTask;
24 public canChangeFormat = true;
25 public scriptOperations = ['JavaScript', 'Groovy'];
27 constructor(private nodeTypeService: NodeTypeService) { }
30 const nodeDataType = this.nodeTypeService.getNodeDataTypeById(this.node.typeId);
31 let scriptFormat = nodeDataType.content.scriptFormat;
32 // scriptFormat is not support, reset it as null;
33 if (undefined === this.scriptOperations.find(format => format == scriptFormat)) {
36 // Defined scriptFormat value, use it as default and can not change.
37 if (scriptFormat && '' != scriptFormat) {
38 this.canChangeFormat = false;
39 if (!this.node.scriptFormat || '' == this.node.scriptFormat) {
40 this.node.scriptFormat = scriptFormat;
41 this.node.script = nodeDataType.content.script;
44 // Default scriptFormat value should be 'JavaScript'
45 if (!this.node.scriptFormat || '' == this.node.scriptFormat) {
46 this.node.scriptFormat = 'JavaScript';
47 this.node.script = '';