Sha256: 8a06f0238e470c15ef8b3394f63c4d016c9eb3b9ef8c145f04acd87a7b8c02a9

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 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
	  	self.organization_ids.map do |uid|
	    	MnoEnterprise::Organization.find_by(uid: uid)
	  	end
	  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

    def to_audit_event
      name
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mno-enterprise-core-2.0.5 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-2.0.4 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-2.0.3 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-2.0.2 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-2.0.1 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-3.0.0 app/models/mno_enterprise/impac/dashboard.rb
mno-enterprise-core-2.0.0 app/models/mno_enterprise/impac/dashboard.rb