Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nostory] refactor scaffold - meeting-type #137

Merged
merged 2 commits into from
Jul 28, 2019
Merged
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: 1 addition & 1 deletion app/controllers/inventory_tallies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ def set_inventory_tally

# Never trust parameters from the scary internet, only allow the white list through.
def inventory_tally_params
params.fetch(:inventory_tally, {})
params.require(:inventory_tally).permit(:additional_location_info, :cached_quantity, :inventory_type_id, :storage_location_id)
end
end
2 changes: 1 addition & 1 deletion app/controllers/inventory_types_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ def set_inventory_type

# Never trust parameters from the scary internet, only allow the white list through.
def inventory_type_params
params.fetch(:inventory_type, {})
params.require(:inventory_type).permit(:name, :description)
end
end
1 change: 0 additions & 1 deletion app/models/inventory_type.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
class InventoryType < ApplicationRecord

end
37 changes: 25 additions & 12 deletions app/views/inventory_adjustments/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@

<%= simple_form_for(@inventory_adjustment, html: { class: 'form-inline' }) do |f| %>
<%= simple_form_for(@inventory_adjustment,
:defaults => {
:label_html => { :class => "col-4" },
:input_html => { :class => "col-8" },
:wrapper_html => { :class => "row" },
:submit_html => { :class => "btn, btn-info"},
:html => { :class => "form-inline" }
}) do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

<div class="form-inputs">
<%= f.association :inventory_tally %>
<%= f.association :purchase %>
<%= f.association :box_item %>
<%= f.input :total_cost %>
<%= f.input :tally_quantity_start, readonly:true %>
<%= f.input :tally_quantity_end, readonly:true %>
<%= f.input :adjustment_quantity %>
<div class="form-inputs container">
<%= f.association :inventory_tally %>
<%= f.association :purchase %>
<%= f.association :box_item %>
<%= f.input :total_cost %>
<%= f.input :tally_quantity_start %>
<%= f.input :tally_quantity_end %>
<%= f.input :adjustment_quantity %>
</div>

<div class="form-actions">
<%= f.button :submit %>
<div class="form-group row mb-0" style="margin: 2rem 0">
<div class="col-12 offset-4" style="padding-left: 0 !important;">
<%= f.button :submit, class: "btn-primary" %>

<button class="btn btn-outline-secondary">
<%= link_to "Back", :back %>
</button>
</div>
</div>
<% end %>
<% end %>
1 change: 0 additions & 1 deletion app/views/inventory_adjustments/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
<%= render 'form', inventory_adjustment: @inventory_adjustment %>

<%= link_to 'Show', @inventory_adjustment %> |
<%= link_to 'Back', inventory_adjustments_path %>
2 changes: 0 additions & 2 deletions app/views/inventory_adjustments/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<h1>New Inventory Adjustment</h1>

<%= render 'form', inventory_adjustment: @inventory_adjustment %>

<%= link_to 'Back', inventory_adjustments_path %>
40 changes: 26 additions & 14 deletions app/views/inventory_tallies/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,29 @@
<%= form_with(model: inventory_tally, local: true) do |form| %>
<% if inventory_tally.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(inventory_tally.errors.count, "error") %> prohibited this inventory_tally from being saved:</h2>

<ul>
<% inventory_tally.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%= simple_form_for(@inventory_tally,
:defaults => {
:label_html => { :class => "col-4" },
:input_html => { :class => "col-8" },
:wrapper_html => { :class => "row" },
:submit_html => { :class => "btn, btn-info"},
:html => { :class => "form-inline" }
}) do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

<div class="form-inputs container">
<%= f.input :additional_location_info %>
<%= f.input :cached_quantity %>
<%= f.association :inventory_type %>
<%= f.association :storage_location %>
</div>

<div class="actions">
<%= form.submit %>
<div class="form-group row mb-0" style="margin: 2rem 0">
<div class="col-12 offset-4" style="padding-left: 0 !important;">
<%= f.button :submit, class: "btn-primary" %>

<button class="btn btn-outline-secondary">
<%= link_to "Back", :back %>
</button>
</div>
</div>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/inventory_tallies/_inventory_tally.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
json.extract! inventory_tally, :id, :created_at, :updated_at
json.extract! inventory_tally, :id, :additional_location_info, :cached_quantity, :inventory_type_id, :storage_location_id, :created_at, :updated_at
json.url inventory_tally_url(inventory_tally, format: :json)
1 change: 0 additions & 1 deletion app/views/inventory_tallies/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
<%= render 'form', inventory_tally: @inventory_tally %>

<%= link_to 'Show', @inventory_tally %> |
<%= link_to 'Back', inventory_tallies_path %>
8 changes: 8 additions & 0 deletions app/views/inventory_tallies/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@
<table>
<thead>
<tr>
<th>Additional location info</th>
<th>Cached quantity</th>
<th>Inventory type</th>
<th>Storage location</th>
<th colspan="3"></th>
</tr>
</thead>

<tbody>
<% @inventory_tallies.each do |inventory_tally| %>
<tr>
<td><%= inventory_tally.additional_location_info %></td>
<td><%= inventory_tally.cached_quantity %></td>
<td><%= inventory_tally.inventory_type %></td>
<td><%= inventory_tally.storage_location %></td>
<td><%= link_to 'Show', inventory_tally %></td>
<td><%= link_to 'Edit', edit_inventory_tally_path(inventory_tally) %></td>
<td><%= link_to 'Destroy', inventory_tally, method: :delete, data: { confirm: 'Are you sure?' } %></td>
Expand Down
4 changes: 1 addition & 3 deletions app/views/inventory_tallies/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<h1>New Inventory Tally</h1>

<%= render 'form', inventory_tally: @inventory_tally %>

<%= link_to 'Back', inventory_tallies_path %>
<%= render 'form', inventory_tally: @inventory_tally %>
20 changes: 20 additions & 0 deletions app/views/inventory_tallies/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,24 @@
<p id="notice"><%= notice %></p>

<p>
<strong>Additional location info:</strong>
<%= @inventory_tally.additional_location_info %>
</p>

<p>
<strong>Cached quantity:</strong>
<%= @inventory_tally.cached_quantity %>
</p>

<p>
<strong>Inventory type:</strong>
<%= @inventory_tally.inventory_type %>
</p>

<p>
<strong>Storage location:</strong>
<%= @inventory_tally.storage_location %>
</p>

<%= link_to 'Edit', edit_inventory_tally_path(@inventory_tally) %> |
<%= link_to 'Back', inventory_tallies_path %>
38 changes: 24 additions & 14 deletions app/views/inventory_types/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
<%= form_with(model: inventory_type, local: true) do |form| %>
<% if inventory_type.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(inventory_type.errors.count, "error") %> prohibited this inventory_type from being saved:</h2>

<ul>
<% inventory_type.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<%= simple_form_for(@inventory_type,
:defaults => {
:label_html => { :class => "col-4" },
:input_html => { :class => "col-8" },
:wrapper_html => { :class => "row" },
:submit_html => { :class => "btn, btn-info"},
:html => { :class => "form-inline" }
}) do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

<div class="form-inputs container">
<%= f.input :name %>
<%= f.input :description %>
</div>

<div class="actions">
<%= form.submit %>
<div class="form-group row mb-0" style="margin: 2rem 0">
<div class="col-12 offset-4" style="padding-left: 0 !important;">
<%= f.button :submit, class: "btn-primary" %>

<button class="btn btn-outline-secondary">
<%= link_to "Back", :back %>
</button>
</div>
</div>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/inventory_types/_inventory_type.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
json.extract! inventory_type, :id, :created_at, :updated_at
json.extract! inventory_type, :id, :name, :description, :created_at, :updated_at
json.url inventory_type_url(inventory_type, format: :json)
4 changes: 4 additions & 0 deletions app/views/inventory_types/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,17 @@
<table>
<thead>
<tr>
<th>Name</th>
<th>Description</th>
<th colspan="3"></th>
</tr>
</thead>

<tbody>
<% @inventory_types.each do |inventory_type| %>
<tr>
<td><%= inventory_type.name %></td>
<td><%= inventory_type.description %></td>
<td><%= link_to 'Show', inventory_type %></td>
<td><%= link_to 'Edit', edit_inventory_type_path(inventory_type) %></td>
<td><%= link_to 'Destroy', inventory_type, method: :delete, data: { confirm: 'Are you sure?' } %></td>
Expand Down
10 changes: 10 additions & 0 deletions app/views/inventory_types/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
<p id="notice"><%= notice %></p>

<p>
<strong>Name:</strong>
<%= @inventory_type.name %>
</p>

<p>
<strong>Description:</strong>
<%= @inventory_type.description %>
</p>

<%= link_to 'Edit', edit_inventory_type_path(@inventory_type) %> |
<%= link_to 'Back', inventory_types_path %>
67 changes: 25 additions & 42 deletions app/views/locations/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,47 +1,30 @@
<%= form_with(model: location, local: true) do |form| %>
<% if location.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(location.errors.count, "error") %> prohibited this location from being saved:</h2>

<ul>
<% location.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= form.label :name %>
<%= form.text_field :name %>
</div>

<div class="field">
<%= form.label :street_address %>
<%= form.text_field :street_address %>
</div>

<div class="field">
<%= form.label :city %>
<%= form.text_field :city %>
<%= simple_form_for(@location,
:defaults => {
:label_html => { :class => "col-4" },
:input_html => { :class => "col-8" },
:wrapper_html => { :class => "row" },
:submit_html => { :class => "btn, btn-info"},
:html => { :class => "form-inline" }
}) do |f| %>
<%= f.error_notification %>
<%= f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present? %>

<div class="form-inputs container">
<%= f.input :name %>
<%= f.input :street_address %>
<%= f.input :city %>
<%= f.input :state %>
<%= f.input :zip %>
</div>

<div class="field">
<%= form.label :state %>
<%= form.text_field :state %>
</div>

<div class="field">
<%= form.label :zip %>
<%= form.text_field :zip %>
</div>
<div class="form-group row mb-0" style="margin: 2rem 0">
<div class="col-12 offset-4" style="padding-left: 0 !important;">
<%= f.button :submit, class: "btn-primary" %>

<div class="field">
<%= form.label :type %>
<%= form.text_field :type %>
</div>

<div class="actions">
<%= form.submit %>
<button class="btn btn-outline-secondary">
<%= link_to "Back", :back %>
</button>
</div>
</div>
<% end %>
<% end %>
1 change: 0 additions & 1 deletion app/views/locations/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@
<%= render 'form', location: @location %>

<%= link_to 'Show', @location %> |
<%= link_to 'Back', locations_path %>
2 changes: 0 additions & 2 deletions app/views/locations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<h1>New Location</h1>

<%= render 'form', location: @location %>

<%= link_to 'Back', locations_path %>
Loading