[SDC] rebase 1710 code
[sdc.git] / catalog-ui / src / app / models / properties-inputs / input-fe-model.ts
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
21 import { SchemaPropertyGroupModel, SchemaProperty } from "../aschema-property";
22 import { PropertyBEModel } from "../../models";
23 import {PROPERTY_DATA} from "../../utils/constants";
24 import {InputBEModel} from "./input-be-model";
25
26 export class InputFEModel extends InputBEModel {
27     isSimpleType: boolean;
28     relatedPropertyValue: any;
29     relatedPropertyName: string;
30
31     constructor(input?: InputBEModel) {
32         super(input);
33         if (input) {
34             this.isSimpleType = PROPERTY_DATA.SIMPLE_TYPES.indexOf(this.type) > -1;
35             let relatedProperty = input.properties && input.properties[0] || input.inputs && input.inputs[0];
36             if (relatedProperty) {
37                 this.relatedPropertyValue = relatedProperty.value;
38                 this.relatedPropertyName = relatedProperty.name;
39             }
40         }
41     }
42
43 }