summaryrefslogtreecommitdiffstats
path: root/catalog-ui/src/app/view-models/forms/property-forms
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
committerMichael Lando <ml636r@att.com>2017-06-09 03:19:04 +0300
commited64b5edff15e702493df21aa3230b81593e6133 (patch)
treea4cb01fdaccc34930a8db403a3097c0d1e40914b /catalog-ui/src/app/view-models/forms/property-forms
parent280f8015d06af1f41a3ef12e8300801c7a5e0d54 (diff)
[SDC-29] catalog 1707 rebase commit.
Change-Id: I43c3dc5cf44abf5da817649bc738938a3e8388c1 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'catalog-ui/src/app/view-models/forms/property-forms')
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts204
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-view.html132
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base.less63
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts322
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html201
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-model.ts206
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-view.html41
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts97
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html74
-rw-r--r--catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal.less63
10 files changed, 1403 insertions, 0 deletions
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts
new file mode 100644
index 0000000000..1ba5a90bb4
--- /dev/null
+++ b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-model.ts
@@ -0,0 +1,204 @@
+/**
+ * Created by obarda on 1/19/2017.
+ */
+'use strict';
+import {DataTypesService} from "app/services/data-types-service";
+import {PropertyModel, DataTypesMap, Component} from "app/models";
+import {ValidationUtils, PROPERTY_DATA} from "app/utils";
+
+export interface IPropertyFormBaseViewScope extends ng.IScope {
+
+ forms:any;
+ editForm:ng.IFormController;
+
+ property:PropertyModel;
+ types:Array<string>;
+ nonPrimitiveTypes:Array<string>;
+ simpleTypes:Array<string>;
+
+ footerButtons:Array<any>;
+ modalPropertyFormBase:ng.ui.bootstrap.IModalServiceInstance;
+ currentPropertyIndex:number;
+ isLastProperty:boolean;
+ innerViewSrcUrl:string;
+
+ //Disabling filed - each child controller can change this when needed
+ isNew:boolean;
+ isTypeSelectorDisable:boolean;
+ isDeleteDisable:boolean;
+ isNameDisable:boolean;
+ isDescriptionDisable:boolean;
+ isPropertyValueDisable:boolean;
+ isArrowsDisabled:boolean;
+
+ //Validation pattern
+ validationPattern:RegExp;
+ propertyNameValidationPattern:RegExp;
+ commentValidationPattern:RegExp;
+ numberValidationPattern:RegExp;
+
+ dataTypes:DataTypesMap;
+
+ isLoading:boolean;
+
+ save():void;
+ close():void;
+ getNext():void;
+ getPrev():void;
+ getValidationPattern(type:string):RegExp;
+}
+
+export abstract class PropertyFormBaseView {
+
+
+ constructor(protected $scope:IPropertyFormBaseViewScope,
+ protected $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance,
+ protected $injector:ng.auto.IInjectorService,
+ protected originalProperty:PropertyModel,
+ protected component:Component,
+ protected filteredProperties:Array<PropertyModel>,
+ protected DataTypesService:DataTypesService) {
+
+ this.initScope();
+
+ }
+
+ protected validationUtils:ValidationUtils;
+
+ protected isPropertyValueOwner = ():boolean => {
+ return this.component.isService() || !!this.component.selectedInstance;
+ };
+
+ private isDisable = ():boolean => {
+ return this.isPropertyValueOwner() || this.$scope.property.readonly;
+ };
+
+
+ //This is the difault state, Childs screens can change if needed
+ protected initButtonsState = ():void => {
+ let isDisable = this.isDisable();
+
+ this.$scope.isArrowsDisabled = false;
+ this.$scope.isDeleteDisable = isDisable;
+ this.$scope.isDescriptionDisable = isDisable;
+ this.$scope.isNameDisable = isDisable;
+ this.$scope.isTypeSelectorDisable = isDisable;
+ this.$scope.isPropertyValueDisable = this.$scope.property.readonly && !this.isPropertyValueOwner();
+ };
+
+ protected initValidations = ():void => {
+
+ this.$scope.validationPattern = this.$injector.get('ValidationPattern');
+ this.$scope.propertyNameValidationPattern = this.$injector.get('PropertyNameValidationPattern');
+ this.$scope.commentValidationPattern = this.$injector.get('CommentValidationPattern');
+ this.$scope.numberValidationPattern = this.$injector.get('NumberValidationPattern');
+ this.validationUtils = this.$injector.get('ValidationUtils');
+ };
+
+ //Functions implemented on child's scope if needed
+ abstract save(doNotCloseModal?:boolean):ng.IPromise<boolean>;
+
+ protected onPropertyChange():void {
+ };
+
+ private updatePropertyByIndex = (index:number):void => {
+ this.$scope.property = new PropertyModel(this.filteredProperties[index]);
+ this.$scope.isLastProperty = this.$scope.currentPropertyIndex == (this.filteredProperties.length - 1);
+ this.onPropertyChange();
+ };
+
+ private initScope = ():void => {
+
+ this.$scope.forms = {};
+ this.$scope.isLoading = false;
+ this.$scope.property = new PropertyModel(this.originalProperty); //we create a new Object so if user press cance we won't update the property
+ this.$scope.types = PROPERTY_DATA.TYPES; //All types - simple type + map + list
+ this.$scope.simpleTypes = PROPERTY_DATA.SIMPLE_TYPES; //All simple types
+ this.$scope.dataTypes = this.DataTypesService.getAllDataTypes(); //Get all data types in service
+ this.$scope.modalPropertyFormBase = this.$uibModalInstance;
+ this.$scope.isNew = !angular.isDefined(this.$scope.property.name);
+
+ this.initValidations();
+ this.initButtonsState();
+ this.filteredProperties = _.sortBy(this.filteredProperties, 'name');
+ this.$scope.currentPropertyIndex = _.findIndex(this.filteredProperties, propety => propety.uniqueId == this.$scope.property.uniqueId);
+ this.$scope.isLastProperty = this.$scope.currentPropertyIndex == (this.filteredProperties.length - 1);
+
+ this.$scope.nonPrimitiveTypes = _.filter(Object.keys(this.$scope.dataTypes), (type:string)=> {
+ return this.$scope.types.indexOf(type) == -1;
+ });
+
+ this.$scope.close = ():void => {
+ this.$uibModalInstance.close();
+ };
+
+ this.$scope.save = ():void => {
+
+ let onSuccess = ():void => {
+ this.$scope.isLoading = false;
+ };
+ let onFailed = ():void => {
+ this.$scope.isLoading = false;
+ };
+
+ this.$scope.isLoading = true;
+ this.save(true).then(onSuccess, onFailed); // Child controller implement save logic
+ };
+
+ // Add the done button at the footer.
+ this.$scope.footerButtons = [
+ {'name': 'Save', 'css': 'blue', 'callback': this.$scope.save},
+ {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close}
+ ];
+
+
+ this.$scope.getPrev = ():void=> {
+
+ let onSuccess = ():void => {
+ this.$scope.isLoading = false;
+ this.updatePropertyByIndex(--this.$scope.currentPropertyIndex);
+ };
+ let onFailed = ():void => {
+ this.$scope.isLoading = false;
+ };
+
+ if (!this.$scope.property.readonly) {
+ this.$scope.isLoading = true;
+ this.save(false).then(onSuccess, onFailed);
+
+ } else {
+ this.updatePropertyByIndex(--this.$scope.currentPropertyIndex);
+ }
+
+ };
+
+ this.$scope.getNext = ():void=> {
+
+ let onSuccess = ():void => {
+ this.$scope.isLoading = false;
+ this.updatePropertyByIndex(++this.$scope.currentPropertyIndex);
+ };
+ let onFailed = ():void => {
+ this.$scope.isLoading = false;
+ };
+
+ if (!this.$scope.property.readonly) {
+ this.$scope.isLoading = true;
+ this.save(false).then(onSuccess, onFailed);
+ } else {
+ this.updatePropertyByIndex(++this.$scope.currentPropertyIndex);
+ }
+
+ };
+
+
+ this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => {
+ this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid;
+ });
+
+
+ this.$scope.getValidationPattern = (type:string):RegExp => {
+ return this.validationUtils.getValidationPattern(type);
+ };
+ }
+}
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-view.html b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-view.html
new file mode 100644
index 0000000000..7cb05bf4ca
--- /dev/null
+++ b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base-view.html
@@ -0,0 +1,132 @@
+<sdc-modal modal="modalPropertyFormBase" type="classic" class="sdc-edit-property-container" buttons="footerButtons" header="{{isNew ? 'Add' : 'Update' }} Property" show-close-button="true" data-tests-id="sdc-edit-property-container">
+ <loader data-display="isLoading" relative="false" size="medium"></loader>
+ <div class="sdc-modal-top-bar" data-ng-if="!isNew">
+ <div class="sdc-modal-top-bar-buttons">
+ <span ng-click="delete(property)" data-ng-class="{'disabled' : isDeleteDisable}" class="sprite-new delete-btn" data-tests-id="delete_property" sdc-smart-tooltip="">Delete</span>
+ <span class="delimiter"></span>
+ <span data-ng-click="getPrev()" data-ng-class="{'disabled' : !currentPropertyIndex || forms.editForm.$invalid || isArrowsDisabled}" class="sprite-new left-arrow" data-tests-id="get-prev" sdc-smart-tooltip="">Previous</span>
+ <span data-ng-click="getNext()" data-ng-class="{'disabled' : isLastProperty || forms.editForm.$invalid || isArrowsDisabled}" class="sprite-new right-arrow" data-tests-id="get-next" sdc-smart-tooltip="">Next</span>
+ </div>
+ </div>
+
+ <div class="sdc-edit-property-form-container" >
+ <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container">
+ <form class="w-sdc-form two-columns" name="forms.editForm" >
+
+ <div class="w-sdc-form-columns-wrapper">
+
+ <div class="w-sdc-form-column">
+
+ <!-- Name -->
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid)}">
+ <label class="i-sdc-form-label" ng-class="{'required': !isService}">Name</label>
+ <input class="i-sdc-form-input"
+ data-tests-id="propertyName"
+ data-ng-maxlength="50"
+ data-ng-disabled="isNameDisable"
+ maxlength="50"
+ data-ng-model="property.name"
+ type="text"
+ name="propertyName"
+ data-ng-pattern="propertyNameValidationPattern"
+ data-required
+ data-ng-model-options="{ debounce: 200 }"
+ autofocus />
+
+ <div class="input-error" data-ng-show="forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid">
+ <span ng-show="forms.editForm.propertyName.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property name' }"></span>
+ <span ng-show="forms.editForm.propertyName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '50' }"></span>
+ <span ng-show="forms.editForm.propertyName.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span>
+ </div>
+ </div>
+ </div>
+
+ <div class="w-sdc-form-column">
+ <div class="w-sdc-form-columns-wrapper">
+ <div class="w-sdc-form-column">
+ <!-- Type -->
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.type.$dirty && forms.editForm.type.$invalid)}">
+ <label class="i-sdc-form-label" ng-class="{'required': !isService}">Type</label>
+ <select class="i-sdc-form-select"
+ data-tests-id="propertyType"
+ data-required
+ data-ng-disabled="isTypeSelectorDisable"
+ name="type"
+ data-ng-change="onTypeChange()"
+ data-ng-model="property.type">
+ <option value="">Choose Type</option>
+ <option data-ng-repeat="type in types"
+ value="{{type}}">{{type}}</option>
+ <option data-ng-repeat="type in nonPrimitiveTypes"
+ value="{{type}}">{{type.replace("org.openecomp.datatypes.heat.","")}}</option>
+ </select>
+
+ <div class="input-error" data-ng-show="forms.editForm.type.$dirty && forms.editForm.type.$invalid">
+ <span ng-show="forms.editForm.type.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Type' }"></span>
+ </div>
+ </div>
+ </div>
+ <div class="w-sdc-form-column" data-ng-if="showSchema()">
+ <!-- Entry Schema -->
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.schemaType.$dirty && forms.editForm.schemaType.$invalid)}">
+ <label class="i-sdc-form-label required">Entry Schema</label>
+ <select class="i-sdc-form-select"
+ data-required
+ data-tests-id="schema-type"
+ data-ng-disabled="isPropertyValueOwner() || property.readonly"
+ name="schemaType"
+ data-ng-change="onSchemaTypeChange()"
+ data-ng-model="property.schema.property.type">
+ <option value="">Choose Schema Type</option>
+ <option data-ng-repeat="type in simpleTypes"
+ value="{{type}}">{{type}}</option>
+ <option data-ng-repeat="type in nonPrimitiveTypes"
+ value="{{type}}">{{type.replace("org.openecomp.datatypes.heat.","")}}</option>
+ </select>
+
+ <div class="input-error" data-ng-show="forms.editForm.schemaType.$dirty && forms.editForm.schemaType.$invalid">
+ <span ng-show="forms.editForm.schemaType.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Entry schema' }"></span>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- Constraints by type -->
+ <div class="i-sdc-form-item" data-ng-if="false">
+ <label class="i-sdc-form-label required">Constraints by type</label>
+ <div>
+ Should be constraints by type(TBD)
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+ <!-- Description -->
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.description.$dirty && forms.editForm.description.$invalid)}">
+ <label class="i-sdc-form-label">Description</label>
+ <textarea class="i-sdc-form-textarea"
+ data-ng-maxlength="256"
+ data-ng-disabled="isDescriptionDisable"
+ maxlength="256"
+ data-ng-pattern="commentValidationPattern"
+ name="description"
+ data-ng-model="property.description"
+ data-ng-model-options="{ debounce: 200 }"
+ data-tests-id="description"
+ ></textarea>
+
+ <div class="input-error" data-ng-show="forms.editForm.description.$dirty && forms.editForm.description.$invalid">
+ <span ng-show="forms.editForm.description.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '256' }"></span>
+ <span ng-show="forms.editForm.description.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span>
+ <span ng-show="forms.editForm.description.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Description' }"></span>
+ </div>
+ </div>
+ <!-- Default value - insert in dynamic template url -->
+ <ng-include src="innerViewSrcUrl"></ng-include>
+ <span class="w-sdc-form-note" data-ng-show="forms.editForm.$invalid && false" translate="LABEL_ALL_FIELDS_ARE_MANDATORY"></span>
+ </form>
+ </perfect-scrollbar>
+ </div>
+
+</sdc-modal>
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base.less b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base.less
new file mode 100644
index 0000000000..15e30af4ee
--- /dev/null
+++ b/catalog-ui/src/app/view-models/forms/property-forms/base-property-form/property-form-base.less
@@ -0,0 +1,63 @@
+.sdc-edit-property-container {
+ .scrollbar-container{
+ height: 415px;
+ width: 830px;
+ .perfect-scrollbar;
+ }
+
+ form{
+ width: 813px;
+ [name="description"]{
+ min-height:50px;
+ }
+ }
+
+ .sdc-modal-top-bar{
+ height: 40px;
+ .sdc-modal-top-bar-buttons {
+ float: right;
+
+ > span:not(.delimiter){
+ vertical-align: middle;
+ .hand;
+
+ &.sprite-new {
+ text-indent: 100%;
+ }
+ &.disabled, &:hover.disabled {
+ pointer-events: none;
+ }
+ }
+
+ .delete-btn{
+ margin-right: 6px;
+ }
+
+ .left-arrow{
+ margin-right: 8px;
+ }
+
+ .delimiter {
+ height: 20px;
+ width: 1px;
+ background-color: #959595;
+ display: inline-block;
+ vertical-align: middle;
+ margin-right: 10px;
+ }
+ }
+ }
+
+ .w-sdc-form-note {
+ .h_9;
+ display: block;
+ position: relative;
+ top: 13px;
+ }
+
+ .default-value-section{
+ border-top: solid 1px @main_color_a;
+ padding-top: 15px;
+ margin-top: 15px;
+ }
+}
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts
new file mode 100644
index 0000000000..b3557b055f
--- /dev/null
+++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view-model.ts
@@ -0,0 +1,322 @@
+'use strict';
+import {
+ PROPERTY_TYPES, ModalsHandler, ValidationUtils, PROPERTY_VALUE_CONSTRAINTS, FormState, PROPERTY_DATA} from "app/utils";
+import {DataTypesService} from "app/services";
+import {PropertyModel, DataTypesMap, Component} from "app/models";
+
+export interface IEditPropertyModel {
+ property:PropertyModel;
+ types:Array<string>;
+ simpleTypes:Array<string>;
+}
+
+interface IPropertyFormViewModelScope extends ng.IScope {
+ forms:any;
+ editForm:ng.IFormController;
+ footerButtons:Array<any>;
+ isNew:boolean;
+ isLoading:boolean;
+ isService:boolean;
+ validationPattern:RegExp;
+ propertyNameValidationPattern:RegExp;
+ commentValidationPattern:RegExp;
+ editPropertyModel:IEditPropertyModel;
+ modalInstanceProperty:ng.ui.bootstrap.IModalServiceInstance;
+ currentPropertyIndex:number;
+ isLastProperty:boolean;
+ myValue:any;
+ nonPrimitiveTypes:Array<string>;
+ dataTypes:DataTypesMap;
+ isTypeDataType:boolean;
+ maxLength:number;
+ isPropertyValueOwner:boolean;
+
+ validateJson(json:string):boolean;
+ save(doNotCloseModal?:boolean):void;
+ getValidationPattern(type:string):RegExp;
+ validateIntRange(value:string):boolean;
+ close():void;
+ onValueChange():void;
+ onSchemaTypeChange():void;
+ onTypeChange(resetSchema:boolean):void;
+ showSchema():boolean;
+ delete(property:PropertyModel):void;
+ getPrev():void;
+ getNext():void;
+ isSimpleType(typeName:string):boolean;
+ getDefaultValue():any;
+}
+
+export class PropertyFormViewModel {
+
+ static '$inject' = [
+ '$scope',
+ 'Sdc.Services.DataTypesService',
+ '$uibModalInstance',
+ 'property',
+ 'ValidationPattern',
+ 'PropertyNameValidationPattern',
+ 'CommentValidationPattern',
+ 'ValidationUtils',
+ 'component',
+ '$filter',
+ 'ModalsHandler',
+ 'filteredProperties',
+ '$timeout',
+ 'isPropertyValueOwner'
+ ];
+
+ private formState:FormState;
+
+ constructor(private $scope:IPropertyFormViewModelScope,
+ private DataTypesService:DataTypesService,
+ private $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance,
+ private property:PropertyModel,
+ private ValidationPattern:RegExp,
+ private PropertyNameValidationPattern:RegExp,
+ private CommentValidationPattern:RegExp,
+ private ValidationUtils:ValidationUtils,
+ private component:Component,
+ private $filter:ng.IFilterService,
+ private ModalsHandler:ModalsHandler,
+ private filteredProperties:Array<PropertyModel>,
+ private $timeout:ng.ITimeoutService,
+ private isPropertyValueOwner:boolean) {
+
+ this.formState = angular.isDefined(property.name) ? FormState.UPDATE : FormState.CREATE;
+ this.initScope();
+ }
+
+ private initResource = ():void => {
+ this.$scope.editPropertyModel.property = new PropertyModel(this.property);
+ this.$scope.editPropertyModel.property.type = this.property.type ? this.property.type : null;
+ this.setMaxLength();
+ this.initAddOnLabels();
+ };
+
+ //init property add-ons labels that show up at the left side of the input.
+ private initAddOnLabels = () => {
+ if (this.$scope.editPropertyModel.property.name == 'network_role' && this.$scope.isService) {
+ //the server sends back the normalized name. Remove it (to prevent interference with validation) and set the addon label to the component name directly.
+ //Note: this cant be done in properties.ts because we dont have access to the component
+ if (this.$scope.editPropertyModel.property.value) {
+ let splitProp = this.$scope.editPropertyModel.property.value.split(new RegExp(this.component.normalizedName + '.', "gi"));
+ this.$scope.editPropertyModel.property.value = splitProp.pop();
+ }
+ this.$scope.editPropertyModel.property.addOn = this.component.name;
+ }
+ }
+
+ private initEditPropertyModel = ():void => {
+ this.$scope.editPropertyModel = {
+ property: null,
+ types: PROPERTY_DATA.TYPES,
+ simpleTypes: PROPERTY_DATA.SIMPLE_TYPES
+ };
+
+ this.initResource();
+ };
+
+ private initForNotSimpleType = ():void => {
+ let property = this.$scope.editPropertyModel.property;
+ this.$scope.isTypeDataType = this.DataTypesService.isDataTypeForPropertyType(this.$scope.editPropertyModel.property);
+ if (property.type && this.$scope.editPropertyModel.simpleTypes.indexOf(property.type) == -1) {
+ if (!(property.value || property.defaultValue)) {
+ switch (property.type) {
+ case PROPERTY_TYPES.MAP:
+ this.$scope.myValue = {'': null};
+ break;
+ case PROPERTY_TYPES.LIST:
+ this.$scope.myValue = [];
+ break;
+ default:
+ this.$scope.myValue = {};
+ }
+ } else {
+ this.$scope.myValue = JSON.parse(property.value || property.defaultValue);
+ }
+ }
+ };
+
+ private setMaxLength = ():void => {
+ switch (this.$scope.editPropertyModel.property.type) {
+ case PROPERTY_TYPES.MAP:
+ case PROPERTY_TYPES.LIST:
+ this.$scope.maxLength = this.$scope.editPropertyModel.property.schema.property.type == PROPERTY_TYPES.JSON ?
+ PROPERTY_VALUE_CONSTRAINTS.JSON_MAX_LENGTH :
+ PROPERTY_VALUE_CONSTRAINTS.MAX_LENGTH;
+ break;
+ case PROPERTY_TYPES.JSON:
+ this.$scope.maxLength = PROPERTY_VALUE_CONSTRAINTS.JSON_MAX_LENGTH;
+ break;
+ default:
+ this.$scope.maxLength =PROPERTY_VALUE_CONSTRAINTS.MAX_LENGTH;
+ }
+ };
+
+
+ private initScope = ():void => {
+
+ //scope properties
+ this.$scope.forms = {};
+ this.$scope.validationPattern = this.ValidationPattern;
+ this.$scope.propertyNameValidationPattern = this.PropertyNameValidationPattern;
+ this.$scope.commentValidationPattern = this.CommentValidationPattern;
+ this.$scope.isLoading = false;
+ this.$scope.isNew = (this.formState === FormState.CREATE);
+ this.$scope.isService = this.component.isService();
+ this.$scope.modalInstanceProperty = this.$uibModalInstance;
+ this.$scope.currentPropertyIndex = _.findIndex(this.filteredProperties, i=> i.name == this.property.name);
+ this.$scope.isLastProperty = this.$scope.currentPropertyIndex == (this.filteredProperties.length - 1);
+ this.$scope.dataTypes = this.DataTypesService.getAllDataTypes();
+ this.$scope.isPropertyValueOwner = this.isPropertyValueOwner;
+ this.initEditPropertyModel();
+
+ this.$scope.nonPrimitiveTypes = _.filter(Object.keys(this.$scope.dataTypes), (type:string)=> {
+ return this.$scope.editPropertyModel.types.indexOf(type) == -1;
+ });
+ this.initForNotSimpleType();
+
+
+ this.$scope.validateJson = (json:string):boolean => {
+ if (!json) {
+ return true;
+ }
+ return this.ValidationUtils.validateJson(json);
+ };
+
+
+ //scope methods
+ this.$scope.save = (doNotCloseModal?:boolean):void => {
+ let property:PropertyModel = this.$scope.editPropertyModel.property;
+ this.$scope.editPropertyModel.property.description = this.ValidationUtils.stripAndSanitize(this.$scope.editPropertyModel.property.description);
+ //if read only - or no changes made - just closes the modal
+ //need to check for property.value changes manually to detect if map properties deleted
+ if ((this.$scope.editPropertyModel.property.readonly && !this.$scope.isPropertyValueOwner)
+ || (!this.$scope.forms.editForm.$dirty && angular.equals(JSON.stringify(this.$scope.myValue), this.$scope.editPropertyModel.property.value))) {
+ this.$uibModalInstance.close();
+ return;
+ }
+
+ this.$scope.isLoading = true;
+
+ let onPropertyFaild = (response):void => {
+ console.info('onFaild', response);
+ this.$scope.isLoading = false;
+ };
+
+ let onPropertySuccess = (propertyFromBE:PropertyModel):void => {
+ console.info('onPropertyResourceSuccess : ', propertyFromBE);
+ this.$scope.isLoading = false;
+
+ if (!doNotCloseModal) {
+ this.$uibModalInstance.close();
+ } else {
+ this.$scope.forms.editForm.$setPristine();
+ this.$scope.editPropertyModel.property = new PropertyModel();
+ }
+ };
+
+ //in case we have uniqueId we call update method
+ if (this.$scope.isPropertyValueOwner) {
+ if (!this.$scope.editPropertyModel.property.simpleType && !this.$scope.isSimpleType(property.type)) {
+ let myValueString:string = JSON.stringify(this.$scope.myValue);
+ property.value = myValueString;
+ }
+ this.component.updateInstanceProperty(property).then(onPropertySuccess, onPropertyFaild);
+ } else {
+ if (!this.$scope.editPropertyModel.property.simpleType && !this.$scope.isSimpleType(property.type)) {
+ let myValueString:string = JSON.stringify(this.$scope.myValue);
+ property.defaultValue = myValueString;
+ } else {
+ this.$scope.editPropertyModel.property.defaultValue = this.$scope.editPropertyModel.property.value;
+ }
+ this.component.addOrUpdateProperty(property).then(onPropertySuccess, onPropertyFaild);
+ }
+ };
+
+ this.$scope.getPrev = ():void=> {
+ this.property = this.filteredProperties[--this.$scope.currentPropertyIndex];
+ this.initResource();
+ this.initForNotSimpleType();
+ this.$scope.isLastProperty = false;
+ };
+
+ this.$scope.getNext = ():void=> {
+ this.property = this.filteredProperties[++this.$scope.currentPropertyIndex];
+ this.initResource();
+ this.initForNotSimpleType();
+ this.$scope.isLastProperty = this.$scope.currentPropertyIndex == (this.filteredProperties.length - 1);
+ };
+
+ this.$scope.isSimpleType = (typeName:string):boolean=> {
+ return typeName && this.$scope.editPropertyModel.simpleTypes.indexOf(typeName) != -1;
+ };
+
+ this.$scope.showSchema = ():boolean => {
+ return [PROPERTY_TYPES.LIST, PROPERTY_TYPES.MAP].indexOf(this.$scope.editPropertyModel.property.type) > -1;
+ };
+
+ this.$scope.getValidationPattern = (type:string):RegExp => {
+ return this.ValidationUtils.getValidationPattern(type);
+ };
+
+ this.$scope.validateIntRange = (value:string):boolean => {
+ return !value || this.ValidationUtils.validateIntRange(value);
+ };
+
+ this.$scope.close = ():void => {
+ this.$uibModalInstance.close();
+ };
+
+ // put default value when instance value is empty
+ this.$scope.onValueChange = ():void => {
+ if (!this.$scope.editPropertyModel.property.value) {
+ if (this.$scope.isPropertyValueOwner) {
+ this.$scope.editPropertyModel.property.value = this.$scope.editPropertyModel.property.defaultValue;
+ }
+ }
+ };
+
+ // Add the done button at the footer.
+ this.$scope.footerButtons = [
+ {'name': 'Save', 'css': 'blue', 'callback': this.$scope.save},
+ {'name': 'Cancel', 'css': 'grey', 'callback': this.$scope.close}
+ ];
+
+ this.$scope.$watch("forms.editForm.$invalid", (newVal, oldVal) => {
+ this.$scope.footerButtons[0].disabled = this.$scope.forms.editForm.$invalid;
+ });
+
+ this.$scope.getDefaultValue = ():any => {
+ return this.$scope.isPropertyValueOwner ? this.$scope.editPropertyModel.property.defaultValue : null;
+ };
+
+ this.$scope.onTypeChange = ():void => {
+ this.$scope.editPropertyModel.property.value = '';
+ this.$scope.editPropertyModel.property.defaultValue = '';
+ this.setMaxLength();
+ this.initForNotSimpleType();
+ };
+
+ this.$scope.onSchemaTypeChange = ():void => {
+ if (this.$scope.editPropertyModel.property.type == PROPERTY_TYPES.MAP) {
+ this.$scope.myValue = {'': null};
+ } else if (this.$scope.editPropertyModel.property.type == PROPERTY_TYPES.LIST) {
+ this.$scope.myValue = [];
+ }
+ this.setMaxLength();
+ };
+
+ this.$scope.delete = (property:PropertyModel):void => {
+ let onOk = ():void => {
+ this.component.deleteProperty(property.uniqueId).then(
+ this.$scope.close
+ );
+ };
+ let title:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TITLE");
+ let message:string = this.$filter('translate')("PROPERTY_VIEW_DELETE_MODAL_TEXT", "{'name': '" + property.name + "'}");
+ this.ModalsHandler.openConfirmationModal(title, message, false).then(onOk);
+ };
+ }
+}
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html
new file mode 100644
index 0000000000..f92d9a5ddc
--- /dev/null
+++ b/catalog-ui/src/app/view-models/forms/property-forms/component-property-form/property-form-view.html
@@ -0,0 +1,201 @@
+<sdc-modal modal="modalInstanceProperty" type="classic" class="sdc-edit-property-container" buttons="footerButtons" header="{{isNew ? 'Add' : 'Update' }} Property" show-close-button="true" data-tests-id="sdc-edit-property-container">
+ <loader data-display="isLoading" relative="false" size="medium"></loader>
+ <div class="sdc-modal-top-bar" data-ng-if="!isNew">
+ <div class="sdc-modal-top-bar-buttons">
+ <span ng-click="delete(editPropertyModel.property)" data-ng-class="{'disabled' : isPropertyValueOwner || editPropertyModel.property.readonly}" class="sprite-new delete-btn" data-tests-id="delete_property" sdc-smart-tooltip="">Delete</span>
+ <span class="delimiter"></span>
+ <span data-ng-click="getPrev()" data-ng-class="{'disabled' : !currentPropertyIndex }" class="sprite-new left-arrow" data-tests-id="get-prev" sdc-smart-tooltip="">Previous</span>
+ <span data-ng-click="getNext()" data-ng-class="{'disabled' : isLastProperty }" class="sprite-new right-arrow" data-tests-id="get-next" sdc-smart-tooltip="">Next</span>
+ </div>
+ </div>
+
+ <div class="sdc-edit-property-form-container" >
+ <perfect-scrollbar scroll-y-margin-offset="0" include-padding="true" class="scrollbar-container">
+ <form novalidate class="w-sdc-form two-columns" name="forms.editForm" >
+
+ <div class="w-sdc-form-columns-wrapper">
+
+ <div class="w-sdc-form-column">
+
+ <!-- Name -->
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid)}">
+ <label class="i-sdc-form-label" ng-class="{'required': !isService}">Name</label>
+ <input class="i-sdc-form-input"
+ data-tests-id="propertyName"
+ data-ng-maxlength="50"
+ data-ng-disabled="!isNew || editPropertyModel.property.readonly"
+ maxlength="50"
+ data-ng-model="editPropertyModel.property.name"
+ type="text"
+ name="propertyName"
+ data-ng-pattern="propertyNameValidationPattern"
+ data-required
+ data-ng-model-options="{ debounce: 200 }"
+ autofocus />
+
+ <div class="input-error" data-ng-show="forms.editForm.propertyName.$dirty && forms.editForm.propertyName.$invalid">
+ <span ng-show="forms.editForm.propertyName.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property name' }"></span>
+ <span ng-show="forms.editForm.propertyName.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '50' }"></span>
+ <span ng-show="forms.editForm.propertyName.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span>
+ </div>
+ </div>
+ </div>
+
+ <div class="w-sdc-form-column">
+ <div class="w-sdc-form-columns-wrapper">
+ <div class="w-sdc-form-column">
+ <!-- Type -->
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.type.$dirty && forms.editForm.type.$invalid)}">
+ <label class="i-sdc-form-label" ng-class="{'required': !isService}">Type</label>
+ <select class="i-sdc-form-select"
+ data-tests-id="propertyType"
+ data-required
+ data-ng-disabled="isPropertyValueOwner || editPropertyModel.property.readonly"
+ name="type"
+ data-ng-change="onTypeChange()"
+ data-ng-model="editPropertyModel.property.type">
+ <option value="">Choose Type</option>
+ <option data-ng-repeat="type in editPropertyModel.types"
+ value="{{type}}">{{type}}</option>
+ <option data-ng-repeat="type in nonPrimitiveTypes"
+ value="{{type}}">{{type.replace("org.openecomp.datatypes.heat.","")}}</option>
+ </select>
+
+ <div class="input-error" data-ng-show="forms.editForm.type.$dirty && forms.editForm.type.$invalid">
+ <span ng-show="forms.editForm.type.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Type' }"></span>
+ </div>
+ </div>
+ </div>
+ <div class="w-sdc-form-column" data-ng-if="showSchema()">
+ <!-- Entry Schema -->
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.schemaType.$dirty && forms.editForm.schemaType.$invalid)}">
+ <label class="i-sdc-form-label required">Entry Schema</label>
+ <select class="i-sdc-form-select"
+ data-required
+ data-tests-id="schema-type"
+ data-ng-disabled="isPropertyValueOwner || editPropertyModel.property.readonly"
+ name="schemaType"
+ data-ng-change="onSchemaTypeChange()"
+ data-ng-model="editPropertyModel.property.schema.property.type">
+ <option value="">Choose Schema Type</option>
+ <option data-ng-repeat="type in editPropertyModel.simpleTypes"
+ value="{{type}}">{{type}}</option>
+ <option data-ng-repeat="type in nonPrimitiveTypes"
+ value="{{type}}">{{type.replace("org.openecomp.datatypes.heat.","")}}</option>
+ </select>
+
+ <div class="input-error" data-ng-show="forms.editForm.schemaType.$dirty && forms.editForm.schemaType.$invalid">
+ <span ng-show="forms.editForm.schemaType.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Entry schema' }"></span>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <!-- Constraints by type -->
+ <div class="i-sdc-form-item" data-ng-if="false">
+ <label class="i-sdc-form-label required">Constraints by type</label>
+ <div>
+ Should be constraints by type(TBD)
+ </div>
+ </div>
+
+ </div>
+
+ </div>
+ <!-- Description -->
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.description.$dirty && forms.editForm.description.$invalid)}">
+ <label class="i-sdc-form-label">Description</label>
+ <textarea class="i-sdc-form-textarea"
+ data-ng-maxlength="400"
+ data-ng-disabled="isPropertyValueOwner || editPropertyModel.property.readonly"
+ maxlength="400"
+ data-ng-pattern="commentValidationPattern"
+ name="description"
+ data-ng-model="editPropertyModel.property.description"
+ data-ng-model-options="{ debounce: 200 }"
+ data-tests-id="description"
+ ></textarea>
+
+ <div class="input-error" data-ng-show="forms.editForm.description.$dirty && forms.editForm.description.$invalid">
+ <span ng-show="forms.editForm.description.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '256' }"></span>
+ <span ng-show="forms.editForm.description.$error.pattern" translate="VALIDATION_ERROR_SPECIAL_CHARS_NOT_ALLOWED"></span>
+ <span ng-show="forms.editForm.description.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Description' }"></span>
+ </div>
+ </div>
+ <!-- Default value -->
+
+ <div class="default-value-section i-sdc-form-item">
+ <label class="i-sdc-form-label">Default Value</label>
+ <div data-ng-if="isTypeDataType">
+ <fields-structure value-obj-ref="myValue"
+ type-name="editPropertyModel.property.type"
+ parent-form-obj="forms.editForm"
+ fields-prefix-name="currentPropertyIndex"
+ read-only="editPropertyModel.property.readonly && !isPropertyValueOwner"
+ default-value="{{getDefaultValue()}}"
+ expand-by-default="true"></fields-structure>
+
+ </div>
+ <div data-ng-if="!isTypeDataType" ng-switch="editPropertyModel.property.type">
+ <div ng-switch-when="map">
+ <type-map value-obj-ref="myValue"
+ schema-property="editPropertyModel.property.schema.property"
+ parent-form-obj="forms.editForm"
+ fields-prefix-name="currentPropertyIndex"
+ read-only="editPropertyModel.property.readonly && !isPropertyValueOwner"
+ default-value="{{getDefaultValue()}}"
+ max-length="maxLength"></type-map>
+ </div>
+ <div ng-switch-when="list">
+ <type-list value-obj-ref="myValue"
+ schema-property="editPropertyModel.property.schema.property"
+ parent-form-obj="forms.editForm"
+ fields-prefix-name="currentPropertyIndex"
+ read-only="editPropertyModel.property.readonly && !isPropertyValueOwner"
+ default-value="{{getDefaultValue()}}"
+ max-length="maxLength"></type-list>
+ </div>
+ <div ng-switch-default>
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid), 'input-group' : editPropertyModel.property.addOn}">
+ <span ng-if="editPropertyModel.property.addOn" class="input-group-addon">{{editPropertyModel.property.addOn}}</span>
+ <input class="i-sdc-form-input"
+ data-tests-id="defaultvalue"
+ ng-if="!((editPropertyModel.property.simpleType||editPropertyModel.property.type) == 'boolean')"
+ data-ng-maxlength="maxLength"
+ data-ng-disabled="editPropertyModel.property.readonly && !isPropertyValueOwner"
+ maxlength="{{maxLength}}"
+ data-ng-model="editPropertyModel.property.value"
+ type="text"
+ name="value"
+ data-ng-pattern="getValidationPattern((editPropertyModel.property.simpleType||editPropertyModel.property.type))"
+ data-ng-model-options="{ debounce: 200 }"
+ data-ng-change="('json'==editPropertyModel.property.type && forms.editForm.value.$setValidity('pattern', validateJson(editPropertyModel.property.value)))
+ ||(!forms.editForm.value.$error.pattern && ('integer'==editPropertyModel.property.type && forms.editForm.value.$setValidity('pattern', validateIntRange(editPropertyModel.property.value)) || onValueChange()))"
+ data-ng-change=""
+ autofocus />
+ <select class="i-sdc-form-select"
+ data-tests-id="booleantype"
+ ng-if="(editPropertyModel.property.simpleType||editPropertyModel.property.type) == 'boolean'"
+ data-ng-disabled="editPropertyModel.property.readonly && !isPropertyValueOwner"
+ name="value"
+ data-ng-change="onValueChange()"
+ data-ng-model="editPropertyModel.property.value">
+ <option value="true">true</option>
+ <option value="false">false</option>
+ </select>
+
+ <div class="input-error" data-ng-show="forms.editForm.value.$dirty && forms.editForm.value.$invalid">
+ <span ng-show="forms.editForm.value.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property' }"></span>
+ <span ng-show="forms.editForm.value.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '{{maxLength}}' }"></span>
+ <span ng-show="forms.editForm.value.$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ <span class="w-sdc-form-note" data-ng-show="forms.editForm.$invalid && false" translate="LABEL_ALL_FIELDS_ARE_MANDATORY"></span>
+ </form>
+ </perfect-scrollbar>
+ </div>
+
+</sdc-modal>
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-model.ts
new file mode 100644
index 0000000000..7359ac0e91
--- /dev/null
+++ b/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-model.ts
@@ -0,0 +1,206 @@
+/**
+ * Created by obarda on 1/18/2017.
+ */
+'use strict';
+import {PropertyModel, DisplayModule, Component, Resource, Service, ComponentInstance} from "app/models";
+import {UNIQUE_GROUP_PROPERTIES_NAME} from "app/utils";
+import {IPropertyFormBaseViewScope, PropertyFormBaseView} from "../base-property-form/property-form-base-model";
+import {DataTypesService} from "app/services/data-types-service";
+
+export interface IModulePropertyViewScope extends IPropertyFormBaseViewScope {
+ onValueChange():void;
+}
+
+export class ModulePropertyView extends PropertyFormBaseView {
+
+ static '$inject' = [
+ '$scope',
+ '$templateCache',
+ '$uibModalInstance',
+ '$injector',
+ 'originalProperty',
+ 'component',
+ 'selectedModule',
+ 'Sdc.Services.DataTypesService',
+ '$q'
+ ];
+
+ constructor(protected $scope:IModulePropertyViewScope,
+ protected $templateCache:ng.ITemplateCacheService,
+ protected $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance,
+ protected $injector:ng.auto.IInjectorService,
+ protected originalProperty:PropertyModel,
+ protected component:Component,
+ private selectedModule:DisplayModule,
+ protected DataTypesService:DataTypesService,
+ private $q:ng.IQService) {
+ super($scope, $uibModalInstance, $injector, originalProperty, component, selectedModule.properties, DataTypesService);
+
+ this.$templateCache.put("module-property-view.html", require('app/view-models/forms/property-forms/module-property-modal/module-property-view.html'));
+ this.$scope.innerViewSrcUrl = "module-property-view.html";
+ this.initChildScope();
+ }
+
+ private findPropertyByName = (propertyName:string):PropertyModel => {
+ let property:PropertyModel = _.find(this.filteredProperties, (property:PropertyModel) => {
+ return property.name === propertyName;
+ });
+ return property;
+ };
+
+ save(isNeedToCloseModal):ng.IPromise<boolean> {
+
+ let deferred = this.$q.defer();
+
+ let onSuccess = (properties:Array<PropertyModel>):void => {
+ deferred.resolve(true);
+ if (isNeedToCloseModal === true) {
+ this.$scope.close();
+ }
+ };
+
+ let onFailed = ():void => {
+ deferred.resolve(false);
+ };
+
+ let property = _.find(this.selectedModule.properties, (property) => {
+ return property.uniqueId === this.$scope.property.uniqueId;
+ });
+ if (property.value !== this.$scope.property.value) {
+ if (this.component.isResource()) {
+ (<Resource>this.component).updateResourceGroupProperties(this.selectedModule, [this.$scope.property]).then(onSuccess, onFailed); // for now we only update one property at a time
+ }
+ if (this.component.isService()) {
+ // Find the component instance of the group instance
+ let componentInstance:ComponentInstance = _.find(this.component.componentInstances, (componentInstance:ComponentInstance) => {
+ let groupInstance = _.find(componentInstance.groupInstances, {uniqueId: this.selectedModule.groupInstanceUniqueId});
+ return groupInstance !== undefined;
+
+ });
+ (<Service>this.component).updateGroupInstanceProperties(componentInstance.uniqueId, this.selectedModule, [this.$scope.property]).then(onSuccess, onFailed); // for now we only update one property at a time
+ }
+ } else {
+ deferred.resolve(true);
+ }
+ return deferred.promise;
+ }
+
+ onPropertyChange():void {
+ this.initValidation();
+ }
+
+ protected initValidation = ():void => {
+
+ this.$scope.isDeleteDisable = true;
+ this.$scope.isNameDisable = true;
+ this.$scope.isTypeSelectorDisable = true;
+ this.$scope.isDescriptionDisable = true;
+
+ switch (this.$scope.property.name) {
+ case UNIQUE_GROUP_PROPERTIES_NAME.IS_BASE:
+ case UNIQUE_GROUP_PROPERTIES_NAME.VF_MODULE_TYPE:
+ case UNIQUE_GROUP_PROPERTIES_NAME.VOLUME_GROUP:
+ case UNIQUE_GROUP_PROPERTIES_NAME.VF_MODULE_LABEL:
+ this.$scope.property.readonly = true;
+ break;
+ case UNIQUE_GROUP_PROPERTIES_NAME.VF_MODULE_DESCRIPTION:
+ if (this.component.isService()) {
+ this.$scope.property.readonly = true;
+ } else {
+ this.$scope.property.readonly = false;
+ }
+ break;
+ }
+ };
+
+ private isUniqueProperty = ():boolean => {
+ return this.$scope.property.name === UNIQUE_GROUP_PROPERTIES_NAME.MIN_VF_MODULE_INSTANCES ||
+ this.$scope.property.name === UNIQUE_GROUP_PROPERTIES_NAME.MAX_VF_MODULE_INSTANCES ||
+ this.$scope.property.name === UNIQUE_GROUP_PROPERTIES_NAME.INITIAL_COUNT;
+ };
+
+
+ private initChildScope = ():void => {
+
+ this.initValidation();
+
+ // put default value when instance value is empty
+ this.$scope.onValueChange = ():void => {
+
+ if (!this.$scope.property.value) { // Resetting to default value
+ if (this.isPropertyValueOwner()) {
+ if (this.component.isService()) {
+ this.$scope.property.value = this.$scope.property.parentValue;
+ } else {
+ this.$scope.property.value = this.$scope.property.defaultValue;
+ }
+ }
+ }
+
+ if (this.isUniqueProperty()) {
+
+ let isValid = true;
+ let maxProperty:PropertyModel = this.findPropertyByName(UNIQUE_GROUP_PROPERTIES_NAME.MAX_VF_MODULE_INSTANCES);
+ let minProperty:PropertyModel = this.findPropertyByName(UNIQUE_GROUP_PROPERTIES_NAME.MIN_VF_MODULE_INSTANCES);
+ let initialCountProperty:PropertyModel = this.findPropertyByName(UNIQUE_GROUP_PROPERTIES_NAME.INITIAL_COUNT);
+
+ let maxPropertyValue = parseInt(maxProperty.value);
+ let minPropertyValue = parseInt(minProperty.value);
+ let initialCountPropertyValue = parseInt(initialCountProperty.value);
+ let propertyValue = parseInt(this.$scope.property.value);
+ let parentPropertyValue = parseInt(this.$scope.property.parentValue);
+
+ switch (this.$scope.property.name) {
+
+ case UNIQUE_GROUP_PROPERTIES_NAME.MIN_VF_MODULE_INSTANCES:
+ if (!maxPropertyValue || maxPropertyValue === null) {
+ isValid = propertyValue <= initialCountPropertyValue;
+ }
+ else {
+ isValid = propertyValue && (propertyValue <= maxPropertyValue && propertyValue <= initialCountPropertyValue);
+ }
+ this.$scope.forms.editForm["value"].$setValidity('maxValidation', isValid);
+ if (this.component.isService()) {
+ if (!parentPropertyValue || parentPropertyValue === null) {
+ isValid = true;
+ } else {
+ isValid = propertyValue >= parentPropertyValue;
+ this.$scope.forms.editForm["value"].$setValidity('minValidationVfLevel', isValid);
+ }
+ }
+ break;
+ case UNIQUE_GROUP_PROPERTIES_NAME.MAX_VF_MODULE_INSTANCES:
+ if (!minPropertyValue || minPropertyValue === null) {
+ isValid = propertyValue >= initialCountPropertyValue;
+ } else {
+ isValid = !propertyValue || (propertyValue >= minPropertyValue && propertyValue >= initialCountPropertyValue);
+ }
+ this.$scope.forms.editForm["value"].$setValidity('minValidation', isValid);
+ if (this.component.isService()) {
+ if (!parentPropertyValue || parentPropertyValue === null) {
+ isValid = true;
+ }
+ else {
+ isValid = propertyValue <= parentPropertyValue;
+ this.$scope.forms.editForm["value"].$setValidity('maxValidationVfLevel', isValid);
+ }
+ }
+ break;
+ case UNIQUE_GROUP_PROPERTIES_NAME.INITIAL_COUNT:
+ if ((!minPropertyValue || minPropertyValue === null) && (!maxPropertyValue || maxPropertyValue === null)) {
+ isValid = true;
+ } else if (!minPropertyValue || minPropertyValue === null) {
+ isValid = propertyValue <= maxPropertyValue;
+ } else if (!maxPropertyValue || maxPropertyValue === null) {
+ isValid = propertyValue >= minPropertyValue;
+ } else {
+ isValid = minPropertyValue <= propertyValue && propertyValue <= maxPropertyValue;
+ }
+ this.$scope.forms.editForm["value"].$setValidity('minOrMaxValidation', isValid);
+ break;
+ }
+ }
+ ;
+ }
+ }
+}
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-view.html b/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-view.html
new file mode 100644
index 0000000000..175f4c199b
--- /dev/null
+++ b/catalog-ui/src/app/view-models/forms/property-forms/module-property-modal/module-property-view.html
@@ -0,0 +1,41 @@
+<div class="default-value-section i-sdc-form-item">
+ <label class="i-sdc-form-label">Default Value</label>
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid)}">
+ <input class="i-sdc-form-input"
+ data-tests-id="defaultvalue"
+ ng-if="!((property.simpleType||property.type) == 'boolean')"
+ data-ng-maxlength="maxLength"
+ data-ng-disabled="property.readonly && !isPropertyValueOwner()"
+ maxlength="100"
+ data-ng-model="property.value"
+ type="text"
+ name="value"
+ data-ng-pattern="getValidationPattern(property.type)"
+ data-ng-model-options="{ debounce: 200 }"
+ data-ng-change="onValueChange()"
+ />
+ <select class="i-sdc-form-select"
+ data-tests-id="booleantype"
+ ng-if="(property.simpleType||property.type) == 'boolean'"
+ data-ng-disabled="property.readonly && !isPropertyValueOwner()"
+ name="value"
+ data-ng-model="property.value">
+ <option value="true">true</option>
+ <option value="false">false</option>
+ </select>
+
+ <div class="input-error" data-ng-show="forms.editForm.value.$dirty && forms.editForm.value.$invalid">
+ <span ng-show="forms.editForm.value.$error.required" translate="VALIDATION_ERROR_REQUIRED"
+ translate-values="{'field': 'Property' }"></span>
+ <span ng-show="forms.editForm.value.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH"
+ translate-values="{'max': '{{maxLength}}' }"></span>
+ <span ng-show="forms.editForm.value.$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span>
+ <span ng-show="forms.editForm.value.$error.minValidation" translate="MIN_VALIDATION_ERROR"></span>
+ <span ng-show="forms.editForm.value.$error.maxValidation" translate="MAX_VALIDATION_ERROR"></span>
+ <span ng-show="forms.editForm.value.$error.minOrMaxValidation" translate="MIN_MAX_VALIDATION"></span>
+ <span ng-show="forms.editForm.value.$error.minValidationVfLevel" translate="MIN_VALIDATION_VF_LEVE_ERROR"></span>
+ <span ng-show="forms.editForm.value.$error.maxValidationVfLevel" translate="MAX_VALIDATION_VF_LEVE_ERROR"></span>
+
+ </div>
+ </div>
+</div>
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts
new file mode 100644
index 0000000000..48aa47fdd0
--- /dev/null
+++ b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view-model.ts
@@ -0,0 +1,97 @@
+'use strict';
+import {DataTypesService} from "app/services/data-types-service";
+import {PropertyModel, InputPropertyBase, Component} from "app/models";
+import {IPropertyFormBaseViewScope, PropertyFormBaseView} from "../base-property-form/property-form-base-model";
+import {PROPERTY_TYPES} from "app/utils/constants";
+
+interface ISelectDataTypeViewModelScope extends IPropertyFormBaseViewScope {
+ selectedPropertiesName:string;
+ dataTypesService:DataTypesService;
+ path:string;
+ isTypeDataType:boolean;
+ myValue:any;
+ isReadOnly:boolean;
+}
+
+export class SelectDataTypeViewModel extends PropertyFormBaseView {
+
+ static '$inject' = [
+ '$scope',
+ '$templateCache',
+ '$uibModalInstance',
+ '$injector',
+ 'originalProperty',
+ 'component',
+ 'filteredProperties',
+ 'Sdc.Services.DataTypesService',
+ 'propertiesMap',
+ '$q'
+ ];
+
+ constructor(protected $scope:ISelectDataTypeViewModelScope,
+ protected $templateCache:ng.ITemplateCacheService,
+ protected $uibModalInstance:ng.ui.bootstrap.IModalServiceInstance,
+ protected $injector:ng.auto.IInjectorService,
+ protected originalProperty:PropertyModel,
+ protected component:Component,
+ protected filteredProperties:Array<PropertyModel>,
+ protected DataTypesService:DataTypesService,
+ private propertiesMap:Array<InputPropertyBase>,
+ private $q:ng.IQService) {
+ super($scope, $uibModalInstance, $injector, originalProperty, component, filteredProperties, DataTypesService);
+
+ this.$templateCache.put("select-datatype-modal-view.html", require('app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html'));
+ this.$scope.innerViewSrcUrl = "select-datatype-modal-view.html";
+ this.initChildScope();
+ }
+
+ //scope methods
+ save(isNeedToCloseModal):ng.IPromise<boolean> {
+ let deferred = this.$q.defer();
+ this.$scope.property.propertiesName = this.DataTypesService.selectedPropertiesName;
+ this.$scope.property.input = this.DataTypesService.selectedInput;
+ this.$scope.property.isAlreadySelected = true;
+ this.$uibModalInstance.close(this.$scope.property);
+ deferred.resolve(true);
+ return deferred.promise;
+ };
+
+ private initForNotSimpleType = ():void => {
+ let property = this.$scope.property;
+ this.$scope.isTypeDataType = this.DataTypesService.isDataTypeForPropertyType(this.$scope.property);
+ if (property.type && this.$scope.simpleTypes.indexOf(property.type) == -1) {
+ if (!(property.value || property.defaultValue)) {
+ switch (property.type) {
+ case PROPERTY_TYPES.MAP:
+ this.$scope.myValue = {'': null};
+ break;
+ case PROPERTY_TYPES.LIST:
+ this.$scope.myValue = [];
+ break;
+ default:
+ this.$scope.myValue = {};
+ }
+ } else {
+ this.$scope.myValue = JSON.parse(property.value || property.defaultValue);
+ }
+ }
+ };
+
+ //remove selection property on the modal
+ private removeSelected = ():void => {
+ this.DataTypesService.selectedPropertiesName = null;
+ this.DataTypesService.selectedInput = null;
+ };
+
+ private initChildScope = ():void => {
+ //scope properties
+ this.$scope.forms = {};
+ this.$scope.path = this.$scope.property.name;
+ this.$scope.isArrowsDisabled = true;
+ this.DataTypesService.alreadySelectedProperties = this.propertiesMap;
+ this.$scope.dataTypesService = this.DataTypesService;
+ this.$scope.isReadOnly = true;
+ this.initForNotSimpleType();
+ this.removeSelected();
+ }
+}
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html
new file mode 100644
index 0000000000..acb0f292ff
--- /dev/null
+++ b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal-view.html
@@ -0,0 +1,74 @@
+<!--<div>selectedPropertiesName - {{dataTypesService.selectedPropertiesName}}</div>-->
+<!--<div>selectedInput - {{dataTypesService.selectedInput}}</div>-->
+
+<div data-ng-if="dataTypes" class="default-value-section i-sdc-form-item">
+ <label class="i-sdc-form-label">Default Value</label>
+ <div data-ng-if="isTypeDataType">
+ <select-fields-structure value-obj-ref="myValue"
+ type-name="property.type"
+ parent-form-obj="forms.editForm"
+ fields-prefix-name="currentPropertyIndex"
+ read-only="true"
+ default-value="{{getDefaultValue()}}"
+ path="{{property.name}}"
+ is-parent-already-input="false"
+ expand-by-default="true"></select-fields-structure>
+
+ </div>
+ <div data-ng-if="!isTypeDataType" ng-switch="property.type">
+ <div ng-switch-when="map">
+
+ <select-type-map value-obj-ref="myValue"
+ schema-property="property.schema.property"
+ parent-form-obj="forms.editForm"
+ fields-prefix-name="currentPropertyIndex"
+ read-only="true"
+ default-value="{{getDefaultValue()}}"
+ max-length="maxLength"></select-type-map>
+ </div>
+ <div ng-switch-when="list">
+ <select-type-list value-obj-ref="myValue"
+ schema-property="property.schema.property"
+ parent-form-obj="forms.editForm"
+ fields-prefix-name="currentPropertyIndex"
+ read-only="true"
+ default-value="{{getDefaultValue()}}"
+ max-length="maxLength"></select-type-list>
+ </div>
+ <div ng-switch-default>
+ <div class="i-sdc-form-item" data-ng-class="{error:(forms.editForm.value.$dirty && forms.editForm.value.$invalid)}">
+ <input class="i-sdc-form-input"
+ data-tests-id="defaultvalue"
+ ng-if="!((property.simpleType||property.type) == 'boolean')"
+ data-ng-maxlength="maxLength"
+ data-ng-disabled="isReadOnly"
+ maxlength="{{maxLength}}"
+ data-ng-model="property.value"
+ type="text"
+ name="value"
+ data-ng-pattern="getValidationPattern((property.simpleType||property.type))"
+ data-ng-model-options="{ debounce: 200 }"
+ data-ng-change="('json'==property.type && forms.editForm.value.$setValidity('pattern', validateJson(property.value)))
+ ||(!forms.editForm.value.$error.pattern && ('integer'==property.type && forms.editForm.value.$setValidity('pattern', validateIntRange(property.value)) || onValueChange()))"
+ data-ng-change=""
+ autofocus />
+ <select class="i-sdc-form-select"
+ data-tests-id="booleantype"
+ ng-if="(property.simpleType||property.type) == 'boolean'"
+ data-ng-disabled="isReadOnly"
+ name="value"
+ data-ng-change="onValueChange()"
+ data-ng-model="property.value">
+ <option value="true">true</option>
+ <option value="false">false</option>
+ </select>
+
+ <div class="input-error" data-ng-show="forms.editForm.value.$dirty && forms.editForm.value.$invalid">
+ <span ng-show="forms.editForm.value.$error.required" translate="VALIDATION_ERROR_REQUIRED" translate-values="{'field': 'Property' }"></span>
+ <span ng-show="forms.editForm.value.$error.maxlength" translate="VALIDATION_ERROR_MAX_LENGTH" translate-values="{'max': '{{maxLength}}' }"></span>
+ <span ng-show="forms.editForm.value.$error.pattern" translate="PROPERTY_EDIT_PATTERN"></span>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
diff --git a/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal.less b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal.less
new file mode 100644
index 0000000000..15e30af4ee
--- /dev/null
+++ b/catalog-ui/src/app/view-models/forms/property-forms/select-datatype-modal/select-datatype-modal.less
@@ -0,0 +1,63 @@
+.sdc-edit-property-container {
+ .scrollbar-container{
+ height: 415px;
+ width: 830px;
+ .perfect-scrollbar;
+ }
+
+ form{
+ width: 813px;
+ [name="description"]{
+ min-height:50px;
+ }
+ }
+
+ .sdc-modal-top-bar{
+ height: 40px;
+ .sdc-modal-top-bar-buttons {
+ float: right;
+
+ > span:not(.delimiter){
+ vertical-align: middle;
+ .hand;
+
+ &.sprite-new {
+ text-indent: 100%;
+ }
+ &.disabled, &:hover.disabled {
+ pointer-events: none;
+ }
+ }
+
+ .delete-btn{
+ margin-right: 6px;
+ }
+
+ .left-arrow{
+ margin-right: 8px;
+ }
+
+ .delimiter {
+ height: 20px;
+ width: 1px;
+ background-color: #959595;
+ display: inline-block;
+ vertical-align: middle;
+ margin-right: 10px;
+ }
+ }
+ }
+
+ .w-sdc-form-note {
+ .h_9;
+ display: block;
+ position: relative;
+ top: 13px;
+ }
+
+ .default-value-section{
+ border-top: solid 1px @main_color_a;
+ padding-top: 15px;
+ margin-top: 15px;
+ }
+}