Skip to content

Commit

Permalink
Merge pull request #17 from enpitut2018/takuya4
Browse files Browse the repository at this point in the history
aaa
  • Loading branch information
IkumaOka authored Nov 21, 2018
2 parents 3bd1758 + 7fc91e6 commit 07581c8
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 25 deletions.
12 changes: 10 additions & 2 deletions app/controllers/destination_form_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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
Expand Down
14 changes: 10 additions & 4 deletions app/views/destination_form/create.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@
</br>
<%= @skk_h %>:<%= @skk_m %> <%= @near2 %>
<% else %>
<%= @gokei_sd2_h %>:<%= @gokei_sd2_m %> <%= @near2 %>

<% @near1,@near2 = @near2, @near1%>

<%= @gokei_sd2_h %>:<%= @gokei_sd2_m %> <%= @near1 %>
</br>
</br>
<%= @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 %>
Expand All @@ -28,11 +31,14 @@
</br>
<%= @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%>)
</br>
</br>
<%= @gokei_sd1d2_h %>:<%= @gokei_sd1d2_m %> <%= @near1 %>
<%= @gokei_sd1d2_h %>:<%= @gokei_sd1d2_m %> <%= @near2 %>
<% end %>
<% end %>

Expand Down
45 changes: 26 additions & 19 deletions app/views/destination_form/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@

<h3>出発時刻を入力してください</h3>
<select class="ui search dropdown" name =<%=(:hour)%>>
<% for h in 0..23 %>
<option value="<%=h%>"><%=h%></option>
<% end %>
</select>
<option value="-1">現在</option>
<% for h in 0..23 %>
<option value="<%=h%>"><%=h%></option>
<% end %>
</select>

<select class="ui search dropdown" name =<%=(:minute)%>>
<% 0.step(50, 10) do |m| %>
<option value="<%=m%>"><%=m%></option>
<% end %>
</select>
<option value="-1">時刻</option>
<% 0.step(50, 10) do |m| %>
<option value="<%=m%>"><%=m%></option>
<% end %>
</select>

<!--ここまで-->
</div>
</div>
Expand All @@ -31,18 +35,20 @@
<h1 class="text-center">目的地を入力してください</h1>
<%= text_field_tag(:destination_1, '', :class=>'mb-3') %>
<h4>経由時刻を入力してください</h4>
<select class="ui search dropdown" name =<%=(:c_hour)%>>
<% for h in 0..23 %>
<option value="<%=h%>"><%=h%></option>
<% end %>
</select>

<select class="ui search dropdown" name =<%=(:c_minute)%>>
<% 0.step(50, 10) do |m| %>
<option value="<%=m%>"><%=m%></option>
<% end %>
</select>
<select class="ui search dropdown" name =<%=(:c_hour)%>>
<% for h in 0..23 %>
<option value="<%=h%>"><%=h%></option>
<% end %>
</select>

<select class="ui search dropdown" name =<%=(:c_minute)%>>
<% 0.step(50, 10) do |m| %>
<option value="<%=m%>"><%=m%></option>
<% end %>
</select>

<!--1つ目の目的地入力フォーム-->

<!--「詳細設定」をクリックすると時間が指定できる-->
<div class="hidden_box">
<label for="labe2">詳細設定</label>
Expand All @@ -53,6 +59,7 @@
<!--ここまで-->
</div>
</div>

</br>

<!--2つ目の目的地入力フォーム-->
Expand Down

0 comments on commit 07581c8

Please sign in to comment.