jie 11 ماه پیش
والد
کامیت
b078b367ea
1فایلهای تغییر یافته به همراه50 افزوده شده و 48 حذف شده
  1. 50 48
      atlas/js/views/search/SearchLayoutView.js

+ 50 - 48
atlas/js/views/search/SearchLayoutView.js

@@ -24,12 +24,12 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
             var events = {}, that = this;
             return events["keyup " + this.ui.searchInput] = function(e) {
                 var code = e.which;
-                this.value.query = e.currentTarget.value, this.query[this.type].query = this.value.query, 
+                this.value.query = e.currentTarget.value, this.query[this.type].query = this.value.query,
                 13 == code && that.findSearchResult(), this.checkForButtonVisiblity();
-            }, events["change " + this.ui.searchType] = "dslFulltextToggle", events["click " + this.ui.searchBtn] = "findSearchResult", 
-            events["click " + this.ui.clearSearch] = "clearSearchData", events["change " + this.ui.typeLov] = "checkForButtonVisiblity", 
-            events["change " + this.ui.tagLov] = "checkForButtonVisiblity", events["change " + this.ui.termLov] = "checkForButtonVisiblity", 
-            events["click " + this.ui.refreshBtn] = "onRefreshButton", events["click " + this.ui.advancedInfoBtn] = "advancedInfo", 
+            }, events["change " + this.ui.searchType] = "dslFulltextToggle", events["click " + this.ui.searchBtn] = "findSearchResult",
+            events["click " + this.ui.clearSearch] = "clearSearchData", events["change " + this.ui.typeLov] = "checkForButtonVisiblity",
+            events["change " + this.ui.tagLov] = "checkForButtonVisiblity", events["change " + this.ui.termLov] = "checkForButtonVisiblity",
+            events["click " + this.ui.refreshBtn] = "onRefreshButton", events["click " + this.ui.advancedInfoBtn] = "advancedInfo",
             events["click " + this.ui.typeAttrFilter] = function() {
                 this.openAttrFilter("type");
             }, events["click " + this.ui.tagAttrFilter] = function() {
@@ -37,7 +37,7 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
             }, events;
         },
         initialize: function(options) {
-            _.extend(this, _.pick(options, "value", "typeHeaders", "searchVent", "entityDefCollection", "enumDefCollection", "classificationDefCollection", "businessMetadataDefCollection", "searchTableColumns", "searchTableFilters", "metricCollection", "classificationAndMetricEvent")), 
+            _.extend(this, _.pick(options, "value", "typeHeaders", "searchVent", "entityDefCollection", "enumDefCollection", "classificationDefCollection", "businessMetadataDefCollection", "searchTableColumns", "searchTableFilters", "metricCollection", "classificationAndMetricEvent")),
             this.type = "basic", this.entityCountObj = _.first(this.metricCollection.toJSON()) || {
                 entity: {
                     entityActive: {},
@@ -72,8 +72,8 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
                     excludeST: this.value ? this.value.excludeST : null,
                     excludeSC: this.value ? this.value.excludeSC : null
                 }
-            }, this.value || (this.value = {}), this.dsl = !1, param && param.searchType && (this.type = param.searchType, 
-            this.updateQueryObject(param)), this.value && this.value.type || this.value && this.value.tag && "basic" === this.value.searchType ? this.setInitialEntityVal = !1 : this.setInitialEntityVal = !0, 
+            }, this.value || (this.value = {}), this.dsl = !1, param && param.searchType && (this.type = param.searchType,
+            this.updateQueryObject(param)), this.value && this.value.type || this.value && this.value.tag && "basic" === this.value.searchType ? this.setInitialEntityVal = !1 : this.setInitialEntityVal = !0,
             this.tagEntityCheck = !1, this.typeEntityCheck = !1, this.bindEvents();
         },
         renderSaveSearch: function() {
@@ -106,7 +106,7 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
                     entityDefCollection: that.entityDefCollection,
                     getValue: function() {
                         var queryObj = that.query[that.type], entityObj = that.searchTableFilters.entityFilters, tagObj = that.searchTableFilters.tagFilters, urlObj = Utils.getUrlState.getQueryParams();
-                        return urlObj && (urlObj.includeDE = "true" == urlObj.includeDE, urlObj.excludeSC = "true" == urlObj.excludeSC, 
+                        return urlObj && (urlObj.includeDE = "true" == urlObj.includeDE, urlObj.excludeSC = "true" == urlObj.excludeSC,
                         urlObj.excludeST = "true" == urlObj.excludeST), _.extend({}, queryObj, urlObj, {
                             entityFilters: entityObj ? entityObj[queryObj.type] : null,
                             tagFilters: tagObj ? tagObj[queryObj.tag] : null,
@@ -143,27 +143,27 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
             }, this), this.listenTo(this.searchVent, "entityList:refresh", function(model, response) {
                 this.onRefreshButton();
             }, this), this.classificationAndMetricEvent.on("classification:Update:Search", function(options) {
-                that.entityCountObj = _.first(that.metricCollection.toJSON()), that.value = Utils.getUrlState.getQueryParams() || {}, 
+                that.entityCountObj = _.first(that.metricCollection.toJSON()), that.value = Utils.getUrlState.getQueryParams() || {},
                 that.value.type || (that.setInitialEntityVal = !0), that.initializeValues();
             });
         },
         initializeValues: function() {
-            this.renderTypeTagList(), this.renderTermList(), this.setValues(), this.checkForButtonVisiblity(), 
+            this.renderTypeTagList(), this.renderTermList(), this.setValues(), this.checkForButtonVisiblity(),
             this.renderSaveSearch(), this.setInitialEntityVal && (this.setInitialEntityVal = !1);
         },
         makeFilterButtonActive: function(filtertypeParam) {
             var filtertype = [ "entityFilters", "tagFilters" ], that = this;
             filtertypeParam && (_.isArray(filtertypeParam) ? filtertype = filtertypeParam : _.isString(filtertypeParam) && (filtertype = [ filtertypeParam ]));
             var typeCheck = function(filterObj, type) {
-                that.value.type ? (filterObj && filterObj.length ? that.ui.typeAttrFilter.addClass("active") : that.ui.typeAttrFilter.removeClass("active"), 
-                that.ui.typeAttrFilter.prop("disabled", !1)) : (that.ui.typeAttrFilter.removeClass("active"), 
+                that.value.type ? (filterObj && filterObj.length ? that.ui.typeAttrFilter.addClass("active") : that.ui.typeAttrFilter.removeClass("active"),
+                that.ui.typeAttrFilter.prop("disabled", !1)) : (that.ui.typeAttrFilter.removeClass("active"),
                 that.ui.typeAttrFilter.prop("disabled", !0));
             }, tagCheck = function(filterObj, type) {
                 var filterAddOn = Enums.addOnClassification.filter(function(a) {
                     a !== Enums.addOnClassification[0];
                 });
-                that.value.tag && !_.contains(filterAddOn, that.value.tag) ? (that.ui.tagAttrFilter.prop("disabled", !1), 
-                filterObj && filterObj.length ? that.ui.tagAttrFilter.addClass("active") : that.ui.tagAttrFilter.removeClass("active")) : (that.ui.tagAttrFilter.removeClass("active"), 
+                that.value.tag && !_.contains(filterAddOn, that.value.tag) ? (that.ui.tagAttrFilter.prop("disabled", !1),
+                filterObj && filterObj.length ? that.ui.tagAttrFilter.addClass("active") : that.ui.tagAttrFilter.removeClass("active")) : (that.ui.tagAttrFilter.removeClass("active"),
                 that.ui.tagAttrFilter.prop("disabled", !0));
             };
             _.each(filtertype, function(type) {
@@ -177,11 +177,11 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
                 var $el = $(e.currentTarget), isTagEl = "tagLOV" == $el.data("id"), isTermEl = "termLOV" == $el.data("id"), isTypeEl = "typeLOV" == $el.data("id"), select2Data = $el.select2("data");
                 if ("change" == e.type && select2Data) {
                     var value = _.isEmpty(select2Data) ? select2Data : _.first(select2Data).id, key = "tag", filterType = isBasicSearch ? "tagFilters" : null, value = value && value.length ? value : null;
-                    if (isTagEl || (key = isTermEl ? "term" : "type", isBasicSearch && (filterType = isTypeEl ? "entityFilters" : null)), 
+                    if (isTagEl || (key = isTermEl ? "term" : "type", isBasicSearch && (filterType = isTypeEl ? "entityFilters" : null)),
                     this.value) {
                         if (this.value[key] !== value || !value && !this.value[key]) {
                             var temp = {};
-                            temp[key] = value, _.extend(this.value, temp), _.isUndefined(options) && (this.value.pageOffset = 0), 
+                            temp[key] = value, _.extend(this.value, temp), _.isUndefined(options) && (this.value.pageOffset = 0),
                             _.extend(this.query[this.type], temp);
                         } else if (isBasicSearch) {
                             if (filterType) {
@@ -293,24 +293,24 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
                     value: rule,
                     formatedDateToLong: !0
                 });
-                if (this.searchTableFilters[filtertype][isTag ? this.value.tag : this.value.type] = ruleUrl, 
-                this.makeFilterButtonActive(filtertype), !isTag && this.value && this.value.type && this.searchTableColumns && (this.searchTableColumns[this.value.type] || (this.searchTableColumns[this.value.type] = [ "selected", "name", "owner", "description", "tag", "typeName" ]), 
-                this.searchTableColumns[this.value.type] = _.sortBy(_.union(this.searchTableColumns[this.value.type], getIdFromRuleObject(rule)))), 
+                if (this.searchTableFilters[filtertype][isTag ? this.value.tag : this.value.type] = ruleUrl,
+                this.makeFilterButtonActive(filtertype), !isTag && this.value && this.value.type && this.searchTableColumns && (this.searchTableColumns[this.value.type] || (this.searchTableColumns[this.value.type] = [ "selected", "name", "owner", "description", "tag", "typeName" ]),
+                this.searchTableColumns[this.value.type] = _.sortBy(_.union(this.searchTableColumns[this.value.type], getIdFromRuleObject(rule)))),
                 rule.rules) {
                     if (!isTag && !that.tagEntityCheck) {
                         var state = _.find(rule.rules, {
                             id: "__state"
                         });
-                        state ? (that.typeEntityCheck = !("ACTIVE" === state.value && "=" === state.operator || "DELETED" === state.value && "!=" === state.operator), 
-                        that.value.includeDE = that.typeEntityCheck) : that.typeEntityCheck && (that.typeEntityCheck = !1, 
+                        state ? (that.typeEntityCheck = !("ACTIVE" === state.value && "=" === state.operator || "DELETED" === state.value && "!=" === state.operator),
+                        that.value.includeDE = that.typeEntityCheck) : that.typeEntityCheck && (that.typeEntityCheck = !1,
                         that.tagEntityCheck || (that.value.includeDE = !1));
                     }
                     if (isTag && !that.typeEntityCheck) {
                         var entityStatus = _.find(rule.rules, {
                             id: "__entityStatus"
                         });
-                        entityStatus ? (that.tagEntityCheck = !("ACTIVE" === entityStatus.value && "=" === entityStatus.operator || "DELETED" === entityStatus.value && "!=" === entityStatus.operator), 
-                        that.value.includeDE = that.tagEntityCheck) : that.tagEntityCheck && (that.tagEntityCheck = !1, 
+                        entityStatus ? (that.tagEntityCheck = !("ACTIVE" === entityStatus.value && "=" === entityStatus.operator || "DELETED" === entityStatus.value && "!=" === entityStatus.operator),
+                        that.value.includeDE = that.tagEntityCheck) : that.tagEntityCheck && (that.tagEntityCheck = !1,
                         that.typeEntityCheck || (that.value.includeDE = !1));
                     }
                 }
@@ -318,7 +318,7 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
             }
         },
         manualRender: function(paramObj) {
-            paramObj && (this.value = paramObj), this.updateQueryObject(paramObj), this.renderTypeTagList(), 
+            paramObj && (this.value = paramObj), this.updateQueryObject(paramObj), this.renderTypeTagList(),
             this.setValues(paramObj);
         },
         getFilterBox: function() {
@@ -334,7 +334,7 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
         },
         renderTypeTagList: function(options) {
             var that = this, serviceTypeToBefiltered = options && options.filterList, isTypeOnly = options && options.isTypeOnly;
-            this.selectedFilter[this.type].length && (serviceTypeToBefiltered = this.selectedFilter[this.type]), 
+            this.selectedFilter[this.type].length && (serviceTypeToBefiltered = this.selectedFilter[this.type]),
             this.ui.typeLov.empty();
             var typeStr = "<option></option>", tagStr = typeStr, foundNewClassification = !1;
             if (this.typeHeaders.fullCollection.each(function(model) {
@@ -345,7 +345,7 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
                 }
                 if (void 0 == isTypeOnly && "CLASSIFICATION" == model.get("category")) {
                     var tagEntityCount = that.entityCountObj.tag.tagEntities[name];
-                    that.value && that.value.tag && name === that.value.tag && (foundNewClassification = !0), 
+                    that.value && that.value.tag && name === that.value.tag && (foundNewClassification = !0),
                     tagStr += '<option value="' + name + '" data-name="' + name + '">' + name + " " + (tagEntityCount ? "(" + _.numberFormatWithComma(tagEntityCount) + ")" : "") + "</option>";
                 }
             }), "dsl" !== this.type && _.each(Enums.addOnEntities, function(entity) {
@@ -435,20 +435,20 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
         },
         setValues: function(paramObj) {
             var that = this;
-            paramObj && (this.value = paramObj), this.value && (this.ui.searchInput.val(this.value.query || ""), 
-            "true" == this.value.dslChecked ? this.ui.searchType.prop("checked") || this.ui.searchType.prop("checked", !0).trigger("change") : this.ui.searchType.prop("checked") && this.ui.searchType.prop("checked", !1).trigger("change"), 
-            this.ui.typeLov.val(this.value.type), this.ui.typeLov.data("select2") && (this.ui.typeLov.val() !== this.value.type ? (this.value.type = null, 
+            paramObj && (this.value = paramObj), this.value && (this.ui.searchInput.val(this.value.query || ""),
+            "true" == this.value.dslChecked ? this.ui.searchType.prop("checked") || this.ui.searchType.prop("checked", !0).trigger("change") : this.ui.searchType.prop("checked") && this.ui.searchType.prop("checked", !1).trigger("change"),
+            this.ui.typeLov.val(this.value.type), this.ui.typeLov.data("select2") && (this.ui.typeLov.val() !== this.value.type ? (this.value.type = null,
             this.ui.typeLov.val("").trigger("change", {
                 manual: !0
             })) : this.ui.typeLov.trigger("change", {
                 manual: !0
-            })), this.dsl || (this.ui.tagLov.val(this.value.tag), this.ui.tagLov.data("select2") && (this.ui.tagLov.val() !== this.value.tag ? (this.value.tag = null, 
+            })), this.dsl || (this.ui.tagLov.val(this.value.tag), this.ui.tagLov.data("select2") && (this.ui.tagLov.val() !== this.value.tag ? (this.value.tag = null,
             this.ui.tagLov.val("").trigger("change", {
                 manual: !0
             })) : this.ui.tagLov.trigger("change", {
                 manual: !0
-            })), this.value.term && this.ui.termLov.append('<option value="' + _.escape(this.value.term) + '" selected="selected">' + _.escape(this.value.term) + "</option>"), 
-            this.ui.termLov.data("select2") && (this.ui.termLov.val() !== this.value.term ? (this.value.term = null, 
+            })), this.value.term && this.ui.termLov.append('<option value="' + _.escape(this.value.term) + '" selected="selected">' + _.escape(this.value.term) + "</option>"),
+            this.ui.termLov.data("select2") && (this.ui.termLov.val() !== this.value.term ? (this.value.term = null,
             this.ui.termLov.val("").trigger("change", {
                 manual: !0
             })) : this.ui.termLov.trigger("change", {
@@ -479,13 +479,13 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
                 if (params.includeDE = !1, params.excludeST = !1, params.excludeSC = !1, this.value) {
                     this.value.tag && (params.tagFilters = tagFilterObj[this.value.tag]), this.value.type && (params.entityFilters = entityFilterObj[this.value.type]);
                     var columnList = this.value.type && this.searchTableColumns ? this.searchTableColumns[this.value.type] : null;
-                    columnList && (params.attributes = columnList.join(",")), params.includeDE = !_.isUndefinedNull(this.value.includeDE) && this.value.includeDE, 
-                    params.excludeST = !_.isUndefinedNull(this.value.excludeST) && this.value.excludeST, 
+                    columnList && (params.attributes = columnList.join(",")), params.includeDE = !_.isUndefinedNull(this.value.includeDE) && this.value.includeDE,
+                    params.excludeST = !_.isUndefinedNull(this.value.excludeST) && this.value.excludeST,
                     params.excludeSC = !_.isUndefinedNull(this.value.excludeSC) && this.value.excludeSC;
                 }
             }
-            this.value && !_.isUndefinedNull(this.value.pageLimit) && (params.pageLimit = this.value.pageLimit), 
-            this.value && !_.isUndefinedNull(this.value.pageOffset) && (_.isUndefinedNull(this.query[this.type]) || this.query[this.type].query == value ? params.pageOffset = this.value.pageOffset : params.pageOffset = 0), 
+            this.value && !_.isUndefinedNull(this.value.pageLimit) && (params.pageLimit = this.value.pageLimit),
+            this.value && !_.isUndefinedNull(this.value.pageOffset) && (_.isUndefinedNull(this.query[this.type]) || this.query[this.type].query == value ? params.pageOffset = this.value.pageOffset : params.pageOffset = 0),
             params.query = value || null, _.extend(this.query[this.type], params), Utils.setUrl({
                 url: "#!/search/searchResult",
                 urlParams: _.extend({}, this.query[this.type]),
@@ -496,12 +496,14 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
         },
         dslFulltextToggle: function(e) {
             var paramObj = Utils.getUrlState.getQueryParams();
-            paramObj && this.type == paramObj.searchType && this.updateQueryObject(paramObj), 
-            e.currentTarget.checked ? (this.type = "dsl", this.dsl = !0, this.$(".typeFilterBtn,.tagBox,.termBox,.basicSaveSearch").hide(), 
-            this.$(".typeFilter").addClass("col-sm-12"), this.$(".typeFilter").removeClass("col-sm-10"), 
-            this.$(".advanceSaveSearch").show(), this.$(".searchText").text("Search By Query"), 
-            this.ui.searchInput.attr("placeholder", 'Search By Query eg. where name="sales_fact"')) : (this.$(".typeFilter").addClass("col-sm-10"), 
-            this.$(".typeFilter").removeClass("col-sm-12"), this.$(".typeFilterBtn,.tagBox,.termBox,.basicSaveSearch").show(), 
+            paramObj && this.type == paramObj.searchType && this.updateQueryObject(paramObj),
+            e.currentTarget.checked ? (this.type = "dsl", this.dsl = !0, this.$(".typeFilterBtn,.tagBox,.termBox,.basicSaveSearch").hide(),
+            this.$(".typeFilter").addClass("col-sm-12"), this.$(".typeFilter").removeClass("col-sm-10"),
+                // this.$(".advanceSaveSearch").show(), this.$(".searchText").text("Search By Query"),
+                this.$(".advanceSaveSearch").show(), this.$(".searchText").text("根据查询搜索"),
+                // this.ui.searchInput.attr("placeholder", 'Search By Query eg. where name="sales_fact"')) : (this.$(".typeFilter").addClass("col-sm-10"),
+                this.ui.searchInput.attr("placeholder", '根据查询搜索,例如:where name="sales_fact"')) : (this.$(".typeFilter").addClass("col-sm-10"),
+            this.$(".typeFilter").removeClass("col-sm-12"), this.$(".typeFilterBtn,.tagBox,.termBox,.basicSaveSearch").show(),
             this.$(".advanceSaveSearch").hide(), this.dsl = !1, this.type = "basic", this.$(".searchText").text("根据文本修改"),
             this.ui.searchInput.attr("placeholder", "根据文本修改")), Utils.getUrlState.isSearchTab() && Utils.setUrl({
                 url: "#!/search/searchResult",
@@ -515,12 +517,12 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
             });
         },
         clearSearchData: function() {
-            this.selectedFilter[this.type] = [], this.renderTypeTagList(), this.updateQueryObject(), 
-            this.ui.typeLov.val("").trigger("change"), this.ui.tagLov.val("").trigger("change"), 
+            this.selectedFilter[this.type] = [], this.renderTypeTagList(), this.updateQueryObject(),
+            this.ui.typeLov.val("").trigger("change"), this.ui.tagLov.val("").trigger("change"),
             this.ui.searchInput.val("");
             var type = "basicSaveSearch";
-            "dsl" == this.type && (type = "advanceSaveSearch"), this.$("." + type + " .saveSearchList").find("li.active").removeClass("active"), 
-            this.$("." + type + ' [data-id="saveBtn"]').attr("disabled", !0), this.dsl || (this.searchTableFilters.tagFilters = {}, 
+            "dsl" == this.type && (type = "advanceSaveSearch"), this.$("." + type + " .saveSearchList").find("li.active").removeClass("active"),
+            this.$("." + type + ' [data-id="saveBtn"]').attr("disabled", !0), this.dsl || (this.searchTableFilters.tagFilters = {},
             this.searchTableFilters.entityFilters = {}), this.checkForButtonVisiblity(), Utils.setUrl({
                 url: "#!/search/searchResult",
                 urlParams: {
@@ -533,4 +535,4 @@ define([ "require", "backbone", "hbs!tmpl/search/SearchLayoutView_tmpl", "utils/
         }
     });
     return SearchLayoutView;
-});
+});