Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/models/scissor_lift.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ class ScissorLift < ApplicationRecord
has_one :organization, through: :scissor_lift_checkouts

scope :ordered_by_name, -> { order(name: :asc) }
scope :checked_out, -> { joins(:scissor_lift_checkouts).merge(ScissorLiftCheckout.current).distinct }
scope :checked_in, -> { where.not(id: checked_out.select(:id)) }

def link
scissor_lift_path(self)
Expand Down
4 changes: 2 additions & 2 deletions app/views/scissor_lifts/checkouts/_checkin_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<%= form_with url: checkin_scissor_lifts_path do |f| %>
<%= hidden_field_tag 'url', request.original_fullpath %>
<%= f.label "Scissor Lift" %>
<%= f.collection_select(:name, ScissorLift.all.ordered_by_name, :name, :name, {prompt: 'Select Scissor Lift...'}) %>
<%= f.collection_select(:name, ScissorLift.checked_out.ordered_by_name, :name, :name, {prompt: 'Select Scissor Lift...'}) %>
<%= f.check_box :checkin_type, {style: 'margin-bottom: 2em'} %>
<%= f.label :checkin_type, "Used the scissor lift without a green wristband?" %>
<%= f.submit 'Checkin', class: 'btn btn-wide'%>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/scissor_lifts/checkouts/_checkout_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</ul>
<%= form_with url: add_scissor_lifts_path do |f| %>
<%= hidden_field_tag 'url', request.original_fullpath %>
<%= f.collection_select(:name, ScissorLift.all.ordered_by_name, :name, :name, {prompt: 'Add Scissor Lift...'}, onchange: 'this.form.submit()') %>
<%= f.collection_select(:name, ScissorLift.checked_in.ordered_by_name, :name, :name, {prompt: 'Add Scissor Lift...'}, onchange: 'this.form.submit()') %>
<% end %>

<h3>The Borrower</h3>
Expand Down
4 changes: 2 additions & 2 deletions app/views/scissor_lifts/checkouts/_renew_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<%= form_with url: renew_scissor_lifts_path do |f| %>
<%= hidden_field_tag 'url', request.original_fullpath %>
<%= f.label "Scissor Lift" %>
<%= f.collection_select(:name, ScissorLift.all.ordered_by_name, :name, :name, {prompt: 'Select Scissor Lift...'}) %>
<%= f.collection_select(:name, ScissorLift.checked_out.ordered_by_name, :name, :name, {prompt: 'Select Scissor Lift...'}) %>
<%= f.label "How many hours?" %>
<%= f.number_field(:duration, value: '2', min: 0, style: 'margin-bottom: 2em') %>
<%= f.submit 'Renew', class: 'btn btn-wide'%>
<% end %>
<% end %>