From fefb6e20834ef7e10ce6db5b8fbe6fdf3fa3c9b3 Mon Sep 17 00:00:00 2001 From: takuya hashimoto Date: Wed, 21 Nov 2018 13:49:30 +0900 Subject: [PATCH] aaa --- .../destination_form_controller.rb | 12 ++++- app/views/destination_form/create.html.erb | 14 ++++-- app/views/destination_form/new.html.erb | 46 +++++++++++-------- 3 files changed, 46 insertions(+), 26 deletions(-) diff --git a/app/controllers/destination_form_controller.rb b/app/controllers/destination_form_controller.rb index 68387aa..d7e8ec0 100644 --- a/app/controllers/destination_form_controller.rb +++ b/app/controllers/destination_form_controller.rb @@ -22,6 +22,14 @@ def create kk_res = [] # 経由地間のjson sk_keisan =[] # 出発地から経由地の途中計算 + + if @hour == "-1" && @minute == "-1" + d = DateTime.now + @hour = d.hour + @minute = d.minute + end + + # スタートからそれぞれの経由地の時間を取得する [@destination_1, @destination_2].each do |d| uri = URI.encode('https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins='+@origin+'&destinations='+d+'&mode=driving&key='+ENV['API_KEY']) @@ -222,8 +230,8 @@ def create if @gokei_sd2_h >= 24 @gokei_sd2_h = @gokei_sd2_h.to_i - 24 end - @gokei_sd2d1_h = @sd2d1hour + @hour.to_i - @gokei_sd2d1_m = @sd2d1minute + @minute.to_i + @gokei_sd2d1_h = @sd2d1hour.to_i + @hour.to_i + @gokei_sd2d1_m = @sd2d1minute.to_i + @minute.to_i if @gokei_sd2d1_m >= 60 @gokei_sd2d1_h += 1 @gokei_sd2d1_m -= 60 diff --git a/app/views/destination_form/create.html.erb b/app/views/destination_form/create.html.erb index 8b415e6..062bba9 100644 --- a/app/views/destination_form/create.html.erb +++ b/app/views/destination_form/create.html.erb @@ -14,11 +14,14 @@
<%= @skk_h %>:<%= @skk_m %> <%= @near2 %> <% else %> - <%= @gokei_sd2_h %>:<%= @gokei_sd2_m %> <%= @near2 %> + + <% @near1,@near2 = @near2, @near1%> + + <%= @gokei_sd2_h %>:<%= @gokei_sd2_m %> <%= @near1 %>

- <%= @gokei_sd2d1_h %>:<%= @gokei_sd2d1_m %> <%= @near1 %> 時間指定(<%= @c_hour%>:<%= @c_minute%>) + <%= @gokei_sd2d1_h %>:<%= @gokei_sd2d1_m %> <%= @near2 %> 時間指定(<%= @c_hour%>:<%= @c_minute%>) <% end %> <% elsif @destination_1 == @near2 %> <% if @orderz <= @reversez %> @@ -28,11 +31,14 @@
<%= @skk_h %>:<%= @skk_m %> <%= @near2 %> 時間指定(<%= @c_hour%>:<%= @c_minute%>) <% else %> - <%= @gokei_sd1_h %>:<%= @gokei_sd1_m %> <%= @near2 %> 時間指定(<%= @c_hour%>:<%= @c_minute%>) + + <% @near1,@near2 = @near2, @near1%> + + <%= @gokei_sd1_h %>:<%= @gokei_sd1_m %> <%= @near1 %> 時間指定(<%= @c_hour%>:<%= @c_minute%>)

- <%= @gokei_sd1d2_h %>:<%= @gokei_sd1d2_m %> <%= @near1 %> + <%= @gokei_sd1d2_h %>:<%= @gokei_sd1d2_m %> <%= @near2 %> <% end %> <% end %> diff --git a/app/views/destination_form/new.html.erb b/app/views/destination_form/new.html.erb index 32464fa..ba4c736 100644 --- a/app/views/destination_form/new.html.erb +++ b/app/views/destination_form/new.html.erb @@ -13,15 +13,19 @@

出発時刻を入力してください

時 + + <% for h in 0..23 %> + + <% end %> + + 分 + + <% 0.step(50, 10) do |m| %> + + <% end %> + + @@ -31,19 +35,20 @@

目的地を入力してください

<%= text_field_tag(:destination_1, '', :class=>'mb-3') %>

経由時刻を入力してください

- 時 - - 分 + 時 + + 分 + - +
@@ -54,6 +59,7 @@
+