2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 import { Component, Input, Output, EventEmitter} from "@angular/core";
22 import {PropertyFEModel, DerivedFEProperty, InstanceFePropertiesMap} from "app/models";
23 import {PropertiesService} from "../../../services/properties.service";
26 selector: 'properties-table',
27 templateUrl: './properties-table.component.html',
28 styleUrls: ['./properties-table.component.less']
30 export class PropertiesTableComponent {
32 @Input() fePropertiesMap: InstanceFePropertiesMap;
33 @Input() feInstanceNamesMap: Map<string, string>;
34 @Input() selectedPropertyId: string;
35 @Input() propertyNameSearchText:string;
36 @Input() searchTerm:string;
37 @Input() readonly:boolean;
38 @Input() isLoading:boolean;
39 @Input() hasDeclareOption:boolean;
40 @Input() hidePropertyType:boolean;
42 @Output('propertyChanged') emitter: EventEmitter<PropertyFEModel> = new EventEmitter<PropertyFEModel>();
43 @Output() selectPropertyRow: EventEmitter<PropertyRowSelectedEvent> = new EventEmitter<PropertyRowSelectedEvent>();
44 @Output() updateCheckedPropertyCount: EventEmitter<boolean> = new EventEmitter<boolean>();//only for hasDeclareOption
46 constructor (private propertiesService:PropertiesService ){
52 onPropertyChanged = (property) => {
53 this.emitter.emit(property);
56 // Click on main row (row of propertyFEModel)
57 onClickPropertyRow = (property:PropertyFEModel, instanceName:string, event?) => {
58 //event && event.stopPropagation();
59 this.selectedPropertyId = property.name;
60 let propertyRowSelectedEvent:PropertyRowSelectedEvent = new PropertyRowSelectedEvent(property, instanceName);
61 this.selectPropertyRow.emit(propertyRowSelectedEvent);
64 // Click on inner row (row of DerivedFEProperty)
65 onClickPropertyInnerRow = (property:DerivedFEProperty, instanceName:string) => {
66 let propertyRowSelectedEvent:PropertyRowSelectedEvent = new PropertyRowSelectedEvent(property, instanceName);
67 this.selectPropertyRow.emit(propertyRowSelectedEvent);
70 propertyChecked = (prop: PropertyFEModel, childPropName?: string) => {
71 let isChecked: boolean = (!childPropName)? prop.isSelected : prop.flattenedChildren.find(prop => prop.propertiesName == childPropName).isSelected;
74 this.propertiesService.undoDisableRelatedProperties(prop, childPropName);
76 this.propertiesService.disableRelatedProperties(prop, childPropName);
78 this.updateCheckedPropertyCount.emit(isChecked);
83 export class PropertyRowSelectedEvent {
84 propertyModel:PropertyFEModel | DerivedFEProperty;
86 constructor ( propertyModel:PropertyFEModel | DerivedFEProperty, instanceName:string ){
87 this.propertyModel = propertyModel;
88 this.instanceName = instanceName;