Project

General

Profile

« Previous | Next » 

Revision 19bd108a

Added by Paul Kelly about 14 years ago

  • ID 19bd108a00fe760cfaac4b6bc7ef0f496ee29c1d

Fixes #240 - Clone operation highlights changes correctly

The clone operation no longer flags edits as errors. This looks better.

View differences:

app/controllers/hosts_controller.rb
# Clone any parameters as well
@original.host_parameters.each{|param| @host.host_parameters << param.clone}
flash[:error_customisation] = {:header_message => nil, :class => "flash notice", :id => nil,
:message => "The following fields will need modification:" }
:message => "The following fields will need reviewing:" }
@host.valid?
render :action => :new
end
app/models/host.rb
validates_length_of :root_pass, :minimum => 8,:too_short => 'should be 8 characters or more'
validates_format_of :mac, :with => /([a-f0-9]{1,2}:){5}[a-f0-9]{1,2}/
validates_format_of :ip, :with => /(\d{1,3}\.){3}\d{1,3}/
validates_presence_of :ptable, :message => "Cant be blank unless a custom partition has been defined",
validates_presence_of :ptable, :message => "cant be blank unless a custom partition has been defined",
:if => Proc.new { |host| host.disk.empty? and not defined?(Rake) }
validates_format_of :sp_mac, :with => /([a-f0-9]{1,2}:){5}[a-f0-9]{1,2}/, :allow_nil => true, :allow_blank => true
validates_format_of :sp_ip, :with => /(\d{1,3}\.){3}\d{1,3}/, :allow_nil => true, :allow_blank => true
app/views/hosts/_architecture.html.erb
<%= label :host, :operatingsystem, "Operating system" %>
Operating system
<%= collection_select :host, :operatingsystem_id, @architecture.operatingsystems, :id, :to_label, :include_blank => true %>
<span id=os_sub_select>
<% if @operatingsystem -%>
app/views/hosts/_form.html.erb
<% field_set_tag 'Primary settings' do -%>
<table>
<tr>
<td><%= f.label :name %></td>
<td>Name</td>
<td><%= f.text_field :name, :size => 16, :value => @host.shortname %></td>
<td><%= f.label :hostgroup, "Host group" %></td>
<td>Host group</td>
<td><%= f.collection_select :hostgroup_id, Hostgroup.all, :id, :name, :include_blank => true %></td>
<td><%= f.label :environment %></td>
<td>Environment</td>
<td><%= f.collection_select :environment_id, Environment.all, :id, :to_label, :include_blank => true %></td>
<td><%= f.label :puppetmaster %></td>
<td>Puppetmaster</td>
<td><%= f.text_field :puppetmaster, :size => 10, :value => @host.puppetmaster %></td>
<td><%= link_to_function "Additional Classes", toggle_div(:classlist) %></td>
</tr>
app/views/hosts/_operatingsystem.html.erb
<%= label :host, :media %>
Media
<%= collection_select :host, :media_id, @operatingsystem.medias, :id, :to_label %>
<%= label :host, :ptable, "Partition Table" %>
Partition Table
<%= collection_select :host, :ptable_id, @operatingsystem.ptables, :id, :to_label %>
app/views/hosts/_unattended.html.erb
<% field_set_tag 'Network settings', :id => "network" do -%>
<table>
<tr>
<td><%= f.label :domain %></td>
<td>Domain</td>
<td><%= f.collection_select :domain_id, Domain.all, :id, :to_label %></td>
<td><%= f.label :ip %></td>
<td>IP</td>
<td><%= f.text_field :ip, :size => 16 %></td>
<td><%= f.label :mac, "MAC" %></td>
<td>MAC</td>
<td><%= f.text_field :mac, :size => 17 %></td>
</tr>
</table>
......
<tr>
<td colspan="6">
<span id="architecture">
<%= f.label :architecture %>
Architecture
<%= f.collection_select :architecture_id, Architecture.all, :id, :to_label, :include_blank => true %>
<span id="host_os">
<% if @architecture -%>
......
</td>
</tr>
<tr>
<td><%= f.label :root_pass, "Root password" %></td>
<td>Root password</td>
<td><%= f.password_field :root_pass %></td>
<td><%= f.label :model %></td>
<td>Model</td>
<td><%= f.collection_select :model_id, Model.all, :id, :to_label, :include_blank => true %></td>
<td><%= f.label :serial %></td>
<td>Serial</td>
<td><%= f.select :serial, ["","0,9600n8","0,19200n8","1,9600n8","1,19200n8"] %></td>
</tr>
<tr>
<td colspan="6">
<%= link_to_function "Switch to custom disk layout", toggle_div("custom_disk") %>
<div id="custom_disk", style=display:none;>
<%= f.label :disk, "Custom Disk layout" %>
Custom Disk layout
<%= f.text_area :disk, :size => "50x10", :disabled => true %>
</div>
</td>
config/initializers/foreman.rb
end
end
end
module ActionView::Helpers::ActiveRecordHelper
def error_messages_for_with_customisation(*params)
if flash[:error_customisation]
if params[-1].is_a? Hash
params[-1].update flash[:error_customisation]
else
params << flash[:error_customisation]
end
end
error_messages_for_without_customisation(*params)
end
alias_method_chain :error_messages_for, :customisation
end

Also available in: Unified diff