34 lines
595 B
JavaScript
34 lines
595 B
JavaScript
class IncludeManager {
|
|
constructor(model) {
|
|
this.data = model.ids;
|
|
}
|
|
has(id) {
|
|
return this.data.has(id);
|
|
}
|
|
select(id) {
|
|
this.data.add(id);
|
|
}
|
|
unselect(id) {
|
|
this.data.delete(id);
|
|
}
|
|
}
|
|
class ExcludeManager {
|
|
constructor(model) {
|
|
this.data = model.ids;
|
|
}
|
|
has(id) {
|
|
return !this.data.has(id);
|
|
}
|
|
select(id) {
|
|
this.data.delete(id);
|
|
}
|
|
unselect(id) {
|
|
this.data.add(id);
|
|
}
|
|
}
|
|
export const createRowSelectionManager = model => {
|
|
if (model.type === 'include') {
|
|
return new IncludeManager(model);
|
|
}
|
|
return new ExcludeManager(model);
|
|
}; |