From 77de46018218c0c6f0e91e2c33bbfad015772085 Mon Sep 17 00:00:00 2001 From: Soufiane Date: Fri, 9 Jun 2023 09:24:32 +0200 Subject: [PATCH] Due date flyout on dashboard calendar [SCI-8600] (#5554) * Change the scope of the DatePicker datetime format in global activities [SCI-8600] --- app/assets/javascripts/application.js.erb | 3 --- app/assets/javascripts/dashboard/calendar.js | 2 ++ app/assets/javascripts/global_activities/date_picker.js | 3 ++- app/views/global_activities/_date_picker.html.erb | 3 ++- app/views/layouts/application.html.erb | 2 +- 5 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/application.js.erb b/app/assets/javascripts/application.js.erb index ed7288660..16b56827d 100644 --- a/app/assets/javascripts/application.js.erb +++ b/app/assets/javascripts/application.js.erb @@ -43,9 +43,6 @@ // forms with clicking on links outside form in cases when other than // GET method is used. -// eslint-disable-next-line no-unused-vars -var formatJS = $('body').data('datetime-picker-format-date-only'); - function initFormSubmitLinks(el) { el = el || $(document.body); diff --git a/app/assets/javascripts/dashboard/calendar.js b/app/assets/javascripts/dashboard/calendar.js index c52a2d5d0..d200467eb 100644 --- a/app/assets/javascripts/dashboard/calendar.js +++ b/app/assets/javascripts/dashboard/calendar.js @@ -83,6 +83,8 @@ var DasboardCalendarWidget = (function() { }; }()); +var formatJS; $(document).on('turbolinks:load', function() { DasboardCalendarWidget.init(); + formatJS = $('body').data('datetime-picker-format'); }); diff --git a/app/assets/javascripts/global_activities/date_picker.js b/app/assets/javascripts/global_activities/date_picker.js index 1c9db9b03..7f55977ab 100644 --- a/app/assets/javascripts/global_activities/date_picker.js +++ b/app/assets/javascripts/global_activities/date_picker.js @@ -1,10 +1,11 @@ -/* global I18n formatJS */ +/* global I18n */ (function() { $('.datetime-picker-container').each(function() { const id = $(this).data('id'); if (id) { const dt = $(`#calendar-${id}`); const useCurrent = $(this).data('use-current'); + const formatJS = $(this).data('datetime-picker-format'); dt.datetimepicker({ useCurrent, ignoreReadonly: true, locale: I18n.locale, format: formatJS }); diff --git a/app/views/global_activities/_date_picker.html.erb b/app/views/global_activities/_date_picker.html.erb index b0cd19f04..d26dbbd07 100644 --- a/app/views/global_activities/_date_picker.html.erb +++ b/app/views/global_activities/_date_picker.html.erb @@ -1,7 +1,8 @@
+ data-use-current="<%= use_current %>" + data-datetime-picker-format="<%= datetime_picker_format_date_only %>"> <% if label %> <% end %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index ccada7d98..8ecaaacf9 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -59,7 +59,7 @@ data-atwho-repositories-url="<%= atwho_menu_team_path(current_team) %>" data-atwho-rep-items-url="<%= atwho_rep_items_team_path(current_team) %>" data-atwho-menu-items="<%= atwho_menu_items_team_path(current_team) %>" - data-datetime-picker-format-date-only="<%= datetime_picker_format_date_only %>" + data-datetime-picker-format="<%= datetime_picker_format_date_only %>" <% end %> >