Draft Documents (#518)

* Mostly there

* Fix up specs

* Working scope, updated tests

* Don't record view on draft

* PR feedback

* Highlight drafts nav item

* Bugaboos

* Styling

* Refactoring, gradually addressing Jori feedback

* Show collection in drafts list
Flow fixes

* Ensure menu actions are hidden when draft
This commit is contained in:
Tom Moor
2018-02-27 22:41:12 -08:00
committed by GitHub
parent 79a0272230
commit 9142d975df
30 changed files with 519 additions and 194 deletions

View File

@@ -33,6 +33,7 @@ class Document extends BaseModel {
text: string = '';
title: string = '';
parentDocument: ?string;
publishedAt: ?string;
updatedAt: string;
updatedBy: User;
url: string;
@@ -71,8 +72,7 @@ class Document extends BaseModel {
if (this.collection.documents) {
traveler(this.collection.documents, []);
invariant(path, 'Path is not available for collection, abort');
return path;
if (path) return path;
}
return [];
@@ -145,7 +145,7 @@ class Document extends BaseModel {
};
@action
save = async () => {
save = async (publish: boolean = false) => {
if (this.isSaving) return this;
this.isSaving = true;
@@ -157,6 +157,7 @@ class Document extends BaseModel {
title: this.title,
text: this.text,
lastRevision: this.revision,
publish,
});
} else {
const data = {
@@ -164,6 +165,7 @@ class Document extends BaseModel {
collection: this.collection.id,
title: this.title,
text: this.text,
publish,
};
if (this.parentDocument) {
data.parentDocument = this.parentDocument;