Sha256: cb8f220f74d1dbc46d99ee83c5bd8e0153597846cca1d921254b1c6b8b9afac5

Contents?: true

Size: 1.17 KB

Versions: 13

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

# Copyright (c) 2008-2013 Michael Dvorkin and contributors.
#
# Fat Free CRM is freely distributable under the terms of MIT license.
# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php
#------------------------------------------------------------------------------
module VersionsHelper
  # Parse the changes for each version
  #----------------------------------------------------------------------------
  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 = Account.find_by_id(first))
        first = link_to(h(account.name), account_path(account))
      end
      if second.present? && (account = Account.find_by_id(second))
        second = link_to(h(account.name), account_path(account))
      end
    end

    [label, first, second]
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
fat_free_crm-0.22.1 app/helpers/versions_helper.rb
fat_free_crm-0.22.0 app/helpers/versions_helper.rb
fat_free_crm-0.21.0 app/helpers/versions_helper.rb
fat_free_crm-0.20.1 app/helpers/versions_helper.rb
fat_free_crm-0.20.0 app/helpers/versions_helper.rb
fat_free_crm-0.19.2 app/helpers/versions_helper.rb
fat_free_crm-0.19.0 app/helpers/versions_helper.rb
fat_free_crm-0.18.2 app/helpers/versions_helper.rb
fat_free_crm-0.17.3 app/helpers/versions_helper.rb
fat_free_crm-0.18.1 app/helpers/versions_helper.rb
fat_free_crm-0.18.0 app/helpers/versions_helper.rb
fat_free_crm-0.17.2 app/helpers/versions_helper.rb
fat_free_crm-0.17.1 app/helpers/versions_helper.rb