From 0006c5f3b0dc697b277faee328244f0dabe9d1c7 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Thu, 18 Oct 2007 16:59:28 +0000 Subject: [PATCH] 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 --- app/controllers/projects_controller.rb | 1 - app/views/common/_attachments_form.rhtml | 6 ++++++ app/views/documents/_form.rhtml | 4 +--- app/views/projects/add_document.rhtml | 4 +--- app/views/projects/list_documents.rhtml | 17 ++++++++++++++++- 5 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 app/views/common/_attachments_form.rhtml 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 @@ +

+ +<%= file_field_tag 'attachments[]', :size => 30 %> +(<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>) +

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 @@

-

+<%= select('document', 'category_id', Enumeration.get_values('DCAT').collect {|c| [c.name, c.id]}) %>

<%= text_field 'document', 'title', :size => 60 %>

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' %>
-

-<%= file_field_tag 'attachments[]', :size => 30 %> (<%= l(:label_max_size) %>: <%= number_to_human_size(Setting.attachment_max_size.to_i.kilobytes) %>)

+<%= render :partial => 'common/attachments_form'%>
<%= 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 @@
-<%= 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;' %> +
+ +

<%=l(:label_document_plural)%>

-- 2.39.5