effective_bootstrap 0.9.35 → 0.9.39
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/effective_has_many/initialize.js.coffee +20 -1
- data/app/assets/stylesheets/effective_has_many/input.scss +4 -0
- data/app/helpers/effective_bootstrap_helper.rb +16 -5
- data/app/models/effective/form_inputs/article_editor.rb +12 -4
- data/app/models/effective/form_inputs/has_many.rb +71 -7
- data/lib/effective_bootstrap/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac9e0d6013b991db010ef717fe181ea041d2d9e756e0bb477d9ff7544248b718
|
4
|
+
data.tar.gz: f212aea0848dd0d7d50b0186b798ce9cb52d8c5e17bba7f4cfd63b69cc716861
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a87134d9311b1837d06e9e37857c03930a52cb0c211a2bd1dd05276ecd7eca76d57615e71cea80b271b9f11a7469647ff4915f790330f19ddd8a2c185a0604c6
|
7
|
+
data.tar.gz: 35fca4a527a44b58237cc6e71ab8846aa4da76d0f1c7e82078d272323bfb90be12ca16c4f27574603b118a90f5831753fb0e010bc7e5586626c982cf8be33901
|
@@ -36,8 +36,27 @@ $(document).on 'click', '[data-effective-form-has-many-add]', (event) ->
|
|
36
36
|
template = atob($obj.data('effective-form-has-many-template')).replace(/HASMANYINDEX/g, uid)
|
37
37
|
|
38
38
|
$fields = $(template).hide().fadeIn('fast')
|
39
|
-
EffectiveBootstrap.initialize($fields)
|
40
39
|
$obj.closest('.has-many-links').before($fields)
|
40
|
+
EffectiveBootstrap.initialize($fields)
|
41
|
+
|
42
|
+
assignPositions($hasMany)
|
43
|
+
true
|
44
|
+
|
45
|
+
$(document).on 'click', '[data-effective-form-has-many-insert]', (event) ->
|
46
|
+
event.preventDefault()
|
47
|
+
|
48
|
+
$obj = $(event.currentTarget)
|
49
|
+
$hasMany = $obj.closest('.form-has-many')
|
50
|
+
return unless $hasMany.length > 0
|
51
|
+
|
52
|
+
$add = $hasMany.children('.has-many-links').find('[data-effective-form-has-many-template]')
|
53
|
+
|
54
|
+
uid = (new Date).valueOf()
|
55
|
+
template = atob($add.data('effective-form-has-many-template')).replace(/HASMANYINDEX/g, uid)
|
56
|
+
|
57
|
+
$fields = $(template).hide().fadeIn('fast')
|
58
|
+
$obj.closest('.has-many-fields').before($fields)
|
59
|
+
EffectiveBootstrap.initialize($fields)
|
41
60
|
|
42
61
|
assignPositions($hasMany)
|
43
62
|
true
|
@@ -3,12 +3,16 @@
|
|
3
3
|
.has-many-move { display: none; }
|
4
4
|
.has-many-remove-disabled { opacity: 0; cursor: default !important; }
|
5
5
|
|
6
|
+
.has-many-actions { margin-bottom: 0.75rem; }
|
6
7
|
.has-many-remove { margin-top: 1rem; }
|
7
8
|
.has-many-move { margin-top: 1.5rem; }
|
8
9
|
}
|
9
10
|
|
10
11
|
.form-has-many.reordering {
|
12
|
+
.has-many-actions { display: none; }
|
11
13
|
.has-many-move { display: inline-block; cursor: grab; }
|
14
|
+
|
15
|
+
.form-has-many { display: none; }
|
12
16
|
}
|
13
17
|
|
14
18
|
.form-has-many.tight {
|
@@ -10,7 +10,7 @@ module EffectiveBootstrapHelper
|
|
10
10
|
def accordion(options = nil, &block)
|
11
11
|
(options ||= {})[:class] = "accordion #{options.delete(:class)}".strip
|
12
12
|
|
13
|
-
id = "accordion-#{
|
13
|
+
id = "accordion-#{effective_bootstrap_unique_id}"
|
14
14
|
|
15
15
|
@_accordion_active = id
|
16
16
|
content = content_tag(:div, capture(&block), options.merge(id: id))
|
@@ -62,7 +62,7 @@ module EffectiveBootstrapHelper
|
|
62
62
|
def collapse(label, opts = {}, &block)
|
63
63
|
raise 'expected a block' unless block_given?
|
64
64
|
|
65
|
-
id = "collapse-#{
|
65
|
+
id = "collapse-#{effective_bootstrap_unique_id}"
|
66
66
|
show = (opts.delete(:show) == true)
|
67
67
|
|
68
68
|
link_opts = { 'data-toggle': 'collapse', role: 'button', href: "##{id}", 'aria-controls': "##{id}", 'aria-expanded': show }
|
@@ -259,7 +259,7 @@ module EffectiveBootstrapHelper
|
|
259
259
|
def nav_dropdown(label, right: false, link_class: [], list_class: [], &block)
|
260
260
|
raise 'expected a block' unless block_given?
|
261
261
|
|
262
|
-
id = "dropdown-#{
|
262
|
+
id = "dropdown-#{effective_bootstrap_unique_id}"
|
263
263
|
|
264
264
|
content_tag(:li, class: 'nav-item dropdown') do
|
265
265
|
content_tag(:a, class: 'nav-link dropdown-toggle', href: '#', id: id, role: 'button', 'data-toggle': 'dropdown', 'aria-haspopup': true, 'aria-expanded': false) do
|
@@ -436,7 +436,7 @@ module EffectiveBootstrapHelper
|
|
436
436
|
|
437
437
|
@_tab_mode = :tablist
|
438
438
|
@_tab_active = (active || :first)
|
439
|
-
@_tab_unique =
|
439
|
+
@_tab_unique = effective_bootstrap_unique_id if unique
|
440
440
|
|
441
441
|
content_tag(:ul, {class: 'nav nav-tabs', role: 'tablist'}.merge(list)) do
|
442
442
|
yield # Yield to tab the first time
|
@@ -476,7 +476,7 @@ module EffectiveBootstrapHelper
|
|
476
476
|
|
477
477
|
@_tab_mode = :tablist_vertical
|
478
478
|
@_tab_active = (active || :first)
|
479
|
-
@_tab_unique =
|
479
|
+
@_tab_unique = effective_bootstrap_unique_id if unique
|
480
480
|
|
481
481
|
content_tag(:div, class: 'row border') do
|
482
482
|
content_tag(:div, class: 'col-3 border-right') do
|
@@ -504,4 +504,15 @@ module EffectiveBootstrapHelper
|
|
504
504
|
end
|
505
505
|
end
|
506
506
|
|
507
|
+
def effective_bootstrap_unique_id
|
508
|
+
# Set the first unique value
|
509
|
+
@_effective_bootstrap_unique_id ||= Time.zone.now.to_i
|
510
|
+
|
511
|
+
# Everytime we access this function make a new one
|
512
|
+
@_effective_bootstrap_unique_id = @_effective_bootstrap_unique_id + 1
|
513
|
+
|
514
|
+
# Return the updated value
|
515
|
+
@_effective_bootstrap_unique_id
|
516
|
+
end
|
517
|
+
|
507
518
|
end
|
@@ -6,9 +6,9 @@ module Effective
|
|
6
6
|
def self.defaults
|
7
7
|
{
|
8
8
|
active_storage: nil,
|
9
|
-
css: '/assets/article_editor/',
|
9
|
+
css: ['/assets/article_editor/arx-frame.min.css'],
|
10
10
|
custom: {
|
11
|
-
css: ['/assets/
|
11
|
+
css: ['/assets/effective_bootstrap_article_editor.css']
|
12
12
|
},
|
13
13
|
classes: {
|
14
14
|
body: 'article-editor-body',
|
@@ -40,7 +40,7 @@ module Effective
|
|
40
40
|
'12': 'col-sm-12'
|
41
41
|
}
|
42
42
|
},
|
43
|
-
plugins: ['blockcode', 'cellcolor', 'imageposition', 'imageresize', 'inlineformat', 'removeformat', 'reorder', 'style'],
|
43
|
+
plugins: ['blockcode', 'cellcolor', 'imageposition', 'imageresize', 'inlineformat', 'listitem', 'removeformat', 'reorder', 'style'],
|
44
44
|
quote: {
|
45
45
|
template: '<blockquote><p></p></blockquote>'
|
46
46
|
},
|
@@ -75,7 +75,15 @@ module Effective
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def input_js_options
|
78
|
-
self.class.defaults.merge(active_storage: active_storage)
|
78
|
+
self.class.defaults.merge(active_storage: active_storage, custom: { css: custom_css })
|
79
|
+
end
|
80
|
+
|
81
|
+
def custom_css
|
82
|
+
[
|
83
|
+
(@template.asset_pack_path('application.css') if @template.respond_to?(:asset_pack_path)),
|
84
|
+
(@template.asset_path('application.css') if @template.respond_to?(:asset_path)),
|
85
|
+
('/assets/effective_bootstrap_article_editor.css')
|
86
|
+
]
|
79
87
|
end
|
80
88
|
|
81
89
|
def active_storage
|
@@ -51,6 +51,20 @@ module Effective
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
# insert: false
|
55
|
+
def insert
|
56
|
+
return @insert unless @insert.nil?
|
57
|
+
|
58
|
+
@insert ||= begin
|
59
|
+
insert = options[:input].delete(:insert)
|
60
|
+
insert.nil? ? false : insert
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def insert?
|
65
|
+
!!insert
|
66
|
+
end
|
67
|
+
|
54
68
|
# errors: true
|
55
69
|
def errors?
|
56
70
|
return @errors unless @errors.nil?
|
@@ -62,7 +76,7 @@ module Effective
|
|
62
76
|
end
|
63
77
|
|
64
78
|
# remove: true
|
65
|
-
def remove
|
79
|
+
def remove
|
66
80
|
return @remove unless @remove.nil?
|
67
81
|
|
68
82
|
@remove ||= begin
|
@@ -77,6 +91,10 @@ module Effective
|
|
77
91
|
end
|
78
92
|
end
|
79
93
|
|
94
|
+
def remove?
|
95
|
+
!!remove
|
96
|
+
end
|
97
|
+
|
80
98
|
def can_remove_method
|
81
99
|
return @can_remove_method unless @can_remove_method.nil?
|
82
100
|
@can_remove_method = (options[:input].delete(:can_remove_method) || false)
|
@@ -114,6 +132,7 @@ module Effective
|
|
114
132
|
def render_resource(resource, block)
|
115
133
|
remove = BLANK
|
116
134
|
reorder = BLANK
|
135
|
+
insert = BLANK
|
117
136
|
can_remove = (can_remove_method.blank? || !!resource.send(can_remove_method))
|
118
137
|
|
119
138
|
content = @builder.fields_for(name, resource) do |form|
|
@@ -129,7 +148,11 @@ module Effective
|
|
129
148
|
remove += (can_remove || resource.new_record?) ? link_to_remove(resource) : disabled_link_to_remove(resource)
|
130
149
|
end
|
131
150
|
|
132
|
-
|
151
|
+
if insert?
|
152
|
+
insert = render_insert() if add? && reorder?
|
153
|
+
end
|
154
|
+
|
155
|
+
content_tag(:div, insert + render_fields(content, remove + reorder), class: 'has-many-fields')
|
133
156
|
end
|
134
157
|
|
135
158
|
def render_fields(content, remove)
|
@@ -141,12 +164,25 @@ module Effective
|
|
141
164
|
content_tag(:div, remove, class: 'col-auto')
|
142
165
|
end
|
143
166
|
when :cards
|
144
|
-
|
167
|
+
content_tag(:div, class: 'form-row mb-3') do
|
168
|
+
(reorder? ? content_tag(:div, has_many_move, class: 'col-auto') : BLANK) +
|
169
|
+
content_tag(:div, content, class: 'col mr-auto') do
|
170
|
+
content_tag(:div, class: 'card') do
|
171
|
+
content_tag(:div, class: 'card-body') do
|
172
|
+
content_tag(:div, remove, class: 'float-right') + content
|
173
|
+
end
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
145
177
|
else
|
146
178
|
content + remove
|
147
179
|
end
|
148
180
|
end
|
149
181
|
|
182
|
+
def render_insert()
|
183
|
+
content_tag(:div, link_to_insert(), class: 'has-many-actions')
|
184
|
+
end
|
185
|
+
|
150
186
|
def render_template(block)
|
151
187
|
resource = build_resource()
|
152
188
|
index = collection.length
|
@@ -176,6 +212,27 @@ module Effective
|
|
176
212
|
)
|
177
213
|
end
|
178
214
|
|
215
|
+
# f.has_many :things, insert: { label: (icon('plus-circle') + 'Insert Article') }
|
216
|
+
# f.has_many :things, insert: (icon('plus-circle') + 'Insert Article')
|
217
|
+
def link_to_insert
|
218
|
+
tag = (insert[:tag] if insert.kind_of?(Hash))
|
219
|
+
title = (insert[:title] || insert[:label] if insert.kind_of?(Hash))
|
220
|
+
html_class = (insert[:class] if insert.kind_of?(Hash))
|
221
|
+
|
222
|
+
label = (insert[:label] if insert.kind_of?(Hash))
|
223
|
+
label = insert if insert.kind_of?(String)
|
224
|
+
|
225
|
+
content_tag(
|
226
|
+
(tag || :button),
|
227
|
+
(label || (icon('plus-circle') + 'Insert Another')),
|
228
|
+
class: 'has-many-insert ' + (html_class || 'btn btn-secondary'),
|
229
|
+
title: (title || 'Insert Another'),
|
230
|
+
data: {
|
231
|
+
'effective-form-has-many-insert': true,
|
232
|
+
}
|
233
|
+
)
|
234
|
+
end
|
235
|
+
|
179
236
|
def link_to_reorder(block)
|
180
237
|
content_tag(
|
181
238
|
:button,
|
@@ -189,11 +246,18 @@ module Effective
|
|
189
246
|
end
|
190
247
|
|
191
248
|
def link_to_remove(resource)
|
249
|
+
tag = (remove[:tag] if remove.kind_of?(Hash))
|
250
|
+
title = (remove[:title] || remove[:label] if remove.kind_of?(Hash))
|
251
|
+
html_class = (remove[:class] if remove.kind_of?(Hash))
|
252
|
+
|
253
|
+
label = (remove[:label] if remove.kind_of?(Hash))
|
254
|
+
label = remove if remove.kind_of?(String)
|
255
|
+
|
192
256
|
content_tag(
|
193
|
-
:button,
|
194
|
-
icon('trash-2'),
|
195
|
-
class: 'has-many-remove btn btn-danger',
|
196
|
-
title: 'Remove',
|
257
|
+
(tag || :button),
|
258
|
+
(label || icon('trash-2')),
|
259
|
+
class: 'has-many-remove ' + (html_class || 'btn btn-danger'),
|
260
|
+
title: (title || 'Remove'),
|
197
261
|
data: {
|
198
262
|
'confirm': "Remove #{resource}?",
|
199
263
|
'effective-form-has-many-remove': true,
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_bootstrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.39
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|