Michael Lando | dd60339 | 2017-07-12 00:54:52 +0300 | [diff] [blame] | 1 | /*- |
| 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 Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 21 | /** |
| 22 | * Created by obarda on 8/24/2016. |
| 23 | */ |
| 24 | 'use strict'; |
| 25 | import {PropertyModel} from "./properties"; |
| 26 | import {InputPropertyBase} from "./input-property-base"; |
vasraz | 26e5029 | 2021-02-16 17:37:57 +0000 | [diff] [blame] | 27 | import {SchemaPropertyGroupModel} from "./schema-property"; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 28 | |
ojasdubey | 4192e3c | 2019-03-18 14:15:03 +0530 | [diff] [blame] | 29 | export class InputsGroup { |
ys9693 | 16a9fce | 2020-01-19 13:50:02 +0200 | [diff] [blame] | 30 | constructor(inputsObj?: InputsGroup) { |
ojasdubey | 4192e3c | 2019-03-18 14:15:03 +0530 | [diff] [blame] | 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 Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 40 | export 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 | } |
| 52 | export 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; |
aribeiro | 5c1f575 | 2020-11-19 13:28:43 +0000 | [diff] [blame] | 68 | toscaDefaultValue?: string; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 69 | |
| 70 | //costom properties |
| 71 | isNew:boolean; |
| 72 | isDeleteDisabled:boolean; |
| 73 | properties:Array<PropertyModel>; |
| 74 | inputs:Array<InputModel>; |
| 75 | isAlreadySelected:boolean; |
| 76 | filterTerm:string; |
| 77 | |
| 78 | constructor(input:InputModel) { |
| 79 | |
| 80 | if (input) { |
| 81 | this.uniqueId = input.uniqueId; |
| 82 | this.name = input.name; |
| 83 | this.type = input.type; |
| 84 | this.description = input.description; |
| 85 | this.password = input.password; |
| 86 | this.required = input.required; |
| 87 | this.definition = input.definition; |
| 88 | this.parentUniqueId = input.parentUniqueId; |
| 89 | this.description = input.description; |
| 90 | this.componentInstanceName = input.componentInstanceName; |
| 91 | this.componentInstanceId = input.componentInstanceId; |
| 92 | this.schema = input.schema; |
| 93 | this.defaultValue = input.defaultValue; |
| 94 | this.value = input.value; |
| 95 | this.filterTerm = this.name + ' ' + this.description + ' ' + this.type + ' ' + this.componentInstanceName; |
| 96 | this.inputs = input.inputs; |
| 97 | this.properties = input.properties; |
aribeiro | 5c1f575 | 2020-11-19 13:28:43 +0000 | [diff] [blame] | 98 | this.toscaDefaultValue = input.toscaDefaultValue; |
Michael Lando | ed64b5e | 2017-06-09 03:19:04 +0300 | [diff] [blame] | 99 | } |
| 100 | } |
| 101 | |
| 102 | public toJSON = ():any => { |
| 103 | let input = angular.copy(this); |
| 104 | input.isNew = undefined; |
| 105 | input.isDeleteDisabled = undefined; |
| 106 | input.properties = undefined; |
| 107 | input.inputs = undefined; |
| 108 | input.isAlreadySelected = undefined; |
| 109 | input.filterTerm = undefined; |
| 110 | return input; |
| 111 | }; |
| 112 | } |
| 113 | |