Merge pull request #1451 from jacobsfletch/fix/draft-patch
fix: ensures draft operations save as drafts
This commit is contained in:
@@ -21,6 +21,8 @@ export const saveCollectionDraft = async ({
|
||||
}: Args): Promise<Record<string, unknown>> => {
|
||||
const VersionsModel = payload.versions[config.slug];
|
||||
|
||||
const dataAsDraft = { ...data, _status: 'draft' };
|
||||
|
||||
let existingAutosaveVersion;
|
||||
|
||||
if (autosave) {
|
||||
@@ -40,7 +42,7 @@ export const saveCollectionDraft = async ({
|
||||
_id: existingAutosaveVersion._id,
|
||||
},
|
||||
{
|
||||
version: data,
|
||||
version: dataAsDraft,
|
||||
},
|
||||
{ new: true, lean: true },
|
||||
);
|
||||
@@ -48,7 +50,7 @@ export const saveCollectionDraft = async ({
|
||||
} else {
|
||||
result = await VersionsModel.create({
|
||||
parent: id,
|
||||
version: data,
|
||||
version: dataAsDraft,
|
||||
autosave: Boolean(autosave),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -17,6 +17,8 @@ export const saveGlobalDraft = async ({
|
||||
}: Args): Promise<void> => {
|
||||
const VersionsModel = payload.versions[config.slug];
|
||||
|
||||
const dataAsDraft = { ...data, _status: 'draft' };
|
||||
|
||||
let existingAutosaveVersion;
|
||||
|
||||
if (autosave) {
|
||||
@@ -34,14 +36,14 @@ export const saveGlobalDraft = async ({
|
||||
_id: existingAutosaveVersion._id,
|
||||
},
|
||||
{
|
||||
version: data,
|
||||
version: dataAsDraft,
|
||||
},
|
||||
{ new: true, lean: true },
|
||||
);
|
||||
// Otherwise, create a new one
|
||||
} else {
|
||||
result = await VersionsModel.create({
|
||||
version: data,
|
||||
version: dataAsDraft,
|
||||
autosave: Boolean(autosave),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ export const ensurePublishedCollectionVersion = async ({
|
||||
req,
|
||||
overrideAccess: true,
|
||||
showHiddenFields: true,
|
||||
flattenLocales: false,
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
@@ -46,6 +46,7 @@ export const ensurePublishedGlobalVersion = async ({
|
||||
req,
|
||||
overrideAccess: true,
|
||||
showHiddenFields: true,
|
||||
flattenLocales: false,
|
||||
});
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user