Переглянути джерело

Merge remote-tracking branch 'origin/master'

zlSun 1 рік тому
батько
коміт
750b1bf703
1 змінених файлів з 31 додано та 30 видалено
  1. 31 30
      atlas/js/utils/CommonViewFunction.js

+ 31 - 30
atlas/js/utils/CommonViewFunction.js

@@ -49,7 +49,7 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
             if (options && options.getValue && (val = options.getValue(val, key)), _.isUndefined(val) || _.isNull(val)) return getEmptyString(key);
             if (!_.isNumber(val) && _.isNaN(parseInt(val)) || !formatIntVal) {
                 var newVal = val;
-                return formatStringVal && (newVal = parseInt(val), newVal = _.isNaN(newVal) ? val : numberFormat(newVal)), 
+                return formatStringVal && (newVal = parseInt(val), newVal = _.isNaN(newVal) ? val : numberFormat(newVal)),
                 getHighlightedString(_.escape(newVal));
             }
             return numberFormat(val);
@@ -59,9 +59,9 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
                     var value = "", deleteButton = "", data = serverData;
                     value = Utils.getName(data);
                     var id = "";
-                    data.guid && (Enums.entityStateReadOnly[data.status || data.entityStatus] && (deleteButton += '<button title="Deleted" class="btn btn-action btn-md deleteBtn"><i class="fa fa-trash"></i></button>'), 
-                    id = data.guid), value.length > 0 ? scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + getValue(value) + "</a>") : scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + _.escape(id) + "</a>"), 
-                    deleteButton.length && (scope.$('td div[data-id="' + id + '"]').addClass("block readOnlyLink"), 
+                    data.guid && (Enums.entityStateReadOnly[data.status || data.entityStatus] && (deleteButton += '<button title="Deleted" class="btn btn-action btn-md deleteBtn"><i class="fa fa-trash"></i></button>'),
+                    id = data.guid), value.length > 0 ? scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + getValue(value) + "</a>") : scope.$('td div[data-id="' + id + '"]').html('<a href="#!/detailPage/' + id + '">' + _.escape(id) + "</a>"),
+                    deleteButton.length && (scope.$('td div[data-id="' + id + '"]').addClass("block readOnlyLink"),
                     scope.$('td div[data-id="' + id + '"]').append(deleteButton));
                 },
                 cust_error: function(error, xhr) {
@@ -74,7 +74,7 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
             !_.isArray(keyValue) && _.isObject(keyValue) && (keyValue = [ keyValue ]);
             for (var subLink = "", i = 0; i < keyValue.length; i++) {
                 var inputOutputField = keyValue[i], id = inputOutputField.guid || (_.isObject(inputOutputField.id) ? inputOutputField.id.id : inputOutputField.id), tempLink = "", status = inputOutputField.status || inputOutputField.entityStatus || (_.isObject(inputOutputField.id) ? inputOutputField.id.state : inputOutputField.state), readOnly = Enums.entityStateReadOnly[status];
-                if (!inputOutputField.attributes && inputOutputField.values && (inputOutputField.attributes = inputOutputField.values), 
+                if (!inputOutputField.attributes && inputOutputField.values && (inputOutputField.attributes = inputOutputField.values),
                 _.isString(inputOutputField) || _.isBoolean(inputOutputField) || _.isNumber(inputOutputField)) {
                     var tempVarfor$check = inputOutputField.toString();
                     if (tempVarfor$check.indexOf("$") == -1) {
@@ -106,13 +106,13 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
                         fetchInputOutputValue(fetchId, defEntity), tempLink += '<div data-id="' + fetchId + '"><div class="value-loader"></div></div>';
                     }
                 }
-                readOnly ? fetch ? (fetch = !1, subLink += tempLink) : (tempLink += '<button title="Deleted" class="btn btn-action btn-md deleteBtn"><i class="fa fa-trash"></i></button>', 
+                readOnly ? fetch ? (fetch = !1, subLink += tempLink) : (tempLink += '<button title="Deleted" class="btn btn-action btn-md deleteBtn"><i class="fa fa-trash"></i></button>',
                 subLink += '<div class="block readOnlyLink">' + tempLink + "</div>") : tempLink.search("href") != -1 ? subLink += "<div>" + tempLink + "</div>" : tempLink.length && (subLink += tempLink);
             }
-            return valueOfArray.length && (subLink = getArrayOfStringFormat ? getArrayOfStringFormat(valueOfArray, key) : valueOfArray.join(", ")), 
+            return valueOfArray.length && (subLink = getArrayOfStringFormat ? getArrayOfStringFormat(valueOfArray, key) : valueOfArray.join(", ")),
             "" === subLink ? getEmptyString(key) : subLink;
         }, valueObjectKeysList = _.keys(valueObject);
-        return (_.isUndefined(sortBy) || 1 == sortBy) && (valueObjectKeysList = _.sortBy(valueObjectKeysList)), 
+        return (_.isUndefined(sortBy) || 1 == sortBy) && (valueObjectKeysList = _.sortBy(valueObjectKeysList)),
         valueObjectKeysList.map(function(key) {
             if ("profileData" != key) {
                 var keyValue = valueObject[key], listCount = showListCount && _.isArray(keyValue) && keyValue.length > 0 ? " (" + numberFormat(keyValue.length) + ")" : "", defEntity = _.find(attributeDefs, {
@@ -132,15 +132,15 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
                     key: key
                 }));
                 var val = "";
-                if (val = _.isObject(valueObject[key]) ? keyValue : "guid" === key || "__guid" === key ? options.guidHyperLink === !1 ? getValue(keyValue, key) : '<a title="' + key + '" href="#!/detailPage/' + _.escape(keyValue) + '">' + getValue(keyValue, key) + "</a>" : getValue(keyValue, key), 
+                if (val = _.isObject(valueObject[key]) ? keyValue : "guid" === key || "__guid" === key ? options.guidHyperLink === !1 ? getValue(keyValue, key) : '<a title="' + key + '" href="#!/detailPage/' + _.escape(keyValue) + '">' + getValue(keyValue, key) + "</a>" : getValue(keyValue, key),
                 isTable) {
                     var value = val, appendClass = "N/A" == value ? "hide-row" : "", htmlTag = '<div class="scroll-y">' + value + "</div>";
                     if (_.isObject(valueObject[key]) && !_.isEmpty(valueObject[key])) {
-                        var matchedLinkString = val.match(/href|value-loader\w*/g), matchedJson = val.match(/json-value|json-string\w*/g), isMatchJSONStringIsSingle = (val.match(/json-key\w*/g), 
+                        var matchedLinkString = val.match(/href|value-loader\w*/g), matchedJson = val.match(/json-value|json-string\w*/g), isMatchJSONStringIsSingle = (val.match(/json-key\w*/g),
                         matchedLinkString && matchedLinkString.length <= 5, matchedJson && 1 == matchedJson.length), expandCollapseButton = "";
                         if (matchedJson || matchedLinkString) {
                             var className = "code-block fixed-height";
-                            isMatchJSONStringIsSingle || (className += " shrink", expandCollapseButton = '<button class="expand-collapse-button"><i class="fa"></i></button>'), 
+                            isMatchJSONStringIsSingle || (className += " shrink", expandCollapseButton = '<button class="expand-collapse-button"><i class="fa"></i></button>'),
                             htmlTag = '<pre class="' + className + '">' + expandCollapseButton + "<code>" + val + "</code></pre>";
                         }
                     }
@@ -155,22 +155,22 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
             obj.guid === tag.entityGuid ? deleteIcon = '<i class="fa fa-times" data-id="delete"  data-assetname="' + entityName + '" data-name="' + tag.typeName + '" data-type="tag" data-guid="' + obj.guid + '" ></i>' : obj.guid !== tag.entityGuid && "DELETED" === tag.entityStatus ? deleteIcon = '<i class="fa fa-times" data-id="delete"  data-assetname="' + entityName + '" data-name="' + tag.typeName + '" data-type="tag" data-entityguid="' + tag.entityGuid + '" data-guid="' + obj.guid + '" ></i>' : className += " propagte-classification";
             var tagString = '<a class="' + className + '" data-id="tagClick"><span title="' + tag.typeName + '">' + tag.typeName + "</span>" + deleteIcon + "</a>";
             count >= 1 ? popTag += tagString : tagHtml += tagString, ++count;
-        }), Enums.entityStateReadOnly[obj.status || obj.entityStatus] || (addTag += obj.guid ? '<a href="javascript:void(0)" data-id="addTag" class="btn btn-action btn-sm assignTag" data-guid="' + obj.guid + '" ><i class="fa fa-plus"></i></a>' : '<a href="javascript:void(0)" data-id="addTag" class="btn btn-action btn-sm assignTag"><i style="right:0" class="fa fa-plus"></i></a>'), 
-        count > 1 && (addTag += '<div data-id="showMoreLess" class="btn btn-action btn-sm assignTag"><i class="fa fa-ellipsis-h" aria-hidden="true"></i><div class="popup-tag-term">' + popTag + "</div></div>"), 
+        }), Enums.entityStateReadOnly[obj.status || obj.entityStatus] || (addTag += obj.guid ? '<a href="javascript:void(0)" data-id="addTag" class="btn btn-action btn-sm assignTag" data-guid="' + obj.guid + '" ><i class="fa fa-plus"></i></a>' : '<a href="javascript:void(0)" data-id="addTag" class="btn btn-action btn-sm assignTag"><i style="right:0" class="fa fa-plus"></i></a>'),
+        count > 1 && (addTag += '<div data-id="showMoreLess" class="btn btn-action btn-sm assignTag"><i class="fa fa-ellipsis-h" aria-hidden="true"></i><div class="popup-tag-term">' + popTag + "</div></div>"),
         '<div class="tagList btn-inline btn-fixed-width">' + tagHtml + addTag + "</div>";
     }, CommonViewFunction.termForTable = function(obj) {
         var terms = obj.meanings, termHtml = "", addTerm = "", popTerm = "", count = 0, entityName = Utils.getName(obj);
         return terms && terms.map(function(term) {
             var displayText = _.escape(term.displayText), className = "btn btn-action btn-sm btn-blue btn-icon", deleteIcon = '<i class="fa fa-times" data-id="delete"  data-assetname="' + entityName + '" data-name="' + displayText + '" data-type="term" data-guid="' + obj.guid + '" data-termGuid="' + term.termGuid + '" ></i>', termString = '<a class="' + className + '" data-id="termClick"><span title="' + displayText + '">' + displayText + "</span>" + deleteIcon + "</a>";
             count >= 1 ? popTerm += termString : termHtml += termString, ++count;
-        }), Enums.entityStateReadOnly[obj.status || obj.entityStatus] || (addTerm += obj.guid ? '<a href="javascript:void(0)" data-id="addTerm" class="btn btn-action btn-sm assignTag" data-guid="' + obj.guid + '" ><i class="fa fa-plus"></i></a>' : '<a href="javascript:void(0)" data-id="addTerm" class="btn btn-action btn-sm assignTag"><i style="right:0" class="fa fa-plus"></i></a>'), 
-        count > 1 && (addTerm += '<div data-id="showMoreLess" class="btn btn-action btn-sm assignTerm"><i class="fa fa-ellipsis-h" aria-hidden="true"></i><div class="popup-tag-term">' + popTerm + "</div></div>"), 
+        }), Enums.entityStateReadOnly[obj.status || obj.entityStatus] || (addTerm += obj.guid ? '<a href="javascript:void(0)" data-id="addTerm" class="btn btn-action btn-sm assignTag" data-guid="' + obj.guid + '" ><i class="fa fa-plus"></i></a>' : '<a href="javascript:void(0)" data-id="addTerm" class="btn btn-action btn-sm assignTag"><i style="right:0" class="fa fa-plus"></i></a>'),
+        count > 1 && (addTerm += '<div data-id="showMoreLess" class="btn btn-action btn-sm assignTerm"><i class="fa fa-ellipsis-h" aria-hidden="true"></i><div class="popup-tag-term">' + popTerm + "</div></div>"),
         '<div class="tagList btn-inline btn-fixed-width">' + termHtml + addTerm + "</div>";
     }, CommonViewFunction.generateQueryOfFilter = function(value) {
         function objToString(filterObj) {
             var generatedQuery = _.map(filterObj.rules, function(obj, key) {
                 var obj = $.extend(!0, {}, obj);
-                return _.has(obj, "condition") ? '&nbsp<span class="operator">' + obj.condition + "</span>&nbsp(" + objToString(obj) + ")" : ("date" === obj.type && (Enums.queryBuilderDateRangeUIValueToAPI[obj.value] ? obj.value = Enums.queryBuilderDateRangeUIValueToAPI[obj.value] : obj.value = obj.value + " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")"), 
+                return _.has(obj, "condition") ? '&nbsp<span class="operator">' + obj.condition + "</span>&nbsp(" + objToString(obj) + ")" : ("date" === obj.type && (Enums.queryBuilderDateRangeUIValueToAPI[obj.value] ? obj.value = Enums.queryBuilderDateRangeUIValueToAPI[obj.value] : obj.value = obj.value + " (" + moment.tz(moment.tz.guess()).zoneAbbr() + ")"),
                 '<span class="key">' + (Enums.systemAttributes[obj.id] ? Enums.systemAttributes[obj.id] : _.escape(obj.id)) + '</span>&nbsp<span class="operator">' + _.escape(obj.operator) + '</span>&nbsp<span class="value">' + (Enums[obj.id] ? Enums[obj.id][obj.value] : _.escape(obj.value)) + "</span>");
             });
             return generatedQuery;
@@ -213,8 +213,8 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
         if (value) return _.each(Enums.extractFromUrlForSearch, function(svalue, skey) {
             _.isObject(svalue) ? _.each(svalue, function(v, k) {
                 var val = value[k];
-                _.isUndefinedNull(val) || ("attributes" == k ? val = val.split(",") : _.contains([ "tagFilters", "entityFilters" ], k) ? val = CommonViewFunction.attributeFilter.generateAPIObj(val) : _.contains([ "includeDE", "excludeST", "excludeSC" ], k) && (val = !val)), 
-                _.contains([ "includeDE", "excludeST", "excludeSC" ], k) && (val = !!_.isUndefinedNull(val) || val), 
+                _.isUndefinedNull(val) || ("attributes" == k ? val = val.split(",") : _.contains([ "tagFilters", "entityFilters" ], k) ? val = CommonViewFunction.attributeFilter.generateAPIObj(val) : _.contains([ "includeDE", "excludeST", "excludeSC" ], k) && (val = !val)),
+                _.contains([ "includeDE", "excludeST", "excludeSC" ], k) && (val = !!_.isUndefinedNull(val) || val),
                 obj[skey] || (obj[skey] = {}), obj[skey][v] = val;
             }) : obj[skey] = value[skey];
         }), obj;
@@ -232,7 +232,7 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
                             collection: classificationDefCollection,
                             attrMerge: !0,
                             data: classificationDef.toJSON()
-                        })), Globals[value[skey].typeName] && (attributeDefs = Globals[value[skey].typeName].attributeDefs), 
+                        })), Globals[value[skey].typeName] && (attributeDefs = Globals[value[skey].typeName].attributeDefs),
                         Globals._ALL_CLASSIFICATION_TYPES && Globals._ALL_CLASSIFICATION_TYPES.attributeDefs && (attributeDefs = attributeDefs.concat(Globals._ALL_CLASSIFICATION_TYPES.attributeDefs));
                     }
                     val = CommonViewFunction.attributeFilter.generateUrl({
@@ -248,7 +248,7 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
                             collection: entityDefCollection,
                             attrMerge: !0,
                             data: entityDef.toJSON()
-                        })), Globals[value[skey].typeName] && (attributeDefs = Globals[value[skey].typeName].attributeDefs), 
+                        })), Globals[value[skey].typeName] && (attributeDefs = Globals[value[skey].typeName].attributeDefs),
                         Globals._ALL_ENTITY_TYPES && Globals._ALL_ENTITY_TYPES.attributeDefs && (attributeDefs = attributeDefs.concat(Globals._ALL_ENTITY_TYPES.attributeDefs));
                     }
                     val = CommonViewFunction.attributeFilter.generateUrl({
@@ -273,7 +273,7 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
                     var type = obj.type || obj.attributeType, value = _.isString(obj.value) && _.contains([ "is_null", "not_null" ], obj.operator) && "date" === type || _.isObject(obj.value) ? "" : _.trim(obj.value || obj.attributeValue), url = [ obj.id || obj.attributeName, mapApiOperatorToUI(obj.operator), value ];
                     return "TIME_RANGE" === obj.operator ? value.indexOf("-") > -1 ? url[2] = value.split("-").map(function(udKey) {
                         return Date.parse(udKey.trim()).toString();
-                    }).join(",") : url[2] = Enums.queryBuilderDateRangeUIValueToAPI[_.trim(value)] || value : value.length && "date" === type && formatedDateToLong && (url[2] = Date.parse(value)), 
+                    }).join(",") : url[2] = Enums.queryBuilderDateRangeUIValueToAPI[_.trim(value)] || value : value.length && "date" === type && formatedDateToLong && (url[2] = Date.parse(value)),
                     type && url.push(type), url.join("::");
                 }).join("|" + spliter + "|") : null;
             }
@@ -288,7 +288,7 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
                 return Enums.queryBuilderUIOperatorToAPI[oper] || oper;
             }, createObject = function(urlObj) {
                 var finalObj = {};
-                return finalObj.condition = /^AND\(/.test(urlObj) ? "AND" : "OR", urlObj = "AND" === finalObj.condition ? urlObj.substr(4).slice(0, -1) : urlObj.substr(3).slice(0, -1), 
+                return finalObj.condition = /^AND\(/.test(urlObj) ? "AND" : "OR", urlObj = "AND" === finalObj.condition ? urlObj.substr(4).slice(0, -1) : urlObj.substr(3).slice(0, -1),
                 finalObj[apiObj ? "criterion" : "rules"] = _.map(urlObj.split("|" + spliter + "|"), function(obj, key) {
                     var isStringNested = obj.split("|" + (spliter + 1) + "|").length > 1, isCondition = /^AND\(/.test(obj) || /^OR\(/.test(obj);
                     if (isStringNested && isCondition) return ++spliter, createObject(obj);
@@ -391,7 +391,7 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
         }
     }, CommonViewFunction.removeCategoryTermAssociation = function(options) {
         if (options) {
-            var selectedGuid = options.selectedGuid, termGuid = options.termGuid, isCategoryView = options.isCategoryView, isTermView = options.isTermView, isEntityView = options.isEntityView, model = (options.collection, 
+            var selectedGuid = options.selectedGuid, termGuid = options.termGuid, isCategoryView = options.isCategoryView, isTermView = options.isTermView, isEntityView = options.isEntityView, model = (options.collection,
             options.model), newModel = new options.collection.model(), noticeRef = null, ajaxOptions = {
                 success: function(rModel, response) {
                     noticeRef && noticeRef.remove(), Utils.notifySuccess({
@@ -435,7 +435,7 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
             var method = settings.type, csrfToken = CommonViewFunction.restCsrfValue;
             null == CommonViewFunction.restCsrfCustomHeader || CommonViewFunction.restCsrfMethodsToIgnore[method] || xhr.setRequestHeader(CommonViewFunction.restCsrfCustomHeader, csrfToken);
         }
-    }, CommonViewFunction.restCsrfCustomHeader = null, CommonViewFunction.restCsrfMethodsToIgnore = null, 
+    }, CommonViewFunction.restCsrfCustomHeader = null, CommonViewFunction.restCsrfMethodsToIgnore = null,
     CommonViewFunction.userDataFetch = function(options) {
         function getTrimmedStringArrayValue(string) {
             var str = string, array = [];
@@ -451,10 +451,10 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
                         var str = "" + response["atlas.rest-csrf.enabled"];
                         csrfEnabled = "true" == str.toLowerCase();
                     }
-                    if (response["atlas.rest-csrf.custom-header"] && (header = response["atlas.rest-csrf.custom-header"].trim()), 
-                    response["atlas.rest-csrf.methods-to-ignore"] && (methods = getTrimmedStringArrayValue(response["atlas.rest-csrf.methods-to-ignore"])), 
+                    if (response["atlas.rest-csrf.custom-header"] && (header = response["atlas.rest-csrf.custom-header"].trim()),
+                    response["atlas.rest-csrf.methods-to-ignore"] && (methods = getTrimmedStringArrayValue(response["atlas.rest-csrf.methods-to-ignore"])),
                     csrfEnabled) {
-                        CommonViewFunction.restCsrfCustomHeader = header, CommonViewFunction.restCsrfMethodsToIgnore = {}, 
+                        CommonViewFunction.restCsrfCustomHeader = header, CommonViewFunction.restCsrfMethodsToIgnore = {},
                         CommonViewFunction.restCsrfValue = response._csrfToken || '""', methods.map(function(method) {
                             CommonViewFunction.restCsrfMethodsToIgnore[method] = !0;
                         });
@@ -487,8 +487,9 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
                 var duplicates = datalist.filter(function(c) {
                     return c.key === val;
                 });
-                keyMap.has(val) || duplicates.length > 1 ? (classes = "form-control errorClass", 
-                hasDup.push("duplicate"), pEl.innerText = "Duplicate key") : keyMap.set(val, val);
+                keyMap.has(val) || duplicates.length > 1 ? (classes = "form-control errorClass",
+                // hasDup.push("duplicate"), pEl.innerText = "Duplicate key") : keyMap.set(val, val);
+                hasDup.push("duplicate"), pEl.innerText = "重复的关键值") : keyMap.set(val, val);
             }
             validation === !1 && (classes = "form-control errorClass"), input.setAttribute("class", classes);
         }
@@ -551,4 +552,4 @@ define([ "require", "utils/Utils", "modules/Modal", "utils/Messages", "utils/Enu
             }
         });
     }, CommonViewFunction;
-});
+});