Added Unit types
This commit is contained in:
parent
b0789e6217
commit
8082e42225
@ -1,2 +1,6 @@
|
|||||||
module UnitsHelper
|
module UnitsHelper
|
||||||
|
def type_options
|
||||||
|
translations = t('.types')
|
||||||
|
Unit.types.map { |k,v| [translations[k.to_sym], k] }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,2 +1,24 @@
|
|||||||
class Unit < ActiveRecord::Base
|
class Unit < ActiveRecord::Base
|
||||||
|
# https://en.wikipedia.org/wiki/International_System_of_Units
|
||||||
|
enum type: {
|
||||||
|
number: 0,
|
||||||
|
share: 1,
|
||||||
|
|
||||||
|
length: 10,
|
||||||
|
mass: 11,
|
||||||
|
time: 12,
|
||||||
|
temperature: 13,
|
||||||
|
|
||||||
|
volume: 20,
|
||||||
|
density: 21,
|
||||||
|
ndensity: 22,
|
||||||
|
|
||||||
|
frequency: 30,
|
||||||
|
velocity: 31,
|
||||||
|
flow: 32,
|
||||||
|
|
||||||
|
energy: 30,
|
||||||
|
|
||||||
|
pressure: 40
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
@ -1,7 +1,13 @@
|
|||||||
<%= error_messages_for @unit %>
|
<%= error_messages_for @unit %>
|
||||||
|
|
||||||
<div class="box tabular">
|
<div class="box tabular">
|
||||||
<p><%= f.text_field :name, :required => true, :size => 40 %></p>
|
<div class="splitcontent">
|
||||||
<p><%= f.text_field :shortname, :required => true, :size => 10 %></p>
|
<div class="splitcontentleft">
|
||||||
<p><%#= f.select :summary, :cols => 60, :rows => 2 %></p>
|
<p><%= f.text_field :shortname, required: true, size: 10 %></p>
|
||||||
|
</div>
|
||||||
|
<div class="splitcontentright">
|
||||||
|
<p><%= f.select :type, type_options, required: true %></p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<p><%= f.text_field :name, required: true, size: 40 %></p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -4,8 +4,7 @@
|
|||||||
|
|
||||||
<div class="contextual">
|
<div class="contextual">
|
||||||
<% if @project && User.current.allowed_to?(:manage_units, @project) %>
|
<% if @project && User.current.allowed_to?(:manage_units, @project) %>
|
||||||
<%= link_to t(".heading_new_unit"), new_project_unit_path(@project),
|
<%= link_to t(".heading_new_unit"), '#', :class => 'icon icon-add',
|
||||||
:class => 'icon icon-add',
|
|
||||||
:onclick => 'showAndScrollTo("add-unit", "unit_name"); return false;' %>
|
:onclick => 'showAndScrollTo("add-unit", "unit_name"); return false;' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -14,3 +14,19 @@ en:
|
|||||||
index:
|
index:
|
||||||
heading: 'Units'
|
heading: 'Units'
|
||||||
heading_new_unit: 'New unit'
|
heading_new_unit: 'New unit'
|
||||||
|
form:
|
||||||
|
types:
|
||||||
|
number: 'count'
|
||||||
|
share: 'share'
|
||||||
|
length: 'length'
|
||||||
|
mass: 'mass'
|
||||||
|
time: 'time'
|
||||||
|
temperature: 'temperature'
|
||||||
|
volume: 'volume'
|
||||||
|
density: 'density'
|
||||||
|
ndensity: 'number density'
|
||||||
|
frequency: 'frequency'
|
||||||
|
velocity: 'velocity'
|
||||||
|
flow: 'flow rate'
|
||||||
|
energy: 'energy'
|
||||||
|
pressure: 'pressure'
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
class CreateUnits < ActiveRecord::Migration
|
class CreateUnits < ActiveRecord::Migration
|
||||||
def change
|
def change
|
||||||
create_table :units do |t|
|
create_table :units do |t|
|
||||||
t.references :project_id
|
t.references :project
|
||||||
t.string :name
|
t.string :name
|
||||||
t.string :shortname
|
t.string :shortname
|
||||||
t.integer :type
|
t.integer :type
|
||||||
|
Reference in New Issue
Block a user