Class: ActionBlocks::SubspaceBuilder
- Inherits:
-
BaseBuilder
- Object
- BaseBuilder
- ActionBlocks::SubspaceBuilder
- Defined in:
- lib/action_blocks/builders/workspace_builder.rb
Overview
class RecordPathBuilder < ActionBlocks::BaseBuilder
sets :model # currently used by table to find this
sets :subspace # What path/url to share to control active navigation
sets :recordspace # What recordspace to render
sets :dashboard # What path/url of the recordspace dashboard to control active navigation
sets :recordboard # What recordboard to render
def before_build(parent, *args)
# When Creating Links for Records of type @model
@model = args[0]
# Create Links with this information
@subspace = args[1]
@recordspace = args[2]
@dashboard = args[3]
@recordboard = args[4]
end
def hashify(user)
{
model: @model,
subspace: @subspace,
dashboard: @dashboard,
recordspace: @recordspace,
recordboard: @recordboard
}
end
end
Instance Attribute Summary collapse
-
#workspace ⇒ Object
Returns the value of attribute workspace.
Attributes inherited from BaseBuilder
Instance Method Summary collapse
- #before_build(parent, *args) ⇒ Object
- #dashboard_categories ⇒ Object
- #hashify(user) ⇒ Object
- #hashify_dashboard_categories(user) ⇒ Object
- #key ⇒ Object
Methods inherited from BaseBuilder
#after_build, #after_load, array_fields, block_type, builds, builds_many, delegate_class, #evaluate, #freeze, includes_scheme_helpers, #initialize, #is_block?, references, sets, sets_many, #ui_reference, #valid?
Constructor Details
This class inherits a constructor from ActionBlocks::BaseBuilder
Instance Attribute Details
#workspace ⇒ Object
Returns the value of attribute workspace.
141 142 143 |
# File 'lib/action_blocks/builders/workspace_builder.rb', line 141 def workspace @workspace end |
Instance Method Details
#before_build(parent, *args) ⇒ Object
154 155 156 157 158 159 160 161 |
# File 'lib/action_blocks/builders/workspace_builder.rb', line 154 def before_build(parent, *args) @workspace = parent @title = args[0].to_s.titleize @category = args[0] if args[1] @model_key = "model-#{args[1]}" end end |
#dashboard_categories ⇒ Object
163 164 165 |
# File 'lib/action_blocks/builders/workspace_builder.rb', line 163 def dashboard_categories @dashboards.map(&:category).uniq end |
#hashify(user) ⇒ Object
186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/action_blocks/builders/workspace_builder.rb', line 186 def hashify(user) { key: key, title: @title, category: @category, model: @model_key, dashboards: @dashboards.map{ |db| db.hashify(user) }, dashboard_categories: hashify_dashboard_categories(user), recordspace_keys: @recordspace_keys } end |
#hashify_dashboard_categories(user) ⇒ Object
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/action_blocks/builders/workspace_builder.rb', line 167 def hashify_dashboard_categories(user) isFirst = true results = [] dashboard_categories.each do |category| results << { first: isFirst, type: 'dashboard_categories', category: category, title: category.to_s.titleize, dashboards: @dashboards. select {|d| d.category == category}. map { |d| d.hashify(user) }, } isFirst = false end return results end |
#key ⇒ Object
150 151 152 |
# File 'lib/action_blocks/builders/workspace_builder.rb', line 150 def key "subspace-#{@id}".to_sym end |