diff --git a/app/helpers/dmsf_helper.rb b/app/helpers/dmsf_helper.rb index ed386183..bd111d16 100644 --- a/app/helpers/dmsf_helper.rb +++ b/app/helpers/dmsf_helper.rb @@ -51,26 +51,4 @@ module DmsfHelper end end - def self.directory_tree(project, current_folder = nil) - tree = [["Documents", nil]] - DmsfFolder.project_root_folders(project).each do |folder| - unless folder == current_folder - tree.push(["...#{folder.name}", folder.id]) - directory_subtree(tree, folder, 2, current_folder) - end - end - return tree - end - - private - - def self.directory_subtree(tree, folder, level, current_folder) - folder.subfolders.each do |subfolder| - unless subfolder == current_folder - tree.push(["#{"..." * level}#{subfolder.name}", subfolder.id]) - directory_subtree(tree, subfolder, level + 1) - end - end - end - end diff --git a/app/models/dmsf_file_revision.rb b/app/models/dmsf_file_revision.rb index 47ec5fdb..b0778d50 100644 --- a/app/models/dmsf_file_revision.rb +++ b/app/models/dmsf_file_revision.rb @@ -108,8 +108,8 @@ class DmsfFileRevision < ActiveRecord::Base self.name = posted.has_key?("name") ? posted["name"] : self.file.name - if posted.has_key?("folder") - self.folder = posted["folder"].blank? ? nil : DmsfFolder.find(posted["folder"]) + if posted.has_key?("dmsf_folder_id") + self.folder = posted["dmsf_folder_id"].blank? ? nil : DmsfFolder.find(posted["dmsf_folder_id"]) else self.folder = self.file.folder end diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index 029903af..4e42d48e 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -65,5 +65,27 @@ class DmsfFolder < ActiveRecord::Base self.save! end + def self.directory_tree(project, current_folder = nil) + tree = [["Documents", nil]] + DmsfFolder.project_root_folders(project).each do |folder| + unless folder == current_folder + tree.push(["...#{folder.name}", folder.id]) + directory_subtree(tree, folder, 2, current_folder) + end + end + return tree + end + + private + + def self.directory_subtree(tree, folder, level, current_folder) + folder.subfolders.each do |subfolder| + unless subfolder == current_folder + tree.push(["#{"..." * level}#{subfolder.name}", subfolder.id]) + directory_subtree(tree, subfolder, level + 1, current_folder) + end + end + end + end diff --git a/app/views/dmsf_detail/_file_new_revision.html.erb b/app/views/dmsf_detail/_file_new_revision.html.erb index 70dc6c05..8577d9f9 100644 --- a/app/views/dmsf_detail/_file_new_revision.html.erb +++ b/app/views/dmsf_detail/_file_new_revision.html.erb @@ -31,8 +31,8 @@ form_for(:dmsf_file_revision, @revision, :url => {:action => "save_file", :id =>

<%= label_tag("", l(:label_file) + ":") %> - <%= f.select(:folder, - options_for_select(DmsfHelper.directory_tree(@project), + <%= f.select(:dmsf_folder_id, + options_for_select(DmsfFolder.directory_tree(@project), :selected => (@revision.folder.id unless @revision.folder.nil?))) %> / <%= f.text_field(:name, :size => "24") %>

diff --git a/app/views/dmsf_detail/file_detail.html.erb b/app/views/dmsf_detail/file_detail.html.erb index 7f4eb7d6..0285e8fc 100644 --- a/app/views/dmsf_detail/file_detail.html.erb +++ b/app/views/dmsf_detail/file_detail.html.erb @@ -79,7 +79,7 @@

<%= label_tag("", l(:label_file) + ":") %> - <%= (h(revision.folder.dmsf_path_str) + " / ") unless revision.folder.nil? %><%= h(revision.name) %> + <%= (h(revision.folder.dmsf_path_str) + "/") unless revision.folder.nil? %><%= h(revision.name) %>

diff --git a/app/views/dmsf_detail/folder_detail.html.erb b/app/views/dmsf_detail/folder_detail.html.erb index fc33a806..8190682c 100644 --- a/app/views/dmsf_detail/folder_detail.html.erb +++ b/app/views/dmsf_detail/folder_detail.html.erb @@ -22,9 +22,9 @@

<%= label_tag("", l(:label_folder) + ":") %> - <%= f.select(:folder, - options_for_select(DmsfHelper.directory_tree(@project), - :selected => (@folder.folder.id unless @folder.folder.nil?))) %> + <%= f.select(:dmsf_folder_id, + options_for_select(DmsfFolder.directory_tree(@project, @folder), + :selected => @folder.nil? ? (@pathfolder.id unless @pathfolder.nil?) : (@folder.folder.id unless @folder.folder.nil?))) %>

diff --git a/config/locales/cs.yml b/config/locales/cs.yml index 6ebc3fb1..531b8ed0 100644 --- a/config/locales/cs.yml +++ b/config/locales/cs.yml @@ -135,4 +135,6 @@ cs: :permission_file_manipulation: "File manipulation" :permission_file_approval: "File approval" :permission_force_file_unlock: "Force file unlock" + :label_file: "File" + :label_folder: "Folder" \ No newline at end of file diff --git a/config/locales/de.yml b/config/locales/de.yml index c6dc05eb..e55dbd64 100644 --- a/config/locales/de.yml +++ b/config/locales/de.yml @@ -131,4 +131,6 @@ de: :permission_file_manipulation: "File manipulation" :permission_file_approval: "File approval" :permission_force_file_unlock: "Force file unlock" + :label_file: "File" + :label_folder: "Folder" \ No newline at end of file diff --git a/config/locales/en-GB.yml b/config/locales/en-GB.yml index cc48bceb..c6e113f3 100644 --- a/config/locales/en-GB.yml +++ b/config/locales/en-GB.yml @@ -131,4 +131,6 @@ en-GB: :permission_file_manipulation: "File manipulation" :permission_file_approval: "File approval" :permission_force_file_unlock: "Force file unlock" + :label_file: "File" + :label_folder: "Folder" \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 6d7a595e..5a87d541 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -127,7 +127,6 @@ en: :label_default_notifications: "File default notifications" :heading_uploaded_files: "Uploaded Files" :submit_commit: "Commit" - :link_documents: "Documents" :permission_browse_documents: "Browse documents" :permission_user_preferences: "User preferences" @@ -136,4 +135,6 @@ en: :permission_file_manipulation: "File manipulation" :permission_file_approval: "File approval" :permission_force_file_unlock: "Force file unlock" + :label_file: "File" + :label_folder: "Folder" \ No newline at end of file diff --git a/config/locales/es.yml b/config/locales/es.yml index 24c2ee5d..0dc7d8f0 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -133,4 +133,6 @@ es: :permission_file_manipulation: "File manipulation" :permission_file_approval: "File approval" :permission_force_file_unlock: "Force file unlock" + :label_file: "File" + :label_folder: "Folder" \ No newline at end of file diff --git a/config/locales/fr.yml b/config/locales/fr.yml index c7e1a589..552758b8 100644 --- a/config/locales/fr.yml +++ b/config/locales/fr.yml @@ -131,4 +131,6 @@ fr: :permission_file_manipulation: "File manipulation" :permission_file_approval: "File approval" :permission_force_file_unlock: "Force file unlock" + :label_file: "File" + :label_folder: "Folder" \ No newline at end of file diff --git a/config/locales/ja.yml b/config/locales/ja.yml index 5dcae882..5a87d541 100644 --- a/config/locales/ja.yml +++ b/config/locales/ja.yml @@ -135,4 +135,6 @@ en: :permission_file_manipulation: "File manipulation" :permission_file_approval: "File approval" :permission_force_file_unlock: "Force file unlock" + :label_file: "File" + :label_folder: "Folder" \ No newline at end of file diff --git a/config/locales/ru.yml b/config/locales/ru.yml index c808880e..ef181062 100644 --- a/config/locales/ru.yml +++ b/config/locales/ru.yml @@ -131,4 +131,6 @@ ru: :permission_file_manipulation: "File manipulation" :permission_file_approval: "File approval" :permission_force_file_unlock: "Force file unlock" + :label_file: "File" + :label_folder: "Folder" \ No newline at end of file