2017-05-12 00:23:56 +00:00
|
|
|
// @flow
|
2017-06-25 23:26:28 +00:00
|
|
|
import { observable, action, computed } from 'mobx';
|
2017-06-28 03:59:53 +00:00
|
|
|
import Document from 'models/Document';
|
2017-06-25 23:26:28 +00:00
|
|
|
import Collection from 'models/Collection';
|
2016-07-15 07:26:34 +00:00
|
|
|
|
|
|
|
class UiStore {
|
2017-06-25 23:26:28 +00:00
|
|
|
@observable activeDocument: ?Document;
|
2017-06-25 00:14:36 +00:00
|
|
|
@observable editMode: boolean = false;
|
2016-07-15 07:26:34 +00:00
|
|
|
|
2017-06-25 23:26:28 +00:00
|
|
|
/* Computed */
|
|
|
|
|
|
|
|
@computed get activeCollection(): ?Collection {
|
|
|
|
return this.activeDocument ? this.activeDocument.collection : undefined;
|
|
|
|
}
|
|
|
|
|
2016-07-15 07:26:34 +00:00
|
|
|
/* Actions */
|
|
|
|
|
2017-06-25 23:26:28 +00:00
|
|
|
@action setActiveDocument = (document: Document): void => {
|
|
|
|
this.activeDocument = document;
|
2016-07-15 07:26:34 +00:00
|
|
|
};
|
|
|
|
|
2017-06-25 23:26:28 +00:00
|
|
|
@action clearActiveDocument = (): void => {
|
|
|
|
this.activeDocument = undefined;
|
2017-06-16 03:39:08 +00:00
|
|
|
};
|
2017-06-25 00:14:36 +00:00
|
|
|
|
|
|
|
@action enableEditMode() {
|
|
|
|
this.editMode = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@action disableEditMode() {
|
|
|
|
this.editMode = false;
|
|
|
|
}
|
2016-08-01 16:03:17 +00:00
|
|
|
}
|
2016-07-15 07:26:34 +00:00
|
|
|
|
|
|
|
export default UiStore;
|