Use the standard helper function for displaying custom values

This commit is contained in:
Karel Pičman 2019-03-12 18:41:25 +01:00
parent 99c6a15795
commit 68130a6718
6 changed files with 10 additions and 12 deletions

View File

@ -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

View File

@ -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

View File

@ -75,7 +75,7 @@
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
<% if DmsfFolder.is_column_on?(c.name) %>
<td class="dmsf_cf">
<%= subfolder.custom_value(c) if subfolder %>
<%= show_value(subfolder.custom_value(c)) if subfolder %>
</td>
<% end %>
<% end %>

View File

@ -59,7 +59,7 @@
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
<% if DmsfFolder.is_column_on?(c.name) %>
<td class="dmsf_cf">
<%= subfolder.custom_value(c) if subfolder %>
<%= show_value(subfolder.custom_value(c)) if subfolder %>
</td>
<% end %>
<% end %>

View File

@ -79,7 +79,7 @@
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
<% if DmsfFolder.is_column_on?(c.name) %>
<td class="dmsf_cf">
<%= file.custom_value(c) %>
<%= show_value file.custom_value(c) %>
</td>
<% end %>
<% end %>

View File

@ -59,7 +59,7 @@
<% CustomField.where(type: 'DmsfFileRevisionCustomField').order(:position).each do |c| %>
<% if DmsfFolder.is_column_on?(c.name) %>
<td class="dmsf_cf">
<%= file.custom_value(c) %>
<%= show_value file.custom_value(c) %>
</td>
<% end %>
<% end %>