Ox.Filter: fix value reset on clicking (+) or (-), fix default value for item type
This commit is contained in:
parent
c593955e8c
commit
17120e6aec
1 changed files with 33 additions and 24 deletions
|
@ -337,7 +337,9 @@ Ox.Filter = function(options, self) {
|
|||
['string', 'text'].indexOf(oldConditionType) == -1
|
||||
|| ['string', 'text'].indexOf(newConditionType) == -1
|
||||
) {
|
||||
condition.value = self.defaultValue[newFindKey.type];
|
||||
condition.value = newFindKey.type == 'item'
|
||||
? newFindKey.values[0].id
|
||||
: self.defaultValue[newFindKey.type];
|
||||
}
|
||||
renderConditions();
|
||||
}
|
||||
|
@ -456,24 +458,28 @@ Ox.Filter = function(options, self) {
|
|||
.css({margin: '0 4px 0 ' + (isGroup ? '292px' : '8px')}) // fixme: 296 is probably correct, but labels seem to be too wide
|
||||
.bindEvent({
|
||||
click: function(data) {
|
||||
var key;
|
||||
if (self.options.value.conditions.length == 1) {
|
||||
key = self.options.findKeys[0];
|
||||
self.options.value.conditions = [{
|
||||
key: key.id,
|
||||
value: '',
|
||||
operator: self.conditionOperators[key.type][0].id
|
||||
}];
|
||||
renderConditions();
|
||||
triggerChangeEvent();
|
||||
} else if (this.$element.parent().data('subposition') == -1) {
|
||||
removeCondition(this.$element.parent().data('position'));
|
||||
} else {
|
||||
removeCondition(
|
||||
this.$element.parent().data('position'),
|
||||
this.$element.parent().data('subposition')
|
||||
);
|
||||
}
|
||||
var key, that = this;
|
||||
that.$element.focus(); // make input trigger change
|
||||
setTimeout(function() {
|
||||
Ox.print(self.options.value.conditions.length, that.$element.parent().data('subposition') == -1);
|
||||
if (self.options.value.conditions.length == 1) {
|
||||
key = self.options.findKeys[0];
|
||||
self.options.value.conditions = [{
|
||||
key: key.id,
|
||||
value: '',
|
||||
operator: self.conditionOperators[key.type][0].id
|
||||
}];
|
||||
renderConditions();
|
||||
triggerChangeEvent();
|
||||
} else if (that.$element.parent().data('subposition') == -1) {
|
||||
removeCondition(that.$element.parent().data('position'));
|
||||
} else {
|
||||
removeCondition(
|
||||
that.$element.parent().data('position'),
|
||||
that.$element.parent().data('subposition')
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
}),
|
||||
Ox.Button({
|
||||
|
@ -486,10 +492,8 @@ Ox.Filter = function(options, self) {
|
|||
.bindEvent({
|
||||
click: function(data) {
|
||||
var that = this;
|
||||
// timeout needed so that input change registers
|
||||
// before all conditions are re-rendered
|
||||
that.$element.focus(); // make input trigger change
|
||||
setTimeout(function() {
|
||||
Ox.Log('Form', 'add...', data, that.$element.parent().data('position'), that.$element.parent().data('subposition'))
|
||||
if (that.$element.parent().data('subposition') == -1) {
|
||||
addCondition(that.$element.parent().data('position') + 1);
|
||||
} else {
|
||||
|
@ -512,8 +516,9 @@ Ox.Filter = function(options, self) {
|
|||
.bindEvent({
|
||||
click: function(data) {
|
||||
var that = this;
|
||||
that.$element.focus(); // make input trigger change
|
||||
setTimeout(function() {
|
||||
addCondition(that.$element.parent().data('position') + 1, -1, true)
|
||||
addCondition(that.$element.parent().data('position') + 1, -1, true);
|
||||
});
|
||||
}
|
||||
})
|
||||
|
@ -684,6 +689,8 @@ Ox.Filter = function(options, self) {
|
|||
if (type == 'boolean') {
|
||||
$input = Ox.Select({
|
||||
items: ['true', 'false'],
|
||||
max: 1,
|
||||
min: 1,
|
||||
value: value ? 'true' : 'false',
|
||||
width: 288
|
||||
});
|
||||
|
@ -699,6 +706,8 @@ Ox.Filter = function(options, self) {
|
|||
} else if (type == 'item') {
|
||||
$input = Ox.Select({
|
||||
items: findKey.values,
|
||||
max: 1,
|
||||
min: 1,
|
||||
value: value,
|
||||
width: 288
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue