diff --git a/app/controllers/dmsf_detail_controller.rb b/app/controllers/dmsf_detail_controller.rb
index 551abdb3..5dd7782a 100644
--- a/app/controllers/dmsf_detail_controller.rb
+++ b/app/controllers/dmsf_detail_controller.rb
@@ -21,22 +21,47 @@ class DmsfDetailController < ApplicationController
before_filter :find_project
before_filter :authorize
- before_filter :find_folder, :only => [:create_folder, :delete_folder, :save_folder,
+ before_filter :find_parent, :only => [:folder_new, :create_folder, :save_folder, :folder_detail]
+ before_filter :find_folder, :only => [:delete_folder, :save_folder,
:upload_files, :commit_files, :folder_detail]
before_filter :find_file, :only => [:save_file, :delete_file, :file_detail]
-
- def create_folder
- @new_folder = DmsfFolder.create_from_params(@project, @folder, params[:dmsf_folder])
- if @new_folder.valid?
- flash[:notice] = l(:notice_folder_created)
- Rails.logger.info "#{Time.now} from #{request.remote_ip}/#{request.env["HTTP_X_FORWARDED_FOR"]}: #{User.current.login} created folder #{@project.identifier}://#{@new_folder.dmsf_path_str}"
- else
- flash[:error] = l(:error_folder_creation_failed) + ": " + l(:error_folder_title_must_be_entered)
- end
- redirect_to({:controller => "dmsf", :action => "index", :id => @project, :folder_id => @folder})
+ def folder_new
+ @pathfolder = @parent
+ render :action => "folder_detail"
end
-
+
+ def create_folder
+ @folder = DmsfFolder.new(params[:dmsf_folder])
+ @folder.project = @project
+ @folder.folder = @parent
+ @folder.user = User.current
+ if @folder.save
+ flash[:notice] = l(:notice_folder_created)
+ Rails.logger.info "#{Time.now} from #{request.remote_ip}/#{request.env["HTTP_X_FORWARDED_FOR"]}: #{User.current.login} created folder #{@project.identifier}://#{@folder.dmsf_path_str}"
+ redirect_to({:controller => "dmsf", :action => "index", :id => @project, :folder_id => @folder})
+ else
+ @pathfolder = @parent
+ render :action => "folder_detail"
+ end
+ end
+
+ def folder_detail
+ @pathfolder = copy_folder(@folder)
+ end
+
+ def save_folder
+ @pathfolder = copy_folder(@folder)
+ @folder.attributes = params[:dmsf_folder]
+ if @folder.save
+ Rails.logger.info "#{Time.now} from #{request.remote_ip}/#{request.env["HTTP_X_FORWARDED_FOR"]}: #{User.current.login} updated folder #{@project.identifier}://#{@folder.dmsf_path_str}"
+ flash[:notice] = l(:notice_folder_details_were_saved)
+ redirect_to :controller => "dmsf", :action => "index", :id => @project, :folder_id => @folder
+ else
+ render :action => "folder_detail"
+ end
+ end
+
def delete_folder
check_project(@delete_folder = DmsfFolder.find(params[:delete_folder_id]))
if !@delete_folder.nil?
@@ -54,32 +79,6 @@ class DmsfDetailController < ApplicationController
render_403
end
- def folder_detail
- end
-
- def save_folder
- @folder.description = params[:description]
-
- if params[:title].blank?
- flash.now[:error] = l(:error_folder_title_must_be_entered)
- render "folder_detail"
- return
- end
-
- @folder.name = params[:title]
-
- if !@folder.valid?
- flash.now[:error] = l(:error_folder_title_is_already_used)
- render "folder_detail"
- return
- end
-
- @folder.save!
- Rails.logger.info "#{Time.now} from #{request.remote_ip}/#{request.env["HTTP_X_FORWARDED_FOR"]}: #{User.current.login} updated folder #{@project.identifier}://#{@folder.dmsf_path_str}"
- flash[:notice] = l(:notice_folder_details_were_saved)
- redirect_to :controller => "dmsf", :action => "index", :id => @project, :folder_id => @folder
- end
-
#TODO: show lock/unlock history
def file_detail
end
@@ -207,6 +206,12 @@ class DmsfDetailController < ApplicationController
private
+ def copy_folder(folder)
+ copy = folder.clone
+ copy.id = folder.id
+ copy
+ end
+
def find_project
@project = Project.find(params[:id])
end
@@ -218,6 +223,13 @@ class DmsfDetailController < ApplicationController
render_403
end
+ def find_parent
+ @parent = DmsfFolder.find(params[:parent_id]) if params.keys.include?("parent_id")
+ check_project(@parent)
+ rescue DmsfAccessError
+ render_403
+ end
+
def find_file
check_project(@file = DmsfFile.find(params[:file_id]))
rescue DmsfAccessError
diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb
index e4f63069..029903af 100644
--- a/app/models/dmsf_folder.rb
+++ b/app/models/dmsf_folder.rb
@@ -33,16 +33,7 @@ class DmsfFolder < ActiveRecord::Base
["dmsf_folder_id is NULL and project_id = :project_id", {:project_id => project.id}], :order => "name ASC")
end
- def self.create_from_params(project, parent_folder, params)
- new_folder = DmsfFolder.new(params)
- new_folder.project = project
- new_folder.folder = parent_folder
- new_folder.user = User.current
- new_folder.save
- new_folder
- end
-
- def dmsf_path
+ def dmsf_path
folder = self
path = []
while !folder.nil?
diff --git a/app/views/dmsf/index.html.erb b/app/views/dmsf/index.html.erb
index 966831dc..9dd4c78d 100644
--- a/app/views/dmsf/index.html.erb
+++ b/app/views/dmsf/index.html.erb
@@ -3,13 +3,13 @@
<% if User.current.allowed_to?(:folder_manipulation, @project) %>
<% unless @folder.nil? %>
- <%= link_to(image_tag("filedetails.png", :plugin => "redmine_dmsf", :style => "vertical-align: text-top;"),
+ <%= link_to(image_tag("edit.png", :style => "vertical-align: text-top;"),
{:controller => "dmsf_detail", :action => "folder_detail", :id => @project, :folder_id => @folder },
- :title => l(:link_details, :title => h(@folder.name))) %> |
- <% end %>
- <% form_for(DmsfFolder.new, :url => {:controller => "dmsf_detail", :action => "create_folder", :id => @project, :folder_id => @folder}, :html => {:method=>:post}) do |f| %>
- Title: <%= f.text_field(:name) %><%= f.submit(l(:submit_create_folder)) %>
+ :title => l(:link_edit, :title => h(@folder.name))) %>
<% end %>
+ <%= link_to(image_tag("add.png", :style => "vertical-align: text-top;"),
+ {:controller => "dmsf_detail", :action => "folder_new", :id => @project, :parent_id => @folder },
+ :title => l(:link_create_folder)) %>
<% end %>
@@ -71,9 +71,9 @@ form_tag({:action => "entries_operation", :id => @project, :folder_id => @folder
<% if User.current.allowed_to?(:folder_manipulation, @project) %>
- <%= link_to(image_tag("filedetails.png", :plugin => "redmine_dmsf", :class =>"detail_icon"),
+ <%= link_to(image_tag("edit.png", :class =>"detail_icon"),
{:controller => "dmsf_detail", :action => "folder_detail", :id => @project, :folder_id => subfolder },
- :title => l(:link_details, :title => h(subfolder.name))) %>
+ :title => l(:link_edit, :title => h(subfolder.name))) %>
<% end %>
diff --git a/app/views/dmsf_detail/folder_detail.html.erb b/app/views/dmsf_detail/folder_detail.html.erb
index e879493a..9b8896f7 100644
--- a/app/views/dmsf_detail/folder_detail.html.erb
+++ b/app/views/dmsf_detail/folder_detail.html.erb
@@ -2,27 +2,29 @@
-
+<% create = @pathfolder == @parent %>
-<%= render(:partial => "/dmsf/path", :locals => {:path => @folder.dmsf_path}) %>
+<%= render(:partial => "/dmsf/path", :locals => {:path => @pathfolder.dmsf_path}) %>
+<%= "/ New Folder" if create %>
-<% form_tag({:action => "save_folder", :id => @project, :folder_id => @folder},
- :method=>:post, :multipart => true, :class => "tabular") do %>
+<% form_for(:dmsf_folder, @folder, :url => {:action => create ? "create_folder" : "save_folder", :id => @project, :folder_id => @folder, :parent_id => @parent},
+ :html => {:method=>:post, :class => "tabular"}) do |f| %>
+ <%= error_messages_for("folder") %>
- <%= label_tag("title", "Title:") %>
- <%= text_field_tag("title", @folder.name, :size => "32") %>
+ <%= label_tag("dmsf_folder_name", "Title:") %>
+ <%= f.text_field(:name, :size => "32") %>
- <%= label_tag("description", "Description:") %>
- <%= text_area_tag("description", @folder.description, :rows => 15, :class => "wiki-edit") %>
+ <%= label_tag("dmsf_folder_description", "Description:") %>
+ <%= f.text_area(:description, :rows => 15, :class => "wiki-edit") %>
- <%= submit_tag("Save") %>
+ <%= submit_tag(create ? "Create" : "Save") %>
<% end %>
-<%= wikitoolbar_for "description" %>
+<%= wikitoolbar_for "dmsf_folder_description" %>
<% content_for :header_tags do %>
<%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %>
diff --git a/config/locales/cs.yml b/config/locales/cs.yml
index 133f4897..ae5c3eaf 100644
--- a/config/locales/cs.yml
+++ b/config/locales/cs.yml
@@ -37,7 +37,9 @@ cs:
:warning_file_notifications_already_deactivated: "File notifications already deactivated"
:notice_file_notifications_deactivated: "File notifications deactivated"
:link_details: "%{title} details"
- :submit_create_folder: "Create folder"
+ :link_edit: "Edit %{title}"
+ :submit_create: "Create"
+ :link_create_folder: "Create folder"
:title_check_uncheck_all_for_zip_download_or_email: "Check/Uncheck all for zip download or email"
:link_title: "Title"
:link_size: "Size"
@@ -68,7 +70,6 @@ cs:
:label_email_documents: "Documents"
:label_email_body: "Body"
:label_email_send: "Send"
-
:title_notifications_active: "Notifications active"
:label_file_size: "File size"
:heading_file_upload: "Upload"
diff --git a/config/locales/de.yml b/config/locales/de.yml
index 0a24a1cf..33d8e70a 100644
--- a/config/locales/de.yml
+++ b/config/locales/de.yml
@@ -37,7 +37,9 @@ de:
:warning_file_notifications_already_deactivated: "File notifications already deactivated"
:notice_file_notifications_deactivated: "File notifications deactivated"
:link_details: "%{title} details"
- :submit_create_folder: "Create folder"
+ :link_edit: "Edit %{title}"
+ :submit_create: "Create"
+ :link_create_folder: "Create folder"
:title_check_uncheck_all_for_zip_download_or_email: "Check/Uncheck all for zip download or email"
:link_title: "Title"
:link_size: "Size"
diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml
index 3a5068cf..019539da 100644
--- a/config/locales/en-GB.yml
+++ b/config/locales/en-GB.yml
@@ -37,7 +37,9 @@ en-GB:
:warning_file_notifications_already_deactivated: "File notifications already deactivated"
:notice_file_notifications_deactivated: "File notifications deactivated"
:link_details: "%{title} details"
- :submit_create_folder: "Create folder"
+ :link_edit: "Edit %{title}"
+ :submit_create: "Create"
+ :link_create_folder: "Create folder"
:title_check_uncheck_all_for_zip_download_or_email: "Check/Uncheck all for zip download or email"
:link_title: "Title"
:link_size: "Size"
diff --git a/config/locales/en.yml b/config/locales/en.yml
index cc9b2b79..d14ffd68 100644
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -37,7 +37,9 @@ en:
:warning_file_notifications_already_deactivated: "File notifications already deactivated"
:notice_file_notifications_deactivated: "File notifications deactivated"
:link_details: "%{title} details"
- :submit_create_folder: "Create folder"
+ :link_edit: "Edit %{title}"
+ :submit_create: "Create"
+ :link_create_folder: "Create folder"
:title_check_uncheck_all_for_zip_download_or_email: "Check/Uncheck all for zip download or email"
:link_title: "Title"
:link_size: "Size"
diff --git a/config/locales/es.yml b/config/locales/es.yml
index 1bf62dbd..786c4585 100644
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -37,7 +37,9 @@ es:
:warning_file_notifications_already_deactivated: "File notifications already deactivated"
:notice_file_notifications_deactivated: "File notifications deactivated"
:link_details: "%{title} details"
- :submit_create_folder: "Create folder"
+ :link_edit: "Edit %{title}"
+ :submit_create: "Create"
+ :link_create_folder: "Create folder"
:title_check_uncheck_all_for_zip_download_or_email: "Check/Uncheck all for zip download or email"
:link_title: "Title"
:link_size: "Size"
diff --git a/config/locales/fr.yml b/config/locales/fr.yml
index f19bfb0e..9e51245c 100644
--- a/config/locales/fr.yml
+++ b/config/locales/fr.yml
@@ -37,7 +37,9 @@ fr:
:warning_file_notifications_already_deactivated: "File notifications already deactivated"
:notice_file_notifications_deactivated: "File notifications deactivated"
:link_details: "%{title} details"
- :submit_create_folder: "Create folder"
+ :link_edit: "Edit %{title}"
+ :submit_create: "Create"
+ :link_create_folder: "Create folder"
:title_check_uncheck_all_for_zip_download_or_email: "Check/Uncheck all for zip download or email"
:link_title: "Title"
:link_size: "Size"
diff --git a/config/locales/ru.yml b/config/locales/ru.yml
index 07517e28..52e7c8dd 100644
--- a/config/locales/ru.yml
+++ b/config/locales/ru.yml
@@ -37,7 +37,9 @@ ru:
:warning_file_notifications_already_deactivated: "File notifications already deactivated"
:notice_file_notifications_deactivated: "File notifications deactivated"
:link_details: "%{title} details"
- :submit_create_folder: "Create folder"
+ :link_edit: "Edit %{title}"
+ :submit_create: "Create"
+ :link_create_folder: "Create folder"
:title_check_uncheck_all_for_zip_download_or_email: "Check/Uncheck all for zip download or email"
:link_title: "Title"
:link_size: "Size"
diff --git a/init.rb b/init.rb
index 3ccaf090..502c11b6 100644
--- a/init.rb
+++ b/init.rb
@@ -48,7 +48,7 @@ Redmine::Plugin.register :redmine_dmsf do
permission :user_preferences, {:dmsf_state => [:user_pref, :user_pref_save]}
permission :view_dmsf_files, {:dmsf => [:download_file, :download_revision, :entries_operation, :email_entries_send],
:dmsf_detail => [:file_detail]}
- permission :folder_manipulation, {:dmsf_detail => [:create_folder, :delete_folder, :folder_detail, :save_folder]}
+ permission :folder_manipulation, {:dmsf_detail => [:folder_new, :create_folder, :delete_folder, :folder_detail, :save_folder]}
permission :file_manipulation, {:dmsf_detail => [:upload_files, :upload_file, :commit_files, :save_file, :delete_file],
:dmsf_state => [:lock_file, :unlock_file]}
permission :file_approval, {:dmsf_detail => [:approve_file, :delete_revision],