Commit 9a4ed469 by kevalbhatt Committed by Madhan Neethiraj

ATLAS-1894: Search using entity/tag attribute filters

parent 7c262b40
The MIT License (MIT)
Copyright (c) 2012-2017 Dan Grossman
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2015 Jonathan Peterson (@Eonasdan)
Copyright (c) 2014-2015 Damien Sorel
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
......
......@@ -248,9 +248,12 @@ MIT License. For details, see 3party-licenses/es5-shim-LICENSE
This product bundles Respond, which is available under
MIT License. For details, see 3party-licenses/Respond-LICENSE
This product bundles bootstrap-datepicker 4.14.30, which is available under
MIT License. For details, see 3party-licenses/bootstrap-datepicker-LICENSE
This product bundles Google Fonts, which are available under
Open Font License. For details, see 3party-licenses/google-fonts-LICENSE
This product bundles bootstrap-daterangepicker 2.1.25, which is available under
MIT License. For details, see 3party-licenses/bootstrap-daterangepicker-LICENSE
This product bundles jQuery QueryBuilder 2.4.3, which is available under
MIT License. For details, see 3party-licenses/jQuery-QueryBuilder-LICENSE
=======================================================================
......@@ -32,9 +32,6 @@ module.exports = function(grunt) {
modulesPath = '../public/'
}
var proxySnippet = require('grunt-connect-proxy/lib/utils').proxyRequest;
grunt.initConfig({
watch: {
js: {
......@@ -130,7 +127,9 @@ module.exports = function(grunt) {
'backgrid-select-all': 'backgrid-select-all/backgrid-select-all.min.js',
'moment/js': 'moment/min/moment.min.js',
'jquery-placeholder/js': 'jquery-placeholder/jquery.placeholder.js',
'platform': 'platform/platform.js'
'platform': 'platform/platform.js',
'jQueryQueryBuilder/js': 'jQuery-QueryBuilder/dist/js/query-builder.standalone.min.js',
'bootstrap-daterangepicker/js': 'bootstrap-daterangepicker/daterangepicker.js'
}
},
css: {
......@@ -149,7 +148,9 @@ module.exports = function(grunt) {
'select2/css': 'select2/dist/css/select2.min.css',
'backgrid-select-all': 'backgrid-select-all/backgrid-select-all.min.css',
'font-awesome/css': 'font-awesome/css/font-awesome.min.css',
'font-awesome/fonts': 'font-awesome/fonts'
'font-awesome/fonts': 'font-awesome/fonts',
'jQueryQueryBuilder/css': 'jQuery-QueryBuilder/dist/css/query-builder.default.min.css',
'bootstrap-daterangepicker/css': 'bootstrap-daterangepicker/daterangepicker.css'
}
},
......@@ -177,13 +178,19 @@ module.exports = function(grunt) {
'dagre-d3': 'dagre-d3/LICENSE',
'backgrid-select-all': 'backgrid-select-all/LICENSE-MIT',
'jquery-placeholder': 'jquery-placeholder/LICENSE.txt',
'platform/': 'platform/LICENSE'
'platform/': 'platform/LICENSE',
'jQueryQueryBuilder/': 'jQuery-QueryBuilder/LICENSE'
}
}
},
sass: {
dist: {
files: {
'dist/css/style.css': 'public/css/scss/style.scss'
}
},
build: {
files: {
'dist/css/style.css': 'dist/css/scss/style.scss'
}
}
......@@ -192,7 +199,13 @@ module.exports = function(grunt) {
dist: {
expand: true,
cwd: modulesPath,
src: ['**', '!**/*.sass'],
src: ['**', '!**/scss/**'],
dest: distPath
},
build: {
expand: true,
cwd: modulesPath,
src: ['**'],
dest: distPath
}
},
......@@ -201,6 +214,41 @@ module.exports = function(grunt) {
options: {
force: true
}
},
uglify: {
build: {
files: [{
expand: true,
cwd: 'dist/js',
src: '**/*.js',
dest: 'dist/js'
}]
}
},
cssmin: {
build: {
files: [{
expand: true,
cwd: 'dist/css',
src: '*.css',
dest: 'dist/css'
}]
}
},
htmlmin: {
build: {
options: {
removeComments: true,
collapseWhitespace: true
},
files: [{
expand: true,
cwd: 'dist/js/templates',
src: '**/*.html',
dest: 'dist/js/templates'
}]
}
}
});
......@@ -208,7 +256,9 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-npmcopy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-htmlmin');
require('load-grunt-tasks')(grunt);
......@@ -226,33 +276,45 @@ module.exports = function(grunt) {
'npmcopy:css',
'npmcopy:license',
'copy:dist',
'sass',
'sass:dist',
'configureProxies:server',
'connect:server',
/* 'concurrent',*/
'watch',
/*'connect:livereload'*/
'watch'
]);
grunt.registerTask('build', [
'clean',
'npmcopy:js',
'npmcopy:css',
'npmcopy:license',
'copy:build',
'sass:build'
]);
grunt.registerTask('dev-minify', [
'clean',
'npmcopy:js',
'npmcopy:css',
'npmcopy:license',
'copy:dist',
'sass'
'sass:dist',
'uglify:build',
'cssmin:build',
'htmlmin:build',
'configureProxies:server',
'connect:server',
'watch'
]);
grunt.registerTask('minify', 'Minify the all js', function() {
var done = this.async();
grunt.task.run(['shell:min']);
done();
});
grunt.registerTask('release', 'Create release package', function() {
var done = this.async();
git.short(function(str) {
gitHash = str;
grunt.task.run(['minify', 'compress:release']);
done();
});
});
grunt.registerTask('build-minify', [
'clean',
'npmcopy:js',
'npmcopy:css',
'npmcopy:license',
'copy:build',
'sass:build',
'uglify:build',
'cssmin:build',
'htmlmin:build'
]);
};
......@@ -28,10 +28,12 @@
"backgrid-select-all": "^0.3.5",
"backgrid-sizeable-columns": "^0.1.1",
"bootstrap": "^3.3.5",
"bootstrap-daterangepicker": "^2.1.25",
"d3": "^3.5.16",
"d3-tip": "^0.6.7",
"dagre-d3": "^0.4.17",
"font-awesome": "^4.6.3",
"jQuery-QueryBuilder": "^2.4.3",
"jquery": "^2.2.2",
"jquery-asBreadcrumbs": "^0.2.1",
"jquery-placeholder": "^2.3.1",
......@@ -55,7 +57,10 @@
"grunt-contrib-compress": "^0.13.0",
"grunt-contrib-connect": "^1.0.0",
"grunt-contrib-copy": "~0.8.0",
"grunt-contrib-cssmin": "^2.0.0",
"grunt-contrib-htmlmin": "^2.2.0",
"grunt-contrib-jshint": "^0.11.0",
"grunt-contrib-uglify": "^2.1.0",
"grunt-contrib-watch": "^0.6.1",
"grunt-dev-update": "^1.0.2",
"grunt-jsbeautifier": "^0.2.6",
......
......@@ -166,6 +166,10 @@ button:focus {
margin-bottom: 10px;
border-radius: 4px;
padding: 5px 10px;
&.active {
background-color: $color_keppel_approx;
color: $white;
}
&:hover {
background-color: $color_keppel_approx;
color: $white;
......
......@@ -46,6 +46,7 @@
position: relative;
padding: 15px;
max-height: 400px;
min-height: 70px;
overflow: auto;
}
......@@ -265,3 +266,23 @@
margin-left: 5px;
cursor: pointer;
}
.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 {
top: -8px;
}
.query-builder .rules-group-header .btn-group.group-conditions label {
display: none;
}
.query-builder .rule-value-container input {
padding: 6px 12px !important;
}
......@@ -114,3 +114,20 @@ $switchTransition: .4s ease-out;
color: $gray
}
}
.filterQuery {
word-break: break-all;
span {
font-size: 15px;
font-weight: bold;
}
.key {
color: $color_jungle_green_approx;
}
.operator {
color: $action_gray;
}
.value {
color: $tag_color;
}
}
......@@ -45,12 +45,13 @@
<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">
<link rel="stylesheet" href="js/external_lib/datetimepicker/bootstrap-datetimepicker.min.css">
<link rel="stylesheet" href="css/googlefonts.css" type='text/css'>
<link rel="stylesheet" type="text/css" href="js/external_lib/jquery-ui/jquery-ui.min.css">
<link href="css/bootstrap-sidebar.css" rel="stylesheet">
<link href="js/libs/font-awesome/css/font-awesome.min.css" rel="stylesheet">
<link href="js/external_lib/pnotify/pnotify.custom.min.css" rel="stylesheet">
<link href="js/libs/jQueryQueryBuilder/css/query-builder.default.min.css" rel="stylesheet">
<link href="js/libs/bootstrap-daterangepicker/css/daterangepicker.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
......
......@@ -39,6 +39,17 @@ define(['require',
this.queryText = resp.queryText;
return resp.entities ? resp.entities : [];
},
getBasicRearchResult: function(options) {
var url = UrlLinks.searchApiUrl('basic');
options = _.extend({
contentType: 'application/json',
dataType: 'json',
}, options);
options.data = JSON.stringify(options.data);
return this.constructor.nonCrudOperation.call(this, url, 'POST', options);
}
},
//Static Class Members
{
......
......@@ -26,7 +26,7 @@ define(['require',
var VTagList = BaseCollection.extend(
//Prototypal attributes
{
url: UrlLinks.typesClassicationApiUrl(),
url: UrlLinks.classificationDefApiUrl(),
model: VTag,
initialize: function() {
this.modelName = 'VTag';
......
/*!
* Datetimepicker for Bootstrap 3
* version : 4.14.30
* https://github.com/Eonasdan/bootstrap-datetimepicker/
*/.bootstrap-datetimepicker-widget{list-style:none}.bootstrap-datetimepicker-widget.dropdown-menu{margin:2px 0;padding:4px;width:19em}@media (min-width:768px){.bootstrap-datetimepicker-widget.dropdown-menu.timepicker-sbs{width:38em}}@media (min-width:992px){.bootstrap-datetimepicker-widget.dropdown-menu.timepicker-sbs{width:38em}}@media (min-width:1200px){.bootstrap-datetimepicker-widget.dropdown-menu.timepicker-sbs{width:38em}}.bootstrap-datetimepicker-widget.dropdown-menu:after,.bootstrap-datetimepicker-widget.dropdown-menu:before{content:'';display:inline-block;position:absolute}.bootstrap-datetimepicker-widget.dropdown-menu.bottom:before{border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #ccc;border-bottom-color:rgba(0,0,0,.2);top:-7px;left:7px}.bootstrap-datetimepicker-widget.dropdown-menu.bottom:after{border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid #fff;top:-6px;left:8px}.bootstrap-datetimepicker-widget.dropdown-menu.top:before{border-left:7px solid transparent;border-right:7px solid transparent;border-top:7px solid #ccc;border-top-color:rgba(0,0,0,.2);bottom:-7px;left:6px}.bootstrap-datetimepicker-widget.dropdown-menu.top:after{border-left:6px solid transparent;border-right:6px solid transparent;border-top:6px solid #fff;bottom:-6px;left:7px}.bootstrap-datetimepicker-widget.dropdown-menu.pull-right:before{left:auto;right:6px}.bootstrap-datetimepicker-widget.dropdown-menu.pull-right:after{left:auto;right:7px}.bootstrap-datetimepicker-widget .list-unstyled{margin:0}.bootstrap-datetimepicker-widget a[data-action]{padding:6px 0}.bootstrap-datetimepicker-widget a[data-action]:active{box-shadow:none}.bootstrap-datetimepicker-widget .timepicker-hour,.bootstrap-datetimepicker-widget .timepicker-minute,.bootstrap-datetimepicker-widget .timepicker-second{width:54px;font-weight:700;font-size:1.2em;margin:0}.bootstrap-datetimepicker-widget button[data-action]{padding:6px}.bootstrap-datetimepicker-widget .btn[data-action=incrementHours]::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Increment Hours"}.bootstrap-datetimepicker-widget .btn[data-action=incrementMinutes]::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Increment Minutes"}.bootstrap-datetimepicker-widget .btn[data-action=decrementHours]::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Decrement Hours"}.bootstrap-datetimepicker-widget .btn[data-action=decrementMinutes]::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Decrement Minutes"}.bootstrap-datetimepicker-widget .btn[data-action=showHours]::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Show Hours"}.bootstrap-datetimepicker-widget .btn[data-action=showMinutes]::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Show Minutes"}.bootstrap-datetimepicker-widget .btn[data-action=togglePeriod]::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Toggle AM/PM"}.bootstrap-datetimepicker-widget .btn[data-action=clear]::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Clear the picker"}.bootstrap-datetimepicker-widget .btn[data-action=today]::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Set the date to today"}.bootstrap-datetimepicker-widget .picker-switch{text-align:center}.bootstrap-datetimepicker-widget .picker-switch::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Toggle Date and Time Screens"}.bootstrap-datetimepicker-widget .picker-switch td{padding:0;margin:0;height:auto;width:auto;line-height:inherit}.bootstrap-datetimepicker-widget .picker-switch td span{line-height:2.5;height:2.5em;width:100%}.bootstrap-datetimepicker-widget table{width:100%;margin:0}.bootstrap-datetimepicker-widget table td,.bootstrap-datetimepicker-widget table th{text-align:center;border-radius:4px}.bootstrap-datetimepicker-widget table th{height:20px;line-height:20px;width:20px}.bootstrap-datetimepicker-widget table th.picker-switch{width:145px}.bootstrap-datetimepicker-widget table th.disabled,.bootstrap-datetimepicker-widget table th.disabled:hover{background:0 0;color:#777;cursor:not-allowed}.bootstrap-datetimepicker-widget table th.prev::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Previous Month"}.bootstrap-datetimepicker-widget table th.next::after{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0;content:"Next Month"}.bootstrap-datetimepicker-widget table thead tr:first-child th{cursor:pointer}.bootstrap-datetimepicker-widget table thead tr:first-child th:hover{background:#eee}.bootstrap-datetimepicker-widget table td{height:54px;line-height:54px;width:54px}.bootstrap-datetimepicker-widget table td.cw{font-size:.8em;height:20px;line-height:20px;color:#777}.bootstrap-datetimepicker-widget table td.day{height:20px;line-height:20px;width:20px}.bootstrap-datetimepicker-widget table td.day:hover,.bootstrap-datetimepicker-widget table td.hour:hover,.bootstrap-datetimepicker-widget table td.minute:hover,.bootstrap-datetimepicker-widget table td.second:hover{background:#eee;cursor:pointer}.bootstrap-datetimepicker-widget table td.new,.bootstrap-datetimepicker-widget table td.old{color:#777}.bootstrap-datetimepicker-widget table td.today{position:relative}.bootstrap-datetimepicker-widget table td.today:before{content:'';display:inline-block;border:0 solid transparent;border-bottom-color:#337ab7;border-top-color:rgba(0,0,0,.2);position:absolute;bottom:4px;right:4px}.bootstrap-datetimepicker-widget table td.active,.bootstrap-datetimepicker-widget table td.active:hover{background-color:#337ab7;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25)}.bootstrap-datetimepicker-widget table td.active.today:before{border-bottom-color:#fff}.bootstrap-datetimepicker-widget table td.disabled,.bootstrap-datetimepicker-widget table td.disabled:hover{background:0 0;color:#777;cursor:not-allowed}.bootstrap-datetimepicker-widget table td span{display:inline-block;width:54px;height:54px;line-height:54px;margin:2px 1.5px;cursor:pointer;border-radius:4px}.bootstrap-datetimepicker-widget table td span:hover{background:#eee}.bootstrap-datetimepicker-widget table td span.active{background-color:#337ab7;color:#fff;text-shadow:0 -1px 0 rgba(0,0,0,.25)}.bootstrap-datetimepicker-widget table td span.old{color:#777}.bootstrap-datetimepicker-widget table td span.disabled,.bootstrap-datetimepicker-widget table td span.disabled:hover{background:0 0;color:#777;cursor:not-allowed}.bootstrap-datetimepicker-widget.usetwentyfour td.hour{height:27px;line-height:27px}.bootstrap-datetimepicker-widget.wider{width:21em}.bootstrap-datetimepicker-widget .datepicker-decades .decade{line-height:1.8em!important}.input-group.date .input-group-addon{cursor:pointer}.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);border:0}
\ No newline at end of file
......@@ -94,10 +94,6 @@ require.config({
'deps': ['d3'],
'exports': ['d3-tip']
},
'datetimepicker': {
'deps': ['jquery'],
'exports': 'datetimepicker'
},
'dagreD3': {
'deps': ['d3'],
'exports': ['dagreD3']
......@@ -107,6 +103,12 @@ require.config({
},
'jquery-placeholder': {
'deps': ['jquery']
},
'query-builder': {
'deps': ['jquery']
},
'daterangepicker': {
'deps': ['jquery', 'moment']
}
},
......@@ -137,12 +139,13 @@ require.config({
'backgrid-select-all': 'libs/backgrid-select-all/backgrid-select-all.min',
'moment': 'libs/moment/js/moment.min',
'jquery-ui': 'external_lib/jquery-ui/jquery-ui.min',
'datetimepicker': 'external_lib/datetimepicker/bootstrap-datetimepicker',
'pnotify': 'external_lib/pnotify/pnotify.custom.min',
'pnotify.buttons': 'external_lib/pnotify/pnotify.custom.min',
'pnotify.confirm': 'external_lib/pnotify/pnotify.custom.min',
'jquery-placeholder': 'libs/jquery-placeholder/js/jquery.placeholder',
'platform': 'libs/platform/platform'
'platform': 'libs/platform/platform',
'query-builder': 'libs/jQueryQueryBuilder/js/query-builder.standalone.min',
'daterangepicker': 'libs/bootstrap-daterangepicker/js/daterangepicker'
},
/**
......@@ -167,7 +170,7 @@ require(['App',
'select2'
], function(App, Router, CommonViewFunction, Globals, UrlLinks, VEntityList, VTagList) {
var that = this;
this.asyncFetchCounter = 4;
this.asyncFetchCounter = 5;
this.entityDefCollection = new VEntityList();
this.entityDefCollection.url = UrlLinks.entitiesDefApiUrl();
this.typeHeaders = new VTagList();
......@@ -175,11 +178,13 @@ require(['App',
this.enumDefCollection = new VTagList();
this.enumDefCollection.url = UrlLinks.enumDefApiUrl();
this.enumDefCollection.modelAttrName = "enumDefs";
this.classificationDefCollection = new VTagList();
App.appRouter = new Router({
entityDefCollection: this.entityDefCollection,
typeHeaders: this.typeHeaders,
enumDefCollection: this.enumDefCollection
enumDefCollection: this.enumDefCollection,
classificationDefCollection: this.classificationDefCollection
});
var startApp = function() {
......@@ -238,4 +243,11 @@ require(['App',
startApp();
}
});
this.classificationDefCollection.fetch({
skipDefaultError: true,
complete: function() {
--that.asyncFetchCounter;
startApp();
}
});
});
......@@ -49,7 +49,7 @@ define(['require',
}, options);
return this.constructor.nonCrudOperation.call(this, url, 'GET', options);
},
}
}, {});
return VSearch;
});
......@@ -23,7 +23,7 @@ define(['require',
], function(require, Globals, vBaseModel, UrlLinks) {
'use strict';
var VTag = vBaseModel.extend({
urlRoot: UrlLinks.typesClassicationApiUrl(),
urlRoot: UrlLinks.classificationDefApiUrl(),
defaults: {},
......@@ -49,7 +49,7 @@ define(['require',
return this.constructor.nonCrudOperation.call(this, url, 'DELETE', options);
},
deleteTag: function(options) {
var url = UrlLinks.typesClassicationApiUrl();
var url = UrlLinks.classificationDefApiUrl();
options = _.extend({
contentType: 'application/json',
dataType: 'json'
......@@ -57,7 +57,7 @@ define(['require',
return this.constructor.nonCrudOperation.call(this, url, 'DELETE', options);
},
saveTagAttribute: function(options) {
var url = UrlLinks.typesClassicationApiUrl();
var url = UrlLinks.classificationDefApiUrl();
options = _.extend({
contentType: 'application/json',
dataType: 'json'
......
......@@ -42,16 +42,16 @@ define([
'*actions': 'defaultAction'
},
initialize: function(options) {
_.extend(this, _.pick(options, 'entityDefCollection', 'typeHeaders', 'enumDefCollection'));
_.extend(this, _.pick(options, 'entityDefCollection', 'typeHeaders', 'enumDefCollection', 'classificationDefCollection'));
this.showRegions();
this.bindCommonEvents();
this.listenTo(this, 'route', this.postRouteExecute, this);
this.tagCollection = new VTagList();
this.searchVent = new Backbone.Wreqr.EventAggregator();
this.preFetchedCollectionLists = {
'entityDefCollection': this.entityDefCollection,
'typeHeaders': this.typeHeaders,
'enumDefCollection': this.enumDefCollection
'enumDefCollection': this.enumDefCollection,
'classificationDefCollection': this.classificationDefCollection
}
},
bindCommonEvents: function() {
......@@ -125,7 +125,6 @@ define([
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'url': url,
'collection': that.tagCollection
}, that.preFetchedCollectionLists)
));
} else {
......@@ -157,9 +156,7 @@ define([
App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'collection': that.tagCollection,
}, that.preFetchedCollectionLists)
_.extend({}, that.preFetchedCollectionLists)
));
} else {
App.rSideNav.currentView.selectTab();
......@@ -196,8 +193,7 @@ define([
}
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'tag': tagName,
'collection': that.tagCollection
'tag': tagName
}, that.preFetchedCollectionLists)
));
} else {
......@@ -221,8 +217,7 @@ define([
}
App.rNContent.show(new TagDetailLayoutView(
_.extend({
'tag': tagName,
'collection': that.tagCollection,
'tag': tagName
}, that.preFetchedCollectionLists)
));
}
......@@ -236,12 +231,17 @@ define([
'views/business_catalog/SideNavLayoutView',
'views/search/SearchDetailLayoutView',
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams();
var paramObj = Utils.getUrlState.getQueryParams(),
filterObj = {
'tagFilters': JSON.parse(Utils.localStorage.getValue('tagFilters')),
'entityFilters': JSON.parse(Utils.localStorage.getValue('entityFilters'))
}
App.rNHeader.show(new Header());
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'collection': that.tagCollection
'searchVent': that.searchVent,
'filterObj': filterObj
}, that.preFetchedCollectionLists)
));
} else {
......@@ -256,7 +256,9 @@ define([
App.rNContent.show(new SearchDetailLayoutView(
_.extend({
'value': paramObj,
'initialView': true
'initialView': true,
'filterObj': filterObj,
'searchVent': that.searchVent
}, that.preFetchedCollectionLists)
));
} else {
......@@ -273,14 +275,42 @@ define([
'views/business_catalog/SideNavLayoutView',
'views/search/SearchDetailLayoutView'
], function(Header, BusinessCatalogLayoutView, SideNavLayoutView, SearchDetailLayoutView) {
var paramObj = Utils.getUrlState.getQueryParams();
var paramObj = Utils.getUrlState.getQueryParams(),
filterObj = {
'tagFilters': JSON.parse(Utils.localStorage.getValue('tagFilters')),
'entityFilters': JSON.parse(Utils.localStorage.getValue('entityFilters'))
}
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());
if (!App.rSideNav.currentView) {
App.rSideNav.show(new SideNavLayoutView(
_.extend({
'value': paramObj,
'collection': that.tagCollection,
'searchVent': that.searchVent
'searchVent': that.searchVent,
'filterObj': filterObj
}, that.preFetchedCollectionLists)
));
} else {
......@@ -291,6 +321,7 @@ define([
_.extend({
'value': paramObj,
'searchVent': that.searchVent,
'filterObj': filterObj,
'initialView': (paramObj.type || (paramObj.dslChecked == "true" ? "" : paramObj.tag) || (paramObj.query ? paramObj.query.trim() : "")).length === 0
}, that.preFetchedCollectionLists)
));
......
<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<div id="builder"></div>
......@@ -33,16 +33,26 @@
</div>
<div class="col-sm-12">
<div class="form-group">
<div class="srchType">
<div class="srchType clearfix">
<span class="srchTitle">Search By Type</span>
<div class="typeLOV">
<select data-id="typeLOV"></select>
<div class="">
<div class="col-sm-10 no-padding temFilter">
<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>
</div>
</div>
</div>
<div class="srchType tagBox">
<div class="srchType tagBox clearfix">
<span class="srchTitle">Search By Tag</span>
<div class="typeLOV">
<select data-id="tagLOV"></select>
<div>
<div class="col-sm-10 no-padding">
<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>
</div>
</div>
</div>
<div class="srchType">
......
<!--
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<div id="r_queryBuilder">
<div class="fontLoader">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
</div>
......@@ -20,6 +20,21 @@
<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>
......
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<div class="fontLoader" style="margin-top:-10px">
<div class="fontLoader">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
<div class="row row-margin-bottom hide">
......
......@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
-->
<div class="fontLoader" style="margin-top:-10px">
<div class="fontLoader">
<i class="fa fa-refresh fa-spin-custom"></i>
</div>
<form name="tagDefinitionform" class="css-form hide" data-id="createTagForm">
......
......@@ -49,7 +49,6 @@ define(['require', 'utils/Utils', 'marionette', 'backgrid', 'asBreadcrumbs', 'jq
}
}
});
// For placeholder support
if (!('placeholder' in HTMLInputElement.prototype)) {
var originalRender = Backbone.Marionette.LayoutView.prototype.render;
......@@ -141,4 +140,8 @@ define(['require', 'utils/Utils', 'marionette', 'backgrid', 'asBreadcrumbs', 'jq
return this;
}
});
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
});
......@@ -28,6 +28,23 @@ define(['require', 'utils/Enums'], function(require, Enums) {
def: this.baseUrlV2 + '/types/typedef'
};
},
entitiesDefApiUrl: function(name) {
return this.getDefApiUrl('entity', name);
},
classificationDefApiUrl: function(name) {
return this.getDefApiUrl('classification', name);
},
enumDefApiUrl: function(name) {
return this.getDefApiUrl('enum', name);
},
getDefApiUrl: function(type, name) {
var defApiUrl = this.typedefsUrl();
if (name) {
return defApiUrl.def + '/name/' + name + '?type=' + type;
} else {
return defApiUrl.defs + '?type=' + type;
}
},
taxonomiesApiUrl: function() {
return this.baseUrl + '/v1/taxonomies';
},
......@@ -44,22 +61,6 @@ define(['require', 'utils/Enums'], function(require, Enums) {
return entitiesUrl;
}
},
entitiesDefApiUrl: function(name) {
var entitieDefUrl = this.typedefsUrl();
if (name) {
return entitieDefUrl.def + '/name/' + name + '?type=entity';
} else {
return entitieDefUrl.defs + '?type=entity';
}
},
enumDefApiUrl: function(name) {
var enumDefApiUrl = this.typedefsUrl();
if (name) {
return enumDefApiUrl.def + '/name/' + name + '?type=enum';
} else {
return enumDefApiUrl.defs + '?type=enum';
}
},
entitiesTraitsApiUrl: function(token) {
if (token) {
return this.baseUrlV2 + '/entity/guid/' + token + '/classifications';
......@@ -67,19 +68,16 @@ define(['require', 'utils/Enums'], function(require, Enums) {
// For Multiple Assignment
return this.baseUrlV2 + '/entity/bulk/classification';
}
},
entityCollectionaudit: function(guid) {
return this.baseUrl + '/entities/' + guid + '/audit';
},
typesClassicationApiUrl: function(name, guid) {
classicationApiUrl: function(name, guid) {
var typeUrl = this.typedefsUrl();
if (name) {
return typeUrl.def + '/name/' + name + '?type=classification';
} else if (guid) {
return typeUrl.def + '/guid/' + guid + '?type=classification';
} else {
return typeUrl.defs + '?type=classification';
}
},
typesApiUrl: function() {
......
......@@ -166,37 +166,11 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button
});
}
};
Utils.localStorage = {
checkLocalStorage: function(key, value) {
if (typeof(Storage) !== "undefined") {
return this.getLocalStorage(key, value);
} else {
console.log('Sorry! No Web Storage support');
Utils.cookie.checkCookie(key, value);
}
},
setLocalStorage: function(key, value) {
localStorage.setItem(key, value);
return { found: false, 'value': value };
},
getLocalStorage: function(key, value) {
var keyValue = localStorage.getItem(key);
if (!keyValue || keyValue == "undefined") {
return this.setLocalStorage(key, value);
} else {
return { found: true, 'value': keyValue };
}
}
};
Utils.cookie = {
setCookie: function(cname, cvalue) {
//var d = new Date();
//d.setTime(d.getTime() + (exdays*24*60*60*1000));
//var expires = "expires=" + d.toGMTString();
setValue: function(cname, cvalue) {
document.cookie = cname + "=" + cvalue + "; ";
return { found: false, 'value': cvalue };
},
getCookie: function(findString) {
getValue: function(findString) {
var search = findString + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
......@@ -207,16 +181,34 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button
}
}
return "";
},
checkCookie: function(key, value) {
var findString = getCookie(key);
if (findString != "" || keyValue != "undefined") {
return { found: true, 'value': ((findString == "undefined") ? (undefined) : (findString)) };
}
};
Utils.localStorage = function() {
this.setValue = function() {
localStorage.setItem(arguments[0], arguments[1]);
}
this.getValue = function(key, value) {
var keyValue = localStorage.getItem(key);
if ((!keyValue || keyValue == "undefined") && (value != undefined)) {
return this.setLocalStorage(key, value);
} else {
return setCookie(key, value);
if (keyValue === "" || keyValue === "undefined" || keyValue === "null") {
return null;
} else {
return keyValue;
}
}
}
};
this.removeValue = function() {
localStorage.removeItem(arguments[0]);
}
if (typeof(Storage) === "undefined") {
_.extend(this, Utils.cookie);
console.log('Sorry! No Web Storage support');
}
}
Utils.localStorage = new Utils.localStorage();
Utils.setUrl = function(options) {
if (options) {
......@@ -509,16 +501,16 @@ define(['require', 'utils/Globals', 'pnotify', 'utils/Messages', 'pnotify.button
}
$('body').on('click', '.expand_collapse_panel', function() {
var icon = $(this).find('i'),
panel = $(this).parents('.panel'),
panel = $(this).parents('.panel').first(),
panelBody = panel.find('.panel-body');
icon.toggleClass('fa-chevron-up fa-chevron-down');
$(this).toggleAttribute('title', 'Collapse', 'Expand');
panelBody.toggle('0.5', 'linear');
panelBody.toggle();
$(this).trigger('expand_collapse_panel', [$(this).parents('.panel')]);
});
$('body').on('click', '.fullscreen_panel', function() {
var icon = $(this).find('i'),
panel = $(this).parents('.panel'),
panel = $(this).parents('.panel').first(),
panelBody = panel.find('.panel-body');
icon.toggleClass('fa-expand fa-compress');
$(this).toggleAttribute('title', 'Fullscreen', 'Exit Fullscreen');
......
......@@ -66,7 +66,7 @@ define(['require',
return events;
},
initialize: function(options) {
_.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'collection', 'typeHeaders', 'searchVent'));
_.extend(this, _.pick(options, 'url', 'value', 'tag', 'selectFirst', 'classificationDefCollection', 'typeHeaders', 'searchVent', 'entityDefCollection', 'enumDefCollection', 'filterObj'));
if (Globals.taxonomy) {
this.tabClass = "tab col-sm-4";
} else {
......@@ -94,7 +94,7 @@ define(['require',
var that = this;
require(['views/tag/TagLayoutView'], function(TagLayoutView) {
that.RTagLayoutView.show(new TagLayoutView({
collection: that.collection,
collection: that.classificationDefCollection,
tag: that.tag,
typeHeaders: that.typeHeaders
}));
......@@ -105,8 +105,12 @@ 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
typeHeaders: that.typeHeaders,
entityDefCollection: that.entityDefCollection,
enumDefCollection: that.enumDefCollection,
classificationDefCollection: that.classificationDefCollection
}));
});
},
......
......@@ -25,13 +25,13 @@ define(['require',
'models/VEntity',
'modules/Modal',
'utils/Messages',
'datetimepicker',
'moment',
'utils/UrlLinks',
'collection/VSearchList',
'utils/Enums',
'utils/Globals'
], function(require, Backbone, CreateEntityLayoutViewTmpl, Utils, VTagList, VEntityList, VEntity, Modal, Messages, datepicker, moment, UrlLinks, VSearchList, Enums, Globals) {
'utils/Globals',
'daterangepicker'
], function(require, Backbone, CreateEntityLayoutViewTmpl, Utils, VTagList, VEntityList, VEntity, Modal, Messages, moment, UrlLinks, VSearchList, Enums, Globals) {
var CreateEntityLayoutView = Backbone.Marionette.LayoutView.extend(
/** @lends CreateEntityLayoutView */
......@@ -145,7 +145,7 @@ define(['require',
}
});
this.ui.entityInputData.on('keyup change dp.change', 'input.true,select.true', function(e) {
this.ui.entityInputData.on('keyup change', 'input.true,select.true', function(e) {
if (this.value !== "") {
if ($(this).data('select2')) {
$(this).data('select2').$container.find('.select2-selection').removeClass("errorClass");
......@@ -171,7 +171,7 @@ define(['require',
},
bindNonRequiredField: function() {
var that = this;
this.ui.entityInputData.off('keyup change dp.change', 'input.false,select.false').on('keyup change dp.change', 'input.false,select.false', function(e) {
this.ui.entityInputData.off('keyup change', 'input.false,select.false').on('keyup change', 'input.false,select.false', function(e) {
if (that.modal.$el.find('button.ok').prop('disabled') && that.ui.entityInputData.find('.errorClass').length === 0) {
that.modal.$el.find('button.ok').prop("disabled", false);
}
......@@ -331,11 +331,12 @@ define(['require',
initilizeElements: function() {
var that = this;
this.$('input[data-type="date"]').each(function() {
if (!$(this).data('datepicker')) {
$(this).datetimepicker({
format: 'DD MMMM YYYY',
keepInvalid: true
});
if (!$(this).data('daterangepicker')) {
var dateObj = { "singleDatePicker": true, "showDropdowns": true };
if (that.guid) {
dateObj["startDate"] = this.value
}
$(this).daterangepicker(dateObj);
}
});
this.initializeValidation();
......@@ -387,9 +388,9 @@ define(['require',
removeText(e, e.currentTarget.value);
});
this.$('input[data-type="date"]').on('dp.hide keydown', function(event) {
this.$('input[data-type="date"]').on('hide.daterangepicker keydown', function(event) {
if (event.type) {
if (event.type == 'dp') {
if (event.type == 'hide') {
this.blur();
} else if (event.type == 'keydown') {
return false;
......@@ -462,7 +463,7 @@ define(['require',
entityValue = dataValue;
}
if (value.typeName === "date" && dataValue) {
entityValue = moment(dataValue).format("DD MMMM YYYY");
entityValue = moment(dataValue).format("MM/DD/YYYY");
}
}
}
......@@ -538,7 +539,7 @@ define(['require',
if (dataTypeEnitity && datakeyEntity) {
if (that.entityDefCollection.fullCollection.find({ name: dataTypeEnitity })) {
entity[datakeyEntity] = extractValue(value, typeName);
} else if (typeof dataTypeEnitity === 'string' && datakeyEntity.indexOf("Time") > -1) {
} else if (dataTypeEnitity === 'date' || dataTypeEnitity === 'time') {
entity[datakeyEntity] = Date.parse(value);
} else if (dataTypeEnitity.indexOf("map") > -1 || (typeNameCategory && typeNameCategory.get('category') === 'STRUCT')) {
try {
......
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
define(['require',
'backbone',
'hbs!tmpl/search/QueryBuilder_tmpl',
'utils/Utils',
'query-builder',
'daterangepicker'
], function(require, Backbone, QueryBuilder_Tmpl, Utils) {
var QueryBuilderView = Backbone.Marionette.LayoutView.extend(
/** @lends QueryBuilderView */
{
_viewName: 'QueryBuilderView',
template: QueryBuilder_Tmpl,
/** Layout sub regions */
regions: {},
/** ui selector cache */
ui: {
"builder": "#builder"
},
/** ui events hash */
events: function() {
var events = {};
return events;
},
/**
* intialize a new QueryBuilderView Layout
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'attrObj', 'value', 'typeHeaders', 'filterObj', 'entityDefCollection', 'enumDefCollection', 'tag'));
this.attrObj = _.sortBy(this.attrObj, 'name');
},
bindEvents: function() {},
getOperator: function(type) {
var obj = {
operators: null
}
if (type === "string") {
obj.operators = ['=', '!=', 'contains', 'begins_with', 'ends_with'];
}
if (type === "enum" || type === "date" || type === "int" || type === "byte" || type === "short" || type === "long" || type === "float" || type === "double") {
obj.operators = ['=', '!=', '>', '<', '>=', '<='];
}
return obj;
},
isPrimitive: function(type) {
if (type === "int" || type === "byte" || type === "short" || type === "long" || type === "float" || type === "double" || type === "string" || type === "boolean" || type === "date") {
return true;
}
return false;
},
getObjDef: function(attrObj, rules) {
var obj = {
id: attrObj.name,
label: attrObj.name.capitalize(),
type: attrObj.typeName
};
if (obj.type === "date") {
obj['plugin'] = 'daterangepicker';
obj['plugin_config'] = {
"singleDatePicker": true,
"showDropdowns": true,
"timePicker": true,
locale: {
format: 'MM/DD/YYYY h:mm A'
}
};
if (rules && rules.rules) {
var valueObj = _.find(rules.rules, { id: obj.id });
if (valueObj) {
obj.plugin_config["startDate"] = valueObj.value;
}
}
_.extend(obj, this.getOperator(obj.type));
return obj;
}
if (this.isPrimitive(obj.type)) {
if (obj.type === "long" || obj.type === "float") {
obj.type = "double";
}
if (obj.type === "int" || obj.type === "byte" || obj.type === "short") {
obj.type = "integer";
}
if (obj.type === "boolean") {
obj['input'] = 'select';
obj['values'] = ['true', 'false'];
}
_.extend(obj, this.getOperator(obj.type));
return obj;
}
var enumObj = this.enumDefCollection.fullCollection.find({ name: obj.type });
if (enumObj) {
obj.type = "string";
obj['input'] = 'select';
var value = [];
_.each(enumObj.get('elementDefs'), function(o) {
value.push(o.value)
})
obj['values'] = value;
_.extend(obj, this.getOperator('enum'));
return obj;
}
},
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;
}
}
}
_.each(this.attrObj, function(obj) {
var returnObj = that.getObjDef(obj, rules_widgets);
if (returnObj) {
filters.push(returnObj);
}
});
if (filters && !_.isEmpty(filters)) {
this.ui.builder.queryBuilder({
plugins: ['bt-tooltip-errors'],
filters: filters,
select_placeholder: '--Select Attribute--',
allow_empty: true,
conditions: ['AND'],
allow_groups: false,
allow_empty: true,
operators: [
{ type: '=', nb_inputs: 1, multiple: false, apply_to: ['number', 'string', 'boolean'] },
{ type: '!=', nb_inputs: 1, multiple: false, apply_to: ['number', 'string', 'boolean'] },
{ type: '>', nb_inputs: 1, multiple: false, apply_to: ['number', 'string', 'boolean'] },
{ type: '<', nb_inputs: 1, multiple: false, apply_to: ['number', 'string', 'boolean'] },
{ type: '>=', nb_inputs: 1, multiple: false, apply_to: ['number', 'string', 'boolean'] },
{ type: '<=', nb_inputs: 1, multiple: false, apply_to: ['number', 'string', 'boolean'] },
{ type: 'contains', nb_inputs: 1, multiple: false, apply_to: ['string'] },
{ type: 'begins_with', nb_inputs: 1, multiple: false, apply_to: ['string'] },
{ type: 'ends_with', nb_inputs: 1, multiple: false, apply_to: ['string'] }
],
lang: {
add_rule: 'Add filter',
add_group: 'Add filter group'
},
rules: rules_widgets
});
this.$('.rules-group-header .btn-group.pull-right.group-actions').toggleClass('pull-right pull-left');
} else {
this.ui.builder.html('<h4>No Attributes are available !</h4>')
}
}
});
return QueryBuilderView;
});
......@@ -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', 'filterObj'));
},
bindEvents: function() {},
onRender: function() {
......@@ -62,6 +62,7 @@ define(['require',
entityDefCollection: that.entityDefCollection,
typeHeaders: that.typeHeaders,
searchVent: that.searchVent,
filterObj: that.filterObj,
enumDefCollection: that.enumDefCollection
}));
}
......
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
define(['require',
'backbone',
'modules/Modal',
'utils/Utils',
'hbs!tmpl/search/SearchQuery_tmpl',
], function(require, Backbone, Modal, Utils, SearchQuery_Tmpl) {
var SearchQueryView = Backbone.Marionette.LayoutView.extend(
/** @lends SearchQueryView */
{
_viewName: 'SearchQueryView',
template: SearchQuery_Tmpl,
/** Layout sub regions */
regions: {
RQueryBuilder: '#r_queryBuilder',
},
/** ui selector cache */
ui: {},
/** ui events hash */
events: function() {
var events = {};
return events;
},
/**
* intialize a new SearchQueryView Layout
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'value', 'entityDefCollection', 'typeHeaders', 'searchVent', 'enumDefCollection', 'classificationDefCollection', 'tag', 'filterObj'));
this.bindEvents();
var that = this;
this.modal = new Modal({
title: 'Attribute Filter',
content: this,
okText: 'Apply',
cancelText: "Cancel",
allowCancel: true,
okCloses: false,
width: '50%'
}).open();
this.modal.on('closeModal', function() {
that.modal.trigger('cancel');
});
},
onRender: function() {
this.$('.fontLoader').show();
var obj = {
value: this.value,
searchVent: this.searchVent,
entityDefCollection: this.entityDefCollection,
enumDefCollection: this.enumDefCollection,
filterObj: this.filterObj,
classificationDefCollection: this.classificationDefCollection
}
if (this.tag) {
obj['tag'] = true;
obj['attrObj'] = this.classificationDefCollection.fullCollection.find({ name: this.value.tag });
if (obj.attrObj) {
obj.attrObj = Utils.getNestedSuperTypeObj({
data: obj.attrObj.toJSON(),
collection: this.classificationDefCollection,
attrMerge: true,
});
}
} else {
obj['type'] = true;
obj['attrObj'] = this.entityDefCollection.fullCollection.find({ name: this.value.type });
if (obj.attrObj) {
obj.attrObj = Utils.getNestedSuperTypeObj({
data: obj.attrObj.toJSON(),
collection: this.entityDefCollection,
attrMerge: true
});
}
}
this.renderQueryBuilder(obj);
// this.showHideFilter(this.value);
},
bindEvents: function() {},
renderQueryBuilder: function(obj) {
var that = this;
require(['views/search/QueryBuilderView'], function(QueryBuilderView) {
that.RQueryBuilder.show(new QueryBuilderView(obj));
});
}
});
return SearchQueryView;
});
......@@ -44,6 +44,7 @@ define(['require',
RTagLayoutView: "#r_tagLayoutView",
RSearchLayoutView: "#r_searchLayoutView",
REntityTableLayoutView: "#r_searchResultTableLayoutView",
RSearchQuery: '#r_searchQuery'
},
/** ui selector cache */
......@@ -61,7 +62,9 @@ define(['require',
editEntityButton: "[data-id='editEntityButton']",
createEntity: "[data-id='createEntity']",
checkDeletedEntity: "[data-id='checkDeletedEntity']",
containerCheckBox: "[data-id='containerCheckBox']"
containerCheckBox: "[data-id='containerCheckBox']",
filterPanel: "#filterPanel",
filterQuery: "#filterQuery"
},
templateHelpers: function() {
return {
......@@ -126,7 +129,7 @@ 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', 'filterObj'));
var pagination = "";
this.entityModel = new VEntity();
this.searchCollection = new VSearchList();
......@@ -198,7 +201,7 @@ define(['require',
} else {
if (response.statusText !== "abort") {
Utils.notifyError({
content: "Invalid Expression : " + model.queryParams.query
content: "Invalid Expression"
});
}
}
......@@ -206,6 +209,9 @@ define(['require',
this.listenTo(this.searchVent, "search:refresh", function(model, response) {
this.fetchCollection();
}, this);
this.listenTo(this.searchVent, "searchAttribute", function(obj) {
this.showHideFilter(obj);
}, this);
},
onRender: function() {
if (!this.initialView) {
......@@ -234,27 +240,74 @@ define(['require',
this.$(".entityLink").show();
}
}
this.showHideFilter();
},
generateQueryOfFilter: function() {
var value = this.value,
entityFilters = this.filterObj && this.filterObj.entityFilters ? this.filterObj.entityFilters[value.type] : null,
tagFilters = this.filterObj && this.filterObj.tagFilters ? this.filterObj.tagFilters[value.tag] : null,
queryArray = [],
objToString = function(filterObj) {
var tempObj = [];
_.each(filterObj.rules, function(obj) {
tempObj.push('<span class="key">' + obj.field + '</span>&nbsp<span class="operator">' + obj.operator + '</span>&nbsp<span class="value">' + obj.value + "</span>")
});
return tempObj.join('&nbsp<span class="operator">AND</span>&nbsp');
}
if (entityFilters) {
var typeKeyValue = '<span class="key">Type:</span>&nbsp<span class="value">' + value.type + '</span>&nbsp<span class="operator">AND</span>&nbsp';
queryArray = queryArray.concat(typeKeyValue + objToString(entityFilters.rule));
}
if (tagFilters) {
var tagKeyValue = '<span class="key">Tag:</span>&nbsp<span class="value">' + value.tag + '</span>&nbsp<span class="operator">AND</span>&nbsp';
queryArray = queryArray.concat(tagKeyValue + objToString(tagFilters.rule));
}
if (queryArray.length == 2) {
return "<span>(</span>&nbsp" + queryArray.join('<span>&nbsp)</span>&nbsp<span>AND</span>&nbsp<span>(</span>&nbsp') + "&nbsp<span>)</span>";
} else {
return queryArray.join();
}
},
showHideFilter: function() {
if (this.value) {
if (Utils.getUrlState.isSearchTab() && this.value.searchType == "basic") {
var query = this.generateQueryOfFilter();
if (query) {
this.ui.filterQuery.html(query);
this.ui.filterPanel.show();
} else
this.ui.filterPanel.hide();
} else {
this.ui.filterPanel.hide();
}
} else {
this.ui.filterPanel.hide();
}
},
fetchCollection: function(value, clickObj) {
var that = this;
var that = this,
isPostMethod = this.value.searchType === "basic" && Utils.getUrlState.isSearchTab(),
tagFilters = this.filterObj && this.filterObj.tagFilters ? this.filterObj.tagFilters[this.value.tag] : null,
entityFilters = this.filterObj && this.filterObj.entityFilters ? this.filterObj.entityFilters[this.value.type] : null,
filterObj = {
'entityFilters': entityFilters ? entityFilters.result : null,
'tagFilters': tagFilters ? tagFilters.result : null
}
this.showLoader();
if (Globals.searchApiCallRef && Globals.searchApiCallRef.readyState === 1) {
Globals.searchApiCallRef.abort();
}
if (value) {
$.extend(this.searchCollection.queryParams, { limit: this.limit, excludeDeletedEntities: 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 });
}
Globals.searchApiCallRef = this.searchCollection.fetch({
var apiObj = {
skipDefaultError: true,
success: function() {
success: function(model, response) {
Globals.searchApiCallRef = undefined;
if (!(that.ui.pageRecordText instanceof jQuery)) {
return;
}
if (isPostMethod) {
that.searchCollection.reset(model.entities);
}
if (that.searchCollection.models.length === 0 && that.offset > that.limit) {
that.ui.nextData.attr('disabled', true);
that.offset = that.offset - that.limit;
......@@ -302,6 +355,38 @@ define(['require',
},
silent: true,
reset: true
}
if (value) {
$.extend(this.searchCollection.queryParams, { limit: this.limit, excludeDeletedEntities: 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) {
apiObj['data'] = _.extend({}, filterObj, _.pick(this.searchCollection.queryParams, 'query', 'excludeDeletedEntities', 'limit', 'offset', 'typeName', 'classification'))
Globals.searchApiCallRef = this.searchCollection.getBasicRearchResult(apiObj);
this.showHideFilter();
} else {
apiObj.data = null;
Globals.searchApiCallRef = this.searchCollection.fetch(apiObj);
}
} else {
if (isPostMethod) {
apiObj['data'] = _.extend({}, filterObj, _.pick(this.searchCollection.queryParams, 'query', 'excludeDeletedEntities', 'limit', 'offset', 'typeName', 'classification'));
Globals.searchApiCallRef = this.searchCollection.getBasicRearchResult(apiObj);
} else {
apiObj.data = null;
Globals.searchApiCallRef = this.searchCollection.fetch(apiObj);
}
}
},
renderSearchQueryView: function() {
var that = this;
require(['views/search/SearchQueryView'], function(SearchQueryView) {
that.RSearchQuery.show(new SearchQueryView({
value: that.value,
searchVent: that.searchVent
}));
});
},
renderTableLayoutView: function(col) {
......@@ -343,7 +428,7 @@ define(['require',
col = {};
col['Check'] = {
name: "selected",
label: "",
label: "Select",
cell: "select-row",
headerCell: "select-all"
};
......
......@@ -44,7 +44,8 @@ define(['require',
* @constructs
*/
initialize: function(options) {
_.extend(this, _.pick(options, 'tag', 'collection', 'entityDefCollection', 'typeHeaders', 'enumDefCollection'));
_.extend(this, _.pick(options, 'tag', 'classificationDefCollection', 'entityDefCollection', 'typeHeaders', 'enumDefCollection'));
this.collection = this.classificationDefCollection;
},
bindEvents: function() {},
onRender: function() {
......
......@@ -64,7 +64,7 @@ define(['require',
bindEvents: function() {
var that = this;
this.listenTo(this.collection, "reset add remove", function() {
this.tagsAndTypeGenerator('collection');
this.tagsGenerator();
}, this);
this.ui.tagsParent.on('click', 'li.parent-node a', function() {
that.setUrl(this.getAttribute("href"));
......@@ -147,7 +147,7 @@ define(['require',
}
}
},
tagsAndTypeGenerator: function(collection, searchString) {
tagsGenerator: function(searchString) {
var that = this,
str = '';
that.collection.fullCollection.comparator = function(model) {
......@@ -340,7 +340,7 @@ define(['require',
},
offlineSearchTag: function(e) {
var type = $(e.currentTarget).data('type');
this.tagsAndTypeGenerator('collection', $(e.currentTarget).val());
this.tagsGenerator($(e.currentTarget).val());
},
createTagAction: function() {
var that = this;
......
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