Commit f511f272 by kevalbhatt Committed by Madhan Neethiraj

ATLAS-1967: search UI - render attribute filter based on browser URL

parent 62d85a4c
...@@ -29,7 +29,7 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb ...@@ -29,7 +29,7 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb
this.trigger('closeModal'); this.trigger('closeModal');
if (this.options.content && this.options.content.trigger) { if (this.options.content && this.options.content.trigger) {
this.options.content.trigger('closeModal', this); this.options.content.trigger('closeModal', this, event);
} }
}, },
'click .cancel': function(event) { 'click .cancel': function(event) {
...@@ -38,7 +38,7 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb ...@@ -38,7 +38,7 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb
this.trigger('closeModal'); this.trigger('closeModal');
if (this.options.content && this.options.content.trigger) { if (this.options.content && this.options.content.trigger) {
this.options.content.trigger('closeModal', this); this.options.content.trigger('closeModal', this, event);
} }
}, },
'click .ok': function(event) { 'click .ok': function(event) {
...@@ -47,7 +47,7 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb ...@@ -47,7 +47,7 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb
this.trigger('ok'); this.trigger('ok');
if (this.options.content && this.options.content.trigger) { if (this.options.content && this.options.content.trigger) {
this.options.content.trigger('ok', this); this.options.content.trigger('ok', this, event);
} }
if (this.options.okCloses) { if (this.options.okCloses) {
...@@ -85,7 +85,8 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb ...@@ -85,7 +85,8 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb
animate: true, animate: true,
contentWithFooter: false, contentWithFooter: false,
template: template, template: template,
width: null width: null,
buttons: null
}, options); }, options);
}, },
......
...@@ -53,10 +53,6 @@ define([ ...@@ -53,10 +53,6 @@ define([
'enumDefCollection': this.enumDefCollection, 'enumDefCollection': this.enumDefCollection,
'classificationDefCollection': this.classificationDefCollection 'classificationDefCollection': this.classificationDefCollection
} }
this.filterObj = {
'tagFilters': JSON.parse(Utils.localStorage.getValue('tagFilters')),
'entityFilters': JSON.parse(Utils.localStorage.getValue('entityFilters'))
}
}, },
bindCommonEvents: function() { bindCommonEvents: function() {
var that = this; var that = this;
...@@ -128,8 +124,7 @@ define([ ...@@ -128,8 +124,7 @@ define([
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView( App.rSideNav.show(new SideNavLayoutView(
_.extend({ _.extend({
'url': url, 'url': url
'filterObj': that.filterObj
}, that.preFetchedCollectionLists) }, that.preFetchedCollectionLists)
)); ));
} else { } else {
...@@ -161,7 +156,7 @@ define([ ...@@ -161,7 +156,7 @@ define([
App.rNHeader.show(new Header()); App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView( App.rSideNav.show(new SideNavLayoutView(
_.extend({ 'filterObj': that.filterObj }, that.preFetchedCollectionLists) _.extend({}, that.preFetchedCollectionLists)
)); ));
} else { } else {
App.rSideNav.currentView.selectTab(); App.rSideNav.currentView.selectTab();
...@@ -198,8 +193,7 @@ define([ ...@@ -198,8 +193,7 @@ define([
} }
App.rSideNav.show(new SideNavLayoutView( App.rSideNav.show(new SideNavLayoutView(
_.extend({ _.extend({
'tag': tagName, 'tag': tagName
'filterObj': that.filterObj
}, that.preFetchedCollectionLists) }, that.preFetchedCollectionLists)
)); ));
} else { } else {
...@@ -242,8 +236,7 @@ define([ ...@@ -242,8 +236,7 @@ define([
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView( App.rSideNav.show(new SideNavLayoutView(
_.extend({ _.extend({
'searchVent': that.searchVent, 'searchVent': that.searchVent
'filterObj': that.filterObj
}, that.preFetchedCollectionLists) }, that.preFetchedCollectionLists)
)); ));
} else { } else {
...@@ -259,7 +252,6 @@ define([ ...@@ -259,7 +252,6 @@ define([
_.extend({ _.extend({
'value': paramObj, 'value': paramObj,
'initialView': true, 'initialView': true,
'filterObj': that.filterObj,
'searchVent': that.searchVent 'searchVent': that.searchVent
}, that.preFetchedCollectionLists) }, that.preFetchedCollectionLists)
)); ));
...@@ -277,39 +269,13 @@ define([ ...@@ -277,39 +269,13 @@ define([
'views/business_catalog/SideNavLayoutView', 'views/business_catalog/SideNavLayoutView',
'views/search/SearchDetailLayoutView' 'views/search/SearchDetailLayoutView'
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) { ], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams(), var paramObj = Utils.getUrlState.getQueryParams();
filterObj = that.filterObj
if (paramObj && paramObj.searchType === "basic") {
if (paramObj.type) {
if (_.has(filterObj.entityFilters, paramObj.type)) {
_.extend(paramObj, {
'entityFilters': +new Date()
})
}
}
if (paramObj.tag) {
if (_.has(filterObj.entityFilters, paramObj.type)) {
_.extend(paramObj, {
'tagFilters': +new Date()
})
}
}
Utils.setUrl({
url: '#!/search/searchResult',
trigger: false,
urlParams: paramObj,
updateTabState: function() {
return { searchUrl: this.url, stateChanged: true };
},
});
}
App.rNHeader.show(new Header()); App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) { if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView( App.rSideNav.show(new SideNavLayoutView(
_.extend({ _.extend({
'value': paramObj, 'value': paramObj,
'searchVent': that.searchVent, 'searchVent': that.searchVent
'filterObj': that.filterObj
}, that.preFetchedCollectionLists) }, that.preFetchedCollectionLists)
)); ));
} else { } else {
...@@ -320,7 +286,6 @@ define([ ...@@ -320,7 +286,6 @@ define([
_.extend({ _.extend({
'value': paramObj, 'value': paramObj,
'searchVent': that.searchVent, 'searchVent': that.searchVent,
'filterObj': that.filterObj,
'initialView': (paramObj.type || (paramObj.dslChecked == "true" ? "" : paramObj.tag) || (paramObj.query ? paramObj.query.trim() : "")).length === 0 'initialView': (paramObj.type || (paramObj.dslChecked == "true" ? "" : paramObj.tag) || (paramObj.query ? paramObj.query.trim() : "")).length === 0
}, that.preFetchedCollectionLists) }, that.preFetchedCollectionLists)
)); ));
......
...@@ -31,10 +31,13 @@ ...@@ -31,10 +31,13 @@
<div class="modal-body">{{content}}</div> <div class="modal-body">{{content}}</div>
{{#if showFooter}} {{#if showFooter}}
<div class="modal-footer"> <div class="modal-footer">
{{#if allowCancel}} {{#if cancelText}} {{#if buttons}} {{#each buttons}}
<button type="button" class="btn btn-atlas {{this.btnClass}}">{{this.text}}</button>
{{/each}} {{else}} {{#if allowCancel}} {{#if cancelText}}
<button type="button" class="btn btn-atlas cancel">{{tt cancelText}}</button> <button type="button" class="btn btn-atlas cancel">{{tt cancelText}}</button>
{{/if}} {{/if}} {{/if}} {{/if}}
<button type="button" class="btn btn-atlas ok">{{tt okText}}</button> <button type="button" class="btn btn-atlas ok">{{tt okText}}</button>
{{/if}}
</div> </div>
{{/if}} {{/if}} {{/if}} {{/if}}
</div> </div>
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
<select data-id="typeLOV"></select> <select data-id="typeLOV"></select>
</div> </div>
<div class="col-sm-2 no-padding temFilterBtn"> <div class="col-sm-2 no-padding temFilterBtn">
<button type="button" class="btn btn-atlasAction btn-atlas pull-right typeLOV" title="Entity Attribute Filter" data-id="typeAttrFilter"><i class="fa fa-filter"></i></button> <button type="button" class="btn btn-atlasAction btn-atlas pull-right typeLOV active" title="Entity Attribute Filter" data-id="typeAttrFilter"><i class="fa fa-filter"></i></button>
</div> </div>
</div> </div>
</div> </div>
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
<select data-id="tagLOV"></select> <select data-id="tagLOV"></select>
</div> </div>
<div class="col-sm-2 no-padding"> <div class="col-sm-2 no-padding">
<button type="button" class="btn btn-atlasAction btn-atlas pull-right" title="Tag Attribute Filter" data-id="tagAttrFilter"><i class="fa fa-filter"></i></button> <button type="button" class="btn btn-atlasAction btn-atlas pull-right active" title="Tag Attribute Filter" data-id="tagAttrFilter"><i class="fa fa-filter"></i></button>
</div> </div>
</div> </div>
</div> </div>
......
...@@ -20,21 +20,6 @@ ...@@ -20,21 +20,6 @@
<div class="fontLoader"> <div class="fontLoader">
<i class="fa fa-refresh fa-spin-custom"></i> <i class="fa fa-refresh fa-spin-custom"></i>
</div> </div>
<div>
<div id="r_searchQuery">
<div class="panel panel-default" id="filterPanel">
<div class="panel-heading clearfix">
<h4 class="panel-title pull-left">Type,Tag filter/s</h4>
<div class="btn-group pull-right">
<button type="button" id="expand_collapse_panel" class="expand_collapse_panel" title="Collapse"><i class="fa fa-chevron-up" aria-hidden="true"></i></button>
</div>
</div>
<div id="panel_body" class="panel-body collapse in" align="center">
<p class="filterQuery" id="filterQuery"></p>
</div>
</div>
</div>
</div>
<div class="ellipsis" style="display: none;"><span class="searchResult" style=" font-size: 16px;"></span> <div class="ellipsis" style="display: none;"><span class="searchResult" style=" font-size: 16px;"></span>
<a href="javascript:void(0)" class="inputAssignTag multiSelectTerm btnAssign" style="display:none" data-id="addTerm"><i class="fa fa-folder-o"></i> Assign Term</a> <a href="javascript:void(0)" class="inputAssignTag multiSelectTerm btnAssign" style="display:none" data-id="addTerm"><i class="fa fa-folder-o"></i> Assign Term</a>
<a href="javascript:void(0)" class="inputAssignTag multiSelectTag assignTag btnAssign" style="display:none" data-id="addAssignTag"><i class="fa fa-plus"></i> Assign Tag</a> <a href="javascript:void(0)" class="inputAssignTag multiSelectTag assignTag btnAssign" style="display:none" data-id="addAssignTag"><i class="fa fa-plus"></i> Assign Tag</a>
......
...@@ -398,6 +398,64 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum ...@@ -398,6 +398,64 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
}); });
}) })
} }
CommonViewFunction.attributeFilter = {
generateUrl: function(attrObj) {
var attrQuery = [];
if (attrObj) {
_.each(attrObj, function(obj) {
attrQuery.push(obj.id + "::" + obj.operator + "::" + obj.value + "::" + obj.type);
});
return attrQuery.join();
} else {
return null;
}
},
extractUrl: function(urlObj) {
var attrObj = [];
if (urlObj && urlObj.length) {
_.each(urlObj.split(","), function(obj) {
var temp = obj.split("::");
attrObj.push({ id: temp[0], operator: temp[1], value: temp[2], type: temp[3] });
});
return attrObj;
} else {
return null;
}
},
generateAPIObj: function(url) {
if (url && url.length) {
var parsObj = {
"condition": 'AND',
"criterion": convertKeyAndExtractObj(this.extractUrl(url))
}
return parsObj;
} else {
return null;
}
function convertKeyAndExtractObj(rules) {
var convertObj = [];
_.each(rules, function(rulObj) {
var tempObj = {};
// For nested
// if (rulObj.rules) {
// tempObj = {
// "condition": "AND",
// "criterion": convertKeyAndExtractObj(rulObj.rules)
// }
// } else {
// }
tempObj = {
"attributeName": rulObj.id,
"operator": rulObj.operator,
"attributeValue": (rulObj.type === "date" ? Date.parse(rulObj.value) : rulObj.value)
}
convertObj.push(tempObj);
});
return convertObj;
}
}
}
CommonViewFunction.addRestCsrfCustomHeader = function(xhr, settings) { CommonViewFunction.addRestCsrfCustomHeader = function(xhr, settings) {
// if (settings.url == null || !settings.url.startsWith('/webhdfs/')) { // if (settings.url == null || !settings.url.startsWith('/webhdfs/')) {
if (settings.url == null) { if (settings.url == null) {
......
...@@ -238,7 +238,9 @@ define(['require', ...@@ -238,7 +238,9 @@ define(['require',
*/ */
renderTable: function() { renderTable: function() {
var that = this; var that = this;
this.rTableList.show(new Backgrid.Grid(this.gridOpts)); this.rTableList.show(new Backgrid.Grid(this.gridOpts).on('backgrid:rendered', function() {
that.trigger('backgrid:rendered', this)
}));
}, },
/** /**
......
...@@ -66,7 +66,7 @@ define(['require', ...@@ -66,7 +66,7 @@ define(['require',
return events; return events;
}, },
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'classificationDefCollection', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'filterObj')); _.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'classificationDefCollection', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection'));
if (Globals.taxonomy) { if (Globals.taxonomy) {
this.tabClass = "tab col-sm-4"; this.tabClass = "tab col-sm-4";
} else { } else {
...@@ -97,7 +97,6 @@ define(['require', ...@@ -97,7 +97,6 @@ define(['require',
collection: that.classificationDefCollection, collection: that.classificationDefCollection,
tag: that.tag, tag: that.tag,
value: that.value, value: that.value,
filterObj: that.filterObj,
typeHeaders: that.typeHeaders typeHeaders: that.typeHeaders
})); }));
}); });
...@@ -107,7 +106,6 @@ define(['require', ...@@ -107,7 +106,6 @@ define(['require',
require(['views/search/SearchLayoutView'], function(SearchLayoutView) { require(['views/search/SearchLayoutView'], function(SearchLayoutView) {
that.RSearchLayoutView.show(new SearchLayoutView({ that.RSearchLayoutView.show(new SearchLayoutView({
value: that.value, value: that.value,
filterObj: that.filterObj,
searchVent: that.searchVent, searchVent: that.searchVent,
typeHeaders: that.typeHeaders, typeHeaders: that.typeHeaders,
entityDefCollection: that.entityDefCollection, entityDefCollection: that.entityDefCollection,
......
...@@ -20,9 +20,10 @@ define(['require', ...@@ -20,9 +20,10 @@ define(['require',
'backbone', 'backbone',
'hbs!tmpl/search/QueryBuilder_tmpl', 'hbs!tmpl/search/QueryBuilder_tmpl',
'utils/Utils', 'utils/Utils',
'utils/CommonViewFunction',
'query-builder', 'query-builder',
'daterangepicker' 'daterangepicker'
], function(require, Backbone, QueryBuilder_Tmpl, Utils) { ], function(require, Backbone, QueryBuilder_Tmpl, Utils, CommonViewFunction) {
var QueryBuilderView = Backbone.Marionette.LayoutView.extend( var QueryBuilderView = Backbone.Marionette.LayoutView.extend(
/** @lends QueryBuilderView */ /** @lends QueryBuilderView */
...@@ -51,8 +52,9 @@ define(['require', ...@@ -51,8 +52,9 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'attrObj', 'value', 'typeHeaders', 'filterObj', 'entityDefCollection', 'enumDefCollection', 'tag')); _.extend(this, _.pick(options, 'attrObj', 'value', 'typeHeaders', 'entityDefCollection', 'enumDefCollection', 'tag'));
this.attrObj = _.sortBy(this.attrObj, 'name'); this.attrObj = _.sortBy(this.attrObj, 'name');
this.filterType = this.tag ? 'tagFilters' : 'entityFilters';
}, },
bindEvents: function() {}, bindEvents: function() {},
getOperator: function(type) { getOperator: function(type) {
...@@ -89,8 +91,8 @@ define(['require', ...@@ -89,8 +91,8 @@ define(['require',
format: 'MM/DD/YYYY h:mm A' format: 'MM/DD/YYYY h:mm A'
} }
}; };
if (rules && rules.rules) { if (rules) {
var valueObj = _.find(rules.rules, { id: obj.id }); var valueObj = _.find(rules, { id: obj.id });
if (valueObj) { if (valueObj) {
obj.plugin_config["startDate"] = valueObj.value; obj.plugin_config["startDate"] = valueObj.value;
} }
...@@ -128,15 +130,8 @@ define(['require', ...@@ -128,15 +130,8 @@ define(['require',
onRender: function() { onRender: function() {
var that = this, var that = this,
filters = []; filters = [];
if (this.filterObj) { if (this.value) {
var filter = this.filterObj[(this.tag ? 'tagFilters' : 'entityFilters')], var rules_widgets = CommonViewFunction.attributeFilter.extractUrl(this.value[this.filterType]);
tagTermName = this.tag ? this.value.tag : this.value.type;
if (filter) {
ruleObj = filter[tagTermName];
if (ruleObj) {
var rules_widgets = ruleObj.rule;
}
}
} }
_.each(this.attrObj, function(obj) { _.each(this.attrObj, function(obj) {
var returnObj = that.getObjDef(obj, rules_widgets); var returnObj = that.getObjDef(obj, rules_widgets);
...@@ -145,20 +140,6 @@ define(['require', ...@@ -145,20 +140,6 @@ define(['require',
} }
}); });
filters = _.uniq(filters, 'id'); filters = _.uniq(filters, 'id');
if (rules_widgets) {
for (var i = 0; i < rules_widgets.rules.length; i++) {
if (!_.find(filters, { id: rules_widgets.rules[i].id })) {
var type = (this.tag ? 'tagFilters' : 'entityFilters');
var list = JSON.parse(Utils.localStorage.getValue(type));
delete list[this.value.tag];
list = _.isEmpty(list) ? null : list;
Utils.localStorage.setValue(type, JSON.stringify(list));
this.filterObj[type] = list;
rules_widgets = null;
break;
}
}
}
if (filters && !_.isEmpty(filters)) { if (filters && !_.isEmpty(filters)) {
this.ui.builder.queryBuilder({ this.ui.builder.queryBuilder({
plugins: ['bt-tooltip-errors'], plugins: ['bt-tooltip-errors'],
......
...@@ -43,7 +43,7 @@ define(['require', ...@@ -43,7 +43,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'filterObj')); _.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection'));
}, },
bindEvents: function() {}, bindEvents: function() {},
onRender: function() { onRender: function() {
...@@ -62,7 +62,6 @@ define(['require', ...@@ -62,7 +62,6 @@ define(['require',
entityDefCollection: that.entityDefCollection, entityDefCollection: that.entityDefCollection,
typeHeaders: that.typeHeaders, typeHeaders: that.typeHeaders,
searchVent: that.searchVent, searchVent: that.searchVent,
filterObj: that.filterObj,
enumDefCollection: that.enumDefCollection enumDefCollection: that.enumDefCollection
})); }));
} }
......
...@@ -50,17 +50,27 @@ define(['require', ...@@ -50,17 +50,27 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'value', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'classificationDefCollection', 'tag', 'filterObj')); _.extend(this, _.pick(options, 'value', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'classificationDefCollection', 'tag'));
this.bindEvents(); this.bindEvents();
var that = this; var that = this;
this.modal = new Modal({ this.modal = new Modal({
title: 'Attribute Filter', title: 'Attribute Filter',
content: this, content: this,
okText: 'Apply',
cancelText: "Cancel",
allowCancel: true, allowCancel: true,
okCloses: false, okCloses: false,
width: '50%' width: '50%',
buttons: [{
text: 'Apply',
btnClass: "ok"
},
{
text: 'Apply & Search',
btnClass: "ok search"
}, {
text: 'Cancel',
btnClass: "cancel"
}
]
}).open(); }).open();
this.modal.on('closeModal', function() { this.modal.on('closeModal', function() {
that.modal.trigger('cancel'); that.modal.trigger('cancel');
...@@ -73,7 +83,6 @@ define(['require', ...@@ -73,7 +83,6 @@ define(['require',
searchVent: this.searchVent, searchVent: this.searchVent,
entityDefCollection: this.entityDefCollection, entityDefCollection: this.entityDefCollection,
enumDefCollection: this.enumDefCollection, enumDefCollection: this.enumDefCollection,
filterObj: this.filterObj,
classificationDefCollection: this.classificationDefCollection classificationDefCollection: this.classificationDefCollection
} }
......
...@@ -59,7 +59,7 @@ define(['require', ...@@ -59,7 +59,7 @@ define(['require',
* @constructs * @constructs
*/ */
initialize: function(options) { initialize: function(options) {
_.extend(this, _.pick(options, 'tag', 'collection', 'typeHeaders', 'filterObj', 'value')); _.extend(this, _.pick(options, 'tag', 'collection', 'typeHeaders', 'value'));
}, },
bindEvents: function() { bindEvents: function() {
var that = this; var that = this;
...@@ -417,15 +417,6 @@ define(['require', ...@@ -417,15 +417,6 @@ define(['require',
} }
that.collection.remove(deleteTagData); that.collection.remove(deleteTagData);
// to update tag list of search tab fetch typeHeaders. // to update tag list of search tab fetch typeHeaders.
var tagList = JSON.parse(Utils.localStorage.getValue('tagFilters'));
if (tagList) {
delete tagList[that.tagName];
}
tagList = _.isEmpty(tagList) ? null : tagList;
if (that.filterObj['tagFilters'] && that.filterObj['tagFilters'][that.tagName]) {
delete that.filterObj['tagFilters'][that.tagName];
}
Utils.localStorage.setValue('tagFilters', JSON.stringify(tagList));
that.typeHeaders.fetch({ reset: true }); that.typeHeaders.fetch({ reset: 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