mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-09-22 04:55:42 +08:00
Merge pull request #1434 from mz3944/mz-SCI-2903
Fix (unite) Date and Time display formats [SCI-2903]
This commit is contained in:
commit
f6c8af105d
9 changed files with 47 additions and 12 deletions
|
@ -115,8 +115,29 @@ function importProtocolFromFile(
|
|||
$("#protocol_authors").val($(this).children("authors").text());
|
||||
$("#import_protocol_description").val($(this).children("description").text());
|
||||
}
|
||||
$("#protocol_created_at").val($(this).children("created_at").text());
|
||||
$("#protocol_updated_at").val($(this).children("updated_at").text());
|
||||
|
||||
$.ajax({
|
||||
url: "/helpers/to_user_date_format.json",
|
||||
type: "GET",
|
||||
data: { "timestamp": $(this).children("created_at").text(),
|
||||
"ts_format": "full" },
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
$("#protocol_created_at").val(data.ts);
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
url: "/helpers/to_user_date_format.json",
|
||||
type: "GET",
|
||||
data: { "timestamp": $(this).children("updated_at").text(),
|
||||
"ts_format": "full" },
|
||||
dataType: "json",
|
||||
async: false,
|
||||
success: function (data) {
|
||||
$("#protocol_updated_at").val(data.ts);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// PREVIEW
|
||||
|
|
|
@ -36,6 +36,16 @@ class ApplicationController < ActionController::Base
|
|||
Team.find_by_id(current_user.current_team_id)
|
||||
end
|
||||
|
||||
def to_user_date_format
|
||||
ts = I18n.l(Time.parse(params[:timestamp]),
|
||||
format: params[:ts_format].to_sym)
|
||||
respond_to do |format|
|
||||
format.json do
|
||||
render json: { ts: ts }, status: :ok
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def render_403(style = 'danger')
|
||||
|
|
|
@ -161,9 +161,9 @@ module ProtocolsIoHelper
|
|||
timestamps = steps.map do |step|
|
||||
step['modified_on'] if step['modified_on'].present?
|
||||
end
|
||||
Time.at(timestamps.max).utc.to_datetime
|
||||
I18n.l(Time.at(timestamps.max), format: :full)
|
||||
rescue StandardError
|
||||
Time.at(0).utc.to_datetime
|
||||
I18n.l(Time.at(0), format: :full)
|
||||
end
|
||||
|
||||
# Checks so that null values are returned as zero length strings
|
||||
|
|
|
@ -30,7 +30,7 @@ class TeamZipExport < ZipExport
|
|||
zip_dir = FileUtils.mkdir_p(File.join(Rails.root, 'tmp/zip-ready')).first
|
||||
zip_file = File.new(
|
||||
File.join(zip_dir,
|
||||
"projects_export_#{Time.now.strftime('%F_%H-%M-%S')}.zip"),
|
||||
"projects_export_#{Time.now.strftime('%F_%H-%M-%S_UTC')}.zip"),
|
||||
'w+'
|
||||
)
|
||||
fill_content(zip_input_dir, data, type, options)
|
||||
|
|
|
@ -56,7 +56,7 @@ class ZipExport < ApplicationRecord
|
|||
).first
|
||||
zip_dir = FileUtils.mkdir_p(File.join(Rails.root, 'tmp/zip-ready')).first
|
||||
zip_file = File.new(
|
||||
File.join(zip_dir, "export_#{Time.now.strftime('%F %H-%M-%S')}.zip"),
|
||||
File.join(zip_dir, "export_#{Time.now.strftime('%F %H-%M-%S_UTC')}.zip"),
|
||||
'w+'
|
||||
)
|
||||
fill_content(zip_input_dir, data, type, options)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="pull-right">
|
||||
<span class="text-muted"><%= l comment.created_at, format: '%H:%M' %></span>
|
||||
<span class="text-muted"><%= l comment.created_at, format: :time %></span>
|
||||
<% if can_manage_comment_in_module?(comment.becomes(Comment)) %>
|
||||
<div class="dropdown dropdown-comment">
|
||||
<a href="#"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="pull-right">
|
||||
<span class="text-muted"><%= l comment.created_at, format: '%H:%M' %></span>
|
||||
<span class="text-muted"><%= l comment.created_at, format: :time %></span>
|
||||
<% if can_manage_comment_in_project?(comment) %>
|
||||
<div class="dropdown dropdown-comment">
|
||||
<a href="#"
|
||||
|
|
|
@ -53,16 +53,14 @@
|
|||
<label><%= t('protocols.import_export.import_modal.created_at_label') %></label>
|
||||
|
||||
<% display_created_at=Time.at(not_null(@json_object['created_on']).to_i) %>
|
||||
<%= f.text_field :created_at, :value => display_created_at.to_s,
|
||||
<%= f.text_field :created_at, :value => I18n.l(display_created_at, format: :full),
|
||||
readonly: true, class: "form-control" %>
|
||||
</div>
|
||||
<div class="col-xs-4">
|
||||
<label><%= t('protocols.import_export.import_modal.updated_at_label') %></label>
|
||||
|
||||
<% display_last_modified=eval_last_modified(@json_object['steps']) %>
|
||||
<%= f.text_field :last_modified, :value =>
|
||||
display_last_modified.to_s,readonly: true, class:
|
||||
"form-control" %>
|
||||
<%= f.text_field :last_modified, :value => display_last_modified, readonly: true, class: "form-control" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -53,6 +53,12 @@ Rails.application.routes.draw do
|
|||
get 'forbidden', to: 'application#forbidden', as: 'forbidden'
|
||||
get 'not_found', to: 'application#not_found', as: 'not_found'
|
||||
|
||||
# JS backend helpers
|
||||
get 'helpers/to_user_date_format',
|
||||
to: 'application#to_user_date_format',
|
||||
as: 'to_user_date_format',
|
||||
defaults: { format: 'json' }
|
||||
|
||||
# Settings
|
||||
resources :users, only: :index # needed for testing signup
|
||||
# needed for testing edit passowrd
|
||||
|
|
Loading…
Add table
Reference in a new issue