From dd0331cd993473e94cd9a782ae425e437ac8b564 Mon Sep 17 00:00:00 2001 From: Tom Johnson Date: Thu, 1 Mar 2018 11:00:36 -0800 Subject: [PATCH] Add `data-sort` attributes to dataTables rows to support date sort Adding a `data-sort` with ISO 8601 datetimes allows dataTables to sort independent of the visible row values. We continue to use javascript to generate the human-readable time for the reasons given in #1416 (support for page caching). We sort to `#iso8601(5)` (i.e. to 5 decimal places). This still allows a mismatch between displayed times and correctly sorted times (off by one second), apparently due to rounding behavior in the javascript sort dates. The actual dates sort correctly, so display dates sort themselves out (ha!) as a notification ages past one minute. Fixes #1653. --- app/views/hyrax/notifications/_notifications.html.erb | 2 +- app/views/hyrax/transfers/_received.html.erb | 2 +- app/views/hyrax/transfers/_sent.html.erb | 2 +- app/views/hyrax/users/_activity_log.html.erb | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/hyrax/notifications/_notifications.html.erb b/app/views/hyrax/notifications/_notifications.html.erb index db3b3eac8e..5399a538c7 100644 --- a/app/views/hyrax/notifications/_notifications.html.erb +++ b/app/views/hyrax/notifications/_notifications.html.erb @@ -12,7 +12,7 @@ <% messages.each do |msg| %> - + <%= msg.last_message.created_at.to_formatted_s(:long_ordinal) %> diff --git a/app/views/hyrax/transfers/_received.html.erb b/app/views/hyrax/transfers/_received.html.erb index fd86b86f31..5ebefc4302 100644 --- a/app/views/hyrax/transfers/_received.html.erb +++ b/app/views/hyrax/transfers/_received.html.erb @@ -13,7 +13,7 @@ <% unless req.sending_user.blank? %> <%= show_transfer_request_title(req) %> - + <%= req.created_at.to_formatted_s(:long_ordinal) %> diff --git a/app/views/hyrax/transfers/_sent.html.erb b/app/views/hyrax/transfers/_sent.html.erb index 6183208964..3782d45560 100644 --- a/app/views/hyrax/transfers/_sent.html.erb +++ b/app/views/hyrax/transfers/_sent.html.erb @@ -13,7 +13,7 @@ <% unless req.receiving_user.blank? %> <%= show_transfer_request_title(req) %> - + <%= req.created_at.to_formatted_s(:long_ordinal) %> diff --git a/app/views/hyrax/users/_activity_log.html.erb b/app/views/hyrax/users/_activity_log.html.erb index 0860115b30..4aa8a8ce4f 100644 --- a/app/views/hyrax/users/_activity_log.html.erb +++ b/app/views/hyrax/users/_activity_log.html.erb @@ -10,8 +10,8 @@ <% next if event[:action].blank? or event[:timestamp].blank? %> <%= event[:action].html_safe %> - - <% time = Time.zone.at(event[:timestamp].to_i) %> + <% time = Time.zone.at(event[:timestamp].to_i) %> + <%= time.to_formatted_s(:long_ordinal) %>