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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b20e80d5aa589293434167198fb19cf11781a9a
4
- data.tar.gz: 0fbd0777cb468990d48ac661129f17bf911c2a4a
3
+ metadata.gz: 9ee9c12645cc53a3675c450f41c7c03b4a7996fb
4
+ data.tar.gz: 9075982586a39f0613bfd16104ce28bf6a0976ff
5
5
  SHA512:
6
- metadata.gz: 6d69ff6e8d66f00fe97b06eb5382ec7f3266d290c79a379f011f146e25bc90a689bf0d80df8e6c41b27a74e5bd6af9a409c88ea63882d5cd087e75f25954e8c0
7
- data.tar.gz: 4a3d13d84b614a5bec5a45f73b9383246bb79eaef4106cd328c394f633ceceb20e7715cfe65c5a28fa42e61ce0de1e1a50fd163d47ec520dedc57669199ef0f1
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(ancestry position created_at updated_at id)
3
+ IGNORED_COLUMNS = %w(position created_at updated_at id)
4
4
  def title_for(item)
5
- return item.title if column_names.include?('title')
6
- return item.name if column_names.include?('name')
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
- column_names.each do |column|
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 ancestry_options(items, symbol = :name)
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, options_from_collection_for_select(f.object.class.all, :id, :title, f.object.parent_id), { include_blank: '- Выбрать -' }
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
@@ -1,3 +1,3 @@
1
1
  module Redde
2
- VERSION = '0.3.10'.freeze
2
+ VERSION = '0.3.11'.freeze
3
3
  end
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.10
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-11 00:00:00.000000000 Z
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.4.5.1
586
+ rubygems_version: 2.5.1
587
587
  signing_key:
588
588
  specification_version: 4
589
589
  summary: Admin scaffold generator for redde projects