Add a Draft to the local store and sync it with remote drafts. Will also
handle cleaning up auto save data (if the autoSaveKey
property is passed).
const draft = {
draftId: 'd3aeb944-d0b3-11ea-87d0-0242ac130003',
title: 'I Will Finish This Later',
formId: 1,
externalId: 'external'
jobId: '0ac41494-723b-4a5d-90bb-534b8360f31d',
previousFormSubmissionApprovalId: '7fa79583-ec45-4ffc-8f72-4be80ef2c2b7',
}
const data = {
formsAppId: 1,
submission: {
form: 'data',
goes: 'here'
},
definition: OneBlinkForm,
}
await draftService.addDraft(
draft,
data,
)
Remove a draft from the local store and sync with remote drafts.
const draftId = 'd3aeb944-d0b3-11ea-87d0-0242ac130003'
await draftService.deleteDraft(draftId)
Get a single Draft and the associated submission data.
const draftId = 'd3aeb944-d0b3-11ea-87d0-0242ac130003'
const { draft, draftData, lastElementUpdated } =
await draftService.getDraftAndData(draftId)
// use "draftData" to prefill a from
Get an array of Drafts for the currently logged in user.
const drafts = await draftService.getDrafts()
Register a listener function that will be passed an array of Drafts when a draft is added, updated or deleted.
const listener = async (drafts) => {
// use drafts here...
}
const deregister = await draftService.registerDraftsListener(listener)
// When no longer needed, remember to deregister the listener
deregister()
Register a listener function that will be passed an array of Drafts when a draft is added, updated or deleted.
const listener = async (drafts) => {
// use drafts here...
}
const deregister = await draftService.registerDraftsListener(listener)
// When no longer needed, remember to deregister the listener
deregister()
Force a sync of remote drafts with locally stored drafts. This function will
swallow all errors thrown unless true
is passed for the throwError
property.
await draftService.syncDrafts({
throwError: true,
formsAppId: 1,
})
The id of the OneBlink Forms App to sync drafts with
true
to throw errors while syncing
Update a Draft in the local store and sync it with remote drafts. Will also
handle cleaning up auto save data (if the autoSaveKey
property is passed).
const draft = {
draftId: 'd3aeb944-d0b3-11ea-87d0-0242ac130003',
title: 'I Will Finish This Later',
formId: 1,
externalId: 'external'
jobId: '0ac41494-723b-4a5d-90bb-534b8360f31d',
previousFormSubmissionApprovalId: '7fa79583-ec45-4ffc-8f72-4be80ef2c2b7',
}
const data = {
formsAppId: 1,
submission: {
form: 'data',
goes: 'here'
},
definition: OneBlinkForm,
}
await draftService.updateDraft(
draft,
data,
)
Draft Service
Helper functions for handling drafts.