def self.get_values(option)
find(:all, :conditions => {:opt => option}, :order => 'position')
end
+
+ def self.default(option)
+ find(:first, :conditions => {:opt => option, :is_default => true}, :order => 'position')
+ end
def option_name
OPTIONS[self.opt]
end
-
- #def <=>(enumeration)
- # position <=> enumeration.position
- #end
+
+ def before_save
+ Enumeration.update_all("is_default = #{connection.quoted_false}", {:opt => opt}) if is_default?
+ end
def to_s; name end
validates_numericality_of :estimated_hours, :allow_nil => true
validates_associated :custom_values, :on => :update
- # set default status for new issues
- def before_validation
- self.status = IssueStatus.default if status.nil?
+ def after_initialize
+ if new_record?
+ # set default values for new records only
+ self.status ||= IssueStatus.default
+ self.priority ||= Enumeration.default('IPRI')
+ end
+ end
+
+ def priority_id=(pid)
+ self.priority = nil
+ write_attribute(:priority_id, pid)
end
def validate
<p><label for="enumeration_name"><%=l(:field_name)%></label>
<%= text_field 'enumeration', 'name' %></p>
+
+<p><label for="enumeration_is_default"><%=l(:field_is_default)%></label>
+<%= check_box 'enumeration', 'is_default' %></p>
<!--[eoform:optvalue]-->
</div>
\ No newline at end of file
<% enumerations.each do |enumeration| %>
<tr class="<%= cycle('odd', 'even') %>">
<td><%= link_to enumeration.name, :action => 'edit', :id => enumeration %></td>
+ <td style="width:15%;"><%= image_tag('true.png') if enumeration.is_default? %></td>
<td style="width:15%;">
<%= link_to image_tag('2uparrow.png', :alt => l(:label_sort_highest)), {:action => 'move', :id => enumeration, :position => 'highest'}, :method => :post, :title => l(:label_sort_highest) %>
<%= link_to image_tag('1uparrow.png', :alt => l(:label_sort_higher)), {:action => 'move', :id => enumeration, :position => 'higher'}, :method => :post, :title => l(:label_sort_higher) %> -
--- /dev/null
+class AddEnumerationsIsDefault < ActiveRecord::Migration
+ def self.up
+ add_column :enumerations, :is_default, :boolean, :default => false, :null => false
+ end
+
+ def self.down
+ remove_column :enumerations, :is_default
+ end
+end
field_status: Status
field_notes: Notes
field_is_closed: Issue closed
-field_is_default: Default status
+field_is_default: Default value
field_html_color: Color
field_tracker: Tracker
field_subject: Subject
field_status: Statut
field_notes: Notes
field_is_closed: Demande fermée
-field_is_default: Statut par défaut
+field_is_default: Valeur par défaut
field_html_color: Couleur
field_tracker: Tracker
field_subject: Sujet