From bdd3a064d633395da7b698b677bd4d2b2ef10634 Mon Sep 17 00:00:00 2001 From: "vit.jonas@gmail.com" Date: Wed, 1 Jun 2011 06:59:58 +0000 Subject: [PATCH] * finished Issue 58: Add description to root of DMSF git-svn-id: http://redmine-dmsf.googlecode.com/svn/trunk/redmine_dmsf@113 5e329b0b-a2ee-ea63-e329-299493fc886d --- app/controllers/dmsf_controller.rb | 12 +++++++++++- app/views/dmsf/edit.html.erb | 2 +- app/views/dmsf/edit_root.html.erb | 25 +++++++++++++++++++++++++ app/views/dmsf/show.html.erb | 8 ++++++-- db/migrate/02_dmsf_normalization.rb | 2 ++ db/migrate/03_dmsf_0_8_0.rb | 28 ++++++++++++++++++++++++++++ init.rb | 2 +- 7 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 app/views/dmsf/edit_root.html.erb create mode 100644 db/migrate/03_dmsf_0_8_0.rb diff --git a/app/controllers/dmsf_controller.rb b/app/controllers/dmsf_controller.rb index 7c34b5a4..71970a41 100644 --- a/app/controllers/dmsf_controller.rb +++ b/app/controllers/dmsf_controller.rb @@ -21,7 +21,7 @@ class DmsfController < ApplicationController before_filter :find_project before_filter :authorize, :except => [:delete_entries] - before_filter :find_folder, :except => [:new, :create] + before_filter :find_folder, :except => [:new, :create, :edit_root, :save_root] before_filter :find_parent, :only => [:new, :create] helper :sort @@ -218,6 +218,16 @@ class DmsfController < ApplicationController render_403 end + def edit_root + end + + def save_root + @project.dmsf_description = params[:project][:dmsf_description] + @project.save! + flash[:notice] = l(:notice_folder_details_were_saved) + redirect_to :controller => "dmsf", :action => "show", :id => @project + end + def notify_activate if @folder.notification flash[:warning] = l(:warning_folder_notifications_already_activated) diff --git a/app/views/dmsf/edit.html.erb b/app/views/dmsf/edit.html.erb index c0bb4cd0..30ff4f55 100644 --- a/app/views/dmsf/edit.html.erb +++ b/app/views/dmsf/edit.html.erb @@ -4,7 +4,7 @@ <% create = @pathfolder == @parent %>

-<%= render(:partial => "/dmsf/path", :locals => {:path => @pathfolder.nil? ? [] : @pathfolder.dmsf_path}) %> +<%= render(:partial => "path", :locals => {:path => @pathfolder.nil? ? [] : @pathfolder.dmsf_path}) %> <%= ("/ " + l(:heading_new_folder)) if create %>

diff --git a/app/views/dmsf/edit_root.html.erb b/app/views/dmsf/edit_root.html.erb new file mode 100644 index 00000000..852593b8 --- /dev/null +++ b/app/views/dmsf/edit_root.html.erb @@ -0,0 +1,25 @@ +<% html_title(l(:dmsf)) %> + +
+
+ +

<%= render(:partial => "path", :locals => {:path => []}) %>

+ +<% form_for(:project, @project, :url => {:action => "save_root", :id => @project}, + :html => {:method=>:post}) do |f| %> +
+

+ <%= label_tag("project_dmsf_description", l(:label_description) + ":") %> +

+
+ <%= f.text_area(:dmsf_description, :rows => 15, :class => "wiki-edit") %> +
+
+ <%= submit_tag(l(:submit_save)) %> +<% end %> + +<%= wikitoolbar_for "dmsf_folder_description" %> + +<% content_for :header_tags do %> + <%= stylesheet_link_tag "dmsf", :plugin => "redmine_dmsf" %> +<% end %> diff --git a/app/views/dmsf/show.html.erb b/app/views/dmsf/show.html.erb index b4192ef8..58061782 100644 --- a/app/views/dmsf/show.html.erb +++ b/app/views/dmsf/show.html.erb @@ -2,7 +2,11 @@
<% if User.current.allowed_to?(:folder_manipulation, @project) %> - <% unless @folder.nil? %> + <% if @folder.nil? %> + <%= link_to(image_tag("edit.png", :style => "vertical-align: text-top;"), + {:action => "edit_root", :id => @project}, + :title => l(:link_edit, :title => l(:link_documents))) %>   + <% else @folder.nil? %> <%= link_to(image_tag("edit.png", :style => "vertical-align: text-top;"), {:action => "edit", :id => @project, :folder_id => @folder }, :title => l(:link_edit, :title => h(@folder.title))) %>   @@ -19,7 +23,7 @@
-<%= textilizable(@folder.description) unless @folder.nil? %> +<%= textilizable(@folder.nil? ? @project.dmsf_description : @folder.description) %>
<% diff --git a/db/migrate/02_dmsf_normalization.rb b/db/migrate/02_dmsf_normalization.rb index 41a66d64..242b04b9 100644 --- a/db/migrate/02_dmsf_normalization.rb +++ b/db/migrate/02_dmsf_normalization.rb @@ -29,6 +29,8 @@ class DmsfNormalization < ActiveRecord::Migration end def self.down + drop_table :dmsf_file_revision_audit + rename_column :dmsf_folders, :title, :name end end diff --git a/db/migrate/03_dmsf_0_8_0.rb b/db/migrate/03_dmsf_0_8_0.rb new file mode 100644 index 00000000..68737d1b --- /dev/null +++ b/db/migrate/03_dmsf_0_8_0.rb @@ -0,0 +1,28 @@ +# Redmine plugin for Document Management System "Features" +# +# Copyright (C) 2011 Vít Jonáš +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + +class Dmsf080 < ActiveRecord::Migration + def self.up + add_column :projects, :dmsf_description, :text + end + + def self.down + remove_column :projects, :dmsf_description + end + +end diff --git a/init.rb b/init.rb index 78b63bbf..4ccac156 100644 --- a/init.rb +++ b/init.rb @@ -55,7 +55,7 @@ Redmine::Plugin.register :redmine_dmsf do permission :user_preferences, {:dmsf_state => [:user_pref_save]} permission :view_dmsf_files, {:dmsf => [:entries_operation, :entries_email], :dmsf_files => [:show]} - permission :folder_manipulation, {:dmsf => [:new, :create, :delete, :edit, :save]} + permission :folder_manipulation, {:dmsf => [:new, :create, :delete, :edit, :save, :edit_root, :save_root]} permission :file_manipulation, {:dmsf_files => [:create_revision, :delete, :lock, :unlock], :dmsf_upload => [:upload_files, :upload_file, :commit_files]} permission :file_approval, {:dmsf_files => [:delete_revision, :notify_activate, :notify_deactivate],