Commit 4e62a062 by kevalbhatt Committed by Madhan Neethiraj

ATLAS-1902: updated search UI to allow user to select columns in search result

parent ea1c3b68
......@@ -119,6 +119,7 @@ module.exports = function(grunt) {
'backgrid-orderable-columns/js': 'backgrid-orderable-columns/backgrid-orderable-columns.js',
'backgrid-paginator/js': 'backgrid-paginator/backgrid-paginator.min.js',
'backgrid-sizeable-columns/js': 'backgrid-sizeable-columns/backgrid-sizeable-columns.js',
'backgrid-columnmanager/js': 'backgrid-columnmanager/src/Backgrid.ColumnManager.js',
'jquery-asBreadcrumbs/js': 'jquery-asBreadcrumbs/dist/jquery-asBreadcrumbs.min.js',
'd3': 'd3/d3.min.js',
'd3/': 'd3-tip/index.js',
......@@ -144,6 +145,7 @@ module.exports = function(grunt) {
'backgrid-orderable-columns/css': 'backgrid-orderable-columns/backgrid-orderable-columns.css',
'backgrid-paginator/css': 'backgrid-paginator/backgrid-paginator.css',
'backgrid-sizeable-columns/css': 'backgrid-sizeable-columns/backgrid-sizeable-columns.css',
'backgrid-columnmanager/css': 'backgrid-columnmanager/lib/Backgrid.ColumnManager.css',
'jquery-asBreadcrumbs/css': 'jquery-asBreadcrumbs/dist/css/asBreadcrumbs.min.css',
'select2/css': 'select2/dist/css/select2.min.css',
'backgrid-select-all': 'backgrid-select-all/backgrid-select-all.min.css',
......@@ -172,6 +174,7 @@ module.exports = function(grunt) {
'backgrid-orderable-columns': 'backgrid-orderable-columns/LICENSE-MIT',
'backgrid-paginator': 'backgrid-paginator/LICENSE-MIT',
'backgrid-sizeable-columns': 'backgrid-sizeable-columns/LICENSE-MIT',
'backgrid-columnmanager': 'backgrid-columnmanager/LICENSE',
'jquery-asBreadcrumbs': 'jquery-asBreadcrumbs/LICENSE',
'd3': 'd3/LICENSE',
'd3/': 'd3-tip/LICENSE',
......
......@@ -21,6 +21,7 @@
"backbone.paginator": "2.0.5",
"backbone.wreqr": "1.4.0",
"backgrid": "0.3.8",
"backgrid-columnmanager": "0.2.4",
"backgrid-filter": "0.3.7",
"backgrid-orderable-columns": "0.1.2",
"backgrid-paginator": "0.3.9",
......
......@@ -199,7 +199,7 @@ ul {
}
.termTableBreadcrumb {
min-width: 200px;
/* min-width: 200px; */
/* width: 200px; */
/* display: inline-block; */
i {
......
......@@ -76,7 +76,7 @@
border-color: $color_jungle_green_approx;
border-bottom-style: solid;
box-shadow: none;
padding: 20px 30px;
padding: 20px 15px;
background-color: transparent;
text-align: left;
font-weight: 800;
......@@ -89,7 +89,7 @@
border-color: $color_gallery_approx;
color: #333333;
font-weight: 100;
padding: 15px 30px;
padding: 10px 15px;
}
.backgrid-paginator ul > li > a:hover,
......@@ -286,3 +286,21 @@
.query-builder .rule-value-container input {
padding: 6px 12px !important;
}
div.columnmanager-visibilitycontrol {
width: auto;
margin-bottom: 5px;
}
.columnmanager-dropdown-container > li > span.column-label {
width: auto;
}
div.columnmanager-dropdown-container.open {
overflow: auto;
}
.columnmanager-visibilitycontrol.open .btn-atlasAction {
background-color: #37bb9b;
color: #fff;
}
......@@ -42,6 +42,7 @@
<link rel="stylesheet" href="js/libs/backgrid-paginator/css/backgrid-paginator.css">
<link rel="stylesheet" href="js/libs/backgrid-orderable-columns/css/backgrid-orderable-columns.css">
<link rel="stylesheet" href="js/libs/backgrid-sizeable-columns/css/backgrid-sizeable-columns.css">
<link rel="stylesheet" href="js/libs/backgrid-columnmanager/css/Backgrid.ColumnManager.css">
<link rel="stylesheet" href="js/libs/select2/css/select2.min.css">
<link rel="stylesheet" href="js/libs/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="js/libs/jquery-asBreadcrumbs/css/asBreadcrumbs.min.css">
......
......@@ -84,6 +84,9 @@ require.config({
'backgrid-select-all': {
'deps': ['backbone', 'backgrid']
},
'backgrid-columnmanager': {
'deps': ['backbone', 'backgrid'],
},
'hbs': {
'deps': ['underscore', 'handlebars']
},
......@@ -126,6 +129,7 @@ require.config({
'backgrid-orderable': 'libs/backgrid-orderable-columns/js/backgrid-orderable-columns',
'backgrid-paginator': 'libs/backgrid-paginator/js/backgrid-paginator.min',
'backgrid-sizeable': 'libs/backgrid-sizeable-columns/js/backgrid-sizeable-columns',
'backgrid-columnmanager': 'libs/backgrid-columnmanager/js/Backgrid.ColumnManager',
'asBreadcrumbs': 'libs/jquery-asBreadcrumbs/js/jquery-asBreadcrumbs.min',
'd3': 'libs/d3/d3.min',
'd3-tip': 'libs/d3/index',
......
......@@ -92,7 +92,8 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
var scope = options.scope,
valueObject = options.valueObject,
extractJSON = options.extractJSON,
entityDef = options.entityDef;
isTable = _.isUndefined(options.isTable) ? true : options.isTable,
attributeDefs = options.attributeDefs;
var table = "",
fetchInputOutputValue = function(id) {
......@@ -212,7 +213,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
_.sortBy(_.keys(valueObject)).map(function(key) {
key = _.escape(key);
var keyValue = valueObject[key];
var defEntity = _.find(entityDef, { name: key });
var defEntity = _.find(attributeDefs, { name: key });
if (defEntity && defEntity.typeName) {
var defEntityType = defEntity.typeName.toLocaleLowerCase();
if (defEntityType === 'date' || defEntityType === 'time') {
......@@ -225,7 +226,12 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
keyValue = extractObject(keyValue)
}
}
table += '<tr><td>' + _.escape(key) + '</td><td>' + (_.isObject(valueObject[key]) ? keyValue : _.escape(keyValue)) + '</td></tr>';
if (isTable) {
table += '<tr><td>' + _.escape(key) + '</td><td>' + (_.isObject(valueObject[key]) ? keyValue : _.escape(keyValue)) + '</td></tr>';
} else {
table += '<div>' + (_.isObject(valueObject[key]) ? keyValue : _.escape(keyValue)) + '</div>';
}
});
return table;
}
......
......@@ -26,7 +26,8 @@ define(['require',
'backgrid-paginator',
'backgrid-sizeable',
'backgrid-orderable',
'backgrid-select-all'
'backgrid-select-all',
'backgrid-columnmanager'
], function(require, Backbone, FSTablelayoutTmpl) {
'use strict';
......@@ -103,10 +104,13 @@ define(['require',
}
},
columnOpts: {
initialColumnsVisible: 4,
// State settings
saveState: false,
loadStateOnInit: true
opts: {
initialColumnsVisible: 4,
// State settings
saveState: false,
loadStateOnInit: true
},
visibilityControlOpts: {}
},
includePagination: true,
......@@ -301,14 +305,20 @@ define(['require',
* ColumnManager for the table
*/
renderColumnManager: function() {
var $el = this.$("[data-id='control']");
var colManager = new Backgrid.Extension.ColumnManager(this.columns, this.columnOpts);
// Add control
var colVisibilityControl = new Backgrid.Extension.ColumnManagerVisibilityControl({
columnManager: colManager
});
var that = this,
$el = this.$("[data-id='control']"),
colManager = new Backgrid.Extension.ColumnManager(this.columns, this.columnOpts.opts),
// Add control
colVisibilityControl = new Backgrid.Extension.ColumnManagerVisibilityControl(_.extend({
columnManager: colManager,
}, this.columnOpts.visibilityControlOpts));
$el.append(colVisibilityControl.render().el);
colManager.on("state-changed", function(state) {
that.collection.trigger("state-changed", state);
});
colManager.on("state-saved", function() {
that.collection.trigger("state-changed");
});
},
renderSizeAbleColumns: function() {
......@@ -323,7 +333,7 @@ define(['require',
// Add resize handlers
var sizeHandler = new Backgrid.Extension.SizeAbleColumnsHandlers({
sizeAbleColumns: sizeAbleCol,
grid: this.getGridObj(),
// grid: this.getGridObj(),
saveModelWidth: true
});
this.$('thead').before(sizeHandler.render().el);
......@@ -341,6 +351,7 @@ define(['require',
grid: this.getGridObj(),
columns: this.columns
});
this.$('thead').before(sizeAbleCol.render().el);
var orderHandler = new Backgrid.Extension.OrderableColumns({
grid: this.getGridObj(),
sizeAbleColumns: sizeAbleCol
......
......@@ -57,7 +57,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'guid', 'entity', 'entityName', 'entityDef'));
_.extend(this, _.pick(options, 'guid', 'entity', 'entityName', 'attributeDefs'));
this.entityCollection = new VEntityList();
this.limit = 26;
this.entityCollection.url = UrlLinks.entityCollectionaudit(this.guid);
......@@ -239,7 +239,7 @@ define(['require',
that.action = $(e.target).data("action");
var eventModel = that.entityCollection.fullCollection.findWhere({ 'eventKey': $(e.currentTarget).data('modalid') }).toJSON(),
collectionModel = new that.entityCollection.model(eventModel),
view = new CreateAuditTableLayoutView({ guid: that.guid, entityModel: collectionModel, action: that.action, entity: that.entity, entityName: that.entityName, entityDef: that.entityDef });
view = new CreateAuditTableLayoutView({ guid: that.guid, entityModel: collectionModel, action: that.action, entity: that.entity, entityName: that.entityName, attributeDefs: that.attributeDefs });
var modal = new Modal({
title: that.action,
content: view,
......
......@@ -55,7 +55,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'guid', 'entityModel', 'action', 'entity', 'entityName', 'entityDef'));
_.extend(this, _.pick(options, 'guid', 'entityModel', 'action', 'entity', 'entityName', 'attributeDefs'));
},
bindEvents: function() {},
onRender: function() {
......@@ -84,7 +84,7 @@ define(['require',
var tagHeader = ((name ? name : this.entityName));
this.ui.tagHeader.append(tagHeader);
this.ui.auditHeaderValue.html('<th>Key</th><th>New Value</th>');
table = CommonViewFunction.propertyTable({ scope: this, valueObject: values, entityDef: this.entityDef, extractJSON: { extractKey: 'value' } });
table = CommonViewFunction.propertyTable({ scope: this, valueObject: values, attributeDefs: this.attributeDefs, extractJSON: { extractKey: 'value' } });
if (table.length) {
this.ui.noData.hide();
this.ui.tableAudit.show();
......
......@@ -242,12 +242,12 @@ define(['require',
},
getEntityDef: function(obj) {
var data = this.entityDefCollection.fullCollection.findWhere({ name: obj.entity.typeName }).toJSON();
var entityDef = Utils.getNestedSuperTypeObj({
var attributeDefs = Utils.getNestedSuperTypeObj({
data: data,
attrMerge: true,
collection: this.entityDefCollection
});
obj['entityDef'] = entityDef;
obj['attributeDefs'] = attributeDefs;
this.renderEntityDetailTableLayoutView(obj);
this.renderAuditTableLayoutView(obj);
},
......
......@@ -48,7 +48,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'entity', 'referredEntities', 'typeHeaders', 'entityDef'));
_.extend(this, _.pick(options, 'entity', 'referredEntities', 'typeHeaders', 'attributeDefs'));
this.entityModel = new VEntity({});
},
bindEvents: function() {},
......@@ -65,7 +65,7 @@ define(['require',
});
attributeObject.columns = valueSorted;
}
var table = CommonViewFunction.propertyTable({ scope: this, valueObject: attributeObject, entityDef: this.entityDef });
var table = CommonViewFunction.propertyTable({ scope: this, valueObject: attributeObject, attributeDefs: this.attributeDefs });
that.ui.detailValue.append(table);
}
});
......
......@@ -403,16 +403,28 @@ define(['require',
},
triggerSearch: function(value) {
this.query[this.type].query = value || null;
var params = {
searchType: this.type,
dslChecked: this.ui.searchType.is(':checked')
}
this.query[this.type].type = this.ui.typeLov.select2('val') || null;
if (!this.dsl) {
this.query[this.type].tag = this.ui.tagLov.select2('val') || null;
}
if (this.dsl) {
params['attributes'] = null;
} else {
var columnList = JSON.parse(Utils.localStorage.getValue('columnList'));
if (columnList) {
params['attributes'] = columnList[this.query[this.type].type];
} else {
params['attributes'] = null;
}
}
Utils.setUrl({
url: '#!/search/searchResult',
urlParams: _.extend(this.query[this.type], {
searchType: this.type,
dslChecked: this.ui.searchType.is(':checked')
}),
urlParams: _.extend(this.query[this.type], params),
updateTabState: function() {
return { searchUrl: this.url, stateChanged: 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