use 'foo=bar,baz' for 'is between', and make sure this gets only parsed for number-like find keys

This commit is contained in:
rlx 2012-02-19 17:21:23 +00:00
parent be44815ce4
commit 4c3b0c41b1

View file

@ -8,7 +8,7 @@ Ox.URL <f> URL controller
options <o> Options object options <o> Options object
findKeys <[o]> Find keys findKeys <[o]> Find keys
id <s> Find key id id <s> Find key id
type <s> Value type ("string" or "number") type <s> Value type (like "string" or "integer")
getItem <f> Tests if a string matches an item getItem <f> Tests if a string matches an item
(string, callback) -> <u> undefined (string, callback) -> <u> undefined
string <s> The string to be tested string <s> The string to be tested
@ -87,8 +87,8 @@ k<v k v < is less than (number)
k!<v k v !< is not less than (number) k!<v k v !< is not less than (number)
k>v k v > is more than (number) k>v k v > is more than (number)
k!>v k v !> is not more than (number) k!>v k v !> is not more than (number)
k=v:w k [v,w] = is between (number), contains (string or text) k=v,w k [v,w] = is between (number), contains (string or text)
k!=v:w k [v,w] != is not between (number), does not contain (string or text) k!=v,w k [v,w] != is not between (number), does not contain (string or text)
All parts of the URL can be omitted, as long as the order is preserved. All parts of the URL can be omitted, as long as the order is preserved.
@ -331,7 +331,6 @@ Ox.URL = function(options) {
return false; return false;
} }
}); });
condition.key = condition.key || '*';
if ( if (
!condition.operator !condition.operator
|| Ox.getIndexById(self.options.findKeys, condition.key) == -1 || Ox.getIndexById(self.options.findKeys, condition.key) == -1
@ -348,7 +347,12 @@ Ox.URL = function(options) {
condition.operator = condition.operator.replace('=', '^') condition.operator = condition.operator.replace('=', '^')
} }
} }
if (condition.value.indexOf(',') > -1) { if (
['date', 'enum', 'float', 'integer', 'time', 'year'].indexOf(
Ox.getObjectById(self.options.findKeys, condition.key).type
) > -1
&& condition.value.indexOf(',') > -1
) {
condition.value = condition.value.split(',').map(function(value) { condition.value = condition.value.split(',').map(function(value) {
return parseValue(decodeValue(value), condition.key); return parseValue(decodeValue(value), condition.key);
}); });