Class: Flexite::Config
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Flexite::Config
show all
- Defined in:
- app/models/flexite/config.rb,
app/services/flexite/config/update_service.rb
Defined Under Namespace
Classes: CreateService, Form, UpdateService
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.tree_view(parent_id) ⇒ Object
27
28
29
30
31
32
|
# File 'app/models/flexite/config.rb', line 27
def self.tree_view(parent_id)
joins("LEFT JOIN #{table_name} AS configs_#{table_name} ON configs_#{table_name}.config_id = #{table_name}.id")
.joins("LEFT JOIN #{Entry.table_name} ON #{Entry.table_name}.parent_id = #{table_name}.id AND #{Entry.table_name}.parent_type = '#{model_name}'")
.select(["#{table_name}.id", "#{table_name}.selectable", "#{table_name}.name", "#{table_name}.updated_at", "COUNT(configs_#{table_name}.id) as nodes_count", "#{Entry.table_name}.id AS entry_id"])
.where(config_id: parent_id).group("#{table_name}.id")
end
|
Instance Method Details
#entry_id ⇒ Object
38
39
40
|
# File 'app/models/flexite/config.rb', line 38
def entry_id
self[:entry_id]
end
|
#nodes ⇒ Object
42
43
44
45
46
47
48
|
# File 'app/models/flexite/config.rb', line 42
def nodes
if selectable
return nil
end
nodes_count > 0 ? [] : nil
end
|
#nodes_count ⇒ Object
34
35
36
|
# File 'app/models/flexite/config.rb', line 34
def nodes_count
self[:nodes_count].to_i
end
|
#to_tree_node ⇒ Object
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'app/models/flexite/config.rb', line 13
def to_tree_node
{
id: id,
editHref: Engine.routes.url_helpers.edit_config_path(self),
selfHref: Engine.routes.url_helpers.config_path(self),
newHref: Engine.routes.url_helpers.new_config_config_path(self),
text: name,
dataHref: selectable ? entry_href : configs_href,
nodes: nodes,
selectable: true,
ajaxOnSelect: selectable
}
end
|