Revision 812
Added by Jean-Philippe Lang over 17 years ago
trunk/app/controllers/issues_controller.rb | ||
---|---|---|
17 | 17 |
|
18 | 18 |
class IssuesController < ApplicationController |
19 | 19 |
layout 'base', :except => :export_pdf |
20 |
before_filter :find_project, :authorize, :except => :index
|
|
20 |
before_filter :find_project, :authorize, :except => [:index, :preview]
|
|
21 | 21 |
accept_key_auth :index |
22 | 22 |
|
23 | 23 |
cache_sweeper :issue_sweeper, :only => [ :edit, :change_status, :destroy ] |
... | ... | |
167 | 167 |
redirect_to :action => 'show', :id => @issue |
168 | 168 |
end |
169 | 169 |
|
170 |
def preview |
|
171 |
issue = Issue.find_by_id(params[:id]) |
|
172 |
@attachements = issue.attachments if issue |
|
173 |
@text = params[:issue][:description] |
|
174 |
render :partial => 'common/preview' |
|
175 |
end |
|
176 |
|
|
170 | 177 |
private |
171 | 178 |
def find_project |
172 | 179 |
@issue = Issue.find(params[:id], :include => [:project, :tracker, :status, :author, :priority, :category]) |
trunk/app/controllers/wiki_controller.rb | ||
---|---|---|
144 | 144 |
page = @wiki.find_page(params[:page]) |
145 | 145 |
@attachements = page.attachments if page |
146 | 146 |
@text = params[:content][:text] |
147 |
render :partial => 'preview' |
|
147 |
render :partial => 'common/preview'
|
|
148 | 148 |
end |
149 | 149 |
|
150 | 150 |
def add_attachment |
trunk/app/views/common/_preview.rhtml | ||
---|---|---|
1 |
<fieldset class="preview"><legend><%= l(:label_preview) %></legend> |
|
2 |
<%= textilizable @text, :attachments => @attachements %> |
|
3 |
</fieldset> |
|
0 | 4 |
trunk/app/views/issues/_form.rhtml | ||
---|---|---|
25 | 25 |
</div> |
26 | 26 |
|
27 | 27 |
<p><%= f.text_field :subject, :size => 80, :required => true %></p> |
28 |
<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> |
|
28 |
<p><%= f.text_area :description, :required => true, |
|
29 |
:cols => 60, |
|
30 |
:rows => (@issue.description.blank? ? 10 : [[10, @issue.description.length / 50].max, 100].min), |
|
31 |
:accesskey => accesskey(:edit), |
|
32 |
:class => 'wiki-edit' %></p> |
|
29 | 33 |
<p><%= f.select :fixed_version_id, (@project.versions.sort.collect {|v| [v.name, v.id]}), { :include_blank => true } %></p> |
30 | 34 |
<% for @custom_value in @custom_values %> |
31 | 35 |
<p><%= custom_field_tag_with_label @custom_value %></p> |
trunk/app/views/issues/edit.rhtml | ||
---|---|---|
1 | 1 |
<h2><%=h "#{@issue.tracker.name} ##{@issue.id}" %></h2> |
2 | 2 |
|
3 |
<% labelled_tabular_form_for :issue, @issue, :url => {:action => 'edit'} do |f| %> |
|
3 |
<% labelled_tabular_form_for :issue, @issue, |
|
4 |
:url => {:action => 'edit'}, |
|
5 |
:html => {:id => 'issue-form'} do |f| %> |
|
4 | 6 |
<%= render :partial => 'form', :locals => {:f => f} %> |
5 | 7 |
<%= f.hidden_field :lock_version %> |
6 | 8 |
<%= submit_tag l(:button_save) %> |
9 |
<%= link_to_remote l(:label_preview), |
|
10 |
{ :url => { :controller => 'issues', :action => 'preview', :id => @issue }, |
|
11 |
:method => 'post', |
|
12 |
:update => 'preview', |
|
13 |
:with => "Form.serialize('issue-form')", |
|
14 |
:complete => "location.href='#preview-top'" |
|
15 |
}, :accesskey => accesskey(:preview) %> |
|
7 | 16 |
<% end %> |
17 |
|
|
18 |
<a name="preview-top"></a> |
|
19 |
<div id="preview" class="wiki"></div> |
trunk/app/views/projects/add_issue.rhtml | ||
---|---|---|
1 | 1 |
<h2><%=l(:label_issue_new)%>: <%= @tracker.name %></h2> |
2 | 2 |
|
3 |
<% labelled_tabular_form_for :issue, @issue, :url => {:action => 'add_issue'}, :html => {:multipart => true} do |f| %> |
|
3 |
<% labelled_tabular_form_for :issue, @issue, |
|
4 |
:url => {:action => 'add_issue'}, |
|
5 |
:html => {:multipart => true, :id => 'issue-form'} do |f| %> |
|
4 | 6 |
<%= hidden_field_tag 'tracker_id', @tracker.id %> |
5 | 7 |
<%= render :partial => 'issues/form', :locals => {:f => f} %> |
6 | 8 |
<%= submit_tag l(:button_create) %> |
9 |
<%= link_to_remote l(:label_preview), |
|
10 |
{ :url => { :controller => 'issues', :action => 'preview', :id => @issue }, |
|
11 |
:method => 'post', |
|
12 |
:update => 'preview', |
|
13 |
:with => "Form.serialize('issue-form')", |
|
14 |
:complete => "location.href='#preview-top'" |
|
15 |
}, :accesskey => accesskey(:preview) %> |
|
7 | 16 |
<% end %> |
17 |
|
|
18 |
<a name="preview-top"></a> |
|
19 |
<div id="preview" class="wiki"></div> |
trunk/app/views/wiki/_preview.rhtml | ||
---|---|---|
1 |
<fieldset class="preview"><legend><%= l(:label_preview) %></legend> |
|
2 |
<%= textilizable @text, :attachments => @attachements %> |
|
3 |
</fieldset> |
|
4 | 0 |
trunk/public/stylesheets/application.css | ||
---|---|---|
139 | 139 |
width: 200px; |
140 | 140 |
} |
141 | 141 |
|
142 |
#preview fieldset {margin-top: 1em; background: url(../images/draft.png)} |
|
143 |
|
|
142 | 144 |
#settings .tabular p{ padding-left: 300px; } |
143 | 145 |
#settings .tabular label{ margin-left: -300px; width: 295px; } |
144 | 146 |
|
Also available in: Unified diff
Added preview on add/edit issue form.