0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-26 02:50:28 +01:00

Allow after time wizards to be updated without changing the time

Dieser Commit ist enthalten in:
Angus McLeod 2018-06-06 22:05:45 +10:00
Ursprung b0223cc62d
Commit e8a28ad22d

Datei anzeigen

@ -15,6 +15,8 @@ class CustomWizard::AdminController < ::ApplicationController
wizard = ::JSON.parse(params[:wizard]) wizard = ::JSON.parse(params[:wizard])
existing = PluginStore.get('custom_wizard', wizard['id']) || {}
error = nil error = nil
if wizard["id"].blank? if wizard["id"].blank?
@ -24,7 +26,7 @@ class CustomWizard::AdminController < ::ApplicationController
elsif wizard["steps"].blank? elsif wizard["steps"].blank?
error = 'steps_required' error = 'steps_required'
elsif wizard["after_time"] elsif wizard["after_time"]
if !wizard["after_time_scheduled"] if !wizard["after_time_scheduled"] && !existing["after_time_scheduled"]
error = 'after_time_need_time' error = 'after_time_need_time'
else else
after_time_scheduled = Time.parse(wizard["after_time_scheduled"]).utc after_time_scheduled = Time.parse(wizard["after_time_scheduled"]).utc
@ -86,7 +88,6 @@ class CustomWizard::AdminController < ::ApplicationController
s['description'] = PrettyText.cook(s['raw_description']) if s['raw_description'] s['description'] = PrettyText.cook(s['raw_description']) if s['raw_description']
end end
existing = PluginStore.get('custom_wizard', wizard['id']) || {}
new_time = existing['after_time_scheduled'] ? new_time = existing['after_time_scheduled'] ?
after_time_scheduled != Time.parse(existing['after_time_scheduled']).utc : after_time_scheduled != Time.parse(existing['after_time_scheduled']).utc :
true true
@ -101,7 +102,7 @@ class CustomWizard::AdminController < ::ApplicationController
Jobs.enqueue(:clear_after_time_wizard, wizard_id: wizard['id']) Jobs.enqueue(:clear_after_time_wizard, wizard_id: wizard['id'])
end end
PluginStore.set('custom_wizard', wizard["id"], wizard) PluginStore.set('custom_wizard', wizard["id"], existing.merge(wizard))
render json: success_json render json: success_json
end end