From 51d50f0ef642e0f996a1c8b8d2ef4838bdfec892 Mon Sep 17 00:00:00 2001 From: Tal Gitelman Date: Sun, 10 Dec 2017 18:55:03 +0200 Subject: Final commit to master merge from Change-Id: Ib464f9a8828437c86fe6def8af238aaf83473507 Issue-ID: SDC-714 Signed-off-by: Tal Gitelman --- .../dynamic-property.component.html | 66 ------- .../dynamic-property.component.less | 74 -------- .../dynamic-property/dynamic-property.component.ts | 205 --------------------- 3 files changed, 345 deletions(-) delete mode 100644 catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html delete mode 100644 catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.less delete mode 100644 catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts (limited to 'catalog-ui/src/app/ng2/components/properties-table/dynamic-property') diff --git a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html deleted file mode 100644 index 3ffc9c16be..0000000000 --- a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.html +++ /dev/null @@ -1,66 +0,0 @@ -
- - -
- -
{{property.name}}
-
-
{{property.name}}
-
- -
-
- - -
- -
-
- -
{{property.type | contentAfterLastDot }}
-
{{property.schema.property.type | contentAfterLastDot }}
-
- -
-
- - - Add value to list - - - - -
- -
- - - - -
diff --git a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.less b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.less deleted file mode 100644 index 48d3d035d0..0000000000 --- a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.less +++ /dev/null @@ -1,74 +0,0 @@ -@import '../../../../../assets/styles/variables.less'; -.flat-children-container { - .dynamic-property-row { - /*create nested left border classes for up to 10 levels of nesting*/ - .nested-border-loop(@i) when (@i > 0) { - @size: (@i - 1) *2; - &.nested-level-@{i} .table-cell:first-child { - border-left: ~"solid @{size}px #009fdb"; - } - .nested-border-loop(@i - 1) - } - .nested-border-loop(10); - } - dynamic-property { - &:first-child .dynamic-property-row.with-top-border { - border-top:solid 1px #d2d2d2; - } - &:not(:last-child) .dynamic-property-row { - border-bottom:solid 1px #d2d2d2; - } - } -} -.dynamic-property-row { - display:flex; - flex-direction:row; - align-items: stretch; - - .table-cell { - flex: 1; - padding:9px; - justify-content: center; - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - - &:first-child { - flex: 0 0 50%; - border-right:#d2d2d2 solid 1px; - &:only-of-type { - flex: 1 1 100%; - border-right:none; - } - } - &.empty { - height:40px; - } - } - .property-icon { - flex: 0 0 auto; - margin-right:10px; - align-self:center; - cursor:pointer; - } - -} - -.filtered { - /deep/ .checkbox-label-content{ - background-color: yellow; - } -} -.inner-cell-div{ - max-width: 100%; - text-overflow: ellipsis; - overflow: hidden; - display: inline; - padding-left: 8px; -} -.error { - border: solid 1px @func_color_q; - color: @func_color_q; - outline: none; - box-sizing: border-box; -} diff --git a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts b/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts deleted file mode 100644 index 9cf043098b..0000000000 --- a/catalog-ui/src/app/ng2/components/properties-table/dynamic-property/dynamic-property.component.ts +++ /dev/null @@ -1,205 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -import {Component, Input, Output, EventEmitter} from "@angular/core"; -import { PropertyBEModel, PropertyFEModel, DerivedFEProperty, DerivedPropertyType, SchemaPropertyGroupModel, DataTypeModel } from "app/models"; -import { PROPERTY_DATA, PROPERTY_TYPES } from 'app/utils'; -import { PropertiesUtils } from "app/ng2/pages/properties-assignment/properties.utils"; -import { DataTypeService } from "../../../services/data-type.service"; -import { trigger, state, style, transition, animate } from '@angular/core'; - - -@Component({ - selector: 'dynamic-property', - templateUrl: './dynamic-property.component.html', - styleUrls: ['./dynamic-property.component.less'], - animations: [trigger('fadeIn', [transition(':enter', [style({ opacity: '0' }), animate('.7s ease-out', style({ opacity: '1' }))])])] -}) -export class DynamicPropertyComponent { - - derivedPropertyTypes = DerivedPropertyType; //http://stackoverflow.com/questions/35835984/how-to-use-a-typescript-enum-value-in-an-angular2-ngswitch-statement - propType: DerivedPropertyType; - propPath: string; - isPropertyFEModel: boolean; - nestedLevel: number; - - @Input() canBeDeclared: boolean; - @Input() property: PropertyFEModel | DerivedFEProperty; - @Input() expandedChildId: string; - @Input() selectedPropertyId: string; - @Input() propertyNameSearchText: string; - @Input() readonly: boolean; - @Input() hasChildren: boolean; - - @Output() valueChanged: EventEmitter = new EventEmitter(); - @Output() expandChild: EventEmitter = new EventEmitter(); - @Output() checkProperty: EventEmitter = new EventEmitter(); - @Output() deleteItem: EventEmitter = new EventEmitter(); - @Output() clickOnPropertyRow: EventEmitter = new EventEmitter(); - @Output() mapKeyChanged: EventEmitter = new EventEmitter(); - @Output() addChildPropsToParent: EventEmitter> = new EventEmitter>(); - - - constructor(private propertiesUtils: PropertiesUtils, private dataTypeService: DataTypeService) { - } - - ngOnInit() { - this.isPropertyFEModel = this.property instanceof PropertyFEModel; - this.propType = this.property.derivedDataType; - this.propPath = (this.property instanceof PropertyFEModel) ? this.property.name : this.property.propertiesName; - this.nestedLevel = (this.property.propertiesName.match(/#/g) || []).length; - } - - - onClickPropertyRow = (property, event) => { - // Because DynamicPropertyComponent is recrusive second time the event is fire event.stopPropagation = undefined - event && event.stopPropagation && event.stopPropagation(); - this.clickOnPropertyRow.emit(property); - } - - - expandChildById = (id: string) => { - this.expandedChildId = id; - this.expandChild.emit(id); - } - - checkedChange = (propName: string) => { - this.checkProperty.emit(propName); - } - - getHasChildren = (property:DerivedFEProperty): boolean => {// enter to this function only from base property (PropertyFEModel) and check for child property if it has children - return _.filter((this.property).flattenedChildren,(prop:DerivedFEProperty)=>{ - return _.startsWith(prop.propertiesName + '#', property.propertiesName); - }).length > 1; - } - - createNewChildProperty = (): void => { - - let newProps: Array = this.propertiesUtils.createListOrMapChildren(this.property, "", undefined); - if (this.property instanceof PropertyFEModel) { - this.addChildProps(newProps, this.property.name); - } else { - this.addChildPropsToParent.emit(newProps); - } - } - - addChildProps = (newProps: Array, childPropName: string) => { - - if (this.property instanceof PropertyFEModel) { - let insertIndex: number = this.property.getIndexOfChild(childPropName) + this.property.getCountOfChildren(childPropName); //insert after parent prop and existing children - this.property.flattenedChildren.splice(insertIndex, 0, ...newProps); //using ES6 spread operator - this.expandChildById(newProps[0].propertiesName); - - - if(!newProps[0].schema.property.isSimpleType){ - if ( newProps[0].mapKey ) {//prevent update the new item value on parent property valueObj and saving on BE if it is map item, it will be updated and saved only after user enter key (when it is list item- the map key is the es type) - this.updateMapKeyValueOnMainParent(newProps); - if (this.property.getParentNamesArray(newProps[0].propertiesName, []).indexOf('') === -1) { - this.valueChanged.emit(this.property.name); - } - } - } - } - } - - updateMapKeyValueOnMainParent(childrenProps: Array){ - if (this.property instanceof PropertyFEModel) { - //Update only if all this property parents has key name - if (this.property.getParentNamesArray(childrenProps[0].propertiesName, []).indexOf('') === -1){ - angular.forEach(childrenProps, (prop:DerivedFEProperty):void => { //Update parent PropertyFEModel with value for each child, including nested props - (this.property).childPropUpdated(prop); - },this); - //grab the cumulative value for the new item from parent PropertyFEModel and assign that value to DerivedFEProp[0] (which is the list or map parent with UUID of the set we just added) - let parentNames = (this.property).getParentNamesArray(childrenProps[0].propertiesName, []); - childrenProps[0].valueObj = _.get(this.property.valueObj, parentNames.join('.')); - } - } - } - - childValueChanged = (property: DerivedFEProperty) => { //value of child property changed - - if (this.property instanceof PropertyFEModel) { // will always be the case - if (this.property.getParentNamesArray(property.propertiesName, []).indexOf('') === -1) {//If one of the parents is empty key -don't save - this.property.childPropUpdated(property); - this.dataTypeService.checkForCustomBehavior(this.property); - this.valueChanged.emit(this.property.name); - } - } - } - - deleteListOrMapItem = (item: DerivedFEProperty) => { - if (this.property instanceof PropertyFEModel) { - this.removeValueFromParent(item); - this.property.flattenedChildren.splice(this.property.getIndexOfChild(item.propertiesName), this.property.getCountOfChildren(item.propertiesName)); - this.expandChildById(item.propertiesName); - } - } - - removeValueFromParent = (item: DerivedFEProperty, target?: any) => { - if (this.property instanceof PropertyFEModel) { - let itemParent = (item.parentName == this.property.name) ? this.property : this.property.flattenedChildren.find(prop => prop.propertiesName == item.parentName); - - if (item.derivedDataType == DerivedPropertyType.MAP) { - let oldKey = item.mapKey; - if (target && typeof target.value == 'string') { //allow saving empty string - let replaceKey:string = target.value; - if (!replaceKey) {//prevent delete map key - return; - } - if(Object.keys(itemParent.valueObj).indexOf(replaceKey) > -1){//the key is exists - target.setCustomValidity('This key is already exists.'); - return; - }else { - target.setCustomValidity(''); - _.set(itemParent.valueObj, replaceKey, itemParent.valueObj[oldKey]); - item.mapKey = replaceKey; - //If the map key was empty its valueObj was not updated on its prent property valueObj, and now we should update it. - if(!oldKey && !item.schema.property.isSimpleType){ - //Search this map item children and update these value on parent property valueOBj - let mapKeyFlattenChildren:Array = _.filter(this.property.flattenedChildren, (prop:DerivedFEProperty) => { - return _.startsWith(prop.propertiesName, item.propertiesName); - }); - this.updateMapKeyValueOnMainParent(mapKeyFlattenChildren); - } - } - } - delete itemParent.valueObj[oldKey]; - } else { - let itemIndex: number = this.property.flattenedChildren.filter(prop => prop.parentName == item.parentName).map(prop => prop.propertiesName).indexOf(item.propertiesName); - itemParent.valueObj.splice(itemIndex, 1); - } - if (item.mapKey) {//prevent going to BE if user tries to delete map item without key (it was not saved in BE) - if (itemParent instanceof PropertyFEModel) { //direct child - this.valueChanged.emit(this.property.name); - } else { //nested child - need to update parent prop by getting flattened name (recurse through parents and replace map/list keys, etc) - this.childValueChanged(itemParent); - } - } - } - } - - preventInsertItem = (property:DerivedFEProperty):boolean => { - if(property.type == PROPERTY_TYPES.MAP && Object.keys(property.valueObj).indexOf('') > -1 ){ - return true; - } - return false; - } - -} -- cgit