Yangman - precheck patharray, fix modal z-index and so on
[dlux.git] / modules / common-yangutils-resources / src / main / resources / yangutils / services / path-utils.services.js
index 90a11e40b52805a75c9267728f6a31c34b4131d6..4902ca9585f31305253120fc603b58d70137fbc9 100644 (file)
@@ -5,6 +5,7 @@ define([], function () {
 
         var service = {
                 clearPath: clearPath,
+                checkEmptyIdentifiers: checkEmptyIdentifiers,
                 createPathElement: createPathElement,
                 getModuleNameFromPath: getModuleNameFromPath,
                 getStorageAndNormalizedPath: getStorageAndNormalizedPath,
@@ -53,7 +54,15 @@ define([], function () {
             }
         }
 
-        // TODO: add service's description
+        /**
+         * Translate path url into path elements array
+         * @param path
+         * @param prefixConverter
+         * @param importNodes
+         * @param getDefaultModuleCallback
+         * @param notIdentifiers
+         * @returns {Array}
+         */
         function translate(path, prefixConverter, importNodes, getDefaultModuleCallback, notIdentifiers) {
             var pathStrElements = path.split('/').filter(function (e) {
                     return e !== '';
@@ -125,6 +134,17 @@ define([], function () {
             });
         }
 
+        /**
+         * Check if in path elements array is empty identifier
+         * @param pathArray
+         * @returns {*}
+         */
+        function checkEmptyIdentifiers(pathArray){
+            return pathArray.some(function (item) {
+                return item.hasEmptyIdentifier();
+            });
+        }
+
         /**
          * Service for filling API url object from url string data
          * @param pathArrayIn
@@ -209,7 +229,12 @@ define([], function () {
             return retObj;
         }
 
-        // TODO: add service's description
+        /**
+         * Fill path element's identifiers
+         * @param identifiers
+         * @param label
+         * @param value
+         */
         function fillIdentifiers(identifiers, label, value) {
             identifiers.some(function (i) {
                 var identifierMatch = i.label === label;
@@ -327,6 +352,12 @@ define([], function () {
                 });
             };
 
+            this.hasEmptyIdentifier = function () {
+                return this.identifiers.some(function (item) {
+                    return item.value.length === 0;
+                });
+            };
+
             this.toString = function () {
                 return (this.module ? this.module + ':' : '') + this.name + '/' + (this.hasIdentifier() ?
                                                                     this.getIdentifierValues().join('/') + '/' : '');