filter rewrite, support most special types

This commit is contained in:
rlx 2011-06-02 05:29:58 +00:00
parent 65aadc19e9
commit 67dd877874

View file

@ -439,27 +439,60 @@ Ox.Filter = function(options, self) {
} }
function renderInput(condition, index) { function renderInput(condition, index) {
return Ox.Input(!Ox.isArray(condition.value) ? { var $input,
value: condition.value, findKey = Ox.getObjectById(self.options.findKeys, condition.key),
width: 288 isArray = Ox.isArray(condition.value),
} : { type = findKey.type == 'integer' ? 'int' : findKey.type,
value: condition.value[index], formatArgs, formatType, title;
width: 128 if (findKey.format) {
}); formatArgs = findKey.format.args
/* formatType = findKey.format.type;
Ox.DateInput({ if (findKey.format.type == 'date') {
id: 'end', $input = Ox.DateInput(!isArray ? {
width: { //value: condition.value,
day: 32, width: {day: 66, month: 66, year: 140}
month: 32, } : {
year: 48 //value: condition.value[index],
width: {day: 32, month: 32, year: 48}
});
} else if ([
'currency', 'percent', 'unit', 'value'
].indexOf(formatType) > -1) {
title = formatType == 'percent' ? '%' : formatArgs[0];
$input = Ox.FormElementGroup({
elements: [
Ox.Input({
type: type,
value: !isArray ? condition.value : condition.value[index],
width: !isArray ? 240 : 80
}),
formatType == 'value' ? Ox.Select({
overlap: 'left',
items: ['K', 'M', 'G', 'T'].map(function(prefix) {
return {id: prefix + title, title: prefix + title};
}),
width: 48
}) : Ox.Label({
overlap: 'left',
textAlign: 'center',
title: title,
width: 48
})
],
float: 'right',
width: !isArray ? 288 : 128
})
} }
}) } else {
*/ $input = Ox.Input({
type: type,
value: !isArray ? condition.value : condition.value[index],
width: !isArray ? 288 : 128
});
}
return $input;
} }
function renderConditions() { function renderConditions() {
Ox.print('renderConditions', self.options.query) Ox.print('renderConditions', self.options.query)
var $conditions = []; var $conditions = [];
@ -524,15 +557,6 @@ Ox.Filter = function(options, self) {
return $condition; return $condition;
} }
function updateConditions() {
self.$conditions.forEach(function(condition, pos) {
condition.data({position: pos, subposition: -1});
});
self.$conditions[0].options('elements')[3].options({
disabled: self.options.query.conditions.length == 1
});
}
return that; return that;
}; };