class IssuesController < ApplicationController
layout 'base', :except => :export_pdf
- before_filter :find_project, :authorize, :except => :index
+ before_filter :find_project, :authorize, :except => [:index, :preview]
accept_key_auth :index
cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ]
redirect_to :action => 'show', :id => @issue
end
+ def preview
+ issue = Issue.find_by_id(params[:id])
+ @attachements = issue.attachments if issue
+ @text = params[:issue][:description]
+ render :partial => 'common/preview'
+ end
+
private
def find_project
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category])
page = @wiki.find_page(params[:page])
@attachements = page.attachments if page
@text = params[:content][:text]
- render :partial => 'preview'
+ render :partial => 'common/preview'
end
def add_attachment
--- /dev/null
+<fieldset class="preview"><legend><%= l(:label_preview) %></legend>
+<%= textilizable @text, :attachments => @attachements %>
+</fieldset>
</div>
<p><%= f.text_field :subject, :size => 80, :required => true %></p>
-<p><%= f.text_area :description, :required => true, :cols => 60, :rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min), :class => 'wiki-edit' %></p>
+<p><%= f.text_area :description, :required => true,
+ :cols => 60,
+ :rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min),
+ :accesskey => accesskey(:edit),
+ :class => 'wiki-edit' %></p>
<p><%= f.select :fixed_version_id, (@project.versions.sort.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p>
<% for @custom_value in @custom_values %>
<p><%= custom_field_tag_with_label @custom_value %></p>
<h2><%=h "#{@issue.tracker.name} ##{@issue.id}" %></h2>
-<% labelled_tabular_form_for :issue, @issue, :url => {:action => 'edit'} do |f| %>
+<% labelled_tabular_form_for :issue, @issue,
+ :url => {:action => 'edit'},
+ :html => {:id => 'issue-form'} do |f| %>
<%= render :partial => 'form', :locals => {:f => f} %>
<%= f.hidden_field :lock_version %>
<%= submit_tag l(:button_save) %>
+ <%= link_to_remote l(:label_preview),
+ { :url => { :controller => 'issues', :action => 'preview', :id => @issue },
+ :method => 'post',
+ :update => 'preview',
+ :with => "Form.serialize('issue-form')",
+ :complete => "location.href='#preview-top'"
+ }, :accesskey => accesskey(:preview) %>
<% end %>
+
+<a name="preview-top"></a>
+<div id="preview" class="wiki"></div>
<h2><%=l(:label_issue_new)%>: <%= @tracker.name %></h2>
-<% labelled_tabular_form_for :issue, @issue, :url => {:action => 'add_issue'}, :html => {:multipart => true} do |f| %>
+<% labelled_tabular_form_for :issue, @issue,
+ :url => {:action => 'add_issue'},
+ :html => {:multipart => true, :id => 'issue-form'} do |f| %>
<%= hidden_field_tag 'tracker_id', @tracker.id %>
<%= render :partial => 'issues/form', :locals => {:f => f} %>
<%= submit_tag l(:button_create) %>
+ <%= link_to_remote l(:label_preview),
+ { :url => { :controller => 'issues', :action => 'preview', :id => @issue },
+ :method => 'post',
+ :update => 'preview',
+ :with => "Form.serialize('issue-form')",
+ :complete => "location.href='#preview-top'"
+ }, :accesskey => accesskey(:preview) %>
<% end %>
+
+<a name="preview-top"></a>
+<div id="preview" class="wiki"></div>
+++ /dev/null
-<fieldset class="preview"><legend><%= l(:label_preview) %></legend>
-<%= textilizable @text, :attachments => @attachements %>
-</fieldset>
width: 200px;
}
+#preview fieldset {margin-top: 1em; background: url(../images/draft.png)}
+
#settings .tabular p{ padding-left: 300px; }
#settings .tabular label{ margin-left: -300px; width: 295px; }