Commit a6fdfbb7 by pratik pandey Committed by Madhan Neethiraj

ATLAS-2285 : UI fix in handling of date attributes during saved searche rename

parent d569e538
......@@ -259,8 +259,8 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
return '<div class="tagList btn-inline btn-fixed-width">' + atags + addTag + '</div>';
}
CommonViewFunction.generateQueryOfFilter = function(value) {
var entityFilters = CommonViewFunction.attributeFilter.extractUrl(value.entityFilters),
tagFilters = CommonViewFunction.attributeFilter.extractUrl(value.tagFilters),
var entityFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.entityFilters, "formatDate": true }),
tagFilters = CommonViewFunction.attributeFilter.extractUrl({ "value": value.tagFilters, "formatDate": true }),
queryArray = [],
objToString = function(filterObj) {
var tempObj = [];
......@@ -348,14 +348,12 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
_.each(val.criterion, function(obj) {
var attributeDef = _.findWhere(attributeDefs, { 'name': obj.attributeName });
if (attributeDef) {
if (attributeDef.typeName == "date") {
obj.attributeValue = moment(parseInt(obj.attributeValue)).format('MM/DD/YYYY h:mm A');
}
obj.attributeValue = obj.attributeValue;
obj['attributeType'] = attributeDef.typeName;
}
});
}
val = CommonViewFunction.attributeFilter.generateUrl(val.criterion);
val = CommonViewFunction.attributeFilter.generateUrl({ "value": val.criterion });
} else if (k == "entityFilters") {
if (entityDefCollection) {
var entityDef = entityDefCollection.fullCollection.findWhere({ 'name': value.typeName }),
......@@ -367,14 +365,12 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
_.each(val.criterion, function(obj) {
var attributeDef = _.findWhere(attributeDefs, { 'name': obj.attributeName });
if (attributeDef) {
if (attributeDef.typeName == "date") {
obj.attributeValue = moment(parseInt(obj.attributeValue)).format('MM/DD/YYYY h:mm A');
}
obj.attributeValue = obj.attributeValue;
obj['attributeType'] = attributeDef.typeName;
}
});
}
val = CommonViewFunction.attributeFilter.generateUrl(val.criterion);
val = CommonViewFunction.attributeFilter.generateUrl({ "value": val.criterion });
} else if (k == "includeDE") {
if (val) {
val = false;
......@@ -389,12 +385,15 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
}
}
CommonViewFunction.attributeFilter = {
generateUrl: function(attrObj) {
var attrQuery = [];
generateUrl: function(options) {
var attrQuery = [],
attrObj = options.value,
formatedDateToLong = options.formatedDateToLong;
if (attrObj) {
_.each(attrObj, function(obj) {
var url = [(obj.id || obj.attributeName), mapApiOperatorToUI(obj.operator), _.trim(obj.value || obj.attributeValue)],
type = (obj.type || obj.attributeType);
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)];
if (type) {
url.push(type);
}
......@@ -436,8 +435,10 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
return oper;
}
},
extractUrl: function(urlObj) {
var attrObj = [];
extractUrl: function(options) {
var attrObj = [],
urlObj = options.value,
formatDate = options.formatDate;
if (urlObj && urlObj.length) {
_.each(urlObj.split(":,:"), function(obj) {
var temp = obj.split("::");
......@@ -445,6 +446,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;
attrObj.push(finalObj);
});
return attrObj;
......@@ -456,7 +458,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
if (url && url.length) {
var parsObj = {
"condition": 'AND',
"criterion": convertKeyAndExtractObj(this.extractUrl(url))
"criterion": convertKeyAndExtractObj(this.extractUrl({ "value": url }))
}
return parsObj;
} else {
......@@ -470,7 +472,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
tempObj = {
"attributeName": rulObj.id,
"operator": mapUiOperatorToAPI(rulObj.operator),
"attributeValue": _.trim(rulObj.type === "date" ? Date.parse(rulObj.value) : rulObj.value)
"attributeValue": _.trim(rulObj.value)
}
convertObj.push(tempObj);
});
......
......@@ -137,7 +137,7 @@ define(['require',
var that = this,
filters = [];
if (this.value) {
var rules_widgets = CommonViewFunction.attributeFilter.extractUrl(this.searchTableFilters[this.filterType][(this.tag ? this.value.tag : this.value.type)]);
var rules_widgets = CommonViewFunction.attributeFilter.extractUrl({ "value": this.searchTableFilters[this.filterType][(this.tag ? this.value.tag : this.value.type)], "formatDate": true });
}
_.each(this.attrObj, function(obj) {
var returnObj = that.getObjDef(obj, rules_widgets);
......
......@@ -396,7 +396,7 @@ define(['require',
var rule = queryBuilderRef.queryBuilder('getRules');
}
if (rule) {
var ruleUrl = CommonViewFunction.attributeFilter.generateUrl(rule.rules);
var ruleUrl = CommonViewFunction.attributeFilter.generateUrl({ "value": rule.rules, "formatedDateToLong": true });
this.searchTableFilters[filtertype][(isTag ? this.value.tag : this.value.type)] = ruleUrl;
this.makeFilterButtonActive(filtertype);
if (!isTag && this.value && this.value.type && this.searchTableColumns) {
......
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