Skip to content

Commit

Permalink
Set correct status in edits
Browse files Browse the repository at this point in the history
  • Loading branch information
benmerckx committed Dec 13, 2024
1 parent 6ecad87 commit 465c4ad
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/Transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from './util/EntryFilenames.js'
import {createEntryRow, entryParentPaths} from './util/EntryRows.js'
import {generateKeyBetween} from './util/FractionalIndexing.js'
import {entries, fromEntries} from './util/Objects.js'
import {basename, extname, join, normalize} from './util/Paths.js'
import {slugify} from './util/Slugs.js'

Expand Down Expand Up @@ -212,13 +213,20 @@ export class UpdateOperation<Definition> extends Operation {
const type = cms.config.schema[current.type]
const mutations: Array<Mutation> = []
const createDraft = changeStatus === EntryStatus.Draft
const fieldUpdates =
set &&
fromEntries(
entries(set).map(([key, value]) => {
return [key, value ?? null]
})
)
const entry = await createEntry(
cms.config,
this.typeName(cms.config, type),
{
...current,
status: EntryStatus.Draft,
data: {...current.data, ...set}
status: createDraft ? EntryStatus.Draft : current.status,
data: {...current.data, ...fieldUpdates}
},
parent
)
Expand Down

0 comments on commit 465c4ad

Please sign in to comment.