forked from 0x2620/oxjs
beginning to unify pandora.URL and pandora.Query as Ox.URL
This commit is contained in:
parent
fdecafe4d7
commit
b7100792c5
5 changed files with 422 additions and 17 deletions
|
|
@ -295,14 +295,17 @@ Ox.Filter = function(options, self) {
|
|||
newType = Ox.getObjectById(self.options.findKeys, key).type,
|
||||
oldConditionType = getConditionType(oldType),
|
||||
newConditionType = getConditionType(newType),
|
||||
changeConditionType = oldConditionType != newConditionType;
|
||||
changeConditionType = oldConditionType != newConditionType,
|
||||
wasUselessCondition = isUselessCondition(pos, subpos);
|
||||
Ox.print('old new', oldConditionType, newConditionType)
|
||||
condition.key = key;
|
||||
if (changeConditionType) {
|
||||
renderConditions();
|
||||
//self.$conditions[pos].replaceElement(1, constructConditionOperator(pos, oldOperator));
|
||||
}
|
||||
triggerChangeEvent();
|
||||
if (!(wasUselessCondition && isUselessCondition(pos, subpos))) {
|
||||
triggerChangeEvent();
|
||||
}
|
||||
}
|
||||
|
||||
function changeConditionOperator(pos, subpos, operator) {
|
||||
|
|
@ -311,7 +314,8 @@ Ox.Filter = function(options, self) {
|
|||
var condition = subpos == -1
|
||||
? self.options.query.conditions[pos]
|
||||
: self.options.query.conditions[pos].conditions[subpos],
|
||||
oldOperator = condition.operator
|
||||
oldOperator = condition.operator,
|
||||
wasUselessCondition = isUselessCondition(pos, subpos);
|
||||
condition.operator = operator;
|
||||
if (oldOperator.indexOf('-') == -1 && operator.indexOf('-') > -1) {
|
||||
condition.value = [condition.value, condition.value]
|
||||
|
|
@ -320,7 +324,9 @@ Ox.Filter = function(options, self) {
|
|||
condition.value = condition.value[0]
|
||||
renderConditions();
|
||||
}
|
||||
triggerChangeEvent();
|
||||
if (!(wasUselessCondition && isUselessCondition(pos, subpos))) {
|
||||
triggerChangeEvent();
|
||||
}
|
||||
}
|
||||
|
||||
function changeConditionValue(pos, subpos, value) {
|
||||
|
|
@ -341,7 +347,7 @@ Ox.Filter = function(options, self) {
|
|||
}
|
||||
});
|
||||
changeGroupOperator && renderConditions();
|
||||
triggerChangeEvent();
|
||||
self.options.query.conditions.length > 1 && triggerChangeEvent();
|
||||
}
|
||||
|
||||
function getConditionType(type) {
|
||||
|
|
@ -360,11 +366,13 @@ Ox.Filter = function(options, self) {
|
|||
: [self.options.query.conditions[pos].conditions[subpos]],
|
||||
isUseless = false;
|
||||
Ox.forEach(conditions, function(condition) {
|
||||
isUseless = ['string', 'text'].indexOf(
|
||||
isUseless = ['string', 'text'].indexOf(getConditionType(
|
||||
Ox.getObjectById(self.options.findKeys, condition.key).type
|
||||
) > -1
|
||||
&& condition.operator == (self.options.query.operator == '&' ? '' : '!')
|
||||
&& condition.value == ''
|
||||
)) > -1
|
||||
&& (
|
||||
self.options.query.operator == '&' ? ['', '^', '$'] : ['!', '!^', '!$']
|
||||
).indexOf(condition.operator) > -1
|
||||
&& condition.value === ''
|
||||
return isUseless;
|
||||
});
|
||||
Ox.print('isUseless', isUseless);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue