]> source.dussan.org Git - redmine.git/commitdiff
New document form can be accessed from the document list with no additional request.
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 18 Oct 2007 16:59:28 +0000 (16:59 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Thu, 18 Oct 2007 16:59:28 +0000 (16:59 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@851 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/projects_controller.rb
app/views/common/_attachments_form.rhtml [new file with mode: 0644]
app/views/documents/_form.rhtml
app/views/projects/add_document.rhtml
app/views/projects/list_documents.rhtml

index 1fc7a82ff203852f1cf43d711c2fe4abaddc2ef2..960255263ba83976505558a8477f5a7ad45e9f18 100644 (file)
@@ -174,7 +174,6 @@ class ProjectsController < ApplicationController
 
   # Add a new document to @project
   def add_document
-    @categories = Enumeration::get_values('DCAT')
     @document = @project.documents.build(params[:document])    
     if request.post? and @document.save        
       # Save the attachments
diff --git a/app/views/common/_attachments_form.rhtml b/app/views/common/_attachments_form.rhtml
new file mode 100644 (file)
index 0000000..673f4a5
--- /dev/null
@@ -0,0 +1,6 @@
+<p id="attachments_p">
+<label for="attachment_file"><%=l(:label_attachment)%>
+<%= image_to_function "add.png", "addFileField();return false" %></label>
+<%= file_field_tag 'attachments[]', :size => 30  %>
+<em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em>
+</p>
index ee7c289f14ddf1814ddf47cd97755341115b1fef..d45e295b0c8f004569b1270846544b41a457b5b3 100644 (file)
@@ -2,9 +2,7 @@
 <div class="box">
 <!--[form:document]-->
 <p><label for="document_category_id"><%=l(:field_category)%></label>
-<select name="document[category_id]">
-<%= options_from_collection_for_select @categories, "id", "name", @document.category_id %>
-</select></p>
+<%= select('document', 'category_id', Enumeration.get_values('DCAT').collect {|c| [c.name, c.id]}) %></p>
 
 <p><label for="document_title"><%=l(:field_title)%> <span class="required">*</span></label>
 <%= text_field 'document', 'title', :size => 60 %></p>
index dc3103a7b7ffdae8ff5bcfa902d837622525963e..6c3fe2c7b770b45557f343e34a881d5a4587a841 100644 (file)
@@ -4,9 +4,7 @@
 <%= render :partial => 'documents/form' %>
 
 <div class="box">
-<p id="attachments_p"><label for="attachment_file"><%=l(:label_attachment)%>
-<%= image_to_function "add.png", "addFileField();return false" %></label>
-<%= file_field_tag 'attachments[]', :size => 30  %> <em>(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)</em></p>
+<%= render :partial => 'common/attachments_form'%>
 </div>
 
 <%= submit_tag l(:button_create) %>
index 9575405f44b181a2d26c84152a362dd0f6d37cf1..595b15fd18bf62aa9318d0ddb5eae880abc3ec86 100644 (file)
@@ -1,5 +1,20 @@
 <div class="contextual">
-<%= link_to_if_authorized l(:label_document_new), {:controller => 'projects', :action => 'add_document', :id => @project}, :class => 'icon icon-add' %>
+<%= link_to_if_authorized l(:label_document_new),
+                          {:controller => 'projects', :action => 'add_document', :id => @project},
+                          :class => 'icon icon-add',
+                          :onclick => 'Element.show("add-document"); return false;' %>
+</div>
+
+<div id="add-document" style="display:none;">
+<h2><%=l(:label_document_new)%></h2>
+<% form_tag({:action => 'add_document', :id => @project}, :class => "tabular", :multipart => true) do %>
+<%= render :partial => 'documents/form' %>
+<div class="box">
+<%= render :partial => 'common/attachments_form'%>
+</div>
+<%= submit_tag l(:button_create) %>
+<%= link_to l(:button_cancel), "#", :onclick => 'Element.hide("add-document")' %>
+<% end %>
 </div>
 
 <h2><%=l(:label_document_plural)%></h2>