Module: VersionsHelper

Defined in:
app/helpers/versions_helper.rb

Overview

Copyright © 2008-2013 Michael Dvorkin and contributors.

Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php


Instance Method Summary collapse

Instance Method Details

#parse_version(attr_name, change) ⇒ Object

Parse the changes for each version




11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/versions_helper.rb', line 11

def parse_version(attr_name, change)
  if attr_name =~ /\Acf_/ && (field = CustomField.where(name: attr_name).first).present?
    label = field.label
    first = field.render(change.first)
    second = field.render(change.second)
  else
    label = t(attr_name)
    first = change.first
    second = change.second
  end

  # Find account and link to it.
  if attr_name == 'account_id'
    if first.present? && ( = Account.find_by_id(first))
      first = link_to(h(.name), ())
    end
    if second.present? && ( = Account.find_by_id(second))
      second = link_to(h(.name), ())
    end
  end

  [label, first, second]
end