From d8fbbafc7993be06cbf8c235b9e06130c51bffa7 Mon Sep 17 00:00:00 2001
From: Damien SOREL
Date: Mon, 10 Jul 2017 12:56:37 +0200
Subject: [PATCH 01/84] Update README.md
---
.github/ISSUE_TEMPLATE.md | 2 +-
LICENSE | 4 ++--
README.md | 4 ++++
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md
index 931f097a..7a8c011b 100644
--- a/.github/ISSUE_TEMPLATE.md
+++ b/.github/ISSUE_TEMPLATE.md
@@ -3,4 +3,4 @@
- Please search in the [documentation](http://querybuilder.js.org) before asking.
- Any issue without enough details won't get any answer and will be closed.
- Help requests must be exhaustive, precise and come with some code explaining the need (use Markdown code highlight).
-- Bug reports must come with a simple test case, preferably on jsFiddle, Plunker, etc. (QueryBuilder is available on [unpkg](https://unpkg.com/jQuery-QueryBuilder/dist/) to be used on such platforms).
+- Bug reports must come with a simple test case, preferably on jsFiddle, Plunker, etc. (QueryBuilder is available on [jsDelivr](https://cdn.jsdelivr.net/npm/jQuery-QueryBuilder/dist/) and [unpkg](https://unpkg.com/jQuery-QueryBuilder/dist/) to be used on such platforms).
diff --git a/LICENSE b/LICENSE
index 99070e3d..50b5d4bd 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)
-Copyright (c) 2014-2015 Damien Sorel
+Copyright (c) 2014-2017 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
@@ -18,4 +18,4 @@ 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
+SOFTWARE.
diff --git a/README.md b/README.md
index e48cf2e2..1fe97bb1 100644
--- a/README.md
+++ b/README.md
@@ -35,6 +35,10 @@ $ bower install jQuery-QueryBuilder
$ npm install jQuery-QueryBuilder
```
+#### Via CDN
+
+jQuery-QueryBuilder is available on [jsDelivr](https://cdn.jsdelivr.net/npm/jQuery-QueryBuilder/dist/) and [unpkg](https://unpkg.com/jQuery-QueryBuilder/dist/))
+
### Dependencies
* jQuery >= 1.10
* Bootstrap >= 3.1 (CSS only)
From 81175dd6fe7e1ada7e69cabd44268932629c5fd7 Mon Sep 17 00:00:00 2001
From: Damien SOREL
Date: Tue, 25 Jul 2017 13:22:03 +0200
Subject: [PATCH 02/84] Use Node version of SASS
---
.sass-lint.yml | 9 +++++++++
.scss-lint.yml | 31 -----------------------------
.travis.yml | 2 --
Gruntfile.js | 13 ++++++------
README.md | 2 --
package.json | 6 +++---
src/plugins/bt-checkbox/plugin.scss | 2 +-
src/plugins/sortable/plugin.scss | 3 ++-
src/scss/default.scss | 6 ++++--
9 files changed, 25 insertions(+), 49 deletions(-)
create mode 100644 .sass-lint.yml
delete mode 100644 .scss-lint.yml
diff --git a/.sass-lint.yml b/.sass-lint.yml
new file mode 100644
index 00000000..2d387551
--- /dev/null
+++ b/.sass-lint.yml
@@ -0,0 +1,9 @@
+rules:
+ property-sort-order: [0]
+ force-pseudo-nesting: [0]
+ force-element-nesting: [0]
+ force-attribute-nesting: [0]
+ no-important: [0]
+ no-qualifying-elements: [0]
+ shorthand-values: [1, {allowed-shorthands: [1, 2, 4]}]
+ hex-notation: [1, {style: uppercase}]
diff --git a/.scss-lint.yml b/.scss-lint.yml
deleted file mode 100644
index db8d4f79..00000000
--- a/.scss-lint.yml
+++ /dev/null
@@ -1,31 +0,0 @@
-linters:
- PropertySortOrder:
- enabled: false
-
- SingleLinePerSelector:
- enabled: false
-
- SelectorDepth:
- max_depth: 4
-
- NestingDepth:
- max_depth: 4
-
- HexLength:
- enabled: false
-
- HexNotation:
- style: uppercase
-
- Shorthand:
- allowed_shorthands: [1, 2, 4]
-
- QualifyingElement:
- enabled: false
-
- ImportantRule:
- enabled: false
-
- VendorPrefix:
- exclude:
- - src/scss/_mixins.scss
diff --git a/.travis.yml b/.travis.yml
index 59e0af84..689c955f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,8 +2,6 @@ language: node_js
node_js:
- "5"
before_install:
- - gem install sass
- - gem install scss_lint -v 0.49.0
- npm install -g grunt-cli
- npm install -g bower
before_script:
diff --git a/Gruntfile.js b/Gruntfile.js
index cfb31c00..218413d0 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -6,7 +6,7 @@ var cleanLn = require('./build/cleanLn');
module.exports = function(grunt) {
require('time-grunt')(grunt);
require('jit-grunt')(grunt, {
- scsslint: 'grunt-scss-lint',
+ sasslint: 'grunt-sass-lint',
sass_injection: 'grunt-sass-injection',
usebanner: 'grunt-banner'
});
@@ -217,8 +217,8 @@ module.exports = function(grunt) {
// parse scss
sass: {
options: {
- sourcemap: 'none',
- style: 'expanded'
+ sourceMap: false,
+ outputStyle: 'expanded'
},
dist: {
files: [{
@@ -293,11 +293,10 @@ module.exports = function(grunt) {
},
// scss tests
- scsslint: {
+ sasslint: {
lib: {
options: {
- colorizeOutput: true,
- config: '.scss-lint.yml'
+ configFile: '.sass-lint.yml'
},
src: ['src/**/*.scss']
}
@@ -410,7 +409,7 @@ module.exports = function(grunt) {
grunt.registerTask('test', [
'jshint',
'jscs',
- 'scsslint',
+ 'sasslint',
'build_lang',
'build_css',
'injector:testSrc',
diff --git a/README.md b/README.md
index 1fe97bb1..4e37d7ac 100644
--- a/README.md
+++ b/README.md
@@ -60,10 +60,8 @@ jQuery-QueryBuilder is available on [jsDelivr](https://cdn.jsdelivr.net/npm/jQue
#### Prerequisites
* NodeJS + NPM: `apt-get install nodejs-legacy npm`
- * Ruby Dev: `apt-get install ruby-dev`
* Grunt CLI: `npm install -g grunt-cli`
* Bower: `npm install -g bower`
- * SASS: `gem install sass`
#### Run
diff --git a/package.json b/package.json
index f9cc0c5e..f2b6283e 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
},
"devDependencies": {
"deepmerge": "^0.2.0",
- "foodoc": "git://github.com/mistic100/foodoc.git#custom",
+ "foodoc": "^0.0.8",
"grunt": "^1.0.0",
"grunt-banner": "^0.6.0",
"grunt-contrib-clean": "^1.0.0",
@@ -27,7 +27,6 @@
"grunt-contrib-cssmin": "^1.0.0",
"grunt-contrib-jshint": "^1.0.0",
"grunt-contrib-qunit": "^0.7.0",
- "grunt-contrib-sass": "^1.0.0",
"grunt-contrib-uglify": "^1.0.0",
"grunt-contrib-watch": "^1.0.0",
"grunt-coveralls": "^1.0.0",
@@ -36,8 +35,9 @@
"grunt-jsdoc": "^2.1.0",
"grunt-open": "^0.2.3",
"grunt-qunit-blanket-lcov": "^0.3.0",
+ "grunt-sass": "^2.0.0",
"grunt-sass-injection": "^1.0.3",
- "grunt-scss-lint": "^0.3.8",
+ "grunt-sass-lint": "^0.2.2",
"grunt-wrap": "^0.3.0",
"jit-grunt": "^0.10.0",
"time-grunt": "^1.3.0"
diff --git a/src/plugins/bt-checkbox/plugin.scss b/src/plugins/bt-checkbox/plugin.scss
index 9b259265..324f610f 100644
--- a/src/plugins/bt-checkbox/plugin.scss
+++ b/src/plugins/bt-checkbox/plugin.scss
@@ -1,5 +1,5 @@
.query-builder.bt-checkbox-glyphicons {
- .checkbox input[type=checkbox]:checked + label::after {
+ .checkbox input[type='checkbox']:checked + label::after {
font-family: 'Glyphicons Halflings';
content: '\e013';
}
diff --git a/src/plugins/sortable/plugin.scss b/src/plugins/sortable/plugin.scss
index cf57c795..ac902fe1 100644
--- a/src/plugins/sortable/plugin.scss
+++ b/src/plugins/sortable/plugin.scss
@@ -14,7 +14,8 @@ $placeholder-border: 1px dashed $placeholder-border-color;
opacity: .5;
z-index: 100;
- &::before, &::after {
+ &::before,
+ &::after {
display: none;
}
}
diff --git a/src/scss/default.scss b/src/scss/default.scss
index ace2f2fb..b8445fb7 100644
--- a/src/scss/default.scss
+++ b/src/scss/default.scss
@@ -62,7 +62,7 @@ $ticks-position: 5px, 10px !default;
.group-conditions {
.btn.readonly:not(.active),
- input[name$=_cond] {
+ input[name$='_cond'] {
border: 0;
clip: rect(0 0 0 0);
height: 1px;
@@ -110,7 +110,9 @@ $ticks-position: 5px, 10px !default;
}
}
- select, input[type=text], input[type=number] {
+ select,
+ input[type='text'],
+ input[type='number'] {
padding: 1px;
}
}
From bb4bbeaf304486ff7869c8210299e84e89ec3bfd Mon Sep 17 00:00:00 2001
From: Damien SOREL
Date: Tue, 25 Jul 2017 13:34:55 +0200
Subject: [PATCH 03/84] Fix #536 Make sure the builder is ready before firing
afterInit
---
src/core.js | 23 +++++++++++++++++++++++
src/jquery.js | 4 +++-
src/main.js | 16 ----------------
3 files changed, 26 insertions(+), 17 deletions(-)
diff --git a/src/core.js b/src/core.js
index b3e2d2ec..764c8c6b 100644
--- a/src/core.js
+++ b/src/core.js
@@ -1,3 +1,26 @@
+/**
+ * Final initialisation of the builder
+ * @param {object} [rules]
+ * @fires QueryBuilder.afterInit
+ * @private
+ */
+QueryBuilder.prototype.init = function(rules) {
+ /**
+ * When the initilization is done, just before creating the root group
+ * @event afterInit
+ * @memberof QueryBuilder
+ */
+ this.trigger('afterInit');
+
+ if (rules) {
+ this.setRules(rules);
+ delete this.settings.rules;
+ }
+ else {
+ this.setRoot(true);
+ }
+};
+
/**
* Checks the configuration of each filter
* @param {QueryBuilder.Filter[]} filters
diff --git a/src/jquery.js b/src/jquery.js
index 62742019..941ea675 100644
--- a/src/jquery.js
+++ b/src/jquery.js
@@ -30,7 +30,9 @@ $.fn.queryBuilder = function(option) {
return this;
}
if (!data) {
- this.data('queryBuilder', new QueryBuilder(this, options));
+ var builder = new QueryBuilder(this, options);
+ this.data('queryBuilder', builder);
+ builder.init(options.rules);
}
if (typeof option == 'string') {
return data[option].apply(data, Array.prototype.slice.call(arguments, 1));
diff --git a/src/main.js b/src/main.js
index 0ebfc940..f799af6f 100644
--- a/src/main.js
+++ b/src/main.js
@@ -14,7 +14,6 @@
* @param {jQuery} $el
* @param {object} options - see {@link http://querybuilder.js.org/#options}
* @constructor
- * @fires QueryBuilder.afterInit
*/
var QueryBuilder = function($el, options) {
$el[0].queryBuilder = this;
@@ -141,21 +140,6 @@ var QueryBuilder = function($el, options) {
this.operators = this.checkOperators(this.operators);
this.bindEvents();
this.initPlugins();
-
- /**
- * When the initilization is done, just before creating the root group
- * @event afterInit
- * @memberof QueryBuilder
- */
- this.trigger('afterInit');
-
- if (options.rules) {
- this.setRules(options.rules);
- delete this.settings.rules;
- }
- else {
- this.setRoot(true);
- }
};
$.extend(QueryBuilder.prototype, /** @lends QueryBuilder.prototype */ {
From 3b2aa03d5dbdd9577ff94bc3aab30124028e6765 Mon Sep 17 00:00:00 2001
From: Damien Sorel
Date: Thu, 10 Aug 2017 18:22:25 +0200
Subject: [PATCH 04/84] Fix #548 Fix event names
---
src/template.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/template.js b/src/template.js
index b1379f47..40b52ce1 100644
--- a/src/template.js
+++ b/src/template.js
@@ -163,7 +163,7 @@ QueryBuilder.prototype.getRuleFilterSelect = function(rule, filters) {
/**
* Modifies the raw HTML of the rule's filter dropdown
- * @event changer:getRuleFilterTemplate
+ * @event changer:getRuleFilterSelect
* @memberof QueryBuilder
* @param {string} html
* @param {Rule} rule
@@ -193,7 +193,7 @@ QueryBuilder.prototype.getRuleOperatorSelect = function(rule, operators) {
/**
* Modifies the raw HTML of the rule's operator dropdown
- * @event changer:getRuleOperatorTemplate
+ * @event changer:getRuleOperatorSelect
* @memberof QueryBuilder
* @param {string} html
* @param {Rule} rule
From 547071d6a20af60506624bdb2edd78ffc25cca0b Mon Sep 17 00:00:00 2001
From: Damien SOREL
Date: Fri, 11 Aug 2017 14:43:23 +0200
Subject: [PATCH 05/84] Disallow Bootstrap 4
---
bower.json | 2 +-
composer.json | 2 +-
package.json | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/bower.json b/bower.json
index 9f597a38..8c6ce3a3 100644
--- a/bower.json
+++ b/bower.json
@@ -14,7 +14,7 @@
],
"dependencies": {
"jquery": ">=1.9.0",
- "bootstrap": ">=3.1.0",
+ "bootstrap": ">=3.1.0 <4",
"moment": ">=2.6.0",
"jquery-extendext": ">=0.1.2",
"doT": ">=1.0.3"
diff --git a/composer.json b/composer.json
index 6cbe2f11..6c74835b 100644
--- a/composer.json
+++ b/composer.json
@@ -11,7 +11,7 @@
"robloach/component-installer": "*",
"components/jquery": ">=1.9.0",
"moment/moment": ">=2.6.0",
- "components/bootstrap": ">=3.1.0"
+ "components/bootstrap": ">=3.1.0 <4"
},
"keywords": [
"jquery",
diff --git a/package.json b/package.json
index f2b6283e..5209cf4e 100644
--- a/package.json
+++ b/package.json
@@ -10,7 +10,7 @@
"main": "dist/js/query-builder.js",
"dependencies": {
"jquery": ">=1.9.0",
- "bootstrap": ">=3.1.0",
+ "bootstrap": ">=3.1.0 <4",
"moment": ">=2.6.0",
"jquery-extendext": ">=0.1.2",
"dot": ">=1.0.3"
From 42a800a7400c9d275da22d803c392e155c33e855 Mon Sep 17 00:00:00 2001
From: manuelsx28 <31009071+manuelsx28@users.noreply.github.com>
Date: Thu, 17 Aug 2017 14:22:28 +0200
Subject: [PATCH 06/84] [fix] ignore case when getting SQL field by ID (#554)
---
src/plugins/sql-support/plugin.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/plugins/sql-support/plugin.js b/src/plugins/sql-support/plugin.js
index 6abc101a..6ef3bc56 100644
--- a/src/plugins/sql-support/plugin.js
+++ b/src/plugins/sql-support/plugin.js
@@ -596,7 +596,7 @@ QueryBuilder.extend(/** @lends module:plugins.SqlSupport.prototype */ {
*/
getSQLFieldID: function(field, value) {
var matchingFilters = this.filters.filter(function(filter) {
- return filter.field === field;
+ return filter.field.toLowerCase() === field.toLowerCase();
});
var id;
From 0827aa9e57478b3a0863a312791849fb8a49d4a8 Mon Sep 17 00:00:00 2001
From: Damien Sorel
Date: Tue, 22 Aug 2017 10:24:47 +0200
Subject: [PATCH 07/84] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 4e37d7ac..f62228aa 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
[](http://querybuilder.js.org)
[](https://www.npmjs.com/package/jQuery-QueryBuilder)
-[](http://www.jsdelivr.com/projects/jquery.query-builder)
+[](https://cdn.jsdelivr.net/npm/jQuery-QueryBuilder/dist/)
[](https://travis-ci.org/mistic100/jQuery-QueryBuilder)
[](https://coveralls.io/r/mistic100/jQuery-QueryBuilder)
From 233de01a0d825a2ebce0ee65ccc571ba29818917 Mon Sep 17 00:00:00 2001
From: mistic100
Date: Tue, 22 Aug 2017 20:31:01 +0200
Subject: [PATCH 08/84] Update Italian translation from @davegraziosi
---
src/i18n/it.json | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/src/i18n/it.json b/src/i18n/it.json
index 015cf3aa..d16fb50c 100644
--- a/src/i18n/it.json
+++ b/src/i18n/it.json
@@ -1,5 +1,6 @@
{
"__locale": "Italian (it)",
+ "__author": "davegraziosi",
"add_rule": "Aggiungi regola",
"add_group": "Aggiungi gruppo",
@@ -20,6 +21,8 @@
"less_or_equal": "minore o uguale",
"greater": "maggiore",
"greater_or_equal": "maggiore o uguale",
+ "between" : "compreso tra",
+ "not_between" : "non compreso tra",
"begins_with": "inizia con",
"not_begins_with": "non inizia con",
"contains": "contiene",
@@ -30,5 +33,29 @@
"is_not_empty": "non è vuoto",
"is_null": "è nullo",
"is_not_null": "non è nullo"
+ },
+
+ "errors": {
+ "no_filter": "Nessun filtro selezionato",
+ "empty_group": "Il gruppo è vuoto",
+ "radio_empty": "No value selected",
+ "checkbox_empty": "Nessun valore selezionato",
+ "select_empty": "Nessun valore selezionato",
+ "string_empty": "Valore vuoto",
+ "string_exceed_min_length": "Deve contenere almeno {0} caratteri",
+ "string_exceed_max_length": "Non deve contenere più di {0} caratteri",
+ "string_invalid_format": "Formato non valido ({0})",
+ "number_nan": "Non è un numero",
+ "number_not_integer": "Non è un intero",
+ "number_not_double": "Non è un numero con la virgola",
+ "number_exceed_min": "Deve essere maggiore di {0}",
+ "number_exceed_max": "Deve essere minore di {0}",
+ "number_wrong_step": "Deve essere multiplo di {0}",
+ "datetime_empty": "Valore vuoto",
+ "datetime_invalid": "Formato data non valido ({0})",
+ "datetime_exceed_min": "Deve essere successivo a {0}",
+ "datetime_exceed_max": "Deve essere precedente a {0}",
+ "boolean_not_valid": "Non è un booleano",
+ "operator_not_multiple": "L'Operatore {0} non può accettare valori multipli"
}
}
\ No newline at end of file
From 4f30d2830f0e8878bc46927c9b792466f2c5d2f9 Mon Sep 17 00:00:00 2001
From: kamel
Date: Sat, 2 Sep 2017 17:08:31 +0430
Subject: [PATCH 09/84] Update fa-IR.json (#563)
add not_between
---
src/i18n/fa-IR.json | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/i18n/fa-IR.json b/src/i18n/fa-IR.json
index 2900248c..55a6e456 100644
--- a/src/i18n/fa-IR.json
+++ b/src/i18n/fa-IR.json
@@ -22,6 +22,7 @@
"greater": "بزرگتر از",
"greater_or_equal": "بزرگتر یا مساوی با",
"between": "مابین",
+ "not_between": "مابین نباشد",
"begins_with": "شروع شود با",
"not_begins_with": "شروع نشود با",
"contains": "شامل شود",
@@ -57,4 +58,4 @@
"boolean_not_valid": "مقدار دودویی وارد کنید",
"operator_not_multiple": "اپراتور \"{1}\" نمی تواند چند مقدار قبول کند"
}
-}
\ No newline at end of file
+}
From f977012f2fb57bac6f9b9b7117a6436ecee4cce9 Mon Sep 17 00:00:00 2001
From: Jason Hafer
Date: Thu, 21 Sep 2017 07:20:35 -0400
Subject: [PATCH 10/84] Fix filter-description plugin not showing button for
'bootbox' option (#565)
The 'bootbox' option for the 'filter-description' plugin failed to re-show the button, once hidden.
In my case, I selected a filter with a description field, pressed the down arrow key to select the next filter in the dropdown, which did not contain a description. I then pressed up arrow key to return to the previous filter with a description, but this time it did now show the filter-description button.
I fixed the code to match the convention of the 'inline' and 'popover' options.
---
src/plugins/filter-description/plugin.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/plugins/filter-description/plugin.js b/src/plugins/filter-description/plugin.js
index 91762b6b..4525cbe0 100644
--- a/src/plugins/filter-description/plugin.js
+++ b/src/plugins/filter-description/plugin.js
@@ -96,6 +96,9 @@ QueryBuilder.define('filter-description', function(options) {
bootbox.alert($b.data('description'));
});
}
+ else {
+ $b.show();
+ }
$b.data('description', description);
}
From 33409b5cf9b0ae08dab63acc2762bcd0401b46d2 Mon Sep 17 00:00:00 2001
From: Damien Sorel
Date: Thu, 12 Oct 2017 20:42:44 +0200
Subject: [PATCH 11/84] Update CDN links
---
README.md | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index f62228aa..6798d48e 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
[](http://querybuilder.js.org)
[](https://www.npmjs.com/package/jQuery-QueryBuilder)
-[](https://cdn.jsdelivr.net/npm/jQuery-QueryBuilder/dist/)
+[](https://www.jsdelivr.com/package/npm/jQuery-QueryBuilder)
[](https://travis-ci.org/mistic100/jQuery-QueryBuilder)
[](https://coveralls.io/r/mistic100/jQuery-QueryBuilder)
@@ -37,8 +37,7 @@ $ npm install jQuery-QueryBuilder
#### Via CDN
-jQuery-QueryBuilder is available on [jsDelivr](https://cdn.jsdelivr.net/npm/jQuery-QueryBuilder/dist/) and [unpkg](https://unpkg.com/jQuery-QueryBuilder/dist/))
-
+jQuery-QueryBuilder is available on [jsDelivr](https://www.jsdelivr.com/package/npm/jQuery-QueryBuilder).
### Dependencies
* jQuery >= 1.10
* Bootstrap >= 3.1 (CSS only)
From ff90ac8221c8ba81a5d48b19de65705209087a7a Mon Sep 17 00:00:00 2001
From: mistic100
Date: Sat, 11 Nov 2017 17:17:25 +0100
Subject: [PATCH 12/84] Fix #595 TypeError when calling getSQL with invalid
rules
---
Gruntfile.js | 2 +-
src/plugins/mongodb-support/plugin.js | 4 ++++
src/plugins/sql-support/plugin.js | 5 +++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/Gruntfile.js b/Gruntfile.js
index 218413d0..40cdd50a 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -177,7 +177,7 @@ module.exports = function(grunt) {
wrap: {
js: {
src: ['dist/js/query-builder.js'],
- dest: '',
+ dest: 'dist/js/query-builder.js',
options: {
separator: '',
wrapper: function() {
diff --git a/src/plugins/mongodb-support/plugin.js b/src/plugins/mongodb-support/plugin.js
index 93a17348..a6aebdc3 100644
--- a/src/plugins/mongodb-support/plugin.js
+++ b/src/plugins/mongodb-support/plugin.js
@@ -105,6 +105,10 @@ QueryBuilder.extend(/** @lends module:plugins.MongoDbSupport.prototype */ {
getMongo: function(data) {
data = (data === undefined) ? this.getRules() : data;
+ if (!data) {
+ return null;
+ }
+
var self = this;
return (function parse(group) {
diff --git a/src/plugins/sql-support/plugin.js b/src/plugins/sql-support/plugin.js
index 6ef3bc56..b6751818 100644
--- a/src/plugins/sql-support/plugin.js
+++ b/src/plugins/sql-support/plugin.js
@@ -248,6 +248,11 @@ QueryBuilder.extend(/** @lends module:plugins.SqlSupport.prototype */ {
*/
getSQL: function(stmt, nl, data) {
data = (data === undefined) ? this.getRules() : data;
+
+ if (!data) {
+ return null;
+ }
+
nl = !!nl ? '\n' : ' ';
var boolean_as_integer = this.getPluginOptions('sql-support', 'boolean_as_integer');
From 3cf90e79b4e43224d397029428f0f42ba8985f05 Mon Sep 17 00:00:00 2001
From: mistic100
Date: Sat, 11 Nov 2017 17:54:54 +0100
Subject: [PATCH 13/84] Fix #579 Add "default_operator" to filters
---
examples/index.html | 3 ++-
src/core.js | 16 +++++++++++++++-
tests/common.js | 3 ++-
tests/data.module.js | 17 +++++++++++++++++
4 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/examples/index.html b/examples/index.html
index 369c9eda..b3cf989f 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -274,7 +274,8 @@ Output
2: 'warning',
5: 'success'
},
- operators: ['in', 'not_in', 'equal', 'not_equal', 'is_null', 'is_not_null']
+ operators: ['equal', 'not_equal', 'in', 'not_in', 'is_null', 'is_not_null'],
+ default_operator: 'in'
},
/*
* select
diff --git a/src/core.js b/src/core.js
index 764c8c6b..31964cc6 100644
--- a/src/core.js
+++ b/src/core.js
@@ -617,7 +617,20 @@ QueryBuilder.prototype.createRuleOperators = function(rule) {
$operatorContainer.html($operatorSelect);
// set the operator without triggering update event
- rule.__.operator = operators[0];
+ if (rule.filter.default_operator) {
+ rule.__.operator = operators.filter(function(operator) {
+ return operator.type === rule.filter.default_operator;
+ })[0];
+
+ if (!rule.__.operator) {
+ Utils.error('Config', 'Invalid operator {0}', rule.filter.default_operator);
+ }
+ }
+ else {
+ rule.__.operator = operators[0];
+ }
+
+ rule.$el.find(QueryBuilder.selectors.rule_operator).val(rule.operator.type);
/**
* After creating the dropdown for operators
@@ -752,6 +765,7 @@ QueryBuilder.prototype.updateRuleOperator = function(rule, previousOperator) {
*/
this.trigger('afterUpdateRuleOperator', rule);
+ // FIXME is it necessary ?
this.updateRuleValue(rule);
};
diff --git a/tests/common.js b/tests/common.js
index 91a3ffb5..89550f42 100644
--- a/tests/common.js
+++ b/tests/common.js
@@ -301,7 +301,8 @@ var basic_filters = [{
label: 'Age',
type: 'integer',
input: 'text',
- value_separator: '|'
+ value_separator: '|',
+ default_operator: 'in'
}];
var basic_rules = {
diff --git a/tests/data.module.js b/tests/data.module.js
index 358df511..ea381717 100644
--- a/tests/data.module.js
+++ b/tests/data.module.js
@@ -411,6 +411,23 @@ $(function() {
);
});
+ /**
+ * Test default operator
+ */
+ QUnit.test('default operator', function(assert) {
+ $b.queryBuilder({
+ filters: basic_filters
+ });
+
+ $('[name=builder_rule_0_filter]').val('age').trigger('change');
+
+ assert.equal(
+ $('[name=builder_rule_0_operator]').val(),
+ 'in',
+ 'Should set "age" operator to "in" by default'
+ );
+ });
+
/**
* Test allow_invalid option
*/
From 6331d3ea61c5eb7c740be8f26f633cd12813c85b Mon Sep 17 00:00:00 2001
From: mistic100
Date: Sat, 11 Nov 2017 18:16:09 +0100
Subject: [PATCH 14/84] Fix #593 Add between/not_between validation
---
src/data.js | 23 +++++++++++++++++++++++
src/i18n/en.json | 2 ++
src/i18n/fr.json | 2 ++
tests/data.module.js | 10 ++++++++++
4 files changed, 37 insertions(+)
diff --git a/src/data.js b/src/data.js
index 1594f334..8d87848a 100644
--- a/src/data.js
+++ b/src/data.js
@@ -221,6 +221,29 @@ QueryBuilder.prototype._validateValue = function(rule, value) {
}
}
+ if ((rule.operator.type === 'between' || rule.operator.type === 'not_between') && value.length === 2) {
+ switch (QueryBuilder.types[filter.type]) {
+ case 'number':
+ if (value[0] > value[1]) {
+ result = ['number_between_invalid', value[0], value[1]];
+ }
+ break;
+
+ case 'datetime':
+ // we need MomentJS
+ if (validation.format) {
+ if (!('moment' in window)) {
+ Utils.error('MissingLibrary', 'MomentJS is required for Date/Time validation. Get it here http://momentjs.com');
+ }
+
+ if (moment(value[0], validation.format).isAfter(moment(value[1], validation.format))) {
+ result = ['datetime_between_invalid', value[0], value[1]];
+ }
+ }
+ break;
+ }
+ }
+
return result;
};
diff --git a/src/i18n/en.json b/src/i18n/en.json
index a0e9fd12..41e48539 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -51,10 +51,12 @@
"number_exceed_min": "Must be greater than {0}",
"number_exceed_max": "Must be lower than {0}",
"number_wrong_step": "Must be a multiple of {0}",
+ "number_between_invalid": "Invalid values, {0} is greater than {1}",
"datetime_empty": "Empty value",
"datetime_invalid": "Invalid date format ({0})",
"datetime_exceed_min": "Must be after {0}",
"datetime_exceed_max": "Must be before {0}",
+ "datetime_between_invalid": "Invalid values, {0} isgreater than {1}",
"boolean_not_valid": "Not a boolean",
"operator_not_multiple": "Operator \"{1}\" cannot accept multiple values"
}
diff --git a/src/i18n/fr.json b/src/i18n/fr.json
index 56cbad52..dabacbfe 100644
--- a/src/i18n/fr.json
+++ b/src/i18n/fr.json
@@ -51,10 +51,12 @@
"number_exceed_min": "Doit être plus grand que {0}",
"number_exceed_max": "Doit être plus petit que {0}",
"number_wrong_step": "Doit être un multiple de {0}",
+ "number_between_invalid": "Valeurs invalides, {0} est plus grand que {1}",
"datetime_empty": "Valeur vide",
"datetime_invalid": "Fomat de date invalide ({0})",
"datetime_exceed_min": "Doit être après {0}",
"datetime_exceed_max": "Doit être avant {0}",
+ "datetime_between_invalid": "Valeurs invalides, {0} est plus grand que {1}",
"boolean_not_valid": "N'est pas un booléen",
"operator_not_multiple": "L'opérateur \"{1}\" ne peut utiliser plusieurs valeurs"
}
diff --git a/tests/data.module.js b/tests/data.module.js
index ea381717..72de4539 100644
--- a/tests/data.module.js
+++ b/tests/data.module.js
@@ -170,6 +170,11 @@ $(function() {
/number_wrong_step/
);
+ assert.validationError($b,
+ { id: 'integer', operator: 'between', value: [5, 1] },
+ /number_between_invalid/
+ );
+
assert.validationError($b,
{ id: 'date' },
/datetime_empty/
@@ -190,6 +195,11 @@ $(function() {
/datetime_exceed_max/
);
+ assert.validationError($b,
+ { id: 'date', operator: 'between', value: ['2015/01/01', '2014/01/01'] },
+ /datetime_between_invalid/
+ );
+
assert.validationError($b,
{ id: 'boolean', value: 'oui' },
/boolean_not_valid/
From ef0b829e750dff5f7d8b70b409249713c031c1e4 Mon Sep 17 00:00:00 2001
From: mistic100
Date: Sat, 11 Nov 2017 18:25:51 +0100
Subject: [PATCH 15/84] Fix #543 use "default_value" in setRules method
---
examples/index.html | 2 +-
src/core.js | 8 +-------
src/public.js | 21 +++++++++++++--------
tests/data.module.js | 29 +++++++++++++++++++++++++++++
4 files changed, 44 insertions(+), 16 deletions(-)
diff --git a/examples/index.html b/examples/index.html
index b3cf989f..350b9896 100644
--- a/examples/index.html
+++ b/examples/index.html
@@ -546,7 +546,7 @@ Output
}, {
id: 'coord',
operator: 'equal',
- value: 'B.3'
+ value: undefined // will use filter's default value
}]
}, {
id: 'name',
diff --git a/src/core.js b/src/core.js
index 31964cc6..5036062f 100644
--- a/src/core.js
+++ b/src/core.js
@@ -618,13 +618,7 @@ QueryBuilder.prototype.createRuleOperators = function(rule) {
// set the operator without triggering update event
if (rule.filter.default_operator) {
- rule.__.operator = operators.filter(function(operator) {
- return operator.type === rule.filter.default_operator;
- })[0];
-
- if (!rule.__.operator) {
- Utils.error('Config', 'Invalid operator {0}', rule.filter.default_operator);
- }
+ rule.__.operator = this.getOperatorByType(rule.filter.default_operator);
}
else {
rule.__.operator = operators[0];
diff --git a/src/public.js b/src/public.js
index 610a4adf..14a16c60 100644
--- a/src/public.js
+++ b/src/public.js
@@ -410,17 +410,22 @@ QueryBuilder.prototype.setRules = function(data, options) {
if (!item.empty) {
model.filter = self.getFilterById(item.id, !options.allow_invalid);
+ }
- if (model.filter) {
- model.operator = self.getOperatorByType(item.operator, !options.allow_invalid);
+ if (model.filter) {
+ model.operator = self.getOperatorByType(item.operator, !options.allow_invalid);
- if (!model.operator) {
- model.operator = self.getOperators(model.filter)[0];
- }
+ if (!model.operator) {
+ model.operator = self.getOperators(model.filter)[0];
+ }
+ }
- if (model.operator && model.operator.nb_inputs !== 0 && item.value !== undefined) {
- model.value = item.value;
- }
+ if (model.operator && model.operator.nb_inputs !== 0) {
+ if (item.value !== undefined) {
+ model.value = item.value;
+ }
+ else if (model.filter.default_value !== undefined) {
+ model.value = model.filter.default_value;
}
}
diff --git a/tests/data.module.js b/tests/data.module.js
index 72de4539..d7f11838 100644
--- a/tests/data.module.js
+++ b/tests/data.module.js
@@ -517,6 +517,35 @@ $(function() {
);
});
+ QUnit.test('apply default value', function(assert) {
+ $b.queryBuilder({
+ filters: [
+ {
+ id: 'name',
+ default_value: 'Mistic'
+ }
+ ],
+ rules: [
+ {
+ id: 'name'
+ }
+ ]
+ });
+
+ assert.rulesMatch(
+ $b.queryBuilder('getRules'),
+ {
+ condition: 'AND',
+ rules: [{
+ id: 'name',
+ operator: 'equal',
+ value: 'Mistic'
+ }]
+ },
+ 'Should have used the filter default value'
+ );
+ });
+
/**
* Test allow_empty_value option
*/
From e1887ad2650531ff3c3a0263442a8d7259251582 Mon Sep 17 00:00:00 2001
From: mistic100
Date: Sat, 11 Nov 2017 18:41:06 +0100
Subject: [PATCH 16/84] Fix #498 add "rulesChanged" event
---
src/core.js | 21 +++++++++++++++++++++
src/plugins/change-filters/plugin.js | 2 ++
src/plugins/invert/plugin.js | 2 ++
src/plugins/not-group/plugin.js | 2 ++
src/plugins/sortable/plugin.js | 2 ++
src/public.js | 4 ++++
6 files changed, 33 insertions(+)
diff --git a/src/core.js b/src/core.js
index 5036062f..dbc0656d 100644
--- a/src/core.js
+++ b/src/core.js
@@ -380,6 +380,13 @@ QueryBuilder.prototype.addGroup = function(parent, addRule, data, flags) {
*/
this.trigger('afterAddGroup', model);
+ /**
+ * After any change in the rules
+ * @event rulesChanged
+ * @memberof QueryBuilder
+ */
+ this.trigger('rulesChanged');
+
model.condition = this.settings.default_condition;
if (addRule) {
@@ -429,6 +436,8 @@ QueryBuilder.prototype.deleteGroup = function(group) {
* @memberof QueryBuilder
*/
this.trigger('afterDeleteGroup');
+
+ this.trigger('rulesChanged');
}
return del;
@@ -454,6 +463,8 @@ QueryBuilder.prototype.updateGroupCondition = function(group) {
* @param {Group} group
*/
this.trigger('afterUpdateGroupCondition', group);
+
+ this.trigger('rulesChanged');
};
/**
@@ -513,6 +524,8 @@ QueryBuilder.prototype.addRule = function(parent, data, flags) {
*/
this.trigger('afterAddRule', model);
+ this.trigger('rulesChanged');
+
this.createRuleFilters(model);
if (this.settings.default_filter || !this.settings.display_empty_filter) {
@@ -565,6 +578,8 @@ QueryBuilder.prototype.deleteRule = function(rule) {
*/
this.trigger('afterDeleteRule');
+ this.trigger('rulesChanged');
+
return true;
};
@@ -719,6 +734,8 @@ QueryBuilder.prototype.updateRuleFilter = function(rule, previousFilter) {
* @param {Rule} rule
*/
this.trigger('afterUpdateRuleFilter', rule);
+
+ this.trigger('rulesChanged');
};
/**
@@ -759,6 +776,8 @@ QueryBuilder.prototype.updateRuleOperator = function(rule, previousOperator) {
*/
this.trigger('afterUpdateRuleOperator', rule);
+ this.trigger('rulesChanged');
+
// FIXME is it necessary ?
this.updateRuleValue(rule);
};
@@ -781,6 +800,8 @@ QueryBuilder.prototype.updateRuleValue = function(rule) {
* @param {Rule} rule
*/
this.trigger('afterUpdateRuleValue', rule);
+
+ this.trigger('rulesChanged');
};
/**
diff --git a/src/plugins/change-filters/plugin.js b/src/plugins/change-filters/plugin.js
index 823edac1..f44934ab 100644
--- a/src/plugins/change-filters/plugin.js
+++ b/src/plugins/change-filters/plugin.js
@@ -59,6 +59,8 @@ QueryBuilder.extend(/** @lends module:plugins.ChangeFilters.prototype */ {
function(rule) {
if (rule.filter && filtersIds.indexOf(rule.filter.id) === -1) {
rule.drop();
+
+ self.trigger('rulesChanged');
}
else {
self.createRuleFilters(rule);
diff --git a/src/plugins/invert/plugin.js b/src/plugins/invert/plugin.js
index 8928d4be..1b1cd686 100644
--- a/src/plugins/invert/plugin.js
+++ b/src/plugins/invert/plugin.js
@@ -147,6 +147,8 @@ QueryBuilder.extend(/** @lends module:plugins.Invert.prototype */ {
* @param {object} options
*/
this.trigger('afterInvert', node, options);
+
+ this.trigger('rulesChanged');
}
}
});
diff --git a/src/plugins/not-group/plugin.js b/src/plugins/not-group/plugin.js
index da6f98b0..8d94b5fc 100644
--- a/src/plugins/not-group/plugin.js
+++ b/src/plugins/not-group/plugin.js
@@ -128,5 +128,7 @@ QueryBuilder.extend(/** @lends module:plugins.NotGroup.prototype */ {
* @param {Group} group
*/
this.trigger('afterUpdateGroupNot', group);
+
+ this.trigger('rulesChanged');
}
});
diff --git a/src/plugins/sortable/plugin.js b/src/plugins/sortable/plugin.js
index 83f0b4df..4cf3cf1a 100644
--- a/src/plugins/sortable/plugin.js
+++ b/src/plugins/sortable/plugin.js
@@ -92,6 +92,8 @@ QueryBuilder.define('sortable', function(options) {
* @param {Node} node
*/
self.trigger('afterMove', src);
+
+ self.trigger('rulesChanged');
}
});
}
diff --git a/src/public.js b/src/public.js
index 14a16c60..d0bbf35a 100644
--- a/src/public.js
+++ b/src/public.js
@@ -54,6 +54,8 @@ QueryBuilder.prototype.reset = function() {
* @memberof QueryBuilder
*/
this.trigger('afterReset');
+
+ this.trigger('rulesChanged');
};
/**
@@ -86,6 +88,8 @@ QueryBuilder.prototype.clear = function() {
* @memberof QueryBuilder
*/
this.trigger('afterClear');
+
+ this.trigger('rulesChanged');
};
/**
From fa0be59e97aa73a2fd6769458590c7de7ca181f7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Marcin=20Charmu=C5=82owicz?=
Date: Thu, 10 Aug 2017 15:03:31 +0200
Subject: [PATCH 17/84] Pass previous operator to afterUpdateRuleOperator event
---
src/core.js | 25 ++++++++++++++++---------
src/i18n/pl.json | 4 ++--
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/src/core.js b/src/core.js
index dbc0656d..dddabca4 100644
--- a/src/core.js
+++ b/src/core.js
@@ -282,7 +282,7 @@ QueryBuilder.prototype.bindEvents = function() {
break;
case 'value':
- self.updateRuleValue(node);
+ self.updateRuleValue(node, oldValue);
break;
}
}
@@ -297,7 +297,7 @@ QueryBuilder.prototype.bindEvents = function() {
break;
case 'condition':
- self.updateGroupCondition(node);
+ self.updateGroupCondition(node, oldValue);
break;
}
}
@@ -446,10 +446,11 @@ QueryBuilder.prototype.deleteGroup = function(group) {
/**
* Performs actions when a group's condition changes
* @param {Group} group
+ * @param {object} previousCondition
* @fires QueryBuilder.afterUpdateGroupCondition
* @private
*/
-QueryBuilder.prototype.updateGroupCondition = function(group) {
+QueryBuilder.prototype.updateGroupCondition = function(group, previousCondition) {
group.$el.find('>' + QueryBuilder.selectors.group_condition).each(function() {
var $this = $(this);
$this.prop('checked', $this.val() === group.condition);
@@ -461,8 +462,9 @@ QueryBuilder.prototype.updateGroupCondition = function(group) {
* @event afterUpdateGroupCondition
* @memberof QueryBuilder
* @param {Group} group
+ * @param {object} previousCondition
*/
- this.trigger('afterUpdateGroupCondition', group);
+ this.trigger('afterUpdateGroupCondition', group, previousCondition);
this.trigger('rulesChanged');
};
@@ -732,8 +734,9 @@ QueryBuilder.prototype.updateRuleFilter = function(rule, previousFilter) {
* @event afterUpdateRuleFilter
* @memberof QueryBuilder
* @param {Rule} rule
+ * @param {object} previousFilter
*/
- this.trigger('afterUpdateRuleFilter', rule);
+ this.trigger('afterUpdateRuleFilter', rule, previousFilter);
this.trigger('rulesChanged');
};
@@ -747,6 +750,7 @@ QueryBuilder.prototype.updateRuleFilter = function(rule, previousFilter) {
*/
QueryBuilder.prototype.updateRuleOperator = function(rule, previousOperator) {
var $valueContainer = rule.$el.find(QueryBuilder.selectors.value_container);
+ var ruleValue = rule.value;
if (!rule.operator || rule.operator.nb_inputs === 0) {
$valueContainer.hide();
@@ -773,22 +777,24 @@ QueryBuilder.prototype.updateRuleOperator = function(rule, previousOperator) {
* @event afterUpdateRuleOperator
* @memberof QueryBuilder
* @param {Rule} rule
+ * @param {object} previousOperator
*/
- this.trigger('afterUpdateRuleOperator', rule);
+ this.trigger('afterUpdateRuleOperator', rule, previousOperator);
this.trigger('rulesChanged');
// FIXME is it necessary ?
- this.updateRuleValue(rule);
+ this.updateRuleValue(rule, ruleValue);
};
/**
* Performs actions when rule's value changes
* @param {Rule} rule
+ * @param {object} previousValue
* @fires QueryBuilder.afterUpdateRuleValue
* @private
*/
-QueryBuilder.prototype.updateRuleValue = function(rule) {
+QueryBuilder.prototype.updateRuleValue = function(rule, previousValue) {
if (!rule._updating_value) {
this.setRuleInputValue(rule, rule.value);
}
@@ -798,8 +804,9 @@ QueryBuilder.prototype.updateRuleValue = function(rule) {
* @event afterUpdateRuleValue
* @memberof QueryBuilder
* @param {Rule} rule
+ * @param {*} previousValue
*/
- this.trigger('afterUpdateRuleValue', rule);
+ this.trigger('afterUpdateRuleValue', rule, previousValue);
this.trigger('rulesChanged');
};
diff --git a/src/i18n/pl.json b/src/i18n/pl.json
index c27069f4..9cddba15 100644
--- a/src/i18n/pl.json
+++ b/src/i18n/pl.json
@@ -8,8 +8,8 @@
"delete_group": "Usuń",
"conditions": {
- "AND": "AND",
- "OR": "OR"
+ "AND": "ORAZ",
+ "OR": "LUB"
},
"operators": {
From 5b5476888e8c1f25d52263ed409e7e4c1941b67d Mon Sep 17 00:00:00 2001
From: Damien Sorel
Date: Mon, 20 Nov 2017 22:27:48 +0100
Subject: [PATCH 18/84] Typo in english file
---
src/i18n/en.json | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/i18n/en.json b/src/i18n/en.json
index 41e48539..15bbb139 100644
--- a/src/i18n/en.json
+++ b/src/i18n/en.json
@@ -56,8 +56,8 @@
"datetime_invalid": "Invalid date format ({0})",
"datetime_exceed_min": "Must be after {0}",
"datetime_exceed_max": "Must be before {0}",
- "datetime_between_invalid": "Invalid values, {0} isgreater than {1}",
+ "datetime_between_invalid": "Invalid values, {0} is greater than {1}",
"boolean_not_valid": "Not a boolean",
"operator_not_multiple": "Operator \"{1}\" cannot accept multiple values"
}
-}
\ No newline at end of file
+}
From 6372712194d7d59df2f512bca7e7cac9a6acc936 Mon Sep 17 00:00:00 2001
From: ocobacho
Date: Mon, 20 Nov 2017 17:27:45 -0500
Subject: [PATCH 19/84] Update es.json (#598)
---
src/i18n/es.json | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/i18n/es.json b/src/i18n/es.json
index 3db3e098..3374aae1 100644
--- a/src/i18n/es.json
+++ b/src/i18n/es.json
@@ -22,6 +22,7 @@
"greater": "mayor",
"greater_or_equal": "mayor o igual",
"between": "entre",
+ "not_between": "no está entre",
"begins_with": "empieza por",
"not_begins_with": "no empieza por",
"contains": "contiene",
@@ -52,6 +53,11 @@
"number_wrong_step": "Debe ser múltiplo de {0}",
"datetime_invalid": "Formato de fecha inválido ({0})",
"datetime_exceed_min": "Debe ser posterior a {0}",
- "datetime_exceed_max": "Debe ser anterior a {0}"
+ "datetime_exceed_max": "Debe ser anterior a {0}",
+ "number_between_invalid": "Valores Inválidos, {0} es mayor que {1}",
+ "datetime_empty": "Campo vacio",
+ "datetime_between_invalid": "Valores Inválidos, {0} es mayor que {1}",
+ "boolean_not_valid": "No es booleano",
+ "operator_not_multiple": "El operador \"{1}\" no puede aceptar valores multiples"
}
}
From 050ac0b47341f53f49e368e6e035986fbd165c7f Mon Sep 17 00:00:00 2001
From: Yuksel Beyti
Date: Wed, 22 Nov 2017 22:32:59 +0100
Subject: [PATCH 20/84] Add turkish translations for between/not_between
validation (#600)
---
src/i18n/tr.json | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/i18n/tr.json b/src/i18n/tr.json
index 2b2d0295..03ce42b5 100644
--- a/src/i18n/tr.json
+++ b/src/i18n/tr.json
@@ -51,10 +51,12 @@
"number_exceed_min": "Sayı {0}'den/dan daha büyük olmalı",
"number_exceed_max": "Sayı {0}'den/dan daha küçük olmalı",
"number_wrong_step": "{0} veya katı olmalı",
+ "number_between_invalid": "Geçersiz değerler, {0} değeri {1} değerinden büyük",
"datetime_empty": "Tarih Seçilmemiş",
"datetime_invalid": "Uygun olmayan tarih formatı ({0})",
"datetime_exceed_min": "{0} Tarihinden daha sonrası olmalı.",
"datetime_exceed_max": "{0} Tarihinden daha öncesi olmalı.",
+ "datetime_between_invalid": "Geçersiz değerler, {0} değeri {1} değerinden büyük",
"boolean_not_valid": "Değer Doğru/Yanlış(bool) olmalı",
"operator_not_multiple": "Operatör \"{1}\" birden fazla değer kabul etmiyor"
}
From 1084cb638eb5ac6c80569128c2c75984f8cd5f69 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Mor?=
Date: Tue, 12 Dec 2017 19:33:24 +0100
Subject: [PATCH 21/84] Use verbs for operators, for consistency (#611)
---
src/i18n/fr.json | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/i18n/fr.json b/src/i18n/fr.json
index dabacbfe..33b27bb6 100644
--- a/src/i18n/fr.json
+++ b/src/i18n/fr.json
@@ -13,14 +13,14 @@
},
"operators": {
- "equal": "égal",
- "not_equal": "non égal",
- "in": "dans",
- "not_in": "pas dans",
- "less": "inférieur",
- "less_or_equal": "inférieur ou égal",
- "greater": "supérieur",
- "greater_or_equal": "supérieur ou égal",
+ "equal": "est égal à",
+ "not_equal": "n'est pas égal à",
+ "in": "est compris dans",
+ "not_in": "n'est pas compris dans",
+ "less": "est inférieur à",
+ "less_or_equal": "est inférieur ou égal à",
+ "greater": "est supérieur à",
+ "greater_or_equal": "est supérieur ou égal à",
"between": "est entre",
"not_between": "n'est pas entre",
"begins_with": "commence par",
@@ -60,4 +60,4 @@
"boolean_not_valid": "N'est pas un booléen",
"operator_not_multiple": "L'opérateur \"{1}\" ne peut utiliser plusieurs valeurs"
}
-}
\ No newline at end of file
+}
From efd3b4fbf428fca3799edcafffe6b9ff6d765ced Mon Sep 17 00:00:00 2001
From: Damien SOREL
Date: Fri, 11 Aug 2017 14:41:36 +0200
Subject: [PATCH 22/84] Fix #544 Always convert int, float and bool values
---
src/core.js | 8 ++++----
src/data.js | 23 ++++++++++++++++-------
src/plugins/mongodb-support/plugin.js | 9 ++-------
src/plugins/sql-support/plugin.js | 10 ++++++----
src/utils.js | 27 ++++++++++++++++++++-------
tests/data.module.js | 2 +-
tests/plugins.mongo-support.module.js | 12 ++++++------
tests/plugins.sql-support.module.js | 12 ++++++------
tests/utils.module.js | 10 ----------
9 files changed, 61 insertions(+), 52 deletions(-)
diff --git a/src/core.js b/src/core.js
index dddabca4..dde71c7e 100644
--- a/src/core.js
+++ b/src/core.js
@@ -682,7 +682,7 @@ QueryBuilder.prototype.createRuleInput = function(rule) {
$valueContainer.show();
$inputs.on('change ' + (filter.input_event || ''), function() {
- if (!this._updating_input) {
+ if (!rule._updating_input) {
rule._updating_value = true;
rule.value = self.getRuleInputValue(rule);
rule._updating_value = false;
@@ -770,6 +770,9 @@ QueryBuilder.prototype.updateRuleOperator = function(rule, previousOperator) {
if (rule.operator) {
rule.$el.find(QueryBuilder.selectors.rule_operator).val(rule.operator.type);
+
+ // refresh value if the format changed for this operator
+ rule.__.value = this.getRuleInputValue(rule);
}
/**
@@ -782,9 +785,6 @@ QueryBuilder.prototype.updateRuleOperator = function(rule, previousOperator) {
this.trigger('afterUpdateRuleOperator', rule, previousOperator);
this.trigger('rulesChanged');
-
- // FIXME is it necessary ?
- this.updateRuleValue(rule, ruleValue);
};
/**
diff --git a/src/data.js b/src/data.js
index 8d87848a..8f6e1dc1 100644
--- a/src/data.js
+++ b/src/data.js
@@ -417,11 +417,20 @@ QueryBuilder.prototype.getRuleInputValue = function(rule) {
}
}
- if (operator.multiple && filter.value_separator) {
- value = value.map(function(val) {
- return val.split(filter.value_separator);
- });
- }
+ value = value.map(function(val) {
+ if (operator.multiple && filter.value_separator && typeof val == 'string') {
+ val = val.split(filter.value_separator);
+ }
+
+ if ($.isArray(val)) {
+ return val.map(function(subval) {
+ return Utils.changeType(subval, filter.type);
+ });
+ }
+ else {
+ return Utils.changeType(val, filter.type);
+ }
+ });
if (operator.nb_inputs === 1) {
value = value[0];
@@ -458,7 +467,7 @@ QueryBuilder.prototype.setRuleInputValue = function(rule, value) {
return;
}
- this._updating_input = true;
+ rule._updating_input = true;
if (filter.valueSetter) {
filter.valueSetter.call(this, rule, value);
@@ -499,7 +508,7 @@ QueryBuilder.prototype.setRuleInputValue = function(rule, value) {
}
}
- this._updating_input = false;
+ rule._updating_input = false;
};
/**
diff --git a/src/plugins/mongodb-support/plugin.js b/src/plugins/mongodb-support/plugin.js
index a6aebdc3..6b0e2b49 100644
--- a/src/plugins/mongodb-support/plugin.js
+++ b/src/plugins/mongodb-support/plugin.js
@@ -132,7 +132,6 @@ QueryBuilder.extend(/** @lends module:plugins.MongoDbSupport.prototype */ {
else {
var mdb = self.settings.mongoOperators[rule.operator];
var ope = self.getOperatorByType(rule.operator);
- var values = [];
if (mdb === undefined) {
Utils.error('UndefinedMongoOperator', 'Unknown MongoDB operation for operator "{0}"', rule.operator);
@@ -142,10 +141,6 @@ QueryBuilder.extend(/** @lends module:plugins.MongoDbSupport.prototype */ {
if (!(rule.value instanceof Array)) {
rule.value = [rule.value];
}
-
- rule.value.forEach(function(v) {
- values.push(Utils.changeType(v, rule.type, false));
- });
}
/**
@@ -159,7 +154,7 @@ QueryBuilder.extend(/** @lends module:plugins.MongoDbSupport.prototype */ {
var field = self.change('getMongoDBField', rule.field, rule);
var ruleExpression = {};
- ruleExpression[field] = mdb.call(self, values);
+ ruleExpression[field] = mdb.call(self, rule.value);
/**
* Modifies the MongoDB expression generated for a rul
@@ -171,7 +166,7 @@ QueryBuilder.extend(/** @lends module:plugins.MongoDbSupport.prototype */ {
* @param {function} valueWrapper - function that takes the value and adds the operator
* @returns {object}
*/
- parts.push(self.change('ruleToMongo', ruleExpression, rule, values, mdb));
+ parts.push(self.change('ruleToMongo', ruleExpression, rule, rule.value, mdb));
}
});
diff --git a/src/plugins/sql-support/plugin.js b/src/plugins/sql-support/plugin.js
index b6751818..98cd1ad2 100644
--- a/src/plugins/sql-support/plugin.js
+++ b/src/plugins/sql-support/plugin.js
@@ -256,7 +256,9 @@ QueryBuilder.extend(/** @lends module:plugins.SqlSupport.prototype */ {
nl = !!nl ? '\n' : ' ';
var boolean_as_integer = this.getPluginOptions('sql-support', 'boolean_as_integer');
- if (stmt === true) stmt = 'question_mark';
+ if (stmt === true) {
+ stmt = 'question_mark';
+ }
if (typeof stmt == 'string') {
var config = getStmtConfig(stmt);
stmt = this.settings.sqlStatements[config[1]](config[2]);
@@ -301,10 +303,10 @@ QueryBuilder.extend(/** @lends module:plugins.SqlSupport.prototype */ {
value += sql.sep;
}
- if (rule.type == 'integer' || rule.type == 'double' || rule.type == 'boolean') {
- v = Utils.changeType(v, rule.type, boolean_as_integer);
+ if (rule.type == 'boolean' && boolean_as_integer) {
+ v = v ? 1 : 0;
}
- else if (!stmt) {
+ else if (!stmt && rule.type !== 'integer' && rule.type !== 'double' && rule.type !== 'boolean') {
v = Utils.escapeString(v);
}
diff --git a/src/utils.js b/src/utils.js
index 94af0956..2489d0d4 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -103,17 +103,30 @@ Utils.error = function() {
* Changes the type of a value to int, float or bool
* @param {*} value
* @param {string} type - 'integer', 'double', 'boolean' or anything else (passthrough)
- * @param {boolean} [boolAsInt=false] - return 0 or 1 for booleans
* @returns {*}
*/
-Utils.changeType = function(value, type, boolAsInt) {
+Utils.changeType = function(value, type) {
+ if (value === '' || value === undefined) {
+ return undefined;
+ }
+
switch (type) {
- // @formatter:off
- case 'integer': return parseInt(value);
- case 'double': return parseFloat(value);
+ // @formatter:off
+ case 'integer':
+ if (typeof value === 'string' && !/^-?\d+$/.test(value)) {
+ return value;
+ }
+ return parseInt(value);
+ case 'double':
+ if (typeof value === 'string' && !/^-?\d+\.?\d*$/.test(value)) {
+ return value;
+ }
+ return parseFloat(value);
case 'boolean':
- var bool = value.trim().toLowerCase() === 'true' || value.trim() === '1' || value === 1;
- return boolAsInt ? (bool ? 1 : 0) : bool;
+ if (typeof value === 'string' && !/^(0|1|true|false){1}$/i.test(value)) {
+ return value;
+ }
+ return value === true || value === 1 || value.toLowerCase() === 'true' || value === '1';
default: return value;
// @formatter:on
}
diff --git a/tests/data.module.js b/tests/data.module.js
index d7f11838..41e7b48d 100644
--- a/tests/data.module.js
+++ b/tests/data.module.js
@@ -414,7 +414,7 @@ $(function() {
}, {
id: 'age',
operator: 'not_in',
- value: ['16', '17', '18']
+ value: [16, 17, 18]
}]
},
'Should split values on comma and pipe'
diff --git a/tests/plugins.mongo-support.module.js b/tests/plugins.mongo-support.module.js
index 73ff20f9..61ea36d8 100644
--- a/tests/plugins.mongo-support.module.js
+++ b/tests/plugins.mongo-support.module.js
@@ -126,27 +126,27 @@ $(function(){
}, {
id: 'price',
operator: 'less',
- value: '5'
+ value: 5
}, {
id: 'price',
operator: 'less_or_equal',
- value: '5'
+ value: 5
}, {
id: 'price',
operator: 'greater',
- value: '4'
+ value: 4
}, {
id: 'price',
operator: 'greater_or_equal',
- value: '4'
+ value: 4
}, {
id: 'price',
operator: 'between',
- value: ['4','5']
+ value: [4,5]
}, {
id: 'price',
operator: 'not_between',
- value: ['4','5']
+ value: [4,5]
}, {
id: 'name',
operator: 'begins_with',
diff --git a/tests/plugins.sql-support.module.js b/tests/plugins.sql-support.module.js
index 7d2da34e..46443b37 100644
--- a/tests/plugins.sql-support.module.js
+++ b/tests/plugins.sql-support.module.js
@@ -406,27 +406,27 @@ $(function() {
}, {
id: 'price',
operator: 'less',
- value: '5'
+ value: 5
}, {
id: 'price',
operator: 'less_or_equal',
- value: '5'
+ value: 5
}, {
id: 'price',
operator: 'greater',
- value: '4'
+ value: 4
}, {
id: 'price',
operator: 'greater_or_equal',
- value: '4'
+ value: 4
}, {
id: 'price',
operator: 'between',
- value: ['4', '5']
+ value: [4,5]
}, {
id: 'price',
operator: 'not_between',
- value: ['4', '5']
+ value: [4,5]
}, {
id: 'name',
operator: 'begins_with',
diff --git a/tests/utils.module.js b/tests/utils.module.js
index 57a2018a..91830280 100644
--- a/tests/utils.module.js
+++ b/tests/utils.module.js
@@ -95,11 +95,6 @@ $(function () {
'"10" should be parsed as integer'
);
- assert.ok(
- Utils.changeType('10.5', 'integer') === 10,
- '"10.5" should be parsed as integer'
- );
-
assert.ok(
Utils.changeType('10.5', 'double') === 10.5,
'"10.5" should be parsed as double'
@@ -109,11 +104,6 @@ $(function () {
Utils.changeType('true', 'boolean') === true,
'"true" should be parsed as boolean'
);
-
- assert.ok(
- Utils.changeType('false', 'boolean', true) === 0,
- '"false" should be parsed as integer'
- );
});
/**
From 43c85fbf5c3bc6c9db558139637bd86cf985f965 Mon Sep 17 00:00:00 2001
From: mistic100
Date: Sat, 16 Dec 2017 17:38:13 +0100
Subject: [PATCH 23/84] Fix #490 Generate valid HTML
Replaced ul/li/dl/dd/dt by divs
---
src/template.js | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/template.js b/src/template.js
index 40b52ce1..41f7dd3a 100644
--- a/src/template.js
+++ b/src/template.js
@@ -1,6 +1,6 @@
QueryBuilder.templates.group = '\
- \
-