web: people: add Header Menu Store
This commit is contained in:
parent
09665b1a9d
commit
673762894e
38
products/ASC.People/Client/src/store/HeaderMenuStore.js
Normal file
38
products/ASC.People/Client/src/store/HeaderMenuStore.js
Normal file
@ -0,0 +1,38 @@
|
||||
import { computed, makeObservable } from "mobx";
|
||||
|
||||
class HeaderMenuStore {
|
||||
constructor(peopleStore) {
|
||||
this.peopleStore = peopleStore;
|
||||
makeObservable(this, {
|
||||
isHeaderVisible: computed,
|
||||
isHeaderIndeterminate: computed,
|
||||
isHeaderChecked: computed,
|
||||
});
|
||||
}
|
||||
|
||||
get isHeaderVisible() {
|
||||
const { selection } = this.peopleStore.selectionStore;
|
||||
|
||||
return !!selection.length;
|
||||
}
|
||||
|
||||
get isHeaderIndeterminate() {
|
||||
const { selection } = this.peopleStore.selectionStore;
|
||||
const { users } = this.peopleStore.usersStore;
|
||||
|
||||
return (
|
||||
this.isHeaderVisible &&
|
||||
!!selection.length &&
|
||||
selection.length < users.length
|
||||
);
|
||||
}
|
||||
|
||||
get isHeaderChecked() {
|
||||
const { selection } = this.peopleStore.selectionStore;
|
||||
const { users } = this.peopleStore.usersStore;
|
||||
|
||||
return this.isHeaderVisible && selection.length === users.length;
|
||||
}
|
||||
}
|
||||
|
||||
export default HeaderMenuStore;
|
Loading…
Reference in New Issue
Block a user