okAttrFilterButton: function()

in dashboardv2/public/js/views/search/SearchLayoutView.js [493:554]


            okAttrFilterButton: function(e) {
                var that = this,
                    isTag = this.attrModal.tag ? true : false,
                    filtertype = isTag ? 'tagFilters' : 'entityFilters',
                    queryBuilderRef = this.attrModal.RQueryBuilder.currentView.ui.builder,
                    col = [];

                function getIdFromRuleObject(rule) {
                    _.map(rule.rules, function(obj, key) {
                        if (_.has(obj, 'condition')) {
                            return getIdFromRuleObject(obj);
                        } else {
                            return col.push(obj.id)
                        }
                    });
                    return col;
                }
                if (queryBuilderRef.data('queryBuilder')) {
                    var rule = queryBuilderRef.queryBuilder('getRules');
                }
                if (rule) {
                    var ruleUrl = CommonViewFunction.attributeFilter.generateUrl({ "value": rule, "formatedDateToLong": true });
                    this.searchTableFilters[filtertype][(isTag ? this.value.tag : this.value.type)] = ruleUrl;
                    this.makeFilterButtonActive(filtertype);
                    if (!isTag && this.value && this.value.type && this.searchTableColumns) {
                        if (!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 (rule.rules) {
                        if (!isTag && !that.tagEntityCheck) {
                            var state = _.find(rule.rules, { id: "__state" });
                            if (state) {
                                that.typeEntityCheck = (state.value === "ACTIVE" && state.operator === "=") || (state.value === "DELETED" && state.operator === "!=") ? false : true;
                                that.value.includeDE = that.typeEntityCheck;
                            } else if (that.typeEntityCheck) {
                                that.typeEntityCheck = false;
                                if (!that.tagEntityCheck) {
                                    that.value.includeDE = false;
                                }
                            }
                        }
                        if (isTag && !that.typeEntityCheck) {
                            var entityStatus = _.find(rule.rules, { id: "__entityStatus" });
                            if (entityStatus) {
                                that.tagEntityCheck = (entityStatus.value === "ACTIVE" && entityStatus.operator === "=") || (entityStatus.value === "DELETED" && entityStatus.operator === "!=") ? false : true;
                                that.value.includeDE = that.tagEntityCheck
                            } else if (that.tagEntityCheck) {
                                that.tagEntityCheck = false;
                                if (!that.typeEntityCheck) {
                                    that.value.includeDE = false;
                                }
                            }
                        }
                    }
                    this.attrModal.modal.close();
                    if ($(e.currentTarget).hasClass('search')) {
                        this.findSearchResult();
                    }
                }
            },