blob: e5b227483566c2537dff41c14420ea38f34467df [file] [log] [blame]
Michael Landodd603392017-07-12 00:54:52 +03001/*-
2 * ============LICENSE_START=======================================================
3 * SDC
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
19 */
20
Michael Landoed64b5e2017-06-09 03:19:04 +030021/**
22 * Created by obarda on 8/24/2016.
23 */
24'use strict';
25import {PropertyModel} from "./properties";
26import {InputPropertyBase} from "./input-property-base";
27import {SchemaPropertyGroupModel} from "./aschema-property";
28
ojasdubey4192e3c2019-03-18 14:15:03 +053029export class InputsGroup {
30 constructor(inputsObj?:InputsGroup) {
31 _.forEach(inputsObj, (inputs:Array<InputModel>, instance) => {
32 this[instance] = [];
33 _.forEach(inputs, (input:InputModel):void => {
34 this[instance].push(new InputModel(input));
35 });
36 });
37 }
38}
39
Michael Landoed64b5e2017-06-09 03:19:04 +030040export interface IInputModel extends InputPropertyBase {
41 //server data
42 definition:boolean;
43 value:string;
44 componentInstanceName:string;
45 //costom properties
46 isNew:boolean;
47 properties:Array<PropertyModel>;
48 inputs:Array<InputModel>;
49 filterTerm:string;
50
51}
52export class InputModel implements IInputModel {
53
54 //server data
55 uniqueId:string;
56 name:string;
57 type:string;
58 password:boolean;
59 required:boolean;
60 definition:boolean;
61 parentUniqueId:string;
62 description:string;
63 componentInstanceName:string;
64 componentInstanceId:string;
65 schema:SchemaPropertyGroupModel;
66 defaultValue:string;
67 value:string;
68
69 //costom properties
70 isNew:boolean;
71 isDeleteDisabled:boolean;
72 properties:Array<PropertyModel>;
73 inputs:Array<InputModel>;
74 isAlreadySelected:boolean;
75 filterTerm:string;
76
77 constructor(input:InputModel) {
78
79 if (input) {
80 this.uniqueId = input.uniqueId;
81 this.name = input.name;
82 this.type = input.type;
83 this.description = input.description;
84 this.password = input.password;
85 this.required = input.required;
86 this.definition = input.definition;
87 this.parentUniqueId = input.parentUniqueId;
88 this.description = input.description;
89 this.componentInstanceName = input.componentInstanceName;
90 this.componentInstanceId = input.componentInstanceId;
91 this.schema = input.schema;
92 this.defaultValue = input.defaultValue;
93 this.value = input.value;
94 this.filterTerm = this.name + ' ' + this.description + ' ' + this.type + ' ' + this.componentInstanceName;
95 this.inputs = input.inputs;
96 this.properties = input.properties;
97 }
98 }
99
100 public toJSON = ():any => {
101 let input = angular.copy(this);
102 input.isNew = undefined;
103 input.isDeleteDisabled = undefined;
104 input.properties = undefined;
105 input.inputs = undefined;
106 input.isAlreadySelected = undefined;
107 input.filterTerm = undefined;
108 return input;
109 };
110}
111