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
if (attrObj) {
_.each(attrObj, function(obj) {
var type = (obj.type || obj.attributeType),
value = _.trim(obj.value || obj.attributeValue),
url = [(obj.id || obj.attributeName), mapApiOperatorToUI(obj.operator), (type === 'date' && formatedDateToLong ? Date.parse(value) : value)];
//obj.value will come as an object when selected type is Date and operator is isNull or not_null;
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) {
url.push(type);
}
......@@ -446,7 +447,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (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);
});
return attrObj;
......
......@@ -125,6 +125,12 @@ define(['require',
saveSearchAdvanceCollection = new VSearchList(),
saveSearchCollection = new VSearchList();
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 = {
value: that.value,
searchVent: that.searchVent,
......@@ -163,18 +169,18 @@ define(['require',
}
that.RSaveSearchBasic.show(new SaveSearchView(_.extend(obj, {
isBasic: true,
collection: saveSearchBaiscCollection
collection: saveSearchBaiscCollection.fullCollection
})));
that.RSaveSearchAdvance.show(new SaveSearchView(_.extend(obj, {
isBasic: false,
collection: saveSearchAdvanceCollection
collection: saveSearchAdvanceCollection.fullCollection
})));
function fetchSaveSearchCollection() {
saveSearchCollection.fetch({
success: function(collection, data) {
saveSearchAdvanceCollection.reset(_.where(data, { "searchType": "ADVANCED" }));
saveSearchBaiscCollection.reset(_.where(data, { "searchType": "BASIC" }));
saveSearchAdvanceCollection.fullCollection.reset(_.where(data, { "searchType": "ADVANCED" }));
saveSearchBaiscCollection.fullCollection.reset(_.where(data, { "searchType": "BASIC" }));
},
silent: true
});
......
......@@ -78,7 +78,7 @@ define(['require',
},
bindEvents: function() {
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();
if (this.collection && this.collection.length) {
this.$(".noFavoriteSearch").hide();
......@@ -192,7 +192,7 @@ define(['require',
wait: true,
success: function(model, data) {
if (that.collection) {
that.collection.remove(data);
that.collection.remove(model);
}
Utils.notifySuccess({
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