Commit d0beadf2 by kevalbhatt Committed by apoorvnaik

ATLAS-2020 : Result Table Column Filter : Filtering using Columns in Result…

ATLAS-2020 : Result Table Column Filter : Filtering using Columns in Result table always sets excludeDeletedEntities to True Signed-off-by: 's avatarapoorvnaik <apoorvnaik@apache.org>
parent e1a142b5
......@@ -4,7 +4,7 @@
"private": true,
"repository": {
"type": "git",
"url": "https://git-wip-us.apache.org/repos/asf/atlas.git"
"url": "https://git-wip-us.apache.org/repos/asf/incubator-atlas.git"
},
"engines": {
"node": "4.4.x",
......
......@@ -69,3 +69,44 @@
display: none;
opacity: 0.2;
}
.value-loader {
height: 4px;
width: 50%;
position: relative;
overflow: hidden;
background-color: #ddd;
}
.value-loader:before {
display: block;
position: absolute;
content: "";
left: -200px;
width: 200px;
height: 4px;
background-color: #2980b9;
animation: value-loader 2s linear infinite;
}
@keyframes value-loader {
from {
left: -200px;
width: 30%;
}
50% {
width: 30%;
}
70% {
width: 70%;
}
80% {
left: 50%;
}
95% {
left: 120%;
}
to {
left: 100%;
}
}
\ No newline at end of file
......@@ -69,9 +69,15 @@
box-shadow: 0px 0px 4px #d8d8d8;
overflow: scroll !important;
max-height: 500px;
}
.table-quickMenu>thead>tr>th {
.resizeHandler {
&.grid-draggable {
background-color: $color_jungle_green_approx !important;
}
&:hover {
border-left: 1px solid #d2d2d2;
}
}
>thead>tr>th {
border-width: thin;
border-color: $color_jungle_green_approx;
border-bottom-style: solid;
......@@ -80,25 +86,29 @@
background-color: transparent;
text-align: left;
font-weight: 800;
border-top: 0;
font-size: 14px;
letter-spacing: 0.25px;
color: rgba(52, 52, 52, 1);
}
.table-quickMenu > tbody > tr > td {
}
>tbody>tr>td {
border-color: $color_gallery_approx;
color: #333333;
font-weight: 100;
padding: 10px 15px;
}
}
.backgrid-paginator ul > li > a:hover,
.backgrid-paginator ul > .active > a,
.backgrid-paginator ul > .active > span {
background-color: #2EBC9A !important;
color: #fff !important;
&:hover {
background-color: none;
td {
div.scroll-y {
max-height: 200px;
overflow-y: auto;
}
}
.backgrid {
td {
white-space: normal;
}
}
......@@ -108,11 +118,25 @@
margin: 20px 0;
border-radius: 4px;
border: 1px #DDDDDD solid;
}
.backgrid {
td {
white-space: normal;
margin: 0px;
float: right;
border-radius: 10px;
overflow: hidden;
>.disabled>span,
>.disabled>a {
&:hover {
cursor: not-allowed;
background-color: #7ed3be !important;
}
}
>.active>span,
>.active>a,
>li>a:hover {
background-color: #2EBC9A !important;
color: #fff !important;
&:hover {
background-color: none;
}
}
}
......@@ -216,21 +240,6 @@
}
}
.backgrid-paginator ul {
margin: 0px;
float: right;
border-radius: 10px;
overflow: hidden;
}
.backgrid-paginator ul > .disabled > span,
.backgrid-paginator ul > .disabled > a {
&:hover {
cursor: not-allowed;
background-color: #7ed3be !important;
}
}
.popover {
z-index: 99;
}
......@@ -248,7 +257,7 @@
}
}
.tab-content > .tab-pane.active {
.tab-content>.tab-pane.active {
overflow-x: hidden;
}
......@@ -267,40 +276,40 @@
cursor: pointer;
}
.query-builder .rule-container .rule-value-container {
.query-builder {
.rule-container .rule-value-container {
display: inline-block !important;
}
.rules-group-header .btn-group.pull-right.group-actions {
float: left !important;
}
.query-builder .rules-list>:first-child::before {
}
.rules-list>:first-child::before {
top: -8px;
}
.query-builder .rules-group-header .btn-group.group-conditions label {
}
.rules-group-header .btn-group.group-conditions label {
display: none;
}
.rule-value-container input {
padding: 6px 12px !important;
}
}
.query-builder .rule-value-container input {
padding: 6px 12px !important;
.rules-group-header .btn-group.pull-right.group-actions {
float: left !important;
}
div.columnmanager-visibilitycontrol {
width: auto;
margin-bottom: 5px;
&.open .btn-atlasAction {
background-color: #37bb9b;
color: #fff;
}
}
.columnmanager-dropdown-container > li > span.column-label {
width: auto;
}
div.columnmanager-dropdown-container.open {
div.columnmanager-dropdown-container {
&.open {
overflow: auto;
}
.columnmanager-visibilitycontrol.open .btn-atlasAction {
background-color: #37bb9b;
color: #fff;
}
>li>span.column-label {
width: auto;
}
}
\ No newline at end of file
......@@ -20,7 +20,7 @@
/* panel.scss */
.panel-default {
> .panel-heading {
>.panel-heading {
color: $color_jungle_green_approx;
background: $white;
border-color: $color_jungle_green_approx;
......@@ -35,7 +35,7 @@
}
}
.nav-tabs {
> li {
>li {
&.active {
>a {
color: $color_jungle_green_approx;
......@@ -53,9 +53,9 @@
//overflow: hidden;
height: calc(100% - 46px)!important;
}
.ui-resizable-handle{
.ui-resizable-handle {
display: none !important;
}
}
}
.nav-tabs {
......@@ -68,8 +68,9 @@
.with-nav-tabs {
.tab-content {
> .tab-pane.active {
>.tab-pane.active {
padding: 20px 10px 0px 10px;
min-height: 50px;
}
}
}
\ No newline at end of file
......@@ -53,6 +53,9 @@ define([
'enumDefCollection': this.enumDefCollection,
'classificationDefCollection': this.classificationDefCollection
}
this.sharedObj = {
searchTableColumns: {}
}
},
bindCommonEvents: function() {
var that = this;
......@@ -237,7 +240,7 @@ define([
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'searchVent': that.searchVent
}, that.preFetchedCollectionLists)
}, that.preFetchedCollectionLists, that.sharedObj)
));
} else {
App.rSideNav.currentView.selectTab();
......@@ -253,7 +256,7 @@ define([
'value': paramObj,
'initialView': true,
'searchVent': that.searchVent
}, that.preFetchedCollectionLists)
}, that.preFetchedCollectionLists, that.sharedObj)
));
} else {
App.rNContent.$el.html("");
......@@ -276,18 +279,22 @@ define([
_.extend({
'value': paramObj,
'searchVent': that.searchVent
}, that.preFetchedCollectionLists)
}, that.preFetchedCollectionLists, that.sharedObj)
));
} else {
App.rSideNav.currentView.RSearchLayoutView.currentView.manualRender(paramObj);
}
App.rSideNav.currentView.selectTab();
var isinitialView = true;
if (paramObj) {
isinitialView = (paramObj.type || (paramObj.dslChecked == "true" ? "" : paramObj.tag) || (paramObj.query ? paramObj.query.trim() : "")).length === 0;
}
App.rNContent.show(new SearchDetailLayoutView(
_.extend({
'value': paramObj,
'searchVent': that.searchVent,
'initialView': (paramObj.type || (paramObj.dslChecked == "true" ? "" : paramObj.tag) || (paramObj.query ? paramObj.query.trim() : "")).length === 0
}, that.preFetchedCollectionLists)
'initialView': isinitialView,
}, that.preFetchedCollectionLists, that.sharedObj)
));
});
},
......
......@@ -35,7 +35,7 @@
</div>
<div class="position-relative thick-border">
<div data-id="r_tableList" class="table-responsive tableBorder"> </div>
<div data-id="r_tableSpinner" class="fontLoader">
<div data-id="r_tableSpinner" class="fontLoader for-ignore">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
</div>
......
......@@ -82,46 +82,46 @@
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs ">
<li role="presentation" class="tab active"><a href="#tab-details" aria-controls="tab-details" role="tab" data-toggle="tab">Properties</a></li>
<li role="presentation"><a href="#tab-tagTable" aria-controls="tab-tagTable" role="tab" data-toggle="tab">Tags</a></li>
<li role="properties" class="tab active"><a href="#tab-details" aria-controls="tab-details" role="tab" data-toggle="tab">Properties</a></li>
<li role="tags"><a href="#tab-tagTable" aria-controls="tab-tagTable" role="tab" data-toggle="tab">Tags</a></li>
{{#if taxonomy}}
<li role="presentation"><a href="#tab-termTable" aria-controls="tab-termTable" role="tab" data-toggle="tab">Terms</a></li>
<li role="terms"><a href="#tab-termTable" aria-controls="tab-termTable" role="tab" data-toggle="tab">Terms</a></li>
{{/if}}
<li role="presentation" class="tab"><a href="#tab-audit" aria-controls="tab-audit" role="tab" data-toggle="tab">Audits</a></li>
<li role="presentation" class="tab schemaTable" style="display:none"><a href="#tab-schema" aria-controls="tab-schema" role="tab" data-toggle="tab">Schema</a></li>
<li role="audits" class="tab"><a href="#tab-audit" aria-controls="tab-audit" role="tab" data-toggle="tab">Audits</a></li>
<li role="schema" class="tab schemaTable" style="display:none"><a href="#tab-schema" aria-controls="tab-schema" role="tab" data-toggle="tab">Schema</a></li>
</ul>
</div>
</div>
<div class="tab-content">
<div id="tab-details" role="tabpanel" class="tab-pane active">
<div id="tab-details" role="properties" class="tab-pane active">
<div id="r_entityDetailTableLayoutView" style="position: relative;">
<div class="fontLoader">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
</div>
</div>
<div id="tab-tagTable" role="tabpanel" class="tab-pane fade">
<div id="tab-tagTable" role="tags" class="tab-pane fade">
<div id="r_tagTableLayoutView" style="position: relative;">
<div class="fontLoader">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
</div>
</div>
<div id="tab-termTable" role="tabpanel" class="tab-pane">
<div id="tab-termTable" role="terms" class="tab-pane">
<div id="r_termTableLayoutView" style="position: relative;">
<div class="fontLoader">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
</div>
</div>
<div id="tab-audit" role="tabpanel" class="tab-pane">
<div id="tab-audit" role="audits" class="tab-pane">
<div id="r_auditTableLayoutView" style="position: relative;">
<div class="fontLoader">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
</div>
</div>
<div id="tab-schema" role="tabpanel" class="tab-pane">
<div id="tab-schema" role="schema" class="tab-pane">
<div id="r_schemaTableLayoutView" style="position: relative;">
<div class="fontLoader">
<i class="fa fa-refresh fa-spin-custom"></i>
......
......@@ -17,7 +17,7 @@
<div class="">
<div class="tableOverlay"></div>
<!-- Not for table Loader its only for initial loading -->
<div class="fontLoader">
<div class="fontLoader" style="z-index:999">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
<div class="ellipsis" style="display: none;"><span class="searchResult" style=" font-size: 16px;"></span>
......@@ -26,7 +26,7 @@
</div>
<div class="searchTable">
<div data-id="containerCheckBox" style="display: none;">
<input type="checkbox" id="inputLabel" class="checkbox-inline" name="queryType" value="text" name="check" value="1" data-id="checkDeletedEntity" />
<input type="checkbox" id="inputLabel" class="checkbox-inline" name="queryType" name="check" data-id="checkDeletedEntity" />
<label class="checkbox-inline" for="inputLabel">
<b>Include historical entities</b></label>
</div>
......@@ -53,3 +53,6 @@
</div>
</div>
</div>
<div class="text-center" data-id="columnEmptyInfo" style="display: none;">
<h4>Please select one/more column to see the data</h4>
</div>
\ No newline at end of file
......@@ -170,7 +170,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
var fetch = true;
var fetchId = (_.isObject(id) ? id.id : id);
fetchInputOutputValue(fetchId);
tempLink += '<div data-id="' + fetchId + '"></div>';
tempLink += '<div data-id="' + fetchId + '"><div class="value-loader"></div></div>';
} else {
tempLink += '<a href="#!/detailPage/' + id + '">' + name + '</a>'
}
......@@ -214,7 +214,7 @@ define(['require', 'utils/Utils', 'modules/Modal', 'utils/Messages', 'utils/Enum
}
}
if (isTable) {
table += '<tr><td>' + _.escape(key) + '</td><td>' + (_.isObject(valueObject[key]) ? keyValue : _.escape(keyValue)) + '</td></tr>';
table += '<tr><td>' + _.escape(key) + '</td><td><div ' + (_.isObject(valueObject[key]) ? 'class="scroll-y"' : '') + '>' + (_.isObject(valueObject[key]) ? keyValue : _.escape(keyValue)) + '</div></td></tr>';
} else {
table += '<div>' + (_.isObject(valueObject[key]) ? keyValue : _.escape(keyValue)) + '</div>';
}
......
......@@ -131,6 +131,8 @@ define(['require',
includeOverlayLoader: false,
includeTableLoader: true,
/** ui events hash */
events: function() {
......@@ -146,7 +148,7 @@ define(['require',
initialize: function(options) {
_.extend(this, _.pick(options, 'collection', 'columns', 'includePagination',
'includeHeaderSearch', 'includeFilter', 'includePageSize',
'includeFooterRecords', 'includeColumnManager', 'includeSizeAbleColumns', 'includeOrderAbleColumns', 'includeOverlayLoader'));
'includeFooterRecords', 'includeColumnManager', 'includeSizeAbleColumns', 'includeOrderAbleColumns', 'includeOverlayLoader', 'includeTableLoader'));
_.extend(this.gridOpts, options.gridOpts, { collection: this.collection, columns: this.columns });
_.extend(this.filterOpts, options.filterOpts);
......@@ -160,14 +162,20 @@ define(['require',
/** all events binding here */
bindEvents: function() {
this.listenTo(this.collection, 'request', function() {
if (this.includeTableLoader) {
this.$('div[data-id="r_tableSpinner"]').addClass('show');
}
if (this.includeOverlayLoader) {
this.$('.t_tableOverlay').addClass('fontLoader');
this.$('.t_tableOverlay').show();
}
}, this);
this.listenTo(this.collection, 'sync error', function() {
if (this.includeTableLoader) {
this.$('div[data-id="r_tableSpinner"]').removeClass('show');
}
if (this.includeOverlayLoader) {
this.$('.t_tableOverlay').removeClass('fontLoader');
this.$('.t_tableOverlay').hide();
}
}, this);
......
......@@ -45,8 +45,25 @@ define(['require',
that = this;
events["click " + this.ui.tabs] = function(e) {
var urlString = "",
elementName = $(e.currentTarget).data();
var tabStateUrls = Globals.saveApplicationState.tabState;
elementName = $(e.currentTarget).data(),
tabStateUrls = Globals.saveApplicationState.tabState,
urlStateObj = Utils.getUrlState,
hashUrl = Utils.getUrlState.getQueryUrl().hash;
if (urlStateObj.isTagTab()) {
if (hashUrl != tabStateUrls.tagUrl) {
Globals.saveApplicationState.tabState.tagUrl = hashUrl;
}
} else if (urlStateObj.isSearchTab()) {
if (hashUrl != tabStateUrls.searchUrl) {
Globals.saveApplicationState.tabState.searchUrl = hashUrl;
}
} else if (urlStateObj.isTaxonomyTab()) {
if (hashUrl != tabStateUrls.taxonomyUrl) {
Globals.saveApplicationState.tabState.isTaxonomyTab = hashUrl;
}
}
if (elementName.name == "tab-tag") {
urlString = tabStateUrls.tagUrl; //'#!/tag';
} else if (elementName.name == "tab-taxonomy") {
......@@ -66,7 +83,7 @@ define(['require',
return events;
},
initialize: function(options) {
_.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'classificationDefCollection', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection'));
_.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'classificationDefCollection', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'searchTableColumns'));
if (Globals.taxonomy) {
this.tabClass = "tab col-sm-4";
} else {
......@@ -110,7 +127,8 @@ define(['require',
typeHeaders: that.typeHeaders,
entityDefCollection: that.entityDefCollection,
enumDefCollection: that.enumDefCollection,
classificationDefCollection: that.classificationDefCollection
classificationDefCollection: that.classificationDefCollection,
searchTableColumns: that.searchTableColumns
}));
});
},
......
......@@ -53,7 +53,7 @@ define(['require',
var VCommonModel = new VCommon();
VCommonModel.aboutUs(url, {
success: function(data) {
var str = "<b>Version : </b>" + data.Version;
var str = "<b>Version : </b>" + _.escape(data.Version);
that.ui.atlasVersion.html(str);
},
complete: function() {}
......
......@@ -112,6 +112,9 @@ define(['require',
this.listenTo(this.collection, 'reset', function() {
this.entityObject = this.collection.first().toJSON();
var collectionJSON = this.entityObject.entity;
// MergerRefEntity.
Utils.findAndMergeRefEntity(collectionJSON.attributes, this.entityObject.referredEntities);
if (collectionJSON && collectionJSON.guid) {
var tagGuid = collectionJSON.guid;
this.readOnly = Enums.entityStateReadOnly[collectionJSON.status];
......@@ -162,20 +165,29 @@ define(['require',
this.ui.editButton.show();
}
}
if (collectionJSON.attributes && collectionJSON.attributes.columns) {
var valueSorted = _.sortBy(collectionJSON.attributes.columns, function(val) {
return val.attributes.position
});
collectionJSON.attributes.columns = valueSorted;
}
}
this.hideLoader();
var obj = {
entity: collectionJSON,
referredEntities: this.entityObject.referredEntities,
guid: this.id,
entityName: this.name,
typeHeaders: this.typeHeaders,
entityDefCollection: this.entityDefCollection,
fetchCollection: this.fetchCollection.bind(that),
enumDefCollection: this.enumDefCollection,
classificationDefCollection: this.classificationDefCollection
classificationDefCollection: this.classificationDefCollection,
attributeDefs: (function() {
return that.getEntityDef(collectionJSON);
})()
}
this.getEntityDef(obj);
this.renderEntityDetailTableLayoutView(obj);
this.renderAuditTableLayoutView(obj);
this.renderTagTableLayoutView(obj);
this.renderTermTableLayoutView(_.extend({}, obj, { term: true }));
// To render Schema check attribute "schemaElementsAttribute"
......@@ -241,16 +253,14 @@ define(['require',
fetchCollection: function() {
this.collection.fetch({ reset: true });
},
getEntityDef: function(obj) {
var data = this.entityDefCollection.fullCollection.findWhere({ name: obj.entity.typeName }).toJSON();
getEntityDef: function(entityObj) {
var data = this.entityDefCollection.fullCollection.findWhere({ name: entityObj.typeName }).toJSON();
var attributeDefs = Utils.getNestedSuperTypeObj({
data: data,
attrMerge: true,
collection: this.entityDefCollection
});
obj['attributeDefs'] = attributeDefs;
this.renderEntityDetailTableLayoutView(obj);
this.renderAuditTableLayoutView(obj);
return attributeDefs;
},
onClickTagCross: function(e) {
var tagName = $(e.currentTarget).parent().text(),
......
......@@ -20,9 +20,8 @@ define(['require',
'backbone',
'hbs!tmpl/entity/EntityDetailTableLayoutView_tmpl',
'utils/CommonViewFunction',
'models/VEntity',
'utils/Utils'
], function(require, Backbone, EntityDetailTableLayoutView_tmpl, CommonViewFunction, VEntity, Utils) {
'models/VEntity'
], function(require, Backbone, EntityDetailTableLayoutView_tmpl, CommonViewFunction, VEntity) {
'use strict';
var EntityDetailTableLayoutView = Backbone.Marionette.LayoutView.extend(
......@@ -49,7 +48,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'entity', 'referredEntities', 'typeHeaders', 'attributeDefs'));
_.extend(this, _.pick(options, 'entity', 'typeHeaders', 'attributeDefs', 'attributes'));
this.entityModel = new VEntity({});
},
bindEvents: function() {},
......@@ -57,17 +56,8 @@ define(['require',
this.entityTableGenerate();
},
entityTableGenerate: function() {
var that = this,
attributeObject = this.entity.attributes;
Utils.findAndMergeRefEntity(attributeObject, that.referredEntities);
if (attributeObject && attributeObject.columns) {
var valueSorted = _.sortBy(attributeObject.columns, function(val) {
return val.attributes.position
});
attributeObject.columns = valueSorted;
}
var table = CommonViewFunction.propertyTable({ scope: this, valueObject: attributeObject, attributeDefs: this.attributeDefs });
that.ui.detailValue.append(table);
var table = CommonViewFunction.propertyTable({ scope: this, valueObject: this.entity.attributes, attributeDefs: this.attributeDefs });
this.ui.detailValue.append(table);
}
});
return EntityDetailTableLayoutView;
......
......@@ -94,7 +94,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'guid', 'entityDefCollection', 'attribute', 'referredEntities', 'fetchCollection', 'enumDefCollection'));
_.extend(this, _.pick(options, 'guid', 'entityDefCollection', 'attribute', 'fetchCollection', 'enumDefCollection'));
this.schemaCollection = new VSchemaList([], {});
this.commonTableOptions = {
collection: this.schemaCollection,
......@@ -166,15 +166,11 @@ define(['require',
}
}
_.each(this.attribute, function(obj) {
newModel = that.referredEntities[obj.guid];
if (newModel.attributes['position']) {
newModel['position'] = newModel.attributes['position'];
}
if (!Enums.entityStateReadOnly[newModel.status]) {
that.activeObj.push(newModel);
that.schemaCollection.push(newModel);
} else if (Enums.entityStateReadOnly[newModel.status]) {
that.deleteObj.push(newModel);
if (!Enums.entityStateReadOnly[obj.status]) {
that.activeObj.push(obj);
that.schemaCollection.push(obj);
} else if (Enums.entityStateReadOnly[obj.status]) {
that.deleteObj.push(obj);
}
});
$('body').click(function(e) {
......
......@@ -43,7 +43,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection'));
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'searchTableColumns'));
},
bindEvents: function() {},
onRender: function() {
......@@ -51,19 +51,9 @@ define(['require',
},
renderSearchResultLayoutView: function() {
var that = this;
require(['views/search/SearchResultLayoutView'], function(SearchResultLayoutView) {
if (that.RSearchResultLayoutView) {
that.RSearchResultLayoutView.show(new SearchResultLayoutView({
value: that.value,
tag: that.tag,
initialView: that.initialView,
entityDefCollection: that.entityDefCollection,
typeHeaders: that.typeHeaders,
searchVent: that.searchVent,
enumDefCollection: that.enumDefCollection
}));
that.RSearchResultLayoutView.show(new SearchResultLayoutView(that.options));
}
});
}
......
......@@ -81,7 +81,7 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'value', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'classificationDefCollection'));
_.extend(this, _.pick(options, 'value', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'classificationDefCollection', 'searchTableColumns'));
this.type = "basic";
var param = Utils.getUrlState.getQueryParams();
this.query = {
......@@ -94,7 +94,8 @@ define(['require',
type: null,
typeFilter: null,
tagFilter: null,
tag: null
tag: null,
attributes: null
}
};
if (!this.value) {
......@@ -244,7 +245,8 @@ define(['require',
type: null,
tag: null,
entityFilters: null,
tagFilters: null
tagFilters: null,
attributes: null
}), param);
},
fetchCollection: function(value) {
......@@ -389,9 +391,9 @@ define(['require',
if (this.dsl) {
params['attributes'] = null;
} else {
var columnList = JSON.parse(Utils.localStorage.getValue('columnList'));
var columnList = this.value && this.value.type && this.searchTableColumns ? this.searchTableColumns[this.value.type] : null;
if (columnList) {
params['attributes'] = columnList[this.query[this.type].type];
params['attributes'] = columnList.join(',');
} else {
params['attributes'] = null;
}
......@@ -408,7 +410,7 @@ define(['require',
});
},
dslFulltextToggle: function(e) {
var paramQuery = "";
var paramObj = Utils.getUrlState.getQueryParams();
if (e.currentTarget.checked) {
this.type = "dsl";
this.dsl = true;
......@@ -422,8 +424,11 @@ define(['require',
this.dsl = false;
this.type = "basic";
}
if (Utils.getUrlState.getQueryParams() && this.type == Utils.getUrlState.getQueryParams().searchType) {
this.updateQueryObject(Utils.getUrlState.getQueryParams());
if (paramObj && this.type == paramObj.searchType) {
this.updateQueryObject(paramObj);
}
if (this.type == "basic") {
this.query[this.type].attribute = paramObj.attributes ? paramObj.attributes : null;
}
Utils.setUrl({
url: '#!/search/searchResult',
......
......@@ -62,7 +62,8 @@ define(['require',
editEntityButton: "[data-id='editEntityButton']",
createEntity: "[data-id='createEntity']",
checkDeletedEntity: "[data-id='checkDeletedEntity']",
containerCheckBox: "[data-id='containerCheckBox']"
containerCheckBox: "[data-id='containerCheckBox']",
columnEmptyInfo: "[data-id='columnEmptyInfo']"
},
templateHelpers: function() {
return {
......@@ -127,20 +128,20 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'tagCollection'));
_.extend(this, _.pick(options, 'value', 'initialView', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'tagCollection', 'searchTableColumns'));
this.entityModel = new VEntity();
this.searchCollection = new VSearchList();
this.limit = 25;
this.asyncFetchCounter = 0;
this.offset = 0;
this.columnToShow = this.value && this.value.attributes ? this.value.attributes.split(',') : [];
this.commonTableOptions = {
collection: this.searchCollection,
includePagination: false,
includeFooterRecords: false,
includeColumnManager: (this.value && this.value.searchType === "basic" ? true : false),
includeOrderAbleColumns: true,
includeSizeAbleColumns: true,
includeColumnManager: (Utils.getUrlState.isSearchTab() && this.value && this.value.searchType === "basic" ? true : false),
includeOrderAbleColumns: false,
includeSizeAbleColumns: false,
includeTableLoader: false,
columnOpts: {
opts: {
initialColumnsVisible: null,
......@@ -216,20 +217,29 @@ define(['require',
this.listenTo(this.searchCollection, "state-changed", function(state) {
if (Utils.getUrlState.isSearchTab()) {
this.updateColumnList(state);
var columnList = JSON.parse(Utils.localStorage.getValue('columnList'));
if (!columnList && this.value.type) {
columnList = {};
columnList[this.value.type] = this.value.attributes;
var excludeDefaultColumn = [];
if (this.value && this.value.type) {
excludeDefaultColumn = _.without(this.searchTableColumns[this.value.type], "selected", "name", "description", "typeName", "owner", "tag", "terms");
if (this.searchTableColumns[this.value.type] === null) {
this.ui.columnEmptyInfo.show();
} else {
columnList[this.value.type] = this.value.attributes;
this.ui.columnEmptyInfo.hide();
}
Utils.localStorage.setValue('columnList', JSON.stringify(columnList));
}
Utils.setUrl({
url: '#!/search/searchResult',
urlParams: this.value,
mergeBrowserUrl: false,
trigger: true
trigger: false,
updateTabState: function() {
return { searchUrl: this.url, stateChanged: true };
}
});
if (excludeDefaultColumn.length > this.searchCollection.filterObj.attributes.length) {
this.fetchCollection(this.value);
}
}
}, this);
this.listenTo(this.searchVent, "search:refresh", function(model, response) {
......@@ -242,6 +252,9 @@ define(['require',
that = this;
if (this.value) {
value = this.value;
if (value && value.includeDE) {
this.ui.checkDeletedEntity.prop('checked', true);
}
} else {
value = {
'query': null,
......@@ -249,6 +262,11 @@ define(['require',
};
}
this.updateColumnList();
if (this.value && this.searchTableColumns && this.searchTableColumns[this.value.type] === null) {
this.ui.columnEmptyInfo.show();
} else {
this.ui.columnEmptyInfo.hide();
}
this.fetchCollection(value);
$('body').click(function(e) {
var iconEvnt = e.target.nodeName;
......@@ -267,7 +285,7 @@ define(['require',
},
updateColumnList: function(updatedList) {
if (updatedList) {
var listOfColumns = []
var listOfColumns = [];
_.map(updatedList, function(obj) {
var key = obj.name;
if (obj.renderable) {
......@@ -276,8 +294,12 @@ define(['require',
});
listOfColumns = _.sortBy(listOfColumns);
this.value.attributes = listOfColumns.length ? listOfColumns.join(",") : null;
if (this.value && this.searchTableColumns) {
this.searchTableColumns[this.value.type] = listOfColumns.length ? listOfColumns : null;
}
} else if (this.value && this.value.type && this.searchTableColumns && this.value.attributes) {
this.searchTableColumns[this.value.type] = this.value.attributes.split(",");
}
this.columnToShow = this.value && this.value.attributes ? this.value.attributes.split(',') : [];
},
generateQueryOfFilter: function() {
var value = this.value,
......@@ -287,26 +309,26 @@ define(['require',
objToString = function(filterObj) {
var tempObj = [];
_.each(filterObj, function(obj) {
tempObj.push('<span class="key">' + obj.id + '</span>&nbsp<span class="operator">' + obj.operator + '</span>&nbsp<span class="value">' + obj.value + "</span>")
tempObj.push('<span class="key">' + _.escape(obj.id) + '</span>&nbsp<span class="operator">' + _.escape(obj.operator) + '</span>&nbsp<span class="value">' + _.escape(obj.value) + "</span>")
});
return tempObj.join('&nbsp<span class="operator">AND</span>&nbsp');
}
if (value.type) {
var typeKeyValue = '<span class="key">Type:</span>&nbsp<span class="value">' + value.type + '</span>';
var typeKeyValue = '<span class="key">Type:</span>&nbsp<span class="value">' + _.escape(value.type) + '</span>';
if (entityFilters) {
typeKeyValue += '&nbsp<span class="operator">AND</span>&nbsp' + objToString(entityFilters);
}
queryArray.push(typeKeyValue)
}
if (value.tag) {
var tagKeyValue = '<span class="key">Tag:</span>&nbsp<span class="value">' + value.tag + '</span>';
var tagKeyValue = '<span class="key">Tag:</span>&nbsp<span class="value">' + _.escape(value.tag) + '</span>';
if (tagFilters) {
tagKeyValue += '&nbsp<span class="operator">AND</span>&nbsp' + objToString(tagFilters);
}
queryArray.push(tagKeyValue);
}
if (value.query) {
queryArray.push('<span class="key">Query:</span>&nbsp<span class="value">' + value.query + '</span>&nbsp');
queryArray.push('<span class="key">Query:</span>&nbsp<span class="value">' + _.escape(value.query) + '</span>&nbsp');
}
if (queryArray.length == 1) {
return queryArray.join();
......@@ -319,33 +341,38 @@ define(['require',
var that = this,
isPostMethod = this.value.searchType === "basic" && Utils.getUrlState.isSearchTab(),
tagFilters = CommonViewFunction.attributeFilter.generateAPIObj(this.value.tagFilters),
entityFilters = CommonViewFunction.attributeFilter.generateAPIObj(this.value.entityFilters),
entityFilters = CommonViewFunction.attributeFilter.generateAPIObj(this.value.entityFilters);
if (isPostMethod) {
var excludeDefaultColumn = this.searchTableColumns ? _.without(this.searchTableColumns[this.value.type], "selected", "name", "description", "typeName", "owner", "tag", "terms") : null,
filterObj = {
'entityFilters': entityFilters,
'tagFilters': tagFilters,
'attributes': this.columnToShow.length ? _.without(this.columnToShow, "selected", "name", "description", "typeName", "owner", "tag", "terms") : null
'attributes': excludeDefaultColumn ? excludeDefaultColumn : null
};
}
this.showLoader();
if (Globals.searchApiCallRef && Globals.searchApiCallRef.readyState === 1) {
Globals.searchApiCallRef.abort();
}
var apiObj = {
skipDefaultError: true,
sort: false,
success: function(model, response) {
Globals.searchApiCallRef = undefined;
if (!(that.ui.pageRecordText instanceof jQuery)) {
return;
}
if (isPostMethod) {
that.searchCollection.referredEntities = model.referredEntities;
that.searchCollection.reset(model.entities);
}
if (that.searchCollection.models.length === 0 && that.offset > that.limit) {
if (!model.entities && that.offset > that.limit) {
that.ui.nextData.attr('disabled', true);
that.offset = that.offset - that.limit;
that.hideLoader();
return;
}
if (isPostMethod) {
that.searchCollection.referredEntities = model.referredEntities;
that.searchCollection.reset(model.entities);
}
if (that.searchCollection.models.length < that.limit) {
that.ui.nextData.attr('disabled', true);
} else {
......@@ -367,38 +394,28 @@ define(['require',
that.ui.previousData.attr('disabled', true);
}
that.renderTableLayoutView();
var resultArr = [];
if (that.searchCollection.queryParams.typeName) {
resultArr.push(that.searchCollection.queryParams.typeName)
}
if (that.searchCollection.queryParams.classification) {
resultArr.push(that.searchCollection.queryParams.classification)
}
if (that.searchCollection.queryParams.query) {
resultArr.push(that.searchCollection.queryParams.query)
}
var searchString = 'Results for: <span class="filterQuery">' + that.generateQueryOfFilter() + "</span>";
if (Globals.entityCreate && Globals.entityTypeConfList && Utils.getUrlState.isSearchTab()) {
searchString += "<p>If you do not find the entity in search result below then you can" + '<a href="javascript:void(0)" data-id="createEntity"> create new entity</a></p>';
}
that.$('.searchResult').html(searchString);
},
silent: true,
reset: true
}
if (value) {
$.extend(this.searchCollection.queryParams, { limit: this.limit, excludeDeletedEntities: true });
$.extend(this.searchCollection.queryParams, { limit: this.limit, excludeDeletedEntities: (value.includeDE ? false : true) });
if (value.searchType) {
this.searchCollection.url = UrlLinks.searchApiUrl(value.searchType);
}
_.extend(this.searchCollection.queryParams, { 'query': (value.query ? value.query.trim() : null), 'typeName': value.type || null, 'classification': value.tag || null });
if (isPostMethod) {
this.searchCollection.filterObj = _.extend({}, filterObj);
apiObj['data'] = _.extend({}, filterObj, _.pick(this.searchCollection.queryParams, 'query', 'excludeDeletedEntities', 'limit', 'offset', 'typeName', 'classification'))
Globals.searchApiCallRef = this.searchCollection.getBasicRearchResult(apiObj);
} else {
apiObj.data = null;
this.searchCollection.filterObj = null;
Globals.searchApiCallRef = this.searchCollection.fetch(apiObj);
}
} else {
......@@ -421,9 +438,9 @@ define(['require',
});
},
renderTableLayoutView: function(col) {
var that = this,
count = 5;
var that = this;
require(['utils/TableLayout'], function(TableLayout) {
// displayOrder added for column manager
var columnCollection = Backgrid.Columns.extend({
sortKey: "displayOrder",
comparator: function(item) {
......@@ -438,7 +455,6 @@ define(['require',
});
var columns = new columnCollection(that.getFixedDslColumn());
columns.setPositions().sort();
//var columns = new Backgrid.Columns(that.getFixedDslColumn());
that.REntityTableLayoutView.show(new TableLayout(_.extend({}, that.commonTableOptions, {
columns: columns
})));
......@@ -470,14 +486,18 @@ define(['require',
getFixedDslColumn: function() {
var that = this,
nameCheck = 0,
columnToShow = null,
col = {};
if (this.value && this.searchTableColumns && (this.searchTableColumns[this.value.type] !== undefined)) {
columnToShow = this.searchTableColumns[this.value.type] == null ? [] : this.searchTableColumns[this.value.type];
}
col['Check'] = {
name: "selected",
label: "Select",
cell: "select-row",
resizeable: false,
orderable: false,
renderable: (that.columnToShow && that.columnToShow.length ? _.contains(that.columnToShow, 'selected') : true),
renderable: (columnToShow ? _.contains(columnToShow, 'selected') : true),
headerCell: "select-all"
};
......@@ -518,9 +538,8 @@ define(['require',
}
})
};
col['description'] = {
label: "Description",
col['owner'] = {
label: "Owner",
cell: "String",
editable: false,
sortable: false,
......@@ -530,46 +549,48 @@ define(['require',
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.attributes && obj.attributes.description) {
return obj.attributes.description;
if (obj && obj.attributes && obj.attributes.owner) {
return obj.attributes.owner;
}
}
})
};
col['typeName'] = {
label: "Type",
cell: "Html",
col['description'] = {
label: "Description",
cell: "String",
editable: false,
sortable: false,
resizeable: true,
orderable: true,
renderable: (that.columnToShow && that.columnToShow.length ? _.contains(that.columnToShow, 'typeName') : true),
renderable: true,
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.typeName) {
return '<a title="Search ' + obj.typeName + '" href="#!/search/searchResult?query=' + obj.typeName + ' &searchType=dsl&dslChecked=true">' + obj.typeName + '</a>';
if (obj && obj.attributes && obj.attributes.description) {
return obj.attributes.description;
}
}
})
};
col['owner'] = {
label: "Owner",
cell: "String",
col['typeName'] = {
label: "Type",
cell: "Html",
editable: false,
sortable: false,
resizeable: true,
orderable: true,
renderable: true,
renderable: (columnToShow ? _.contains(columnToShow, 'typeName') : true),
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
var obj = model.toJSON();
if (obj && obj.attributes && obj.attributes.owner) {
return obj.attributes.owner;
if (obj && obj.typeName) {
return '<a title="Search ' + obj.typeName + '" href="#!/search/searchResult?query=' + obj.typeName + ' &searchType=dsl&dslChecked=true">' + obj.typeName + '</a>';
}
}
})
};
col['tag'] = {
label: "Tags",
cell: "Html",
......@@ -577,7 +598,7 @@ define(['require',
sortable: false,
resizeable: true,
orderable: true,
renderable: (that.columnToShow && that.columnToShow.length ? _.contains(that.columnToShow, 'tag') : true),
renderable: (columnToShow ? _.contains(columnToShow, 'tag') : true),
className: 'searchTag',
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
......@@ -599,7 +620,7 @@ define(['require',
sortable: false,
resizeable: true,
orderable: true,
renderable: (that.columnToShow && that.columnToShow.length ? _.contains(that.columnToShow, 'terms') : true),
renderable: (columnToShow ? _.contains(columnToShow, 'terms') : true),
className: 'searchTerm',
formatter: _.extend({}, Backgrid.CellFormatter.prototype, {
fromRaw: function(rawValue, model) {
......@@ -616,16 +637,15 @@ define(['require',
}
})
};
}
if (this.value && this.value.searchType === "basic") {
var def = this.entityDefCollection.fullCollection.find({ name: this.value.type });
if (def) {
var attrObj = Utils.getNestedSuperTypeObj({ data: def.toJSON(), collection: this.entityDefCollection, attrMerge: true });
_.each(attrObj, function(obj, key) {
var key = obj.name,
isRenderable = _.contains(that.columnToShow, key)
isRenderable = _.contains(columnToShow, key)
if (key == "name" || key == "description" || key == "owner") {
if (that.columnToShow && that.columnToShow.length) {
if (columnToShow) {
col[key].renderable = isRenderable;
}
return;
......@@ -660,6 +680,7 @@ define(['require',
});
}
}
}
return this.searchCollection.constructor.getTableCols(col, this.searchCollection);
},
addTagModalView: function(guid, multiple) {
......@@ -700,11 +721,11 @@ define(['require',
},
showLoader: function() {
this.$('.fontLoader').show();
this.$('.fontLoader:not(.for-ignore)').show();
this.$('.tableOverlay').show();
},
hideLoader: function() {
this.$('.fontLoader').hide();
this.$('.fontLoader:not(.for-ignore)').hide();
this.$('.ellipsis,.labelShowRecord').show(); // only for first time
this.$('.tableOverlay').hide();
},
......@@ -846,11 +867,25 @@ define(['require',
});
},
onCheckDeletedEntity: function(e) {
var includeDE = false;
if (e.target.checked) {
includeDE = true;
$.extend(this.searchCollection.queryParams, { limit: this.limit, excludeDeletedEntities: false });
} else {
$.extend(this.searchCollection.queryParams, { limit: this.limit, excludeDeletedEntities: true });
}
if (this.value) {
this.value.includeDE = includeDE;
Utils.setUrl({
url: '#!/search/searchResult',
urlParams: this.value,
mergeBrowserUrl: false,
trigger: false,
updateTabState: function() {
return { searchUrl: this.url, stateChanged: true };
}
});
}
this.fetchCollection();
}
});
......
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