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
this.trigger('closeModal');
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) {
......@@ -38,7 +38,7 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb
this.trigger('closeModal');
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) {
......@@ -47,7 +47,7 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb
this.trigger('ok');
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) {
......@@ -85,7 +85,8 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb
animate: true,
contentWithFooter: false,
template: template,
width: null
width: null,
buttons: null
}, options);
},
......@@ -250,4 +251,4 @@ define(['require', 'backbone', 'hbs!tmpl/common/modal'], function(require, Backb
});
return Modal;
});
});
\ No newline at end of file
......@@ -53,10 +53,6 @@ define([
'enumDefCollection': this.enumDefCollection,
'classificationDefCollection': this.classificationDefCollection
}
this.filterObj = {
'tagFilters': JSON.parse(Utils.localStorage.getValue('tagFilters')),
'entityFilters': JSON.parse(Utils.localStorage.getValue('entityFilters'))
}
},
bindCommonEvents: function() {
var that = this;
......@@ -128,8 +124,7 @@ define([
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'url': url,
'filterObj': that.filterObj
'url': url
}, that.preFetchedCollectionLists)
));
} else {
......@@ -161,7 +156,7 @@ define([
App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView(
_.extend({ 'filterObj': that.filterObj }, that.preFetchedCollectionLists)
_.extend({}, that.preFetchedCollectionLists)
));
} else {
App.rSideNav.currentView.selectTab();
......@@ -198,8 +193,7 @@ define([
}
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'tag': tagName,
'filterObj': that.filterObj
'tag': tagName
}, that.preFetchedCollectionLists)
));
} else {
......@@ -242,8 +236,7 @@ define([
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'searchVent': that.searchVent,
'filterObj': that.filterObj
'searchVent': that.searchVent
}, that.preFetchedCollectionLists)
));
} else {
......@@ -259,7 +252,6 @@ define([
_.extend({
'value': paramObj,
'initialView': true,
'filterObj': that.filterObj,
'searchVent': that.searchVent
}, that.preFetchedCollectionLists)
));
......@@ -277,39 +269,13 @@ define([
'views/business_catalog/SideNavLayoutView',
'views/search/SearchDetailLayoutView'
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) {
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 };
},
});
}
var paramObj = Utils.getUrlState.getQueryParams();
App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'value': paramObj,
'searchVent': that.searchVent,
'filterObj': that.filterObj
'searchVent': that.searchVent
}, that.preFetchedCollectionLists)
));
} else {
......@@ -320,7 +286,6 @@ define([
_.extend({
'value': paramObj,
'searchVent': that.searchVent,
'filterObj': that.filterObj,
'initialView': (paramObj.type || (paramObj.dslChecked == "true" ? "" : paramObj.tag) || (paramObj.query ? paramObj.query.trim() : "")).length === 0
}, that.preFetchedCollectionLists)
));
......
......@@ -31,11 +31,14 @@
<div class="modal-body">{{content}}</div>
{{#if showFooter}}
<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>
{{/if}} {{/if}}
<button type="button" class="btn btn-atlas ok">{{tt okText}}</button>
{{/if}}
</div>
{{/if}} {{/if}}
</div>
</div>
</div>
\ No newline at end of file
......@@ -40,7 +40,7 @@
<select data-id="typeLOV"></select>
</div>
<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>
......@@ -51,7 +51,7 @@
<select data-id="tagLOV"></select>
</div>
<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>
......
......@@ -20,21 +20,6 @@
<div class="fontLoader">
<i class="fa fa-refresh fa-spin-custom"></i>
</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>
<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>
......
......@@ -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) {
// if (settings.url == null || !settings.url.startsWith('/webhdfs/')) {
if (settings.url == null) {
......
......@@ -238,7 +238,9 @@ define(['require',
*/
renderTable: function() {
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)
}));
},
/**
......@@ -392,4 +394,4 @@ define(['require',
});
return FSTableLayout;
});
});
\ No newline at end of file
......@@ -66,7 +66,7 @@ define(['require',
return events;
},
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) {
this.tabClass = "tab col-sm-4";
} else {
......@@ -97,7 +97,6 @@ define(['require',
collection: that.classificationDefCollection,
tag: that.tag,
value: that.value,
filterObj: that.filterObj,
typeHeaders: that.typeHeaders
}));
});
......@@ -107,7 +106,6 @@ define(['require',
require(['views/search/SearchLayoutView'], function(SearchLayoutView) {
that.RSearchLayoutView.show(new SearchLayoutView({
value: that.value,
filterObj: that.filterObj,
searchVent: that.searchVent,
typeHeaders: that.typeHeaders,
entityDefCollection: that.entityDefCollection,
......
......@@ -20,9 +20,10 @@ define(['require',
'backbone',
'hbs!tmpl/search/QueryBuilder_tmpl',
'utils/Utils',
'utils/CommonViewFunction',
'query-builder',
'daterangepicker'
], function(require, Backbone, QueryBuilder_Tmpl, Utils) {
], function(require, Backbone, QueryBuilder_Tmpl, Utils, CommonViewFunction) {
var QueryBuilderView = Backbone.Marionette.LayoutView.extend(
/** @lends QueryBuilderView */
......@@ -51,8 +52,9 @@ define(['require',
* @constructs
*/
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.filterType = this.tag ? 'tagFilters' : 'entityFilters';
},
bindEvents: function() {},
getOperator: function(type) {
......@@ -89,8 +91,8 @@ define(['require',
format: 'MM/DD/YYYY h:mm A'
}
};
if (rules && rules.rules) {
var valueObj = _.find(rules.rules, { id: obj.id });
if (rules) {
var valueObj = _.find(rules, { id: obj.id });
if (valueObj) {
obj.plugin_config["startDate"] = valueObj.value;
}
......@@ -128,15 +130,8 @@ define(['require',
onRender: function() {
var that = this,
filters = [];
if (this.filterObj) {
var filter = this.filterObj[(this.tag ? 'tagFilters' : 'entityFilters')],
tagTermName = this.tag ? this.value.tag : this.value.type;
if (filter) {
ruleObj = filter[tagTermName];
if (ruleObj) {
var rules_widgets = ruleObj.rule;
}
}
if (this.value) {
var rules_widgets = CommonViewFunction.attributeFilter.extractUrl(this.value[this.filterType]);
}
_.each(this.attrObj, function(obj) {
var returnObj = that.getObjDef(obj, rules_widgets);
......@@ -145,20 +140,6 @@ define(['require',
}
});
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)) {
this.ui.builder.queryBuilder({
plugins: ['bt-tooltip-errors'],
......
......@@ -43,7 +43,7 @@ define(['require',
* @constructs
*/
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() {},
onRender: function() {
......@@ -62,7 +62,6 @@ define(['require',
entityDefCollection: that.entityDefCollection,
typeHeaders: that.typeHeaders,
searchVent: that.searchVent,
filterObj: that.filterObj,
enumDefCollection: that.enumDefCollection
}));
}
......
......@@ -50,17 +50,27 @@ define(['require',
* @constructs
*/
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();
var that = this;
this.modal = new Modal({
title: 'Attribute Filter',
content: this,
okText: 'Apply',
cancelText: "Cancel",
allowCancel: true,
okCloses: false,
width: '50%'
width: '50%',
buttons: [{
text: 'Apply',
btnClass: "ok"
},
{
text: 'Apply & Search',
btnClass: "ok search"
}, {
text: 'Cancel',
btnClass: "cancel"
}
]
}).open();
this.modal.on('closeModal', function() {
that.modal.trigger('cancel');
......@@ -73,7 +83,6 @@ define(['require',
searchVent: this.searchVent,
entityDefCollection: this.entityDefCollection,
enumDefCollection: this.enumDefCollection,
filterObj: this.filterObj,
classificationDefCollection: this.classificationDefCollection
}
......@@ -110,4 +119,4 @@ define(['require',
}
});
return SearchQueryView;
});
});
\ No newline at end of file
......@@ -59,7 +59,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'tag', 'collection', 'typeHeaders', 'filterObj', 'value'));
_.extend(this, _.pick(options, 'tag', 'collection', 'typeHeaders', 'value'));
},
bindEvents: function() {
var that = this;
......@@ -417,15 +417,6 @@ define(['require',
}
that.collection.remove(deleteTagData);
// 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 });
}
});
......
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