activeadmin_polymorphic 0.2.3 → 0.3.0
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/Gemfile +1 -0
- data/app/assets/javascripts/activeadmin_polymorphic.js.coffee +30 -7
- data/lib/activeadmin_polymorphic/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6e9bb8fba098550adca9dca00c11b4bc3fa3ec3
|
4
|
+
data.tar.gz: 2260658e276d864d4104838ebe0a4a6130193610
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73ba47366b8b609b69d1325cf6a2f5ef3e52d4abbb219116c6deb11fec0058e7e45de56bbcef7978434a7e9fa7f84e32e71cb40eb3c4aed31603ee140a444192
|
7
|
+
data.tar.gz: 90d1a036bb4f4b5cf2b001148ef67b76f5201ad41b6458b43cf2dee946bb4f4de48af29d4906312eb53a81b84dc9561a6ae63b6b2b31be9668ac31a5013e521b
|
data/Gemfile
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
#= require spin
|
2
|
+
|
3
|
+
spinner_opts =
|
4
|
+
lines: 8
|
5
|
+
length: 4
|
6
|
+
width: 3
|
7
|
+
radius: 5
|
8
|
+
|
1
9
|
$ ->
|
2
10
|
if $('.polymorphic_has_many_container').length
|
3
11
|
form = $('#main_content').find('form:first')
|
@@ -34,7 +42,7 @@ $ ->
|
|
34
42
|
|
35
43
|
extractAndInsertForm formPath, rapper
|
36
44
|
|
37
|
-
$(document).on 'click', 'a.button.polymorphic_has_many_remove', (e)->
|
45
|
+
$(document).on 'click', 'a.button.polymorphic_has_many_remove', (e) ->
|
38
46
|
e.preventDefault()
|
39
47
|
parent = $(@).closest '.polymorphic_has_many_container'
|
40
48
|
to_remove = $(@).closest 'fieldset'
|
@@ -44,7 +52,7 @@ $ ->
|
|
44
52
|
to_remove.remove()
|
45
53
|
parent.trigger 'polymorphic_has_many_remove:after', [to_remove, parent]
|
46
54
|
|
47
|
-
$(document).on 'click', 'a.button.polymorphic_has_many_add', (e)->
|
55
|
+
$(document).on 'click', 'a.button.polymorphic_has_many_add', (e) ->
|
48
56
|
e.preventDefault()
|
49
57
|
parent = $(@).closest '.polymorphic_has_many_container'
|
50
58
|
parent.trigger before_add = $.Event('polymorphic_has_many_add:before'), [parent]
|
@@ -98,7 +106,7 @@ stripEmptyRelations = ->
|
|
98
106
|
if $(@).val() == ""
|
99
107
|
$(@).parents('.polymorphic_has_many_fields').remove()
|
100
108
|
|
101
|
-
recompute_positions = (parent)->
|
109
|
+
recompute_positions = (parent) ->
|
102
110
|
parent = if parent instanceof jQuery then parent else $(@)
|
103
111
|
input_name = parent.data 'sortable'
|
104
112
|
position = parseInt(parent.data('sortable-start') || 0, 10)
|
@@ -112,23 +120,38 @@ recompute_positions = (parent)->
|
|
112
120
|
if sortable_input.length
|
113
121
|
sortable_input.val if destroy_input.is ':checked' then '' else position++
|
114
122
|
|
115
|
-
|
123
|
+
init_loading_indicator = (target) ->
|
124
|
+
spinner = new Spinner(spinner_opts).spin()
|
125
|
+
$(target).height(50).children().hide()
|
126
|
+
$(target).append spinner.el
|
127
|
+
|
128
|
+
spinner
|
129
|
+
|
130
|
+
stop_loading_indicator = (target, spinner) ->
|
131
|
+
spinner.stop()
|
132
|
+
$(target).height('').children().show()
|
133
|
+
|
134
|
+
window.extractAndInsertForm = (url, target) ->
|
116
135
|
target = $ target
|
136
|
+
spinner = init_loading_indicator(target)
|
117
137
|
container = $(target).closest '.polymorphic_has_many_container'
|
118
138
|
container.trigger "polymorphic_has_many_form:beforeInsert", [ target ]
|
119
139
|
|
120
140
|
$.ajax url,
|
121
141
|
headers:
|
122
142
|
Accept: 'text/html'
|
123
|
-
success: (data)->
|
143
|
+
success: (data) ->
|
124
144
|
elements = $(data)
|
125
145
|
form = $('#main_content form', elements).first()
|
126
146
|
$(form).find('.actions').remove()
|
127
147
|
$(form).on 'submit', -> return false
|
128
148
|
|
149
|
+
stop_loading_indicator(target, spinner)
|
129
150
|
target.prepend form
|
130
151
|
|
131
152
|
container.trigger "polymorphic_has_many_form:inserted", [form]
|
153
|
+
error: (xhr, status, error) ->
|
154
|
+
stop_loading_indicator(target, spinner)
|
132
155
|
|
133
156
|
window.loadErrors = (target) ->
|
134
157
|
$(target).off('ajax:success').off('ajax:beforeSend')
|
@@ -145,7 +168,7 @@ window.loadErrors = (target) ->
|
|
145
168
|
container = $(form).closest '.polymorphic_has_many_container'
|
146
169
|
container.trigger "polymorphic_has_many_form:inserted", [ form ]
|
147
170
|
|
148
|
-
window.remoteSubmit = (target, callback)->
|
171
|
+
window.remoteSubmit = (target, callback) ->
|
149
172
|
action = $(target).attr('action')
|
150
173
|
$(target).data('remote', true)
|
151
174
|
$(target).removeAttr('novalidate')
|
@@ -159,7 +182,7 @@ window.remoteSubmit = (target, callback)->
|
|
159
182
|
.trigger('submit.rails')
|
160
183
|
.on 'ajax:aborted:file', (inputs) ->
|
161
184
|
false
|
162
|
-
.on 'ajax:error', (event, response, status)->
|
185
|
+
.on 'ajax:error', (event, response, status) ->
|
163
186
|
if response.status == 422
|
164
187
|
loadErrors(target)
|
165
188
|
.on 'ajax:success', (event, object, status, response) ->
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activeadmin_polymorphic
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Sergeev
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-10-
|
12
|
+
date: 2015-10-12 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: This gem extends formtastic's form builder to support polymoprhic has
|
15
15
|
many relations in your forms
|