From 5b5476888e8c1f25d52263ed409e7e4c1941b67d Mon Sep 17 00:00:00 2001
From: Damien Sorel
Date: Mon, 20 Nov 2017 22:27:48 +0100
Subject: [PATCH 01/67] 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 02/67] 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 03/67] 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 04/67] 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 05/67] 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 06/67] 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 = '\
- \
-