mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
Feature: Workspaces, at All Boards page.
Thanks to xet7 !
This commit is contained in:
parent
16a74bb748
commit
0afbdc95b4
148 changed files with 3137 additions and 162 deletions
73
client/lib/boardMultiSelection.js
Normal file
73
client/lib/boardMultiSelection.js
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
import { ReactiveCache } from '/imports/reactiveCache';
|
||||
|
||||
BoardMultiSelection = {
|
||||
_selectedBoards: new ReactiveVar([]),
|
||||
|
||||
_isActive: new ReactiveVar(false),
|
||||
|
||||
reset() {
|
||||
this._selectedBoards.set([]);
|
||||
},
|
||||
|
||||
isActive() {
|
||||
return this._isActive.get();
|
||||
},
|
||||
|
||||
count() {
|
||||
return this._selectedBoards.get().length;
|
||||
},
|
||||
|
||||
isEmpty() {
|
||||
return this.count() === 0;
|
||||
},
|
||||
|
||||
getSelectedBoardIds() {
|
||||
return this._selectedBoards.get();
|
||||
},
|
||||
|
||||
activate() {
|
||||
if (!this.isActive()) {
|
||||
this._isActive.set(true);
|
||||
Tracker.flush();
|
||||
}
|
||||
},
|
||||
|
||||
disable() {
|
||||
if (this.isActive()) {
|
||||
this._isActive.set(false);
|
||||
this.reset();
|
||||
}
|
||||
},
|
||||
|
||||
add(boardIds) {
|
||||
return this.toggle(boardIds, { add: true, remove: false });
|
||||
},
|
||||
|
||||
remove(boardIds) {
|
||||
return this.toggle(boardIds, { add: false, remove: true });
|
||||
},
|
||||
|
||||
toogle(boardIds) {
|
||||
return this.toggle(boardIds, { add: true, remove: true });
|
||||
},
|
||||
|
||||
toggle(boardIds, { add, remove } = {}) {
|
||||
boardIds = _.isString(boardIds) ? [boardIds] : boardIds;
|
||||
let selectedBoards = this._selectedBoards.get();
|
||||
|
||||
boardIds.forEach(boardId => {
|
||||
const index = selectedBoards.indexOf(boardId);
|
||||
if (index > -1 && remove) {
|
||||
selectedBoards = selectedBoards.filter(id => id !== boardId);
|
||||
} else if (index === -1 && add) {
|
||||
selectedBoards.push(boardId);
|
||||
}
|
||||
});
|
||||
|
||||
this._selectedBoards.set(selectedBoards);
|
||||
},
|
||||
|
||||
isSelected(boardId) {
|
||||
return this._selectedBoards.get().includes(boardId);
|
||||
},
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue