fix filter selection
This commit is contained in:
parent
fabd50bef1
commit
0afae95e8b
2 changed files with 55 additions and 7 deletions
|
@ -158,13 +158,57 @@ oml.ui.filter = function(id) {
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
change: function(data) {
|
change: function(data) {
|
||||||
var isOuter = filterIndex % 4 == 0, id = data.checked[0].id;
|
var id_ = data.checked[0].id,
|
||||||
ui.filters[filterIndex] = Ox.getObjectById(oml.config.user.ui.filters, id);
|
filter_ = Ox.getObjectById(oml.config.filters, id_),
|
||||||
ui._filterState = oml.getFilterState(ui.find);
|
filterIndex_ = Ox.getIndexById(ui.filters, id_),
|
||||||
oml.$ui[isOuter ? 'filtersOuterPanel' : 'filtersInnerPanel'].replaceElement(
|
filters = Ox.clone(ui.filters),
|
||||||
isOuter ? filterIndex / 2 : filterIndex - 1,
|
filterState,
|
||||||
oml.$ui.filters[filterIndex] = oml.ui.filter(id)
|
find;
|
||||||
);
|
if (filterIndex_ == -1) {
|
||||||
|
// New filter was not part of old filter set
|
||||||
|
if (ui._filterState[filterIndex].selectedLength) {
|
||||||
|
// Filter with selection gets replaced, update find
|
||||||
|
find = Ox.clone(ui.find, true);
|
||||||
|
find.conditions.splice(
|
||||||
|
ui._filterState[filterIndex].index, 1
|
||||||
|
);
|
||||||
|
}
|
||||||
|
filters[filterIndex] = {
|
||||||
|
id: id_,
|
||||||
|
sort: filter_.sort
|
||||||
|
};
|
||||||
|
oml.UI.set(Ox.extend({
|
||||||
|
filters: filters
|
||||||
|
}, find ? {
|
||||||
|
find: find
|
||||||
|
} : {}));
|
||||||
|
replaceFilter(filterIndex, id_);
|
||||||
|
} else {
|
||||||
|
// Swap two exisiting filters
|
||||||
|
filterState = Ox.clone(ui._filterState[filterIndex]);
|
||||||
|
ui._filterState[filterIndex] = ui._filterState[filterIndex_];
|
||||||
|
ui._filterState[filterIndex_] = filterState;
|
||||||
|
filters[filterIndex] = {
|
||||||
|
id: id_,
|
||||||
|
sort: ui.filters[filterIndex_].sort
|
||||||
|
};
|
||||||
|
filters[filterIndex_] = {
|
||||||
|
id: id,
|
||||||
|
sort: ui.filters[filterIndex].sort
|
||||||
|
};
|
||||||
|
oml.UI.set({filters: filters});
|
||||||
|
replaceFilter(filterIndex, id_);
|
||||||
|
replaceFilter(filterIndex_, id);
|
||||||
|
}
|
||||||
|
function replaceFilter(index, id) {
|
||||||
|
var isOuter = index % 4 == 0;
|
||||||
|
oml.$ui[
|
||||||
|
isOuter ? 'filtersOuterPanel' : 'filtersInnerPanel'
|
||||||
|
].replaceElement(
|
||||||
|
isOuter ? index / 2 : index - 1,
|
||||||
|
oml.$ui.filters[index] = oml.ui.filter(id)
|
||||||
|
);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
click: function(data) {
|
click: function(data) {
|
||||||
if (data.id == 'clearFilter') {
|
if (data.id == 'clearFilter') {
|
||||||
|
|
|
@ -58,6 +58,10 @@
|
||||||
}).map(function(key) {
|
}).map(function(key) {
|
||||||
return {
|
return {
|
||||||
id: key.id,
|
id: key.id,
|
||||||
|
sort: [{
|
||||||
|
key: key.id == 'date' ? 'name' : 'items',
|
||||||
|
operator: '-'
|
||||||
|
}],
|
||||||
title: key.title,
|
title: key.title,
|
||||||
type: Ox.isArray(key.type) ? key.type[0] : key.type
|
type: Ox.isArray(key.type) ? key.type[0] : key.type
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue