checkForButtonVisiblity: function()

in dashboardv2/public/js/views/search/RelationSearchLayoutView.js [186:241]


            checkForButtonVisiblity: function(e, options) {
                var isBasicSearch = true;
                this.ui.relationshipAttrFilter.prop('disabled', true);
                if (e && e.currentTarget) {
                    var $el = $(e.currentTarget),
                        isRelationshipEl = $el.data('id') == "relationshipLOV",
                        select2Data = $el.select2('data');
                    if (e.type === "change" && select2Data) {
                        var value = _.first($(this.ui.relationshipLov).select2('data')).id,
                            key = "relationshipName",
                            filterType = "relationshipFilters";
                        value = value && value.length ? value : null;
                        if (this.value) {
                            //On Change handle
                            if (this.value[key] !== value || (!value && !this.value[key])) {
                                var temp = {};
                                temp[key] = value;
                                _.extend(this.value, temp);
                                if (_.isUndefined(options)) {
                                    this.value.pageOffset = 0;
                                }
                            } else if (isBasicSearch) {
                                // Initial loading handle.
                                if (filterType) {
                                    var filterObj = this.searchTableFilters[filterType];
                                    if (filterObj && this.value[key]) {
                                        this.searchTableFilters[filterType][this.value[key]] = this.value[filterType] ? this.value[filterType] : null;
                                    }
                                }
                                if (this.value.relationshipName) {
                                    if (this.value.attributes) {
                                        var attributes = _.sortBy(this.value.attributes.split(',')),
                                            tableColumn = this.searchTableColumns[this.value.type];
                                        if (_.isEmpty(this.searchTableColumns) || !tableColumn) {
                                            this.searchTableColumns[this.value.relationshipName] = attributes
                                        } else if (tableColumn.join(",") !== attributes.join(",")) {
                                            this.searchTableColumns[this.value.relationshipName] = attributes;
                                        }
                                    } else if (this.searchTableColumns[this.value.relationshipName]) {
                                        this.searchTableColumns[this.value.relationshipName] = undefined;
                                    }
                                }
                            }
                            if (isBasicSearch && filterType) {
                                this.makeFilterButtonActive();
                            }
                        }
                    }
                }
                var value = this.ui.relationshipLov.val();
                if (value && value.length) {
                    this.ui.searchBtn.removeAttr("disabled");
                } else {
                    this.ui.searchBtn.attr("disabled", "true");
                }
            },