From f7599f3b3033880c2f840517c81e5171a0c8508c Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Fri, 11 Nov 2011 09:18:07 +0000 Subject: [PATCH] in filter, for single condition, replace disabled remove button with clear button --- source/Ox.UI/js/Form/Ox.Filter.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source/Ox.UI/js/Form/Ox.Filter.js b/source/Ox.UI/js/Form/Ox.Filter.js index 7bd13fef..754d8579 100644 --- a/source/Ox.UI/js/Form/Ox.Filter.js +++ b/source/Ox.UI/js/Form/Ox.Filter.js @@ -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(