Added ways to define the save location of the document
This commit is contained in:
@ -15,6 +15,11 @@ import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
|||||||
collection: Collection,
|
collection: Collection,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onNewDocument = () => {
|
||||||
|
const { collection, history } = this.props;
|
||||||
|
history.push(`${collection.url}/new`);
|
||||||
|
};
|
||||||
|
|
||||||
onEdit = () => {
|
onEdit = () => {
|
||||||
const { collection } = this.props;
|
const { collection } = this.props;
|
||||||
this.props.ui.setActiveModal('collection-edit', { collection });
|
this.props.ui.setActiveModal('collection-edit', { collection });
|
||||||
@ -31,6 +36,10 @@ import { DropdownMenu, DropdownMenuItem } from 'components/DropdownMenu';
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<DropdownMenu label={label || <Icon type="MoreHorizontal" />}>
|
<DropdownMenu label={label || <Icon type="MoreHorizontal" />}>
|
||||||
|
{collection &&
|
||||||
|
<DropdownMenuItem onClick={this.onNewDocument}>
|
||||||
|
New document
|
||||||
|
</DropdownMenuItem>}
|
||||||
{collection &&
|
{collection &&
|
||||||
<DropdownMenuItem onClick={this.onEdit}>Edit</DropdownMenuItem>}
|
<DropdownMenuItem onClick={this.onEdit}>Edit</DropdownMenuItem>}
|
||||||
{allowDelete &&
|
{allowDelete &&
|
||||||
|
@ -33,7 +33,7 @@ class Document extends BaseModel {
|
|||||||
starred: boolean = false;
|
starred: boolean = false;
|
||||||
text: string = '';
|
text: string = '';
|
||||||
title: string = '';
|
title: string = '';
|
||||||
parentDocument: ?Document;
|
parentDocument: ?string;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
updatedBy: User;
|
updatedBy: User;
|
||||||
url: string;
|
url: string;
|
||||||
@ -95,6 +95,12 @@ class Document extends BaseModel {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@computed get parentDocumentId(): ?string {
|
||||||
|
return this.pathToDocument.length > 1
|
||||||
|
? this.pathToDocument[this.pathToDocument.length - 1].id
|
||||||
|
: null;
|
||||||
|
}
|
||||||
|
|
||||||
/* Actions */
|
/* Actions */
|
||||||
|
|
||||||
@action star = async () => {
|
@action star = async () => {
|
||||||
@ -166,9 +172,10 @@ class Document extends BaseModel {
|
|||||||
title: this.title,
|
title: this.title,
|
||||||
text: this.text,
|
text: this.text,
|
||||||
};
|
};
|
||||||
// if (this.parentDocument) {
|
if (this.parentDocument) {
|
||||||
// data.parentDocument = this.parentDocument.id;
|
data.parentDocument = this.parentDocument;
|
||||||
// }
|
}
|
||||||
|
debugger;
|
||||||
res = await client.post('/documents.create', data);
|
res = await client.post('/documents.create', data);
|
||||||
}
|
}
|
||||||
runInAction('Document#save', () => {
|
runInAction('Document#save', () => {
|
||||||
|
@ -39,6 +39,7 @@ Are you sure you want to discard them?
|
|||||||
type Props = {
|
type Props = {
|
||||||
match: Object,
|
match: Object,
|
||||||
history: Object,
|
history: Object,
|
||||||
|
location: Object,
|
||||||
keydown: Object,
|
keydown: Object,
|
||||||
documents: DocumentsStore,
|
documents: DocumentsStore,
|
||||||
newDocument?: boolean,
|
newDocument?: boolean,
|
||||||
@ -88,6 +89,9 @@ type Props = {
|
|||||||
if (props.newDocument) {
|
if (props.newDocument) {
|
||||||
const newDocument = new Document({
|
const newDocument = new Document({
|
||||||
collection: { id: props.match.params.id },
|
collection: { id: props.match.params.id },
|
||||||
|
parentDocument: new URLSearchParams(props.location.search).get(
|
||||||
|
'parentDocument'
|
||||||
|
),
|
||||||
title: '',
|
title: '',
|
||||||
text: '',
|
text: '',
|
||||||
});
|
});
|
||||||
@ -139,7 +143,10 @@ type Props = {
|
|||||||
|
|
||||||
onClickNew = () => {
|
onClickNew = () => {
|
||||||
if (!this.document) return;
|
if (!this.document) return;
|
||||||
this.props.history.push(`${this.document.collection.url}/new`);
|
let newUrl = `${this.document.collection.url}/new`;
|
||||||
|
if (this.document.parentDocumentId)
|
||||||
|
newUrl = `${newUrl}?parentDocument=${this.document.parentDocumentId}`;
|
||||||
|
this.props.history.push(newUrl);
|
||||||
};
|
};
|
||||||
|
|
||||||
handleCloseMoveModal = () => (this.moveModalOpen = false);
|
handleCloseMoveModal = () => (this.moveModalOpen = false);
|
||||||
|
Reference in New Issue
Block a user