handle type ["integer"] in url and fix inbetween vs ["integer"] filter
This commit is contained in:
parent
b0c0bd36be
commit
b7c201a74f
2 changed files with 32 additions and 19 deletions
|
@ -683,15 +683,21 @@ Ox.URL = function(options) {
|
||||||
condition.operator = condition.operator.replace('=', '^')
|
condition.operator = condition.operator.replace('=', '^')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
var key = Ox.getObjectById(self.options.findKeys[state.type], condition.key)
|
||||||
if (
|
if (
|
||||||
['date', 'enum', 'float', 'integer', 'time', 'year'].indexOf(
|
['date', 'enum', 'float', 'integer', 'time', 'year'].indexOf(key.type) > -1
|
||||||
Ox.getObjectById(self.options.findKeys[state.type], condition.key).type
|
|
||||||
) > -1
|
|
||||||
&& condition.value.indexOf(',') > -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, state);
|
return parseValue(decodeValue(value), condition.key, state);
|
||||||
});
|
});
|
||||||
|
} else if (Ox.isArray(key.type) && key.type[0] == "integer" && condition.value.indexOf(',') > -1) {
|
||||||
|
condition.value = condition.value.split(',').map(function(value) {
|
||||||
|
return parseValue(decodeValue(value), condition.key, state);
|
||||||
|
});
|
||||||
|
if (condition.value.length == 4) {
|
||||||
|
condition.value = [condition.value.slice(0,2), condition.value.slice(2)]
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
condition.value = parseValue(decodeValue(condition.value), condition.key, state);
|
condition.value = parseValue(decodeValue(condition.value), condition.key, state);
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,6 +355,13 @@ Ox.Filter = function(options, self) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isBetweenCondition(condition) {
|
||||||
|
if (condition.key == "resolution") {
|
||||||
|
return Ox.isArray(condition.value) && Ox.isArray(condition.value[0])
|
||||||
|
}
|
||||||
|
return Ox.isArray(condition.value)
|
||||||
|
}
|
||||||
|
|
||||||
function changeConditionOperator(pos, subpos, operator) {
|
function changeConditionOperator(pos, subpos, operator) {
|
||||||
subpos = Ox.isUndefined(subpos) ? -1 : subpos;
|
subpos = Ox.isUndefined(subpos) ? -1 : subpos;
|
||||||
Ox.Log('FILTER', 'chCoOp', 'query', self.options.value)
|
Ox.Log('FILTER', 'chCoOp', 'query', self.options.value)
|
||||||
|
@ -362,7 +369,7 @@ Ox.Filter = function(options, self) {
|
||||||
? self.options.value.conditions[pos]
|
? self.options.value.conditions[pos]
|
||||||
: self.options.value.conditions[pos].conditions[subpos],
|
: self.options.value.conditions[pos].conditions[subpos],
|
||||||
isBetween = operator.indexOf(',') > -1,
|
isBetween = operator.indexOf(',') > -1,
|
||||||
wasBetween = Ox.isArray(condition.value),
|
wasBetween = isBetweenCondition(condition),
|
||||||
wasUselessCondition = isUselessCondition(pos, subpos);
|
wasUselessCondition = isUselessCondition(pos, subpos);
|
||||||
Ox.Log('FILTER', 'chCoOp', 'iB/wB', isBetween, wasBetween)
|
Ox.Log('FILTER', 'chCoOp', 'iB/wB', isBetween, wasBetween)
|
||||||
condition.operator = operator;
|
condition.operator = operator;
|
||||||
|
@ -577,7 +584,7 @@ Ox.Filter = function(options, self) {
|
||||||
Ox.getObjectById(self.options.findKeys, condition.key).type
|
Ox.getObjectById(self.options.findKeys, condition.key).type
|
||||||
)],
|
)],
|
||||||
overlap: 'right',
|
overlap: 'right',
|
||||||
value: condition.operator + (Ox.isArray(condition.value) ? ',' : ''),
|
value: condition.operator + (isBetweenCondition(condition) ? ',' : ''),
|
||||||
width: 128
|
width: 128
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
|
@ -593,7 +600,7 @@ Ox.Filter = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderConditionValue(condition) {
|
function renderConditionValue(condition) {
|
||||||
return (!Ox.isArray(condition.value)
|
return (!isBetweenCondition(condition)
|
||||||
? renderInput(condition)
|
? renderInput(condition)
|
||||||
: Ox.InputGroup({
|
: Ox.InputGroup({
|
||||||
inputs: [
|
inputs: [
|
||||||
|
@ -699,11 +706,11 @@ Ox.Filter = function(options, self) {
|
||||||
Ox.Log('Form', 'renderInput', condition)
|
Ox.Log('Form', 'renderInput', condition)
|
||||||
var $input,
|
var $input,
|
||||||
findKey = Ox.getObjectById(self.options.findKeys, condition.key),
|
findKey = Ox.getObjectById(self.options.findKeys, condition.key),
|
||||||
isArray = Ox.isArray(condition.value),
|
isBetween = isBetweenCondition(condition),
|
||||||
isHue,
|
isHue,
|
||||||
// FIXME: always use 'int'
|
// FIXME: always use 'int'
|
||||||
type = findKey.type == 'integer' ? 'int' : findKey.type,
|
type = findKey.type == 'integer' ? 'int' : findKey.type,
|
||||||
value = !isArray ? condition.value : condition.value[index],
|
value = !isBetween ? condition.value : condition.value[index],
|
||||||
formatArgs, formatType, title;
|
formatArgs, formatType, title;
|
||||||
if (type == 'boolean') {
|
if (type == 'boolean') {
|
||||||
$input = Ox.Select({
|
$input = Ox.Select({
|
||||||
|
@ -720,7 +727,7 @@ Ox.Filter = function(options, self) {
|
||||||
return {id: i, title: v}
|
return {id: i, title: v}
|
||||||
}),
|
}),
|
||||||
value: value,
|
value: value,
|
||||||
width: !isArray ? 288 : 128
|
width: !isBetween ? 288 : 128
|
||||||
});
|
});
|
||||||
} else if (type == 'item') {
|
} else if (type == 'item') {
|
||||||
$input = Ox.Select({
|
$input = Ox.Select({
|
||||||
|
@ -747,8 +754,8 @@ Ox.Filter = function(options, self) {
|
||||||
$input = Ox.Range({
|
$input = Ox.Range({
|
||||||
max: isHue ? 360 : 1,
|
max: isHue ? 360 : 1,
|
||||||
min: 0,
|
min: 0,
|
||||||
size: !isArray ? 288 : 128, // fixme: should be width!
|
size: !isBetween ? 288 : 128, // fixme: should be width!
|
||||||
width: !isArray ? 288 : 128, // have to set this too, for formatting when tuple
|
width: !isBetween ? 288 : 128, // have to set this too, for formatting when tuple
|
||||||
step: isHue ? 1 : 0.01,
|
step: isHue ? 1 : 0.01,
|
||||||
thumbSize: 48,
|
thumbSize: 48,
|
||||||
thumbValue: true,
|
thumbValue: true,
|
||||||
|
@ -761,7 +768,7 @@ Ox.Filter = function(options, self) {
|
||||||
value: value
|
value: value
|
||||||
});
|
});
|
||||||
} else if (formatType == 'date') {
|
} else if (formatType == 'date') {
|
||||||
$input = Ox.DateInput(!isArray ? {
|
$input = Ox.DateInput(!isBetween ? {
|
||||||
value: value,
|
value: value,
|
||||||
width: {day: 66, month: 66, year: 140}
|
width: {day: 66, month: 66, year: 140}
|
||||||
} : {
|
} : {
|
||||||
|
@ -769,7 +776,7 @@ Ox.Filter = function(options, self) {
|
||||||
width: {day: 32, month: 32, year: 48}
|
width: {day: 32, month: 32, year: 48}
|
||||||
});
|
});
|
||||||
} else if (formatType == 'duration') {
|
} else if (formatType == 'duration') {
|
||||||
$input = Ox.TimeInput(!isArray ? {
|
$input = Ox.TimeInput(!isBetween ? {
|
||||||
seconds: true,
|
seconds: true,
|
||||||
value: value,
|
value: value,
|
||||||
width: {hours: 91, minutes: 91, seconds: 90}
|
width: {hours: 91, minutes: 91, seconds: 90}
|
||||||
|
@ -796,16 +803,16 @@ Ox.Filter = function(options, self) {
|
||||||
Ox.Input({
|
Ox.Input({
|
||||||
id: 'width',
|
id: 'width',
|
||||||
type: 'int',
|
type: 'int',
|
||||||
value: value
|
value: value[0]
|
||||||
}),
|
}),
|
||||||
Ox.Input({
|
Ox.Input({
|
||||||
id: 'height',
|
id: 'height',
|
||||||
type: 'int',
|
type: 'int',
|
||||||
value: value
|
value: value[1]
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
separators: [{title: 'x', width: 16}],
|
separators: [{title: 'x', width: 16}],
|
||||||
width: !isArray ? 288 : 128
|
width: !isBetween ? 288 : 128
|
||||||
})
|
})
|
||||||
} else if ([
|
} else if ([
|
||||||
'currency', 'percent', 'unit', 'value'
|
'currency', 'percent', 'unit', 'value'
|
||||||
|
@ -816,7 +823,7 @@ Ox.Filter = function(options, self) {
|
||||||
Ox.Input({
|
Ox.Input({
|
||||||
type: type,
|
type: type,
|
||||||
value: value,
|
value: value,
|
||||||
width: !isArray ? 242 : 80
|
width: !isBetween ? 242 : 80
|
||||||
}),
|
}),
|
||||||
formatType == 'value' ? Ox.Select({
|
formatType == 'value' ? Ox.Select({
|
||||||
overlap: 'left',
|
overlap: 'left',
|
||||||
|
@ -840,7 +847,7 @@ Ox.Filter = function(options, self) {
|
||||||
split: function(value) {
|
split: function(value) {
|
||||||
|
|
||||||
},
|
},
|
||||||
width: !isArray ? 288 : 128
|
width: !isBetween ? 288 : 128
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -850,7 +857,7 @@ Ox.Filter = function(options, self) {
|
||||||
autocomplete: findKey.autocomplete,
|
autocomplete: findKey.autocomplete,
|
||||||
autocompleteSelect: true,
|
autocompleteSelect: true,
|
||||||
autocompleteSelectSubmit: true,
|
autocompleteSelectSubmit: true,
|
||||||
width: !isArray ? 288 : 128
|
width: !isBetween ? 288 : 128
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return $input;
|
return $input;
|
||||||
|
|
Loading…
Reference in a new issue