adjust capture revision
This commit is contained in:
@@ -77,8 +77,6 @@ class TemplatesController < ApplicationController
|
||||
|
||||
WebhookUrls.enqueue_events(@template, 'template.updated')
|
||||
|
||||
TemplateVersions.find_or_create_for(@template, author: current_user) if params[:revision]
|
||||
|
||||
head :ok
|
||||
end
|
||||
|
||||
|
||||
@@ -14,4 +14,12 @@ class TemplatesVersionsController < ApplicationController
|
||||
|
||||
render json: TemplateVersions.serialize(version)
|
||||
end
|
||||
|
||||
def create
|
||||
authorize!(:update, @template)
|
||||
|
||||
TemplateVersions.find_or_create_for(@template, author: current_user)
|
||||
|
||||
head :ok
|
||||
end
|
||||
end
|
||||
|
||||
@@ -3146,7 +3146,11 @@ export default {
|
||||
|
||||
const dynamicDocumentSaves = dynamicDocumentRefs.map((ref) => ref.saveBody())
|
||||
|
||||
Promise.all([this.save({ force: true, revision: this.withRevisions }), ...dynamicDocumentSaves]).then(() => {
|
||||
Promise.all([this.save({ force: true }), ...dynamicDocumentSaves]).then(() => {
|
||||
if (this.withRevisions) {
|
||||
this.captureRevision()
|
||||
}
|
||||
|
||||
window.Turbo.visit(`/templates/${this.template.id}`)
|
||||
}).finally(() => {
|
||||
this.isSaving = false
|
||||
@@ -3377,7 +3381,7 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
save ({ force = false, revision = false } = {}) {
|
||||
save ({ force = false } = {}) {
|
||||
this.pendingFieldAttachmentUuids = []
|
||||
|
||||
if (this.beforeRevisionSnapshot) {
|
||||
@@ -3409,8 +3413,7 @@ export default {
|
||||
submitters: this.template.submitters,
|
||||
fields: this.template.fields,
|
||||
variables_schema: this.template.variables_schema
|
||||
},
|
||||
...(revision ? { revision: true } : {})
|
||||
}
|
||||
}),
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
}).then(() => {
|
||||
@@ -3419,6 +3422,12 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
captureRevision () {
|
||||
return this.baseFetch(`/templates/${this.template.id}/versions`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' }
|
||||
})
|
||||
},
|
||||
onDynamicDocumentUpdate () {
|
||||
this.rebuildVariablesSchema()
|
||||
|
||||
|
||||
+1
-1
@@ -109,7 +109,7 @@ Rails.application.routes.draw do
|
||||
resource :form, only: %i[show], controller: 'templates_form_preview'
|
||||
resource :code_modal, only: %i[show], controller: 'templates_code_modal'
|
||||
resource :preferences, only: %i[show create destroy], controller: 'templates_preferences'
|
||||
resources :versions, only: %i[index show], controller: 'templates_versions'
|
||||
resources :versions, only: %i[index show create], controller: 'templates_versions'
|
||||
resource :share_link, only: %i[show create], controller: 'templates_share_link'
|
||||
resource :share_link_qr, only: %i[show], controller: 'templates_share_link_qr'
|
||||
resources :recipients, only: %i[create], controller: 'templates_recipients'
|
||||
|
||||
Reference in New Issue
Block a user