mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-30 03:27:52 +08:00
Fix Date and Time display formats on JS side
This commit is contained in:
parent
b64df7d8cc
commit
8070b7f8b5
3 changed files with 39 additions and 2 deletions
|
@ -115,8 +115,29 @@ function importProtocolFromFile(
|
||||||
$("#protocol_authors").val($(this).children("authors").text());
|
$("#protocol_authors").val($(this).children("authors").text());
|
||||||
$("#import_protocol_description").val($(this).children("description").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
|
// PREVIEW
|
||||||
|
|
|
@ -36,6 +36,16 @@ class ApplicationController < ActionController::Base
|
||||||
Team.find_by_id(current_user.current_team_id)
|
Team.find_by_id(current_user.current_team_id)
|
||||||
end
|
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
|
protected
|
||||||
|
|
||||||
def render_403(style = 'danger')
|
def render_403(style = 'danger')
|
||||||
|
|
|
@ -53,6 +53,12 @@ Rails.application.routes.draw do
|
||||||
get 'forbidden', to: 'application#forbidden', as: 'forbidden'
|
get 'forbidden', to: 'application#forbidden', as: 'forbidden'
|
||||||
get 'not_found', to: 'application#not_found', as: 'not_found'
|
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
|
# Settings
|
||||||
resources :users, only: :index # needed for testing signup
|
resources :users, only: :index # needed for testing signup
|
||||||
# needed for testing edit passowrd
|
# needed for testing edit passowrd
|
||||||
|
|
Loading…
Reference in a new issue