Sha256: eff63752de3a4d80123fcacb77b53144762d9cfcd8ca4f5f18894975326b41fc
Contents?: true
Size: 1.87 KB
Versions: 17
Compression:
Stored size: 1.87 KB
Contents
module KirguduBase module DynamicPages class MenuItem < ::KirguduBase::DynamicPages::PageElement mergeable_attributes :label, :link, :target, :controller_link, :items fixable_attributes :items, :controller_link validates_presence_of :label #validates_presence_of :link, if: controller_link == nil validates_presence_of :target validates_inclusion_of :target, in: ::KirguduBase::DynamicPages::Enums::SUPPORTED_LINK_TARGETS, allow_nil: true def initialize(options = {}) self.label = nil self.link = nil self.target = :same self.controller_link = nil self.items = nil super(options) end attr_accessor :label attr_accessor :link attr_accessor :target attr_accessor :controller_link attr_accessor :items def to_external_hash(options = {}) options ||= {} options.merge!({ #url: self.url, #data_format: self.data_format, #http_method: self.http_method, #label_property: self.label_property, #value_property: self.value_property }) super(options) end def build_url(controller, prms) if self.link self.link else link_ids = {} if self.controller_link.id link_ids[self.controller_link.id.to] = prms[self.controller_link.id.from] elsif self.controller_link.ids self.controller_link.ids.each do |id| link_ids[id.to] = prms[id.from] end else prms.each_pair do |key, value| link_ids[key] = value end end kontroller_klass = nil if self.controller_link.controller.is_a?(String) kontroller_klass = eval(self.controller_link.controller) else kontroller_klass = self.controller_link.controller end kontroller_klass.to_url_for(self.controller_link.action, link_ids) end end end end end
Version data entries
17 entries across 17 versions & 1 rubygems