<% if @patch_version != @patch.latest_version -%>
Showing version <%= @patch_version.version %>. <%= link_to 'Go to latest', :action => 'show', :id => @patch %>
<% end %>

Patch #<%= @patch.id %> (by <%= @patch.author.login %>)

<% other_unapplied_patches = @patch.program.unapplied_patches.find(:all, :conditions => ["id != :id", {:id => @patch.id}]) %> <% other_applied_patches = @patch.program.applied_patches.find(:all, :conditions => ["id != :id", {:id => @patch.id}]) %>

<%= @patch.applied? ? '' : 'Other' %> Unapplied Patches for '<%= @patch.program.name %>'

<% if other_unapplied_patches.size > 0 %> <% other_unapplied_patches.each_with_index do |p,i| %> <% if i >= 5 %> <%= link_to('More...', :action => 'search', 'patch[program_id]' => @patch.program_id, 'patch_extra[applied]' => 0) %> <% break %> <% end %> <%= link_to(p.title, :action => 'edit', :id => p) %> (for <%= p.latest_version.for_upstream_version %>)
<% end %> <% else %> None <% end %>

<%= @patch.applied? ? 'Other' : '' %> Applied Patches for '<%= @patch.program.name %>'

<% if other_applied_patches.size > 0 %> <% other_applied_patches.each_with_index do |p,i| %> <% if i >= 5 %> <%= link_to('More...', :action => 'search', 'patch[program_id]' => @patch.program_id, 'patch_extra[applied]' => 1) %> <% break %> <% end %> <%= link_to(p.title, :action => 'edit', :id => p) %> (in <%= p.applied_since_version %>)
<% end %> <% else %> None <% end %>

Basic Info

<%= ajax_field_updater :patch, :program_id, :error_element_id => 'error', :edit_html => collection_select(:patch, :program_id, Program.find(:all), :id, :name), :data_html => link_to(@patch.program.name, :controller => 'programs', :action => 'edit', :id => @patch.program), :readonly => (! can_edit_patch?(@patch)) %> <%= ajax_field_updater :patch, :title, :error_element_id => 'error', :readonly => (! can_edit_patch?(@patch)) %> <%= ajax_field_updater :patch, :description, :error_element_id => 'error', :edit_html => text_area(:patch, :description, :rows => 4, :cols => 60), :data_html => textilize_without_paragraph(@patch.description), :readonly => (! can_edit_patch?(@patch)) %> <%= ajax_field_updater :patch, :applied_since_version, :error_element_id => 'error', :edit_html => " "+text_field(:patch, :applied_since_version, :size => 5, :value => @patch.latest_version.for_upstream_version), :data_html => "", :readonly => (! can_edit_patch?(@patch)) %>

Patch History

<% versions = @patch.patch_versions.size %> <% @patch.patch_versions.reverse.each_with_index do |pv, i| %>
<%= link_to("Version #{pv.version}", {'patch_extra[version]' => pv.id}) %> (<%= link_to("download", :action => 'view_patch', :id => pv.id, :download => true) %>)
<%= pv.for_upstream_version %> <%= human_size(pv.size) %> <%= pv.created_at.strftime(DATETIME_FORMAT) %>
<%= (pv.comment and not pv.comment.strip.empty?) ? textilize_without_paragraph(pv.comment) : 'None' %>
<% if i == 2 and versions > 3 %>
<%= link_to_function 'Show Entire History', "new Effect.Fade('older_versions_button'); new Effect.SlideDown('older_versions')" %>
<% end %> <% end %> <% if can_update_patch?(@patch) %>

Update Patch

<%= start_form_tag({:action => 'new_patch_version', :id => @patch.id}, :enctype => 'multipart/form-data', :onsubmit => "if ($('version_for_upstream_version').value == '') { alert('The upstream version is mandatory. Please fill it in.'); $('version_for_upstream_version').focus(); return false; } if ($('patch_file').value == '') { alert('You have not specified the patch file to upload. Please do.'); return false;}") %> <%= text_field :version, :for_upstream_version, :size => 5, :maxlength => 10, :value => @patch_version.for_upstream_version %>
<%= text_area :version, :comment, :cols => 60, :rows => 4 %>
:
<%= end_form_tag %> <% end %>

Patch Text <% if @patch_version != @patch.latest_version -%> (Old Version <%= @patch_version.version %>) <% end -%>

<%= render :partial => 'patch_version', :locals => {:patch_version => @patch_version} %>