effective_bootstrap 0.9.38 → 0.9.39
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
|
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 {
|
|
@@ -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-07-
|
|
11
|
+
date: 2021-07-28 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|