Project

General

Profile

Feature #9174 » fix_documents_preview.diff

patch - Preethi Sriram, 2011-10-08 00:11

View differences:

app/controllers/previews_controller.rb (working copy)
38 38
    render :partial => 'common/preview'
39 39
  end
40 40

  
41
  def documents
42
    @text = (params[:document] ? params[:document][:description] : nil)
43
    render :partial => 'common/preview'
44
  end
45
  
41 46
  private
42 47
  
43 48
  def find_project
app/views/documents/edit.rhtml (working copy)
1 1
<h2><%=l(:label_document)%></h2>
2 2

  
3
<% form_tag({:action => 'edit', :id => @document}, :class => "tabular") do %>
4
  <%= render :partial => 'form' %>
5
  <%= submit_tag l(:button_save) %>
3
<% form_for :document, @document, :url => {:action => 'edit'}, :html => {:multipart => true, :id => 'document-form'} do |f| %>
4
<%= render :partial => 'form', :locals => { :f => f } %>
5
<%= submit_tag l(:button_save) %>
6
<%= link_to_remote l(:label_preview), 
7
                   { :url => preview_documents_path(:project_id => @project),
8
                     :method => 'post',
9
                     :update => 'preview',
10
                     :with => "Form.serialize('document-form')"
11
                   }, :accesskey => accesskey(:preview) %>
6 12
<% end %>
13
<div id="preview" class="wiki"></div>
7 14

  
15
<% content_for :header_tags do %>
16
  <%= stylesheet_link_tag 'scm' %>
17
<% end %>
8 18

  
app/views/documents/index.rhtml (working copy)
7 7

  
8 8
<div id="add-document" style="display:none;">
9 9
<h2><%=l(:label_document_new)%></h2>
10
<% form_tag({:controller => 'documents', :action => 'new', :project_id => @project}, :class => "tabular", :multipart => true) do %>
10

  
11
<% form_tag({:controller => 'documents', :action => 'new', :project_id => @project}, :id=>"documents-form",:class => "tabular", :multipart => true) do %>
11 12
<%= render :partial => 'documents/form' %>
12 13
<div class="box">
13 14
<p><label><%=l(:label_attachment_plural)%></label><%= render :partial => 'attachments/form' %></p>
14 15
</div>
15 16
<%= submit_tag l(:button_create) %>
17
<%= link_to_remote l(:label_preview), 
18
                   { :url => preview_documents_path(:project_id => @project),
19
                     :method => 'post',
20
                     :update => 'preview',
21
                     :with => "Form.serialize('documents-form')"
22
                   }, :accesskey => accesskey(:preview) %>| 
16 23
<%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-document")' %>
17 24
<% end %>
25
<div id="preview" class="wiki"></div>
26

  
18 27
</div>
19 28

  
20 29
<h2><%=l(:label_document_plural)%></h2>
config/routes.rb (working copy)
144 144
  map.all_news 'news', :controller => 'news', :action => 'index'
145 145
  map.formatted_all_news 'news.:format', :controller => 'news', :action => 'index'
146 146
  map.preview_news '/news/preview', :controller => 'previews', :action => 'news'
147
  map.preview_documents '/documents/preview', :controller => 'previews', :action => 'documents'
147 148
  map.connect 'news/:id/comments', :controller => 'comments', :action => 'create', :conditions => {:method => :post}
148 149
  map.connect 'news/:id/comments/:comment_id', :controller => 'comments', :action => 'destroy', :conditions => {:method => :delete}
149 150

  
(1-1/2)