in filter, for single condition, replace disabled remove button with clear button

This commit is contained in:
rlx 2011-11-11 09:18:07 +00:00
parent 3becce1667
commit f7599f3b30

View file

@ -450,16 +450,25 @@ Ox.Filter = function(options, self) {
var isGroup = subpos == -1 && self.options.query.conditions[pos].conditions;
return Ox.merge([
Ox.Button({
disabled: self.options.query.conditions.length == 1,
id: 'remove',
title: 'remove',
title: self.options.query.conditions.length == 1
? 'close' : 'remove',
type: 'image'
})
.css({margin: '0 4px 0 ' + (isGroup ? '292px' : '8px')}) // fixme: 296 is probably correct, but labels seem to be too wide
.bindEvent({
click: function(data) {
Ox.Log('Form', 'remove...', data)
if (data._element.parent().data('subposition') == -1) {
var key;
if (self.options.query.conditions.length == 1) {
key = self.options.findKeys[0];
self.options.query.conditions = [{
key: key.id,
value: '',
operator: self.conditionOperators[key.type][0].id
}];
renderConditions();
triggerChangeEvent();
} else if (data._element.parent().data('subposition') == -1) {
removeCondition(data._element.parent().data('position'));
} else {
removeCondition(