diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-18 16:59:28 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2007-10-18 16:59:28 +0000 |
commit | 0006c5f3b0dc697b277faee328244f0dabe9d1c7 (patch) | |
tree | 8ce19da27ddfb46d60f85a172fe8be4d6714dc51 | |
parent | 3c42abe07e12932a6e839ab3f635f86745cb39ed (diff) | |
download | redmine-0006c5f3b0dc697b277faee328244f0dabe9d1c7.tar.gz redmine-0006c5f3b0dc697b277faee328244f0dabe9d1c7.zip |
New document form can be accessed from the document list with no additional request.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@851 e93f8b46-1217-0410-a6f0-8f06a7374b81
-rw-r--r-- | app/controllers/projects_controller.rb | 1 | ||||
-rw-r--r-- | app/views/common/_attachments_form.rhtml | 6 | ||||
-rw-r--r-- | app/views/documents/_form.rhtml | 4 | ||||
-rw-r--r-- | app/views/projects/add_document.rhtml | 4 | ||||
-rw-r--r-- | app/views/projects/list_documents.rhtml | 17 |
5 files changed, 24 insertions, 8 deletions
diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 1fc7a82ff..960255263 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -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 index 000000000..673f4a52e --- /dev/null +++ b/app/views/common/_attachments_form.rhtml @@ -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> diff --git a/app/views/documents/_form.rhtml b/app/views/documents/_form.rhtml index ee7c289f1..d45e295b0 100644 --- a/app/views/documents/_form.rhtml +++ b/app/views/documents/_form.rhtml @@ -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> diff --git a/app/views/projects/add_document.rhtml b/app/views/projects/add_document.rhtml index dc3103a7b..6c3fe2c7b 100644 --- a/app/views/projects/add_document.rhtml +++ b/app/views/projects/add_document.rhtml @@ -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) %> diff --git a/app/views/projects/list_documents.rhtml b/app/views/projects/list_documents.rhtml index 9575405f4..595b15fd1 100644 --- a/app/views/projects/list_documents.rhtml +++ b/app/views/projects/list_documents.rhtml @@ -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> |