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(oldConditionType) == -1
|
||||||
|| ['string', 'text'].indexOf(newConditionType) == -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();
|
renderConditions();
|
||||||
}
|
}
|
||||||
|
@ -456,7 +458,10 @@ 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
|
.css({margin: '0 4px 0 ' + (isGroup ? '292px' : '8px')}) // fixme: 296 is probably correct, but labels seem to be too wide
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function(data) {
|
click: function(data) {
|
||||||
var key;
|
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) {
|
if (self.options.value.conditions.length == 1) {
|
||||||
key = self.options.findKeys[0];
|
key = self.options.findKeys[0];
|
||||||
self.options.value.conditions = [{
|
self.options.value.conditions = [{
|
||||||
|
@ -466,14 +471,15 @@ Ox.Filter = function(options, self) {
|
||||||
}];
|
}];
|
||||||
renderConditions();
|
renderConditions();
|
||||||
triggerChangeEvent();
|
triggerChangeEvent();
|
||||||
} else if (this.$element.parent().data('subposition') == -1) {
|
} else if (that.$element.parent().data('subposition') == -1) {
|
||||||
removeCondition(this.$element.parent().data('position'));
|
removeCondition(that.$element.parent().data('position'));
|
||||||
} else {
|
} else {
|
||||||
removeCondition(
|
removeCondition(
|
||||||
this.$element.parent().data('position'),
|
that.$element.parent().data('position'),
|
||||||
this.$element.parent().data('subposition')
|
that.$element.parent().data('subposition')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Ox.Button({
|
Ox.Button({
|
||||||
|
@ -486,10 +492,8 @@ Ox.Filter = function(options, self) {
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function(data) {
|
click: function(data) {
|
||||||
var that = this;
|
var that = this;
|
||||||
// timeout needed so that input change registers
|
that.$element.focus(); // make input trigger change
|
||||||
// before all conditions are re-rendered
|
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
Ox.Log('Form', 'add...', data, that.$element.parent().data('position'), that.$element.parent().data('subposition'))
|
|
||||||
if (that.$element.parent().data('subposition') == -1) {
|
if (that.$element.parent().data('subposition') == -1) {
|
||||||
addCondition(that.$element.parent().data('position') + 1);
|
addCondition(that.$element.parent().data('position') + 1);
|
||||||
} else {
|
} else {
|
||||||
|
@ -512,8 +516,9 @@ Ox.Filter = function(options, self) {
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
click: function(data) {
|
click: function(data) {
|
||||||
var that = this;
|
var that = this;
|
||||||
|
that.$element.focus(); // make input trigger change
|
||||||
setTimeout(function() {
|
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') {
|
if (type == 'boolean') {
|
||||||
$input = Ox.Select({
|
$input = Ox.Select({
|
||||||
items: ['true', 'false'],
|
items: ['true', 'false'],
|
||||||
|
max: 1,
|
||||||
|
min: 1,
|
||||||
value: value ? 'true' : 'false',
|
value: value ? 'true' : 'false',
|
||||||
width: 288
|
width: 288
|
||||||
});
|
});
|
||||||
|
@ -699,6 +706,8 @@ Ox.Filter = function(options, self) {
|
||||||
} else if (type == 'item') {
|
} else if (type == 'item') {
|
||||||
$input = Ox.Select({
|
$input = Ox.Select({
|
||||||
items: findKey.values,
|
items: findKey.values,
|
||||||
|
max: 1,
|
||||||
|
min: 1,
|
||||||
value: value,
|
value: value,
|
||||||
width: 288
|
width: 288
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue