web: people: add Header Menu Store

This commit is contained in:
Vladislav Makhov 2021-02-10 13:30:39 +03:00
parent 09665b1a9d
commit 673762894e

View 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;