Sha256: 8a87c3db76b714619e1a3f86d6e26634b81715fb85a47e880b5526688b04b009

Contents?: true

Size: 1.08 KB

Versions: 37

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Decidim
  module Events
    # This module is used to be included in event classes inheriting from SimpleEvent
    # whose resource has an in the "extra" options a user_group in the keyword :group.
    #
    # It adds the group_name, group_nickname, group_path and group_url to the i18n interpolations.
    module UserGroupEvent
      extend ActiveSupport::Concern

      included do
        i18n_attributes :group_name, :group_nickname, :group_path, :group_url

        def group_nickname
          group_presenter&.nickname.to_s
        end

        def group_name
          group_presenter&.name.to_s
        end

        def group_path
          group_presenter&.profile_path.to_s
        end

        def group_url
          group_presenter&.profile_url.to_s
        end

        def group_presenter
          return unless group

          @group_presenter ||= Decidim::UserGroupPresenter.new(group)
        end

        def group
          @group ||= Decidim::UserGroup.find_by(id: extra[:group_id]) if extra[:group_id]
        end
      end
    end
  end
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
decidim-core-0.29.1 lib/decidim/events/user_group_event.rb
decidim-core-0.28.4 lib/decidim/events/user_group_event.rb
decidim-core-0.27.9 lib/decidim/events/user_group_event.rb
decidim-core-0.29.0 lib/decidim/events/user_group_event.rb
decidim-core-0.28.3 lib/decidim/events/user_group_event.rb
decidim-core-0.27.8 lib/decidim/events/user_group_event.rb
decidim-core-0.29.0.rc4 lib/decidim/events/user_group_event.rb
decidim-core-0.29.0.rc3 lib/decidim/events/user_group_event.rb
decidim-core-0.29.0.rc2 lib/decidim/events/user_group_event.rb
decidim-core-0.29.0.rc1 lib/decidim/events/user_group_event.rb
decidim-core-0.28.2 lib/decidim/events/user_group_event.rb
decidim-core-0.27.7 lib/decidim/events/user_group_event.rb
decidim-core-0.28.1 lib/decidim/events/user_group_event.rb
decidim-core-0.27.6 lib/decidim/events/user_group_event.rb
decidim-core-0.26.10 lib/decidim/events/user_group_event.rb
decidim-core-0.26.9 lib/decidim/events/user_group_event.rb
decidim-core-0.28.0 lib/decidim/events/user_group_event.rb
decidim-core-0.27.5 lib/decidim/events/user_group_event.rb
decidim-core-0.28.0.rc5 lib/decidim/events/user_group_event.rb
decidim-core-0.28.0.rc4 lib/decidim/events/user_group_event.rb