X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=skyquake%2Fplugins%2Fcomposer%2Fsrc%2Fsrc%2Flibraries%2Fmodel%2FDescriptorModelMetaProperty.js;h=89d1fe9dca8eced78ad9eb8561e16d9eb14f61f1;hb=d3b3a1c5d521361bfa40dbdec779495eb2bfd8a0;hp=67f34e29bdc889e8d14d7f221d94f393a8da528b;hpb=8a726817e3e9acdaaa8e669bcea0e3eb56ba1372;p=osm%2FUI.git diff --git a/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelMetaProperty.js b/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelMetaProperty.js index 67f34e29b..89d1fe9dc 100644 --- a/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelMetaProperty.js +++ b/skyquake/plugins/composer/src/src/libraries/model/DescriptorModelMetaProperty.js @@ -29,6 +29,7 @@ import changeCase from 'change-case' import InstanceCounter from './../InstanceCounter' import DescriptorModelFields from './DescriptorModelFields' import DescriptorTemplateFactory from './DescriptorTemplateFactory' +import utils from '../utils' export default { isLeaf(property = {}) { @@ -40,6 +41,10 @@ export default { isLeafList(property = {}) { return property.type === 'leaf_list'; }, + isLeafRef(property = {}) { + const type = property['data-type'] || {}; + return type.hasOwnProperty('leafref'); + }, isArray(property = {}) { // give '1' or '0..N' or '0..1' or '0..5' determine if represents an array // '0..1' is not an array @@ -61,7 +66,7 @@ export default { return !/^(leaf|leaf_list)$/.test(property.type); }, isSimpleList(property = {}) { - return _.contains(DescriptorModelFields.simpleList, property.name); + return _.includes(DescriptorModelFields.simpleList, property.name); }, isPrimativeDataType(property = {}) { const Property = this; @@ -107,6 +112,30 @@ export default { return {name: enumName, value: enumValue, isSelected: String(enumValue) === String(value)}; }); }, + getLeafRef(property = {}, path, value, fullFieldKey, transientCatalogs, container) { + const leafRefPath = property['data-type']['leafref']['path']; + + const transientCatalogHash = {}; + + transientCatalogs.map((catalog) => { + transientCatalogHash[catalog.type + '-catalog'] = {}; + transientCatalogHash[catalog.type + '-catalog'][catalog.type] = catalog['descriptors']; + }); + + let leafRefPathValues = utils.resolveLeafRefPath(transientCatalogHash, leafRefPath, fullFieldKey, path, container); + + let leafRefObjects = []; + + leafRefPathValues && leafRefPathValues.map((leafRefPathValue) => { + leafRefObjects.push({ + name: leafRefPathValue, + value: leafRefPathValue, + isSelected: String(leafRefPathValue) === String(value) + }); + }); + + return leafRefObjects; + }, isGuid(property = {}) { const type = property['data-type']; if (typeof type === 'object' && type.leafref && type.leafref.path) { @@ -123,7 +152,7 @@ export default { if (uiState.name === 'name') { return changeCase.param(parentMeta.name) + '-' + InstanceCounter.count(parentMeta[':qualified-type']); } - if (_.isArray(parentMeta.key) && _.contains(parentMeta.key, uiState.name)) { + if (_.isArray(parentMeta.key) && _.includes(parentMeta.key, uiState.name)) { if (/uuid/.test(uiState['data-type'])) { return guid(); }