fix: Enable toggling of insights while document is draft

This commit is contained in:
Tom Moor
2023-07-23 13:06:34 -04:00
parent 404f5ff871
commit 217e53d8b6
6 changed files with 32 additions and 23 deletions

View File

@@ -84,7 +84,6 @@ export default class Document extends ParanoidModel {
/**
* Whether team members can see who has viewed this document.
*/
@Field
@observable
insightsEnabled: boolean;
@@ -352,12 +351,18 @@ export default class Document extends ParanoidModel {
templatize = () => this.store.templatize(this.id);
@action
save = async (options?: SaveOptions | undefined) => {
const params = this.toAPI();
save = async (
fields: Partial<Document> | undefined,
options?: SaveOptions | undefined
) => {
const params = fields ?? this.toAPI();
this.isSaving = true;
try {
const model = await this.store.save({ ...params, id: this.id }, options);
const model = await this.store.save(
{ ...params, ...fields, id: this.id },
options
);
// if saving is successful set the new values on the model itself
set(this, { ...params, ...model });