From c26f8e7193eb70953fa1d800106e626c3d5ddc16 Mon Sep 17 00:00:00 2001 From: aignatov-bio Date: Wed, 16 Sep 2020 15:18:54 +0200 Subject: [PATCH] Add before send condition for status change --- app/assets/javascripts/my_modules.js | 6 ++++++ app/views/my_modules/status_flow/_task_flow_button.html.erb | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/my_modules.js b/app/assets/javascripts/my_modules.js index a77645055..cfb2fb20e 100644 --- a/app/assets/javascripts/my_modules.js +++ b/app/assets/javascripts/my_modules.js @@ -258,6 +258,12 @@ animateSpinner(); $.ajax({ url: list.data('link-url'), + beforeSend: function(e, ajaxSettings) { + if (item.data('beforeSend') instanceof Function) { + return item.data('beforeSend')(item, ajaxSettings) + } + return true + }, type: 'PATCH', data: { my_module: { status_id: item.data('state-id') } }, error: function(e) { diff --git a/app/views/my_modules/status_flow/_task_flow_button.html.erb b/app/views/my_modules/status_flow/_task_flow_button.html.erb index 2a5c80804..54fb84ab8 100644 --- a/app/views/my_modules/status_flow/_task_flow_button.html.erb +++ b/app/views/my_modules/status_flow/_task_flow_button.html.erb @@ -25,7 +25,7 @@ <% unless status.initial_status? %> <% previous_s = status.previous_status %> <% previous_s_errors = previous_s.conditions_errors(my_module) %> -
  • +
  • <%= t('my_module_statuses.dropdown.return_label') %>
    @@ -40,7 +40,7 @@ <% unless status.final_status? %> <% next_s = status.next_status %> <% next_s_errors = next_s.conditions_errors(my_module) %> -
  • +
  • <%= t('my_module_statuses.dropdown.move_label') %>