diff options
Diffstat (limited to 'catalog-ui/src/app/ng2/pages/properties-assignment')
3 files changed, 23 insertions, 51 deletions
diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts index b59ef9dbda..b14f3afd6b 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.module.ts @@ -15,7 +15,6 @@ import { DataTypeService } from './../../services/data-type.service'; import { PropertiesService } from './../../services/properties.service'; import { HierarchyNavService } from './../../services/hierarchy-nav.service'; import { PropertiesUtils } from './properties.utils'; -import { PostsService } from "../../services/posts.service"; import { DynamicElementModule } from 'app/ng2/components/dynamic-element/dynamic-element.module'; import { DynamicPropertyComponent } from './../../components/properties-table/dynamic-property/dynamic-property.component'; import {ConfirmationDeleteInputComponent} from "app/ng2/components/inputs-table/confirmation-delete-input/confirmation-delete-input.component" @@ -27,6 +26,7 @@ import {TooltipModule} from "../../components/tooltip/tooltip.module"; import { ComponentModeService } from "app/ng2/services/component-mode.service" import { ModalComponent } from "app/ng2/components/modal/modal.component" import {LoaderComponent} from "app/ng2/components/loader/loader.component" +import {HttpInterceptor} from "../../services/http.interceptor.service"; @NgModule({ declarations: [ @@ -63,7 +63,7 @@ import {LoaderComponent} from "app/ng2/components/loader/loader.component" // PopoverContentComponent, // PopoverComponent ], - providers: [PropertiesService, HierarchyNavService, PropertiesUtils, DataTypeService, PostsService, ContentAfterLastDotPipe, GroupByPipe, KeysPipe, ComponentModeService] + providers: [PropertiesService, HierarchyNavService, PropertiesUtils, DataTypeService,HttpInterceptor, ContentAfterLastDotPipe, GroupByPipe, KeysPipe, ComponentModeService] }) export class PropertiesAssignmentModule { diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts index 22d6f2fe51..e66ed59ad7 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties-assignment.page.component.ts @@ -1,5 +1,4 @@ import {Component, ViewChild, ElementRef, Renderer, Inject} from "@angular/core"; -import {PostsService} from "../../services/posts.service"; import { PropertiesService } from "../../services/properties.service"; import { HierarchyNavService } from "../../services/hierarchy-nav.service"; import { PropertiesUtils } from './properties.utils'; @@ -8,15 +7,13 @@ import { PROPERTY_TYPES, ResourceType } from "app/utils"; import property = require("lodash/property"); import {ComponentServiceNg2} from "../../services/component-services/component.service"; import {ComponentInstanceServiceNg2} from "../../services/component-instance-services/component-instance.service" -import { InputFEModel, ComponentInstance, PropertyBEModel, DerivedPropertyType, DerivedFEProperty, ResourceInstance, SimpleFlatProperty } from "app/models"; +import { InputBEModel, InputFEModel, ComponentInstance, PropertyBEModel, DerivedPropertyType, DerivedFEProperty, ResourceInstance, SimpleFlatProperty } from "app/models"; import {HierarchyDisplayOptions} from "../../components/hierarchy-navigtion/hierarchy-display-options" import {PropertyRowSelectedEvent} from "./../../components/properties-table/properties-table.component"; import { KeysPipe } from 'app/ng2/pipes/keys.pipe'; import {FilterPropertiesAssignmentComponent} from "../../components/filter-properties-assignment/filter-properties-assignment.component"; import { ComponentModeService } from "app/ng2/services/component-mode.service" import {WorkspaceMode, EVENTS} from "../../../utils/constants"; -import {ComponentInstanceProperty, InputBEModel} from "app/models" -import {ComponentInstanceInput} from "../../../models/properties-inputs/input-be-model"; import {EventListenerService} from "app/services/event-listener-service" @Component({ templateUrl: './properties-assignment.page.component.html', @@ -102,6 +99,7 @@ export class PropertiesAssignmentComponent { } this.selectFirstInstanceByDefault(); }); + }; ngOnDestroy() { @@ -292,41 +290,23 @@ export class PropertiesAssignmentComponent { this.setInputTabIndication(response.length); this.checkedPropertiesCount = 0; _.forEach(response, (input: InputBEModel) => { - this.inputs.push(new InputFEModel(input)); - this.updatePropertyValueAfterDeclare(input); + let newInput: InputFEModel = new InputFEModel(input); + this.inputs.push(newInput); + this.updatePropertyValueAfterDeclare(newInput); }); }); }; - updatePropertyValueAfterDeclare = (input: InputBEModel) => { - _.forEach(input.properties, (property: ComponentInstanceProperty) => { - this.updatePropertyOrInputValueAfterDeclare(property, input); - }); - - _.forEach(input.inputs, (inputInstance: ComponentInstanceInput) => { - this.updatePropertyOrInputValueAfterDeclare(inputInstance, input); - }); - } - updatePropertyOrInputValueAfterDeclare = (inputSource: ComponentInstanceProperty | ComponentInstanceInput, input: InputBEModel) => { - if (this.instanceFePropertiesMap[inputSource.componentInstanceId]) { - let propertyForUpdatindVal = _.find(this.instanceFePropertiesMap[inputSource.componentInstanceId], (feProperty: PropertyFEModel) => { - return feProperty.name == inputSource.name; + updatePropertyValueAfterDeclare = (input: InputFEModel) => { + if (this.instanceFePropertiesMap[input.instanceUniqueId]) { + let propertyForUpdatindVal = _.find(this.instanceFePropertiesMap[input.instanceUniqueId], (feProperty: PropertyFEModel) => { + return feProperty.name == input.relatedProperty.name; }); - if (input.inputPath == propertyForUpdatindVal.name) input.inputPath = null; //Fix - if inputPath is sent for parent props, remove it - - propertyForUpdatindVal.setAsDeclared(input.inputPath); //set prop as declared before assigning value - this.propertiesService.disableRelatedProperties(propertyForUpdatindVal, input.inputPath); - this.propertiesUtils.resetPropertyValue(propertyForUpdatindVal, inputSource.value, input.inputPath); - // if (input.inputPath) { - // let childProp = _.find(propertyForUpdatindVal.flattenedChildren, (child: DerivedFEProperty) => { - // return child.propertiesName == input.inputPath; - // }); - // this.propertiesUtils.assignFlattenedChildrenValues(JSON.parse(inputSource.value), [childProp], inputSource.name); - // } else { - // propertyForUpdatindVal.valueObj = inputSource.value; - // } + propertyForUpdatindVal.setAsDeclared(input.relatedProperty.nestedPath); //set prop as declared before assigning value + this.propertiesService.disableRelatedProperties(propertyForUpdatindVal, input.relatedProperty.nestedPath); + this.propertiesUtils.resetPropertyValue(propertyForUpdatindVal, input.relatedProperty.value, input.relatedProperty.nestedPath); } } @@ -368,14 +348,6 @@ export class PropertiesAssignmentComponent { }); }; - getInstanceUniqueId = (instanceName: string): string => { - let wantedInstance: ComponentInstance = this.instances.find((instance) => { - return instance.normalizedName === instanceName; - }); - - return wantedInstance.uniqueId; - }; - /*** SEARCH RELATED FUNCTIONS ***/ diff --git a/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts b/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts index 0eb8534595..bdfbc4c402 100644 --- a/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts +++ b/catalog-ui/src/app/ng2/pages/properties-assignment/properties.utils.ts @@ -20,8 +20,8 @@ export class PropertiesUtils { */ public convertPropertiesMapToFEAndCreateChildren = (instancePropertiesMap:InstanceBePropertiesMap, inputs:Array<InputFEModel>): InstanceFePropertiesMap => { let instanceFePropertiesMap:InstanceFePropertiesMap = new InstanceFePropertiesMap(); - angular.forEach(instancePropertiesMap, (properties:Array<PropertyBEModel>, instanceName:string) => { - let instanceInputs: Array<InputFEModel> = inputs.filter(input => input.instanceName == instanceName.split('.').pop()); + angular.forEach(instancePropertiesMap, (properties:Array<PropertyBEModel>, instanceId:string) => { + let instanceInputs: Array<InputFEModel> = inputs.filter(input => input.instanceUniqueId == instanceId); let propertyFeArray: Array<PropertyFEModel> = []; _.forEach(properties, (property: PropertyBEModel) => { @@ -35,9 +35,9 @@ export class PropertiesUtils { newFEProp.flattenedChildren = this.createFlattenedChildren(newFEProp.type, newFEProp.name); } if (instanceInputs.length) { //if this prop (or any children) are declared, set isDeclared and disable checkbox on parents/children - instanceInputs.filter(input => input.propertyName == newFEProp.name).forEach((input) => { - newFEProp.setAsDeclared(input.inputPath); //if a path was sent, its a child prop. this param is optional - this.propertiesService.disableRelatedProperties(newFEProp, input.inputPath); + instanceInputs.filter(input => input.relatedProperty.name == newFEProp.name).forEach((input) => { + newFEProp.setAsDeclared(input.relatedProperty.nestedPath); //if a path was sent, its a child prop. this param is optional + this.propertiesService.disableRelatedProperties(newFEProp, input.relatedProperty.nestedPath); }); } this.initValueObjectRef(newFEProp); //initialize valueObj. @@ -46,7 +46,7 @@ export class PropertiesUtils { this.dataTypeService.checkForCustomBehavior(newFEProp); } }); - instanceFePropertiesMap[instanceName] = propertyFeArray; + instanceFePropertiesMap[instanceId] = propertyFeArray; }); return instanceFePropertiesMap; @@ -140,10 +140,10 @@ export class PropertiesUtils { }); } - public resetPropertyValue = (property: PropertyFEModel, newValue: string, inputPath?: string): void => { + public resetPropertyValue = (property: PropertyFEModel, newValue: string, nestedPath?: string): void => { property.value = newValue; - if (inputPath) { - let newProp = property.flattenedChildren.find(prop => prop.propertiesName == inputPath); + if (nestedPath) { + let newProp = property.flattenedChildren.find(prop => prop.propertiesName == nestedPath); newProp && this.assignFlattenedChildrenValues(JSON.parse(newValue), [newProp], property.name); } else { this.initValueObjectRef(property); |