Skip to content
This repository has been archived by the owner on Jan 19, 2019. It is now read-only.

Commit

Permalink
added new part data structure
Browse files Browse the repository at this point in the history
  • Loading branch information
morops committed Dec 27, 2017
1 parent 4f977b5 commit 5e868bf
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 20 deletions.
5 changes: 2 additions & 3 deletions db/migrations/005_add_material_and_priority_to_parts.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
Sequel.migration do
change do
alter_table(:parts) do
add_column :source_material, String, :null => false
add_column :have_material, Integer, :null => false
add_column :mfg_method, String, :null => false
add_column :finish, String, :null => false
add_column :quantity, String, :null => false
add_column :cut_length, String, :null => false
add_column :priority, Integer, :null => false
add_column :drawing_created, Integer, :null => false
end
Expand Down
Binary file added models/.part.rb.swp
Binary file not shown.
24 changes: 17 additions & 7 deletions models/part.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,29 @@ class Part < Sequel::Model

# The list of possible part statuses. Key: string stored in database, value: what is displayed to the user.
STATUS_MAP = { "designing" => "Design in progress",
"material" => "Material needs to be ordered",
# "material" => "Material needs to be ordered",
"ordered" => "Waiting for materials",
"drawing" => "Needs drawing",
"ready" => "Ready to manufacture",
"manufacturing" => "Manufacturing in progress",
"outsourced" => "Waiting for outsourced manufacturing",
"welding" => "Waiting for welding",
"scotchbrite" => "Waiting for Scotch-Brite",
"anodize" => "Ready for anodize",
"powder" => "Ready for powder coating",
"coating" => "Waiting for coating",
# "outsourced" => "Waiting for outsourced manufacturing",
# "welding" => "Waiting for welding",
# "scotchbrite" => "Waiting for Scotch-Brite",
# "anodize" => "Ready for anodize",
# "powder" => "Ready for powder coating",
# "coating" => "Waiting for coating",
"assembly" => "Waiting for assembly",
"done" => "Done" }
MFG_MAP = { "manual" => "Manual/hand tools",
"milled" => "Milled",
"turned" => "Turned",
"printed" => "3D Printed",
"outsourced" => "Outsourced" }

FINISH_MAP = { "none" => "None",
"powder_coated" => "Powder coated",
"painted" => "Painted",
"polished" => "Polished" }

# Mapping of priority integer stored in database to what is displayed to the user.
PRIORITY_MAP = { 0 => "High", 1 => "Normal", 2 => "Low" }
Expand Down
5 changes: 2 additions & 3 deletions views/part.erb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@
</tr>
<tr><td><b>Notes</b></td><td><%= (@part.notes || "").gsub("\n", "<br />") %></td></tr>
<% if @part.type == "part" %>
<tr><td><b>Source material</b></td><td><%= @part.source_material %></td></tr>
<tr><td><b>Have material?</b></td><td><%= (@part.have_material == 1) ? "Yes" : "No" %></td></tr>
<tr><td><b>Material cut length</b></td><td><%= @part.cut_length %></td></tr>
<tr><td><b>Manufacturing method</b></td><td><%= @part.mfg_method %></td></tr>
<tr><td><b>Finish type</b></td><td><%= @part.finish %></td></tr>
<% end %>
<tr><td><b>Quantity required</b></td><td><%= @part.quantity %></td></tr>
<tr><td><b>Drawing created?</b></td><td><%= (@part.drawing_created == 1) ? "Yes" : "No" %></td></tr>
Expand Down
24 changes: 17 additions & 7 deletions views/part_edit.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,30 @@
</option>
<% end %>
</select>
<label>Manufacturing Method</label>
<select name="mfg_method">
<% Part::MFG_MAP.each_pair do |key, value| %>
<option value="<%= key %>"<% if @part.mfg_method == key %> selected<% end %>>
<%= value %>
</option>
<% end %>
</select>
<label>Notes</label>
<textarea name="notes" rows="4"><%= @part.notes %></textarea>
<label>Source Material</label>
<input type="text" name="source_material" value="<%= @part.source_material %>" />
<label>Have Material?</b>
<input type="checkbox" name="have_material"<% if @part.have_material == 1 %>checked<% end %>/>
</label>
<label>Material Cut Length</label>
<input type="text" name="cut_length" value="<%= @part.cut_length %>" />
<label>Quantity Required</label>
<input type="text" name="quantity" value="<%= @part.quantity %>" />
<label>Drawing Created?</b>
<input type="checkbox" name="drawing_created"<% if @part.drawing_created == 1 %>checked<% end %>/>
</label>
<label>Finish Type</label>
<select name="finish">
<% Part::FINISH_MAP.each_pair do |key, value| %>
<option value="<%= key %>"<% if @part.finish == key %> selected<% end %>>
<%= value %>
</option>
<% end %>
</select>

<label>Priority</label>
<select name="priority">
<% Part::PRIORITY_MAP.each_pair do |key, value| %>
Expand Down

0 comments on commit 5e868bf

Please sign in to comment.