Commit 7435801a by kevalbhatt

ATLAS-3446:UI: Regression: Attribute filter buttons are highlighted by default

parent 5dffddd0
...@@ -102,18 +102,18 @@ define(['require', ...@@ -102,18 +102,18 @@ define(['require',
pageLimit: this.value ? this.value.pageLimit : null pageLimit: this.value ? this.value.pageLimit : null
}, },
basic: { basic: {
query: this.value ? this.value.query: null, query: this.value ? this.value.query : null,
type: this.value ? this.value.type: null, type: this.value ? this.value.type : null,
tag: this.value ? this.value.tag: null, tag: this.value ? this.value.tag : null,
term: this.value ? this.value.term: null, term: this.value ? this.value.term : null,
attributes: this.value ? this.value.attributes: null, attributes: this.value ? this.value.attributes : null,
tagFilters: this.value ? this.value.tagFilters: null, tagFilters: this.value ? this.value.tagFilters : null,
pageOffset: this.value ? this.value.pageOffset: null, pageOffset: this.value ? this.value.pageOffset : null,
pageLimit: this.value ? this.value.pageLimit: null, pageLimit: this.value ? this.value.pageLimit : null,
entityFilters: this.value ? this.value.entityFilters: null, entityFilters: this.value ? this.value.entityFilters : null,
includeDE: this.value ? this.value.includeDE: null, includeDE: this.value ? this.value.includeDE : null,
excludeST: this.value ? this.value.excludeST: null, excludeST: this.value ? this.value.excludeST : null,
excludeSC: this.value ? this.value.excludeSC: null excludeSC: this.value ? this.value.excludeSC : null
} }
}; };
if (!this.value) { if (!this.value) {
...@@ -263,7 +263,7 @@ define(['require', ...@@ -263,7 +263,7 @@ define(['require',
isTypeEl = $el.data('id') == "typeLOV", isTypeEl = $el.data('id') == "typeLOV",
select2Data = $el.select2('data'); select2Data = $el.select2('data');
if (e.type == "change" && select2Data) { if (e.type == "change" && select2Data) {
var value = (_.isEmpty(select2Data) ? select2Data : _.first(select2Data).id) || this.value.tag, var value = (_.isEmpty(select2Data) ? select2Data : _.first(select2Data).id),
key = "tag", key = "tag",
filterType = isBasicSearch ? 'tagFilters' : null, filterType = isBasicSearch ? 'tagFilters' : null,
value = value && value.length ? value : null; value = value && value.length ? value : null;
...@@ -486,7 +486,9 @@ define(['require', ...@@ -486,7 +486,9 @@ define(['require',
var isTypeOnly = options && options.isTypeOnly; var isTypeOnly = options && options.isTypeOnly;
this.ui.typeLov.empty(); this.ui.typeLov.empty();
var typeStr = '<option></option>', var typeStr = '<option></option>',
tagStr = typeStr; tagStr = typeStr,
foundNewClassification = false,
optionsValue = this.options.value;
this.typeHeaders.fullCollection.each(function(model) { this.typeHeaders.fullCollection.each(function(model) {
var name = Utils.getName(model.toJSON(), 'name'); var name = Utils.getName(model.toJSON(), 'name');
if (model.get('category') == 'ENTITY' && (serviceTypeToBefiltered && serviceTypeToBefiltered.length ? _.contains(serviceTypeToBefiltered, model.get('serviceType')) : true)) { if (model.get('category') == 'ENTITY' && (serviceTypeToBefiltered && serviceTypeToBefiltered.length ? _.contains(serviceTypeToBefiltered, model.get('serviceType')) : true)) {
...@@ -495,9 +497,21 @@ define(['require', ...@@ -495,9 +497,21 @@ define(['require',
} }
if (isTypeOnly == undefined && model.get('category') == 'CLASSIFICATION') { if (isTypeOnly == undefined && model.get('category') == 'CLASSIFICATION') {
var tagEntityCount = that.entityCountObj.tag.tagEntities[name]; var tagEntityCount = that.entityCountObj.tag.tagEntities[name];
if (optionsValue) { // to check if wildcard classification is present in our data
if (name === optionsValue.tag) {
foundNewClassification = true;
}
}
tagStr += '<option value="' + (name) + '" data-name="' + (name) + '">' + (name) + ' ' + (tagEntityCount ? "(" + _.numberFormatWithComa(tagEntityCount) + ")" : '') + '</option>'; tagStr += '<option value="' + (name) + '" data-name="' + (name) + '">' + (name) + ' ' + (tagEntityCount ? "(" + _.numberFormatWithComa(tagEntityCount) + ")" : '') + '</option>';
} }
}); });
if (!foundNewClassification && optionsValue) {
if (optionsValue.tag) {
var classificationValue = decodeURIComponent(optionsValue.tag);
tagStr += '<option value="' + (classificationValue) + '" data-name="' + (classificationValue) + '">' + classificationValue + '</option>';
}
}
if (_.isUndefined(isTypeOnly)) { if (_.isUndefined(isTypeOnly)) {
//to insert extra classification list //to insert extra classification list
_.each(Enums.addOnClassification, function(classificationName) { _.each(Enums.addOnClassification, function(classificationName) {
...@@ -595,30 +609,26 @@ define(['require', ...@@ -595,30 +609,26 @@ define(['require',
this.ui.searchType.prop("checked", false).trigger("change"); this.ui.searchType.prop("checked", false).trigger("change");
} }
} }
if (this.value.type) { this.ui.typeLov.val(this.value.type);
this.ui.typeLov.val(this.value.type); if (this.ui.typeLov.data('select2')) {
if (this.ui.typeLov.data('select2')) { if (this.ui.typeLov.val() !== this.value.type) {
if (this.ui.typeLov.val() !== this.value.type) { this.value.type = null;
this.value.type = null; this.ui.typeLov.val("").trigger("change", { 'manual': true });
this.ui.typeLov.val("").trigger("change", { 'manual': true }); } else {
} else { this.ui.typeLov.trigger("change", { 'manual': true });
this.ui.typeLov.trigger("change", { 'manual': true });
}
} }
} }
if (!this.dsl) { if (!this.dsl) {
if (this.value.tag) { this.ui.tagLov.val(this.value.tag);
this.ui.tagLov.val(this.value.tag); if (this.ui.tagLov.data('select2')) {
if (this.ui.tagLov.data('select2')) { // To handle delete scenario.
// To handle delete scenario. if (this.ui.tagLov.val() !== this.value.tag) {
if (this.ui.tagLov.val() !== this.value.tag) { this.value.tag = null;
// this.value.tag = null; this.ui.tagLov.val("").trigger("change", { 'manual': true });
this.ui.tagLov.val("").trigger("change", { 'manual': true }); } else {
} else { this.ui.tagLov.trigger("change", { 'manual': true });
this.ui.tagLov.trigger("change", { 'manual': true });
}
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment