refactoring
This commit is contained in:
parent
066b434a33
commit
85a058d7ac
1 changed files with 37 additions and 28 deletions
|
@ -52,7 +52,7 @@ Ox.ColumnList = function(options, self) {
|
|||
return Ox.CustomList({
|
||||
item: self.options.columns[i].item,
|
||||
itemHeight: self.options.columns[i].itemHeight,
|
||||
items: i == 0 ? self.options.items : [],
|
||||
items: getItems(i),
|
||||
itemWidth: self.columnWidths[i],
|
||||
keys: self.options.columns[i].keys,
|
||||
// FIXME: undefined max will overwrite CustomList default
|
||||
|
@ -89,35 +89,9 @@ Ox.ColumnList = function(options, self) {
|
|||
}
|
||||
},
|
||||
select: function(data) {
|
||||
var items = [];
|
||||
self.options.columns[i].selected = data.ids;
|
||||
if (i < self.numberOfColumns - 1) {
|
||||
data.ids.forEach(function(id) {
|
||||
var index;
|
||||
if (i == 0) {
|
||||
index = Ox.getIndexById(self.options.items, id);
|
||||
items = items.concat(
|
||||
self.options.items[index].items
|
||||
);
|
||||
} else if (i == 1) {
|
||||
index = [];
|
||||
Ox.forEach(self.options.columns[0].selected, function(id_) {
|
||||
index[0] = Ox.getIndexById(
|
||||
self.options.items, id_
|
||||
);
|
||||
index[1] = Ox.getIndexById(
|
||||
self.options.items[index[0]].items, id
|
||||
);
|
||||
if (index[1] > -1) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
items = items.concat(
|
||||
self.options.items[index[0]].items[index[1]].items
|
||||
);
|
||||
}
|
||||
});
|
||||
self.$lists[i + 1].options({items: items})
|
||||
self.$lists[i + 1].options({items: getItems(i + 1)});
|
||||
}
|
||||
if (i == 0 || data.ids.length) {
|
||||
that.triggerEvent('select', {
|
||||
|
@ -151,6 +125,41 @@ Ox.ColumnList = function(options, self) {
|
|||
return Ox.splitInt(self.options.width, 3);
|
||||
}
|
||||
|
||||
function getItems(i) {
|
||||
var items;
|
||||
if (i == 0) {
|
||||
items = self.options.items;
|
||||
} else {
|
||||
items = [];
|
||||
self.options.columns[i - 1].selected.forEach(function(id) {
|
||||
var index;
|
||||
if (i == 1) {
|
||||
index = Ox.getIndexById(self.options.items, id);
|
||||
items = items.concat(
|
||||
self.options.items[index].items
|
||||
);
|
||||
} else if (i == 2) {
|
||||
index = [];
|
||||
Ox.forEach(self.options.columns[0].selected, function(id_) {
|
||||
index[0] = Ox.getIndexById(
|
||||
self.options.items, id_
|
||||
);
|
||||
index[1] = Ox.getIndexById(
|
||||
self.options.items[index[0]].items, id
|
||||
);
|
||||
if (index[1] > -1) {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
items = items.concat(
|
||||
self.options.items[index[0]].items[index[1]].items
|
||||
);
|
||||
}
|
||||
});
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
function updateQuery() {
|
||||
if (self.options.query.conditions.length == 0) {
|
||||
self.items = self.options.items;
|
||||
|
|
Loading…
Reference in a new issue