in dashboardv2/public/js/views/search/SearchLayoutView.js [308:385]
checkForButtonVisiblity: function(e, options) {
var that = this,
isBasicSearch = (this.type == "basic");
if (e && e.currentTarget) {
var $el = $(e.currentTarget),
isTagEl = $el.data('id') == "tagLOV",
isTermEl = $el.data('id') == "termLOV",
isTypeEl = $el.data('id') == "typeLOV",
select2Data = $el.select2('data');
if (e.type == "change" && 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");
if (isBasicSearch) {
filterType = (isTypeEl ? "entityFilters" : 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);
// on change of type/tag change the offset.
if (_.isUndefined(options)) {
this.value.pageOffset = 0;
}
_.extend(this.query[this.type], temp);
} 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.type) {
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.type] = attributes
} else if (tableColumn.join(",") !== attributes.join(",")) {
this.searchTableColumns[this.value.type] = attributes;
}
} else if (this.searchTableColumns[this.value.type]) {
this.searchTableColumns[this.value.type] = undefined;
}
}
}
if (isBasicSearch && filterType) {
this.makeFilterButtonActive(filterType);
}
} else if (isBasicSearch) {
this.ui.tagAttrFilter.prop('disabled', true);
this.ui.typeAttrFilter.prop('disabled', true);
}
}
}
var value = this.ui.searchInput.val() || _.first($(this.ui.typeLov).select2('data')).id;
if (!this.dsl && _.isEmpty(value)) {
var termData = _.first($(this.ui.termLov).select2('data'));
value = _.first($(this.ui.tagLov).select2('data')).id || (termData ? termData.id : "");
}
if (value && value.length) {
this.ui.searchBtn.removeAttr("disabled");
setTimeout(function() {
that.ui.searchInput.focus();
}, 0);
} else {
this.ui.searchBtn.attr("disabled", "true");
}
},