redde 0.3.10 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/helpers/redde/index_helper.rb +23 -6
- data/app/views/admin/base/edit.html.haml +1 -1
- data/lib/redde/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ee9c12645cc53a3675c450f41c7c03b4a7996fb
|
4
|
+
data.tar.gz: 9075982586a39f0613bfd16104ce28bf6a0976ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ae3d469cdcb9281fd6c3ee760b327fbea46a451ba7e6b3da28659d51df737b6facf306ad51a4e2dccfa8660e062916e0b83433312bb80b4887833e5a6c353f5
|
7
|
+
data.tar.gz: bdc2fde36b52b309343cb21fae9bf3fc13a9b325f695aadf947f995068450bf329fd1014d6db15909e7829d58df514d1a410c3d371bd5a4d2b86e378ad5daa2b
|
@@ -1,9 +1,13 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
module Redde::IndexHelper
|
3
|
-
IGNORED_COLUMNS = %w(
|
3
|
+
IGNORED_COLUMNS = %w(position created_at updated_at id)
|
4
4
|
def title_for(item)
|
5
|
-
|
6
|
-
|
5
|
+
item.send(title_symbol_for(item))
|
6
|
+
end
|
7
|
+
|
8
|
+
def title_symbol_for(item)
|
9
|
+
return 'title' if column_names.include?('title')
|
10
|
+
return 'name' if column_names.include?('name')
|
7
11
|
model_name.columns.select { |i| i.type == :string }.first
|
8
12
|
end
|
9
13
|
|
@@ -17,7 +21,7 @@ module Redde::IndexHelper
|
|
17
21
|
|
18
22
|
def list_table_row item, &block
|
19
23
|
render layout: 'admin/redde/row', locals: { item: item } do
|
20
|
-
|
24
|
+
index_columns.each do |column|
|
21
25
|
concat list_table_cell(item, column, &block)
|
22
26
|
end
|
23
27
|
end
|
@@ -59,7 +63,14 @@ module Redde::IndexHelper
|
|
59
63
|
.sort { |a, b| sort_priority(a) <=> sort_priority(b) }
|
60
64
|
end
|
61
65
|
|
66
|
+
def index_columns
|
67
|
+
return model_name.INDEX_COLUMNS if defined?(model_name.INDEX_COLUMNS)
|
68
|
+
column_names
|
69
|
+
end
|
70
|
+
|
62
71
|
def form_column_names
|
72
|
+
return model_name.FORM_COLUMNS if defined?(model_name.FORM_COLUMNS)
|
73
|
+
return model_name.INDEX_COLUMNS if defined?(model_name.INDEX_COLUMNS)
|
63
74
|
column_names.select { |i| !IGNORED_COLUMNS.include?(i) }
|
64
75
|
end
|
65
76
|
|
@@ -108,11 +119,17 @@ module Redde::IndexHelper
|
|
108
119
|
content_tag :li, raw(html), id: "list_#{c.id}"
|
109
120
|
end
|
110
121
|
|
111
|
-
def
|
122
|
+
def ancestry_tree(obj_class, symbol)
|
123
|
+
ancestry_options(obj_class.unscoped.arrange(order: :position), symbol) { |i| "#{'--' * i.depth} #{i.send(symbol)}" }
|
124
|
+
end
|
125
|
+
|
126
|
+
def ancestry_options(items, symbol = :name, &block)
|
127
|
+
return ancestry_options(items, symbol) { |i| "#{'-' * i.depth} #{i.send(symbol)}" } unless block_given?
|
128
|
+
|
112
129
|
result = []
|
113
130
|
items.map do |item, sub_items|
|
114
131
|
result << [yield(item), item.id]
|
115
|
-
result += ancestry_options(sub_items) { |i| "#{'---' * i.depth} #{i.send(symbol)}" }
|
132
|
+
result += ancestry_options(sub_items, symbol) { |i| "#{'---' * i.depth} #{i.send(symbol)}" }
|
116
133
|
end
|
117
134
|
result
|
118
135
|
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
- form_column_names.each do |column|
|
3
3
|
= f.redde_field column.to_sym
|
4
4
|
- if column_names.include?('ancestry')
|
5
|
-
= f.redde_select :parent_id,
|
5
|
+
= f.redde_select :parent_id, ancestry_tree(model_name.roots.order(:position), title_symbol_for(instance_variable_get("@#{record}"))), include_blank: 'Корневая'
|
6
6
|
|
7
7
|
-# %div= render 'redditor/admin/page', { f: f } if @article.methods.include?(:page)
|
8
8
|
|
data/lib/redde/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redde
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Bovykin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-03-
|
12
|
+
date: 2016-03-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: jquery-rails
|
@@ -583,7 +583,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
583
583
|
version: '0'
|
584
584
|
requirements: []
|
585
585
|
rubyforge_project:
|
586
|
-
rubygems_version: 2.
|
586
|
+
rubygems_version: 2.5.1
|
587
587
|
signing_key:
|
588
588
|
specification_version: 4
|
589
589
|
summary: Admin scaffold generator for redde projects
|