Sha256: 916103d3de321726f41a04099261d7a1d8d5f37c4c9dcaf6ba5a808f9a3577e7

Contents?: true

Size: 1.4 KB

Versions: 6

Compression:

Stored size: 1.4 KB

Contents

module MnoEnterprise
  class Impac::Dashboard < BaseResource

    attributes :name, :widgets_order, :organization_ids, :widgets_templates, :currency

    has_many :widgets, class_name: 'MnoEnterprise::Impac::Widget', dependent: :destroy
    has_many :kpis, class_name: 'MnoEnterprise::Impac::Kpi', dependent: :destroy
    belongs_to :owner, polymorphic: true

    #============================================
    # Instance methods
    #============================================
    # Return the full name of this dashboard
    # Currently a simple accessor to the dashboard name (used to include the company name)
    def full_name
      self.name
    end

    # Return all the organizations linked to this dashboard and to which
    # the user has access
    def organizations
      MnoEnterprise::Organization.where('uid.in' => self.organization_ids).to_a
    end

    def sorted_widgets
      order = self.widgets_order.map(&:to_i) | self.widgets.map{|w| w.id }
      order.map { |id| self.widgets.to_a.find{ |w| w.id == id} }.compact
    end

    # Filter widgets list based on config
    def filtered_widgets_templates
      if MnoEnterprise.widgets_templates_listing
        return self.widgets_templates.select do |t|
          MnoEnterprise.widgets_templates_listing.include?(t[:path])
        end
      else
        return self.widgets_templates
      end
    end

    def to_audit_event
      name
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mno-enterprise-core-3.1.4 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-3.0.7 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-3.1.3 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-3.0.6 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-3.1.2 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-3.0.5 app/models/mno_enterprise/impac/dashboard.rb