Commit adfc526e by kevalbhatt

ATLAS-3449: UI : Beta UI : Invalid Filter validation case for classification

parent 7ba3213e
...@@ -124,6 +124,8 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa ...@@ -124,6 +124,8 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
initialize: function(options) { initialize: function(options) {
_.extend(this.options, options); _.extend(this.options, options);
this.hidenFilter = false; this.hidenFilter = false;
this.tagAttributeLength = 0;
this.entityAttributeLength = 0;
}, },
bindEvents: function() {}, bindEvents: function() {},
onRender: function() { onRender: function() {
...@@ -138,34 +140,13 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa ...@@ -138,34 +140,13 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
var filters = CommonViewFunction.attributeFilter.extractUrl({ "value": isTag ? this.options.value.tagFilters : this.options.value.entityFilters, "formatDate": true }), var filters = CommonViewFunction.attributeFilter.extractUrl({ "value": isTag ? this.options.value.tagFilters : this.options.value.entityFilters, "formatDate": true }),
rules = filters.rules, rules = filters.rules,
filtertype = isTag ? "tagFilters" : "entityFilters", filtertype = isTag ? "tagFilters" : "entityFilters",
that = this, that = this;
col = [];
function getIdFromRuleObject(rule) {
_.map(rule.rules, function(obj, key) {
if (_.has(obj, "condition")) {
return getIdFromRuleObject(obj);
} else {
return col.push(obj.id);
}
});
return col;
}
filters.rules = _.filter(rules, function(obj, key) { filters.rules = _.filter(rules, function(obj, key) {
return obj.id != $(e.currentTarget).data("id"); return obj.id != $(e.currentTarget).data("id");
}); });
if (filters) { if (filters) {
var ruleUrl = CommonViewFunction.attributeFilter.generateUrl({ value: filters, formatedDateToLong: true }); that.updateFilterOptions(filters, filtertype, isTag);
that.options.searchTableFilters[filtertype][isTag ? that.options.value.tag : that.options.value.type] = ruleUrl;
//this.makeFilterButtonActive(filtertype);
if (!isTag && that.options.value && that.options.value.type && that.options.searchTableColumns) {
if (!that.options.searchTableColumns[that.options.value.type]) {
that.options.searchTableColumns[that.options.value.type] = ["selected", "name", "owner", "description", "tag", "typeName"];
}
that.options.searchTableColumns[that.options.value.type] = _.sortBy(_.union(that.options.searchTableColumns[that.options.value.type], getIdFromRuleObject(filters)));
}
} else {
} }
if (filters.rules.length == 0) { if (filters.rules.length == 0) {
if (isTag) { if (isTag) {
...@@ -262,101 +243,106 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa ...@@ -262,101 +243,106 @@ define(["require", "backbone", "utils/Globals", "hbs!tmpl/search/SearchDefaultLa
if (that.options.value.tag) { if (that.options.value.tag) {
this.ui.classificationRegion.show(); this.ui.classificationRegion.show();
// this.ui.entityRegion.hide(); // this.ui.entityRegion.hide();
var attrObj = that.options.classificationDefCollection.fullCollection.find({ name: that.options.value.tag }); var attrTagObj = that.options.classificationDefCollection.fullCollection.find({ name: that.options.value.tag });
if (attrObj) { if (attrTagObj) {
attrObj = Utils.getNestedSuperTypeObj({ attrTagObj = Utils.getNestedSuperTypeObj({
data: attrObj.toJSON(), data: attrTagObj.toJSON(),
collection: that.options.classificationDefCollection, collection: that.options.classificationDefCollection,
attrMerge: true, attrMerge: true,
}); });
this.tagAttributeLength = attrTagObj.length;
} }
this.renderQueryBuilder(_.extend({}, obj, { this.renderQueryBuilder(_.extend({}, obj, {
tag: true, tag: true,
type: false, type: false,
attrObj: attrObj attrObj: attrTagObj
}), this.RQueryBuilderClassification); }), this.RQueryBuilderClassification);
this.ui.classificationName.html(that.options.value.tag); this.ui.classificationName.html(that.options.value.tag);
} }
if (that.options.value.type) { if (that.options.value.type) {
this.ui.entityRegion.show(); this.ui.entityRegion.show();
var attrObj = that.options.entityDefCollection.fullCollection.find({ name: that.options.value.type }); var attrTypeObj = that.options.entityDefCollection.fullCollection.find({ name: that.options.value.type });
if (attrObj) { if (attrTypeObj) {
attrObj = Utils.getNestedSuperTypeObj({ attrTypeObj = Utils.getNestedSuperTypeObj({
data: attrObj.toJSON(), data: attrTypeObj.toJSON(),
collection: that.options.entityDefCollection, collection: that.options.entityDefCollection,
attrMerge: true attrMerge: true
}); });
this.entityAttributeLength = attrTypeObj.length;
} }
this.renderQueryBuilder(_.extend({}, obj, { this.renderQueryBuilder(_.extend({}, obj, {
tag: false, tag: false,
type: true, type: true,
attrObj: attrObj attrObj: attrTypeObj
}), this.RQueryBuilderEntity); }), this.RQueryBuilderEntity);
this.ui.entityName.html(that.options.value.type); this.ui.entityName.html(that.options.value.type);
} }
}, },
okAttrFilterButton: function(e) { okAttrFilterButton: function(e) {
// var isTag = this.attrModal.tag ? true : false,
var isTag, var isTag,
filtertype, filtertype,
queryBuilderRef, queryBuilderRef,
col = [], isFilterValidate = true,
that = this; that = this;
if (this.options.value.tag) { if (this.options.value.tag) {
isTag = true; isTag = true;
filtertype = isTag ? "tagFilters" : "entityFilters"; filtertype = isTag ? "tagFilters" : "entityFilters";
if (this.tagAttributeLength !== 0) {
queryBuilderRef = this.RQueryBuilderClassification.currentView.ui.builder; queryBuilderRef = this.RQueryBuilderClassification.currentView.ui.builder;
searchAttribute(); searchAttribute();
}
} }
if (this.options.value.type) { if (this.options.value.type) {
isTag = false; isTag = false;
filtertype = isTag ? "tagFilters" : "entityFilters"; filtertype = isTag ? "tagFilters" : "entityFilters";
if (this.entityAttributeLength !== 0) {
queryBuilderRef = this.RQueryBuilderEntity.currentView.ui.builder; queryBuilderRef = this.RQueryBuilderEntity.currentView.ui.builder;
searchAttribute(); searchAttribute();
} }
function getIdFromRuleObject(rule) {
_.map(rule.rules, function(obj, key) {
if (_.has(obj, "condition")) {
return getIdFromRuleObject(obj);
} else {
return col.push(obj.id);
}
});
return col;
} }
filterPopupStatus();
function searchAttribute() { function searchAttribute() {
if (queryBuilderRef.data("queryBuilder")) { if (queryBuilderRef.data("queryBuilder")) {
var rule = queryBuilderRef.queryBuilder("getRules"); var rule = queryBuilderRef.queryBuilder("getRules");
} }
if (rule) { rule ? that.updateFilterOptions(rule, filtertype, isTag) : isFilterValidate = false;
var ruleUrl = CommonViewFunction.attributeFilter.generateUrl({ value: rule, formatedDateToLong: true });
that.options.searchTableFilters[filtertype][isTag ? that.options.value.tag : that.options.value.type] = ruleUrl;
//this.makeFilterButtonActive(filtertype);
if (!isTag && that.options.value && that.options.value.type && that.options.searchTableColumns) {
if (!that.options.searchTableColumns[that.options.value.type]) {
that.options.searchTableColumns[that.options.value.type] = ["selected", "name", "owner", "description", "tag", "typeName"];
}
that.options.searchTableColumns[that.options.value.type] = _.sortBy(_.union(that.options.searchTableColumns[that.options.value.type], getIdFromRuleObject(rule)));
} }
function filterPopupStatus() {
if (isFilterValidate) {
if ($(e.currentTarget).hasClass("search")) { if ($(e.currentTarget).hasClass("search")) {
// this.$('.attribute-filter-container').hide();
// that.$('.fa-chevron-right').toggleClass('fa-chevron-down');
that.$('.fa-angle-right').toggleClass('fa-angle-down'); that.$('.fa-angle-right').toggleClass('fa-angle-down');
that.$('.attribute-filter-container, .attr-filter-overlay').toggleClass('hide'); that.$('.attribute-filter-container, .attr-filter-overlay').toggleClass('hide');
that.searchAttrFilter(); that.searchAttrFilter();
that.$('.attributeResultContainer').removeClass("overlay"); that.$('.attributeResultContainer').removeClass("overlay");
//console.log('Done')
} }
} }
} }
}, },
getIdFromRuleObj: function(rule) {
var col = []
_.map(rule.rules, function(obj, key) {
if (_.has(obj, "condition")) {
return this.getIdFromRuleObj(obj);
} else {
return col.push(obj.id);
}
});
return col;
},
updateFilterOptions: function(rule, filtertype, isTag) {
var ruleUrl = CommonViewFunction.attributeFilter.generateUrl({ value: rule, formatedDateToLong: true });
this.options.searchTableFilters[filtertype][isTag ? this.options.value.tag : this.options.value.type] = ruleUrl;
if (!isTag && this.options.value && this.options.value.type && this.options.searchTableColumns) {
if (!this.options.searchTableColumns[this.options.value.type]) {
this.options.searchTableColumns[this.options.value.type] = ["selected", "name", "owner", "description", "tag", "typeName"];
}
this.options.searchTableColumns[this.options.value.type] = _.sortBy(_.union(this.options.searchTableColumns[this.options.value.type], this.getIdFromRuleObj(rule)));
}
},
renderQueryBuilder: function(obj, rQueryBuilder) { renderQueryBuilder: function(obj, rQueryBuilder) {
var that = this; var that = this;
require(['views/search/QueryBuilderView'], function(QueryBuilderView) { require(['views/search/QueryBuilderView'], function(QueryBuilderView) {
......
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