Commit 71a30876 by pratik24mac Committed by nixonrodrigues

ATLAS-2282 : Saved favorite search appears only on refresh after creation when…

ATLAS-2282 : Saved favorite search appears only on refresh after creation when there are 25+ favorite searches . Signed-off-by: 's avatarnixonrodrigues <nixon@apache.org>
parent 5ba64a8b
...@@ -392,8 +392,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -392,8 +392,9 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (attrObj) { if (attrObj) {
_.each(attrObj, function(obj) { _.each(attrObj, function(obj) {
var type = (obj.type || obj.attributeType), var type = (obj.type || obj.attributeType),
value = _.trim(obj.value || obj.attributeValue), //obj.value will come as an object when selected type is Date and operator is isNull or not_null;
url = [(obj.id || obj.attributeName), mapApiOperatorToUI(obj.operator), (type === 'date' && formatedDateToLong ? Date.parse(value) : value)]; value = (_.isObject(obj.value) ? "" : _.trim(obj.value || obj.attributeValue)),
url = [(obj.id || obj.attributeName), mapApiOperatorToUI(obj.operator), (type === 'date' && formatedDateToLong && value.length ? Date.parse(value) : value)];
if (type) { if (type) {
url.push(type); url.push(type);
} }
...@@ -446,7 +447,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -446,7 +447,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (temp[3]) { if (temp[3]) {
finalObj['type'] = temp[3]; finalObj['type'] = temp[3];
} }
finalObj.value = finalObj.type === 'date' && formatDate ? moment(parseInt(finalObj.value)).format('MM/DD/YYYY h:mm A') : finalObj.value; finalObj.value = finalObj.type === 'date' && formatDate && finalObj.value.length ? moment(parseInt(finalObj.value)).format('MM/DD/YYYY h:mm A') : finalObj.value;
attrObj.push(finalObj); attrObj.push(finalObj);
}); });
return attrObj; return attrObj;
......
...@@ -125,6 +125,12 @@ define(['require', ...@@ -125,6 +125,12 @@ define(['require',
saveSearchAdvanceCollection = new VSearchList(), saveSearchAdvanceCollection = new VSearchList(),
saveSearchCollection = new VSearchList(); saveSearchCollection = new VSearchList();
saveSearchCollection.url = UrlLinks.saveSearchApiUrl(); saveSearchCollection.url = UrlLinks.saveSearchApiUrl();
saveSearchBaiscCollection.fullCollection.comparator = function(model) {
return model.get('name').toLowerCase();
}
saveSearchAdvanceCollection.fullCollection.comparator = function(model) {
return model.get('name').toLowerCase();
}
var obj = { var obj = {
value: that.value, value: that.value,
searchVent: that.searchVent, searchVent: that.searchVent,
...@@ -163,18 +169,18 @@ define(['require', ...@@ -163,18 +169,18 @@ define(['require',
} }
that.RSaveSearchBasic.show(new SaveSearchView(_.extend(obj, { that.RSaveSearchBasic.show(new SaveSearchView(_.extend(obj, {
isBasic: true, isBasic: true,
collection: saveSearchBaiscCollection collection: saveSearchBaiscCollection.fullCollection
}))); })));
that.RSaveSearchAdvance.show(new SaveSearchView(_.extend(obj, { that.RSaveSearchAdvance.show(new SaveSearchView(_.extend(obj, {
isBasic: false, isBasic: false,
collection: saveSearchAdvanceCollection collection: saveSearchAdvanceCollection.fullCollection
}))); })));
function fetchSaveSearchCollection() { function fetchSaveSearchCollection() {
saveSearchCollection.fetch({ saveSearchCollection.fetch({
success: function(collection, data) { success: function(collection, data) {
saveSearchAdvanceCollection.reset(_.where(data, { "searchType": "ADVANCED" })); saveSearchAdvanceCollection.fullCollection.reset(_.where(data, { "searchType": "ADVANCED" }));
saveSearchBaiscCollection.reset(_.where(data, { "searchType": "BASIC" })); saveSearchBaiscCollection.fullCollection.reset(_.where(data, { "searchType": "BASIC" }));
}, },
silent: true silent: true
}); });
......
...@@ -78,7 +78,7 @@ define(['require', ...@@ -78,7 +78,7 @@ define(['require',
}, },
bindEvents: function() { bindEvents: function() {
var that = this; var that = this;
this.listenTo(this.collection, "add reset error", function(model, collection) { this.listenTo(this.collection, "add reset error remove", function(model, collection) {
this.$('.fontLoader-relative').hide(); this.$('.fontLoader-relative').hide();
if (this.collection && this.collection.length) { if (this.collection && this.collection.length) {
this.$(".noFavoriteSearch").hide(); this.$(".noFavoriteSearch").hide();
...@@ -192,7 +192,7 @@ define(['require', ...@@ -192,7 +192,7 @@ define(['require',
wait: true, wait: true,
success: function(model, data) { success: function(model, data) {
if (that.collection) { if (that.collection) {
that.collection.remove(data); that.collection.remove(model);
} }
Utils.notifySuccess({ Utils.notifySuccess({
content: options.model.get('name') + Messages.deleteSuccessMessage content: options.model.get('name') + Messages.deleteSuccessMessage
......
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