Sha256: ad8b8c9a4db0cc102113c514fbfb96820d593bdc5deed3ccac57cbf9bf2181ae

Contents?: true

Size: 721 Bytes

Versions: 3

Compression:

Stored size: 721 Bytes

Contents

module Elabs
  module ActsHelper
    def act_action(action)
      actions = {
        create:    _('created'),
        update:    _('updated'),
        lock:      _('locked'),
        unlock:    _('unlocked'),
        publish:   _('published'),
        unpublish: _('removed from publication')
      }.freeze
      actions[action.to_sym] || "[missing: #{action}]"
    end

    def act_notice_string(act)
      string = format('%<type>s #%<id>i', type: act.content_type.demodulize, id: act.content_id)
      string = link_to string, act.content unless %w[unpublish destroy lock].include? act.event

      format(_('%<string>s has been %<event>s'), string: string, event: act_action(act.event)).html_safe
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
elabs-3.0.0 app/helpers/elabs/acts_helper.rb
elabs-2.0.0 app/helpers/elabs/acts_helper.rb
elabs-2.0.0.pre app/helpers/elabs/acts_helper.rb