From 68130a67180b74e88fc45767c8bd55fe83935ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Pi=C4=8Dman?= Date: Tue, 12 Mar 2019 18:41:25 +0100 Subject: [PATCH] Use the standard helper function for displaying custom values --- app/models/dmsf_file.rb | 8 ++------ app/models/dmsf_folder.rb | 6 ++++-- app/views/dmsf/_dir.html.erb | 2 +- app/views/dmsf/_dir_trash.html.erb | 2 +- app/views/dmsf/_file.html.erb | 2 +- app/views/dmsf/_file_trash.html.erb | 2 +- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/models/dmsf_file.rb b/app/models/dmsf_file.rb index 801649dd..bbb6deb2 100644 --- a/app/models/dmsf_file.rb +++ b/app/models/dmsf_file.rb @@ -500,11 +500,7 @@ class DmsfFile < ActiveRecord::Base def custom_value(custom_field) last_revision.custom_field_values.each do |cv| if cv.custom_field == custom_field - if cv.value.is_a? Array - return cv.value.reject{ |x| x.empty? }.join(',') - else - return cv.value - end + return cv end end nil @@ -584,7 +580,7 @@ class DmsfFile < ActiveRecord::Base end # Custom fields CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| - csv << custom_value(c) if columns.include?(c.name) + csv << custom_value(c).value if columns.include?(c.name) end csv end diff --git a/app/models/dmsf_folder.rb b/app/models/dmsf_folder.rb index 016f49de..42592636 100644 --- a/app/models/dmsf_folder.rb +++ b/app/models/dmsf_folder.rb @@ -348,7 +348,9 @@ class DmsfFolder < ActiveRecord::Base def custom_value(custom_field) custom_field_values.each do |cv| - return cv.value if cv.custom_field == custom_field + if cv.custom_field == custom_field + return cv + end end nil end @@ -475,7 +477,7 @@ class DmsfFolder < ActiveRecord::Base csv << '' if columns.include?(l(:label_last_revision_id)) # Custom fields CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| - csv << custom_value(c) if columns.include?(c.name) + csv << custom_value(c).value if columns.include?(c.name) end csv end diff --git a/app/views/dmsf/_dir.html.erb b/app/views/dmsf/_dir.html.erb index 5085a21f..c943fd7b 100644 --- a/app/views/dmsf/_dir.html.erb +++ b/app/views/dmsf/_dir.html.erb @@ -75,7 +75,7 @@ <% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %> <% if DmsfFolder.is_column_on?(c.name) %> - <%= subfolder.custom_value(c) if subfolder %> + <%= show_value(subfolder.custom_value(c)) if subfolder %> <% end %> <% end %> diff --git a/app/views/dmsf/_dir_trash.html.erb b/app/views/dmsf/_dir_trash.html.erb index add594ef..5988a470 100644 --- a/app/views/dmsf/_dir_trash.html.erb +++ b/app/views/dmsf/_dir_trash.html.erb @@ -59,7 +59,7 @@ <% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %> <% if DmsfFolder.is_column_on?(c.name) %> - <%= subfolder.custom_value(c) if subfolder %> + <%= show_value(subfolder.custom_value(c)) if subfolder %> <% end %> <% end %> diff --git a/app/views/dmsf/_file.html.erb b/app/views/dmsf/_file.html.erb index 680e58e0..831d7cce 100644 --- a/app/views/dmsf/_file.html.erb +++ b/app/views/dmsf/_file.html.erb @@ -79,7 +79,7 @@ <% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %> <% if DmsfFolder.is_column_on?(c.name) %> - <%= file.custom_value(c) %> + <%= show_value file.custom_value(c) %> <% end %> <% end %> diff --git a/app/views/dmsf/_file_trash.html.erb b/app/views/dmsf/_file_trash.html.erb index 7159093b..47484704 100644 --- a/app/views/dmsf/_file_trash.html.erb +++ b/app/views/dmsf/_file_trash.html.erb @@ -59,7 +59,7 @@ <% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %> <% if DmsfFolder.is_column_on?(c.name) %> - <%= file.custom_value(c) %> + <%= show_value file.custom_value(c) %> <% end %> <% end %>