#1064 Wrong sorting of Czech characters
This commit is contained in:
parent
6d454993cd
commit
b66e0df77e
@ -674,7 +674,7 @@ class DmsfController < ApplicationController
|
||||
end
|
||||
# Remove system folders you are not allowed to see because you are not allowed to see the issue or you are not
|
||||
# permitted to see system folders
|
||||
@subfolders = DmsfHelper.visible_folders(@subfolders, @project)
|
||||
@subfolders = DmsfFolder.visible_folders(@subfolders, @project)
|
||||
end
|
||||
|
||||
@ajax_upload_size = Setting.plugin_redmine_dmsf['dmsf_max_ajax_upload_filesize'].presence || 100
|
||||
|
||||
@ -98,32 +98,10 @@ module DmsfHelper
|
||||
ret
|
||||
end
|
||||
|
||||
def self.visible_folders(folders, project)
|
||||
allowed = Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
|
||||
(project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS) &&
|
||||
User.current.allowed_to?(:display_system_folders, project)
|
||||
folders.reject do |folder|
|
||||
if folder.system
|
||||
if allowed
|
||||
issue_id = folder.title.to_i
|
||||
if issue_id > 0
|
||||
issue = Issue.find_by(id: issue_id)
|
||||
issue && !issue.visible?(User.current)
|
||||
else
|
||||
false
|
||||
end
|
||||
else
|
||||
true
|
||||
end
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def self.all_children_sorted(parent, pos, ident)
|
||||
def all_children_sorted(parent, pos, ident)
|
||||
# Folders && files && links
|
||||
nodes = visible_folders(parent.dmsf_folders.visible.to_a, parent.is_a?(Project) ? parent : parent.project) + parent.dmsf_links.visible + parent.dmsf_files.visible
|
||||
nodes = DmsfFolder::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
|
||||
nodes.sort! do |x, y|
|
||||
if (x.is_a?(DmsfFolder) || (x.is_a?(DmsfLink) && x.is_folder?)) &&
|
||||
@ -133,7 +111,7 @@ module DmsfHelper
|
||||
(y.is_a?(DmsfFolder) || (y.is_a?(DmsfLink) && y.is_folder?))
|
||||
1
|
||||
else
|
||||
x.title.downcase <=> y.title.downcase
|
||||
clear_title(x.title).downcase <=> clear_title(y.title).downcase
|
||||
end
|
||||
end
|
||||
# Calculate position
|
||||
@ -154,7 +132,6 @@ module DmsfHelper
|
||||
end
|
||||
|
||||
def self.dmsf_to_csv(parent, columns)
|
||||
#Redmine::Export::CSV.generate do |csv|
|
||||
CSV.generate(:force_quotes => true, :encoding => 'UTF-8') do |csv|
|
||||
# Header
|
||||
csv << columns.map { |c| c.capitalize }
|
||||
@ -194,8 +171,8 @@ module DmsfHelper
|
||||
# Replace specifics characters with their ASCII version + 'z' in order to fix the wrong ordering
|
||||
# e.g. 'č' -> 'cz'
|
||||
def clear_title(title)
|
||||
title.gsub!(/[ěščřýáíéůúďťňĚŠČŘÝÁÍÉÚŮĎŤŇ]/) { |c| c + 'z' }
|
||||
title.tr('ěščřýáíéůúďťňĚŠČŘÝÁÍÉÚŮĎŤŇ', 'escryaieuudtnESCRYAIEUUDTN')
|
||||
str = title.gsub(/[ěščřýáíéůúďťňĚŠČŘÝÁÍÉÚŮĎŤŇ]/) { |c| c + 'z' }
|
||||
str.tr('ěščřýáíéůúďťňĚŠČŘÝÁÍÉÚŮĎŤŇ', 'escryaieuudtnESCRYAIEUUDTN')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@ -549,6 +549,29 @@ class DmsfFolder < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def self.visible_folders(folders, project)
|
||||
allowed = Setting.plugin_redmine_dmsf['dmsf_act_as_attachable'] &&
|
||||
(project.dmsf_act_as_attachable == Project::ATTACHABLE_DMS_AND_ATTACHMENTS) &&
|
||||
User.current.allowed_to?(:display_system_folders, project)
|
||||
folders.reject do |folder|
|
||||
if folder.system
|
||||
if allowed
|
||||
issue_id = folder.title.to_i
|
||||
if issue_id > 0
|
||||
issue = Issue.find_by(id: issue_id)
|
||||
issue && !issue.visible?(User.current)
|
||||
else
|
||||
false
|
||||
end
|
||||
else
|
||||
true
|
||||
end
|
||||
else
|
||||
false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.directory_subtree(tree, folder, level, current_folder)
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
%>
|
||||
|
||||
<% parent = @folder ? @folder : @project %>
|
||||
<% DmsfHelper.all_children_sorted(parent, @pos, @idnt).each do |obj, position| %>
|
||||
<% all_children_sorted(parent, @pos, @idnt).each do |obj, position| %>
|
||||
<% classes = "dmsf_tree idnt-#{@idnt} hascontextmenu" %>
|
||||
<% if obj.is_a?(DmsfFolder) && ((obj.dmsf_folders.visible.any?) || (obj.dmsf_files.visible.any?) || (obj.dmsf_links.visible.any?)) %>
|
||||
<% classes += ' idnt dmsf_collapsed dmsf-not-loaded' %>
|
||||
|
||||
@ -244,7 +244,7 @@ class DmsfControllerTest < RedmineDmsf::Test::TestCase
|
||||
@role.add_permission! :view_dmsf_folders
|
||||
get :show, :params => {id: @project.id, format: 'csv', :settings => { dmsf_columns: %w(id title) }}
|
||||
assert_response :success
|
||||
assert_equal 'text/csv', @response.content_type
|
||||
assert_equal 'text/csv; header=present', @response.content_type
|
||||
end
|
||||
|
||||
def test_show_folder_doesnt_correspond_the_project
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user