From 341b69499553512b49e11ebd76ac98219c0f7f3f Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Thu, 11 Jan 2024 14:06:10 -0500 Subject: [PATCH 1/2] Fix copy timeline modal actions --- .../javascripts/avalon_timelines/timelines.js.coffee | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/avalon_timelines/timelines.js.coffee b/app/assets/javascripts/avalon_timelines/timelines.js.coffee index 1c70a0d5c0..e7367f8cdc 100644 --- a/app/assets/javascripts/avalon_timelines/timelines.js.coffee +++ b/app/assets/javascripts/avalon_timelines/timelines.js.coffee @@ -1,11 +1,11 @@ # Copyright 2011-2023, The Trustees of Indiana University and Northwestern # University. Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. -# +# # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software distributed # under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR # CONDITIONS OF ANY KIND, either express or implied. See the License for the @@ -66,11 +66,11 @@ $('#copy-timeline-form').submit( $('#copy-timeline-form').bind('ajax:success', (event, data, status, xhr) -> - if (data.errors) + if (data?.errors) console.log(data.errors.title[0]) else if (submit_edit) - window.location.href = data.path + window.location.href = event.detail[0].path else if ( $('#with_refresh').val() ) location.reload() From bcdd05b80a81159c671ae38ede1d775151d2d770 Mon Sep 17 00:00:00 2001 From: Mason Ballengee Date: Fri, 12 Jan 2024 09:11:46 -0500 Subject: [PATCH 2/2] Improve fix by assigning variables from event.detail --- .../javascripts/avalon_timelines/timelines.js.coffee | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/avalon_timelines/timelines.js.coffee b/app/assets/javascripts/avalon_timelines/timelines.js.coffee index e7367f8cdc..87b115d403 100644 --- a/app/assets/javascripts/avalon_timelines/timelines.js.coffee +++ b/app/assets/javascripts/avalon_timelines/timelines.js.coffee @@ -65,17 +65,19 @@ $('#copy-timeline-form').submit( ) $('#copy-timeline-form').bind('ajax:success', - (event, data, status, xhr) -> - if (data?.errors) + (event) -> + [data, status, xhr] = event.detail + if (data.errors) console.log(data.errors.title[0]) else if (submit_edit) - window.location.href = event.detail[0].path + window.location.href = data.path else if ( $('#with_refresh').val() ) location.reload() ).bind('ajax:error', - (e, xhr, status, error) -> + (event) -> + [data, status, xhr] = event.detail console.log(xhr.responseJSON.errors) )