Edit collection (#173)

* Collection edit modal

* Add icon

* 💚

* Oh look, some specs

* Delete collection

* Remove from collection

* Handle error responses
Protect against deleting last collection

* Fix key

* 💚

* Keyboard navigate documents list

* Add missing database constraints
This commit is contained in:
Tom Moor
2017-08-29 08:37:17 -07:00
committed by GitHub
parent e0b1c259e8
commit 8558b92cae
22 changed files with 515 additions and 53 deletions

View File

@@ -16,11 +16,13 @@ import stores from 'stores';
import Document from 'models/Document';
import ErrorsStore from 'stores/ErrorsStore';
import CacheStore from 'stores/CacheStore';
import UiStore from 'stores/UiStore';
const DOCUMENTS_CACHE_KEY = 'DOCUMENTS_CACHE_KEY';
type Options = {
cache: CacheStore,
ui: UiStore,
};
class DocumentsStore extends BaseStore {
@@ -31,6 +33,7 @@ class DocumentsStore extends BaseStore {
errors: ErrorsStore;
cache: CacheStore;
ui: UiStore;
/* Computed */
@@ -49,6 +52,12 @@ class DocumentsStore extends BaseStore {
return _.filter(this.data.values(), 'starred');
}
@computed get active(): ?Document {
return this.ui.activeDocumentId
? this.getById(this.ui.activeDocumentId)
: undefined;
}
/* Actions */
@action fetchAll = async (request: string = 'list'): Promise<*> => {
@@ -127,6 +136,7 @@ class DocumentsStore extends BaseStore {
this.errors = stores.errors;
this.cache = options.cache;
this.ui = options.ui;
this.cache.getItem(DOCUMENTS_CACHE_KEY).then(data => {
if (data) {