#48 Project's preferences
This commit is contained in:
parent
1342033692
commit
84d971404c
@ -729,7 +729,7 @@ class DmsfController < ApplicationController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
# Remove system folders you are not allowed to see because you are not allowed to see the issue
|
# Remove system folders you are not allowed to see because you are not allowed to see the issue
|
||||||
@subfolders = DmsfHelper.visible_folders(@subfolders)
|
@subfolders = DmsfHelper.visible_folders(@subfolders, @project)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ajax_upload_size = Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'].present? ? Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'] : 100
|
@ajax_upload_size = Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'].present? ? Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'] : 100
|
||||||
|
|||||||
@ -39,7 +39,10 @@ class DmsfStateController < ApplicationController
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
flash[:warning] = l(:user_is_not_project_member)
|
flash[:warning] = l(:user_is_not_project_member)
|
||||||
end
|
end
|
||||||
|
if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable']
|
||||||
|
@project.update_attribute :dmsf_act_as_attachable, params[:act_as_attachable]
|
||||||
|
end
|
||||||
redirect_to settings_project_path(@project, :tab => 'dmsf')
|
redirect_to settings_project_path(@project, :tab => 'dmsf')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -89,8 +89,9 @@ module DmsfHelper
|
|||||||
'plupload/js/i18n/en.js'
|
'plupload/js/i18n/en.js'
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.visible_folders(folders)
|
def self.visible_folders(folders, project)
|
||||||
allowed = Setting.plugin_redmine_dmsf['dmsf_act_as_attachable']
|
allowed = Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
|
||||||
|
(project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS)
|
||||||
folders.reject{ |folder|
|
folders.reject{ |folder|
|
||||||
if folder.system
|
if folder.system
|
||||||
unless allowed
|
unless allowed
|
||||||
@ -112,7 +113,7 @@ module DmsfHelper
|
|||||||
|
|
||||||
def self.all_children_sorted(parent, pos, ident)
|
def self.all_children_sorted(parent, pos, ident)
|
||||||
# Folders && files && links
|
# Folders && files && links
|
||||||
nodes = visible_folders(parent.dmsf_folders.visible.to_a) + parent.dmsf_links.visible + parent.dmsf_files.visible
|
nodes = visible_folders(parent.dmsf_folders.visible.to_a, parent.is_a?(Project) ? parent : parent.project) + parent.dmsf_links.visible + parent.dmsf_files.visible
|
||||||
# Alphabetical and type sort
|
# Alphabetical and type sort
|
||||||
nodes.sort! do |x, y|
|
nodes.sort! do |x, y|
|
||||||
if ((x.is_a?(DmsfFolder) || (x.is_a?(DmsfLink) && x.is_folder?)) &&
|
if ((x.is_a?(DmsfFolder) || (x.is_a?(DmsfLink) && x.is_folder?)) &&
|
||||||
|
|||||||
@ -44,8 +44,8 @@ class DmsfFile < ActiveRecord::Base
|
|||||||
:class_name => 'DmsfLink', :foreign_key => 'target_id', :dependent => :destroy
|
:class_name => 'DmsfLink', :foreign_key => 'target_id', :dependent => :destroy
|
||||||
has_many :dmsf_public_urls, :dependent => :destroy
|
has_many :dmsf_public_urls, :dependent => :destroy
|
||||||
|
|
||||||
STATUS_DELETED = 1
|
STATUS_DELETED = 1.freeze
|
||||||
STATUS_ACTIVE = 0
|
STATUS_ACTIVE = 0.freeze
|
||||||
|
|
||||||
scope :visible, -> { where(:deleted => STATUS_ACTIVE) }
|
scope :visible, -> { where(:deleted => STATUS_ACTIVE) }
|
||||||
scope :deleted, -> { where(:deleted => STATUS_DELETED) }
|
scope :deleted, -> { where(:deleted => STATUS_DELETED) }
|
||||||
|
|||||||
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<%= form_tag(dmsf_user_pref_save_path(@project)) do %>
|
<%= form_tag(dmsf_user_pref_save_path(@project)) do %>
|
||||||
<fieldset class="box tabular">
|
<fieldset class="box tabular">
|
||||||
<legend><%= l(:link_user_preferences) %></legend>
|
<legend><%= l(:link_user_preferences) %></legend>
|
||||||
<p>
|
<p>
|
||||||
<%= content_tag(:label, "#{l(:label_notifications)}:") %>
|
<%= content_tag(:label, "#{l(:label_notifications)}:") %>
|
||||||
<%= select_tag(
|
<%= select_tag(
|
||||||
@ -41,5 +41,19 @@
|
|||||||
<em class="info"><%= l(:text_title_format) %></em>
|
<em class="info"><%= l(:text_title_format) %></em>
|
||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
<% if Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] %>
|
||||||
|
<fieldset class="box tabular">
|
||||||
|
<legend><%= l(:field_project) %> <%= l(:label_preferences) %></legend>
|
||||||
|
<p>
|
||||||
|
<%= content_tag(:label, "#{l(:label_act_as_attachable)}:") %>
|
||||||
|
<%= select_tag(
|
||||||
|
'act_as_attachable',
|
||||||
|
options_for_select([
|
||||||
|
[l(:label_attachment_plural) + ' & ' + l(:menu_dmsf), Project::ATTACHABLE_DMS_AND_ATTACHMENTS],
|
||||||
|
[l(:label_attachment_plural), Project::ATTACHABLE_ATTACHMENTS],
|
||||||
|
],:selected => @project.dmsf_act_as_attachable)) %>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
<% end %>
|
||||||
<%= submit_tag(l(:submit_save), :title => l(:title_save_preferences)) %>
|
<%= submit_tag(l(:submit_save), :title => l(:title_save_preferences)) %>
|
||||||
<% end %>
|
<% end %>
|
||||||
31
db/migrate/20170526144701_dmsf_attachable.rb
Normal file
31
db/migrate/20170526144701_dmsf_attachable.rb
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
#
|
||||||
|
# Redmine plugin for Document Management System "Features"
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011-17 Karel Pičman <karel.picman@kontron.com>
|
||||||
|
#
|
||||||
|
# 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 DmsfAttachable < ActiveRecord::Migration
|
||||||
|
def self.up
|
||||||
|
# DMSF - project's root folder notification
|
||||||
|
add_column :projects, :dmsf_act_as_attachable, :integer, :default => 1, :null => false
|
||||||
|
Project.update_all dmsf_act_as_attachable: 1
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.down
|
||||||
|
remove_column :projects, :dmsf_act_as_attachable
|
||||||
|
end
|
||||||
|
end
|
||||||
@ -29,7 +29,8 @@ module RedmineDmsf
|
|||||||
# Add Dmsf upload form
|
# Add Dmsf upload form
|
||||||
issue = context[:issue]
|
issue = context[:issue]
|
||||||
if User.current.allowed_to?(:file_manipulation, issue.project) &&
|
if User.current.allowed_to?(:file_manipulation, issue.project) &&
|
||||||
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable']
|
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
|
||||||
|
(issue.project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS)
|
||||||
html = "<div class=\"dmsf_uploader\">"
|
html = "<div class=\"dmsf_uploader\">"
|
||||||
html << '<p>'
|
html << '<p>'
|
||||||
html << "<label>#{l(:label_document_plural)}</label>"
|
html << "<label>#{l(:label_document_plural)}</label>"
|
||||||
@ -47,7 +48,8 @@ module RedmineDmsf
|
|||||||
# Add list of attached documents
|
# Add list of attached documents
|
||||||
issue = context[:issue]
|
issue = context[:issue]
|
||||||
if User.current.allowed_to?(:view_dmsf_files, issue.project) &&
|
if User.current.allowed_to?(:view_dmsf_files, issue.project) &&
|
||||||
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable']
|
Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
|
||||||
|
(issue.project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS)
|
||||||
links = []
|
links = []
|
||||||
for dmsf_file in issue.dmsf_files
|
for dmsf_file in issue.dmsf_files
|
||||||
if dmsf_file.last_revision
|
if dmsf_file.last_revision
|
||||||
|
|||||||
@ -48,6 +48,9 @@ module RedmineDmsf
|
|||||||
before_save :set_default_dmsf_notification
|
before_save :set_default_dmsf_notification
|
||||||
|
|
||||||
validates_length_of :dmsf_description, :maximum => 65535
|
validates_length_of :dmsf_description, :maximum => 65535
|
||||||
|
|
||||||
|
Project.const_set(:ATTACHABLE_DMS_AND_ATTACHMENTS, 1)
|
||||||
|
Project.const_set(:ATTACHABLE_ATTACHMENTS, 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user