From 38ca68df03cd8975b8ecf3843db0a941fdd32132 Mon Sep 17 00:00:00 2001
From: Jeffrey Sturek <jsturek8@unl.edu>
Date: Mon, 25 Feb 2019 12:03:55 -0600
Subject: [PATCH] Fix hours form to display in 5.0

---
 views/admin/new_hours.erb | 131 +++++++++++++++++++++-----------------
 1 file changed, 74 insertions(+), 57 deletions(-)

diff --git a/views/admin/new_hours.erb b/views/admin/new_hours.erb
index 292a8f2..9c167ea 100644
--- a/views/admin/new_hours.erb
+++ b/views/admin/new_hours.erb
@@ -22,65 +22,82 @@
     </div>
 
     <fieldset>
-        <legend>Hours</legend>
-        <label>Studio will be closed for all hours you do not indicate here.</label>
-        <input type="text" class="hidden" name="hours" id="hours" />
-        <div id="hours-container">
-            <% hours = [{:status => 'open', :start => 540, :end => 1020}] if hours.nil? %>
-            <% hours.each_index do |x| %>
-            <% record = hours[x] %>
-            <div id="base-hours-<%=x%>" class="date-time-select hours-record">
-                <select class="hours-type">
-                    <option <%= 'selected="selected"' if record[:status] == 'open' %> value="open">Open</option>
-                    <option <%= 'selected="selected"' if record[:status] == 'open_without_reservations' %> value="open_without_reservations">Open but Machine Reservations are Not Allowed</option>
-                    <option <%= 'selected="selected"' if record[:status] == 'closed' %> value="closed">Closed</option>
-                </select>
-                <label>from</label>
-                <select class="start-time-hour" title="Start Time Hour">
-                    <option value=""></option>
-                    <% (1..12).each do |i| %>
-                    <option <%= 'selected="selected"' if [y = record[:start] / 60, y+12, y-12].include?(i) %> value="<%= i %>"><%= i %></option>
-                    <% end %>
-                </select> : 
-
-                <select class="start-time-minute"title="Start Time Minute">
-                    <option value=""></option>
-                    <% (0..11).each do |i| %>
-                    <option <%= 'selected="selected"' if record[:start] % 60 == i*5 %> value="<%= i * 5 %>"><%= (i*5).to_s.rjust(2, '0') %></option>
-                    <% end %>
-                </select>
-
-                <div class="am_pm">
-                    <input <%= 'checked="checked"' if record[:start] < 720 %> class="start-time-am-pm" title="AM" type="radio" value="am" name="<%= z = String.token %>">AM<br>
-                    <input <%= 'checked="checked"' if record[:start] >= 720 %> class="start-time-am-pm" title="PM" type="radio" value="pm" name="<%= z %>">PM
-                </div>&nbsp;
-                <label>until</label>
-                &nbsp;
-                <select class="end-time-hour" title="End Time Hour">
-                    <option value=""></option>
-                    <% (1..12).each do |i| %>
-                    <option <%= 'selected="selected"' if [y = record[:end] / 60, y+12, y-12].include?(i) %> value="<%= i %>"><%= i %></option>
-                    <% end %>
-                </select> : 
-
-                <select class="end-time-minute"title="End Time Minute">
-                    <option value=""></option>
-                    <% (0..11).each do |i| %>
-                    <option <%= 'selected="selected"' if record[:end] % 60 == i*5 %> value="<%= i * 5 %>"><%= (i*5).to_s.rjust(2, '0') %></option>
-                    <% end %>
-                </select>
-
-                <div class="am_pm">
-                    <input <%= 'checked="checked"' if record[:end] < 720 %> class="end-time-am-pm" title="AM" type="radio" value="am" name="<%= z = String.token %>">AM<br>
-                    <input <%= 'checked="checked"' if record[:end] >= 720 %> class="end-time-am-pm" title="PM" type="radio" value="pm" name="<%= z %>">PM
+            <legend>Hours</legend>
+            <label>Studio will be closed for all hours you do not indicate here.</label>
+            <input type="text" class="hidden" name="hours" id="hours" />
+            <div id="hours-container">
+                <% hours = [{:status => 'open', :start => 540, :end => 1020}] if hours.nil? %>
+                <% hours.each_index do |x| %>
+                <% record = hours[x] %>
+                <div id="base-hours-<%=x%>" class="date-time-select hours-record">
+                    <select class="hours-type dcf-input-select">
+                        <option <%= 'selected="selected"' if record[:status] == 'open' %> value="open">Open</option>
+                        <option <%= 'selected="selected"' if record[:status] == 'open_without_reservations' %> value="open_without_reservations">Open but Machine Reservations are Not Allowed</option>
+                        <option <%= 'selected="selected"' if record[:status] == 'closed' %> value="closed">Closed</option>
+                    </select>
+                    <label for="start-date">from</label>
+                    <div class="dcf-d-flex dcf-ai-center dcf-flex-grow-1 dcf-mt-4 dcf-mr-4">
+                        <select class="start-time-hour dcf-flex-grow-1 dcf-input-select" title="Start Time Hour">
+                            <option value=""></option>
+                            <% (1..12).each do |i| %>
+                            <option <%= 'selected="selected"' if [y = record[:start] / 60, y+12, y-12].include?(i) %> value="<%= i %>"><%= i %></option>
+                            <% end %>
+                        </select>&nbsp;:&nbsp;
+
+                        <select class="start-time-minute dcf-flex-grow-1 dcf-input-select" title="Start Time Minute">
+                            <option value=""></option>
+                            <% (0..11).each do |i| %>
+                            <option <%= 'selected="selected"' if record[:start] % 60 == i*5 %> value="<%= i * 5 %>"><%= (i*5).to_s.rjust(2, '0') %></option>
+                            <% end %>
+                        </select>
+
+                        <div class="am_pm dcf-mb-0 dcf-pl-3">
+                            <div class="dcf-d-flex dcf-ai-center">
+                                <label class="dcf-label dcf-2nd dcf-mt-0 dcf-ml-1" for="hours-start-am">AM</label>
+                                <input <%= 'checked="checked"' if record[:start] < 720 %> class="start-time-am-pm dcf-flex-shrink-0" title="AM" type="radio" value="am" name="<%= z = String.token %>">
+                            </div>
+                            <div class="dcf-d-flex dcf-ai-center">
+                                <label class="dcf-label dcf-2nd dcf-mt-0 dcf-ml-1" for="hours-start-pm">PM</label>
+                                <input <%= 'checked="checked"' if record[:start] >= 720 %> class="start-time-am-pm dcf-flex-shrink-0" title="PM" type="radio" value="pm" name="<%= z %>">
+                            </div>
+                        </div>
+                    </div>
+
+                    <label for="end-date">until</label>
+                    <div class="dcf-d-flex dcf-ai-center dcf-flex-grow-1 dcf-mt-4 dcf-mr-4">
+                        <select class="end-time-hour dcf-flex-grow-1 dcf-input-select" title="End Time Hour">
+                            <option value=""></option>
+                            <% (1..12).each do |i| %>
+                            <option <%= 'selected="selected"' if [y = record[:end] / 60, y+12, y-12].include?(i) %> value="<%= i %>"><%= i %></option>
+                            <% end %>
+                        </select>&nbsp;:&nbsp;
+
+                        <select class="end-time-minute dcf-flex-grow-1 dcf-input-select" title="End Time Minute">
+                            <option value=""></option>
+                            <% (0..11).each do |i| %>
+                            <option <%= 'selected="selected"' if record[:start] % 60 == i*5 %> value="<%= i * 5 %>"><%= (i*5).to_s.rjust(2, '0') %></option>
+                            <% end %>
+                        </select>
+
+                        <div class="am_pm dcf-mb-0 dcf-pl-3">
+                            <div class="dcf-d-flex dcf-ai-center">
+                                <label class="dcf-label dcf-2nd dcf-mt-0 dcf-ml-1" for="hours-end-am">AM</label>
+                                <input <%= 'checked="checked"' if record[:end] < 720 %> class="end-time-am-pm dcf-flex-shrink-0" title="AM" type="radio" value="am" name="<%= z = String.token %>">
+                            </div>
+                            <div class="dcf-d-flex dcf-ai-center">
+                                <label class="dcf-label dcf-2nd dcf-mt-0 dcf-ml-1" for="hours-end-pm">PM</label>
+                                <input <%= 'checked="checked"' if record[:end] >= 720 %> class="end-time-am-pm dcf-flex-shrink-0" title="PM" type="radio" value="pm" name="<%= z %>">
+                            </div>
+                        </div>
+                    </div>
+
+                    &nbsp;
+                    <button title="Remove" type="button" class="<%= 'hidden' if x == 0 %> remove-hours dcf-btn">&times;</button>
                 </div>
-                &nbsp;
-                <button title="Remove" type="button" class="<%= 'hidden' if x == 0 %> remove-hours dcf-btn">&times;</button>
+                <% end %>
             </div>
-            <% end %>
-        </div>
-        <button id="add-hours" type="button" class="dcf-btn wdn-button-complement">Add Hours</button>
-    </fieldset>
+            <button id="add-hours" type="button" class="dcf-btn wdn-button-complement">Add Hours</button>
+        </fieldset>
 
     <button type="submit" class="dcf-btn dcf-btn-primary">Submit</button>
 </form>
-- 
GitLab