redde 0.3.22 → 0.3.23
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/assets/stylesheets/redde/blocks/list.sass +3 -1
- data/app/controllers/admin/base_controller.rb +0 -3
- data/app/helpers/redde/index_helper.rb +98 -23
- data/app/views/admin/base/edit.html.haml +4 -3
- data/app/views/admin/base/index.html.haml +3 -4
- data/lib/redde/version.rb +1 -1
- metadata +1 -2
- data/app/views/admin/base/welcome.haml +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d0efa702172d1b777179f2041fdab06a083f4f01
|
4
|
+
data.tar.gz: eb958f7bc8cc84e9524ea3f586bfa05d8d58480c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 458cdf655e6ee8990d5aafe0e48bc231112cce07c35dff89d13a01bf894182fca5842aef1c8bc9a67aeada5091537b076845c097b5c5b81d2de602ff27cd2c8c
|
7
|
+
data.tar.gz: cede951278c32817510c45fe5e2d73c72cfb875a05c2876f43f9a2ea0e188eaf302fdb21a0a74d81d37a68e1c13307ab5fec8aad31b777df0b91bbee9879b83c
|
@@ -31,6 +31,7 @@
|
|
31
31
|
background: #d7e4ef
|
32
32
|
padding-right: 0
|
33
33
|
min-width: 10px
|
34
|
+
width: 0.01%
|
34
35
|
|
35
36
|
&._img
|
36
37
|
padding-left: 20px
|
@@ -62,7 +63,8 @@
|
|
62
63
|
&:first-child,
|
63
64
|
&:last-child
|
64
65
|
padding-right: 0
|
65
|
-
width: 10px
|
66
|
+
min-width: 10px
|
67
|
+
width: 0.01%
|
66
68
|
border-bottom: 0 none
|
67
69
|
|
68
70
|
&._handle
|
@@ -11,36 +11,111 @@ module Redde::IndexHelper
|
|
11
11
|
model_name.columns.select { |i| i.type == :string }.first
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
class IndexBuilder
|
15
|
+
include ActionView::Helpers::TagHelper
|
16
|
+
include ActionView::Context
|
17
|
+
|
18
|
+
attr_accessor :list, :params
|
19
|
+
|
20
|
+
def initialize(list, params)
|
21
|
+
@list = list
|
22
|
+
@params = params
|
23
|
+
end
|
24
|
+
|
25
|
+
def empty( options = {} )
|
26
|
+
content_tag(:th, "", class: ['list__head', options[:class]])
|
27
|
+
end
|
28
|
+
|
29
|
+
def thead insert
|
30
|
+
content_tag :thead do
|
31
|
+
content_tag(:tr, empty + visible + insert + empty(class: 'list__head_del') + empty)
|
18
32
|
end
|
19
33
|
end
|
20
|
-
end
|
21
34
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
35
|
+
def visible
|
36
|
+
empty(class: '_eye') if list.column_names.include?('visible')
|
37
|
+
end
|
38
|
+
|
39
|
+
class IndexHeadCellBuilder
|
40
|
+
include ActionView::Helpers::TagHelper
|
41
|
+
include ActionView::Context
|
42
|
+
|
43
|
+
attr_accessor :list
|
44
|
+
|
45
|
+
def initialize(list)
|
46
|
+
@list = list
|
47
|
+
end
|
48
|
+
|
49
|
+
def cell field = nil, options = {}, &block
|
50
|
+
content_tag :th, list.human_attribute_name(field), class: ['list__head', options[:class]]
|
26
51
|
end
|
27
52
|
end
|
28
|
-
end
|
29
53
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
54
|
+
class IndexCellBuilder
|
55
|
+
include ActionView::Helpers
|
56
|
+
include ActionView::Context
|
57
|
+
include ActionView::Helpers::UrlHelper
|
58
|
+
include Rails.application.routes.url_helpers
|
59
|
+
include Haml::Helpers
|
60
|
+
|
61
|
+
attr_accessor :item, :builder
|
62
|
+
|
63
|
+
def initialize(item, builder)
|
64
|
+
@item = item
|
65
|
+
@builder = builder
|
66
|
+
init_haml_helpers
|
43
67
|
end
|
68
|
+
|
69
|
+
def self.content value
|
70
|
+
case value.class.name
|
71
|
+
when 'Time' then I18n.l(value, format: '%d %b %Y, %H:%M')
|
72
|
+
when 'Date' then I18n.l(value, format: '%d %b %Y')
|
73
|
+
else
|
74
|
+
value
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def cell(field, options = {}, &block)
|
79
|
+
# через content_tag ... do не работает
|
80
|
+
content_tag :td, if block_given? then capture(&block) else IndexCellBuilder.content(item.send(field)) end, class: ['list__cell', options[:class]]
|
81
|
+
end
|
82
|
+
|
83
|
+
def empty(options = {})
|
84
|
+
content_tag(:td, "", class: ['list__cell', options[:class]])
|
85
|
+
end
|
86
|
+
|
87
|
+
def handle
|
88
|
+
return content_tag(:td, "", class: ['list__cell', '_handle'], 'data-sortable-handle' => "") if item.class.column_names.include?('position')
|
89
|
+
empty
|
90
|
+
end
|
91
|
+
|
92
|
+
def visible
|
93
|
+
content_tag :td, class: 'list__cell _eye' do
|
94
|
+
link_to('', url_for(id: item, controller: builder.params[:controller], action: :update, item.class.model_name.param_key => { visible: !item.visible} ), class: ['list__eye', ('_disactive' if !item.visible)], data: { method: 'put' })
|
95
|
+
end if item.class.column_names.include?('visible')
|
96
|
+
end
|
97
|
+
|
98
|
+
def del
|
99
|
+
content_tag :td, class: 'list__cell list__cell_del' do
|
100
|
+
link_to('', url_for(id: item, action: :destroy, controller: builder.params[:controller]), method: :delete, data: { confirm: 'Точно удалить?' }, class: 'list__del')
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
def list_table(list, options = {}, &block)
|
107
|
+
raise ArgumentError, "Missing block" unless block_given?
|
108
|
+
builder = IndexBuilder.new(list, params)
|
109
|
+
|
110
|
+
html = list.map do |item|
|
111
|
+
cb = IndexBuilder::IndexCellBuilder.new(item, builder)
|
112
|
+
content_tag(:tr, cb.handle + cb.visible + capture(cb, &block) + cb.del + cb.empty, 'data-href' => url_for(id: item, action: :edit), 'data-sortable-item' => "", id: "pos_#{item.id}")
|
113
|
+
end.join.html_safe
|
114
|
+
|
115
|
+
hb = IndexBuilder::IndexHeadCellBuilder.new(list)
|
116
|
+
content_tag :table, class: ['list', options[:class]], style: options[:style], "data-sortable" => { handle: "[data-sortable-handle]" }.to_json do
|
117
|
+
concat builder.thead( capture(hb, &block) )
|
118
|
+
concat html
|
44
119
|
end
|
45
120
|
end
|
46
121
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
= redde_page do |f|
|
2
2
|
- form_column_names.each do |column|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
- if column == 'ancestry'
|
4
|
+
= f.redde_select :parent_id, ancestry_tree(model_name.roots.order(:position), title_symbol_for(instance_variable_get("@#{record}"))), include_blank: 'Корневая'
|
5
|
+
- else
|
6
|
+
= f.redde_field column.to_sym
|
6
7
|
|
7
8
|
-# %div= render 'redditor/admin/page', { f: f } if @article.methods.include?(:page)
|
8
9
|
|
@@ -1,6 +1,5 @@
|
|
1
1
|
= page_header
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
=
|
6
|
-
%td.list__cell= render_item_column(item, column)
|
3
|
+
= list_table instance_variable_get("@#{collection}") do |t|
|
4
|
+
- (index_columns - ['position', 'visible']).each do |column|
|
5
|
+
= t.cell column
|
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.23
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oleg Bovykin
|
@@ -522,7 +522,6 @@ files:
|
|
522
522
|
- app/views/admin/base/edit.html.haml
|
523
523
|
- app/views/admin/base/index.html.haml
|
524
524
|
- app/views/admin/base/tree.html.haml
|
525
|
-
- app/views/admin/base/welcome.haml
|
526
525
|
- app/views/admin/managers/edit.html.haml
|
527
526
|
- app/views/admin/redde/_header.html.haml
|
528
527
|
- app/views/admin/redde/_list.html.haml
|