activeadmin_polymorphic 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38734d64a3a49cacac95b52d252669e4a6f8da48
4
- data.tar.gz: 50322538d61f978ac685e9d7fd2ce159d2bb17f7
3
+ metadata.gz: 43398c27e99911511850142ccc62840fe7379cce
4
+ data.tar.gz: df4359fa2f201f03432e208c5029c1b556151198
5
5
  SHA512:
6
- metadata.gz: 1fb80e97f99a5665121eb268847265925514bda9b694cb7756d7d3a34f9e9038c6545990d2f29e800a9425215c6c8f9b3f418746f09b825cc6dada64ca19c41a
7
- data.tar.gz: c3d4a08f4d83a8e0332338f3e48ca59450588524569d10930a5ca59818a943798fb28bc1aba8e15184ea1069f20114e4f8226ac3c6df19eddb4e1788a20164af
6
+ metadata.gz: 215e4a12f450e2841a318b4e1fc8e6bb6a5a4e23548a1ce1e8693a0fd8e413f829aea0626d837b3a16e548334cb32a05a43c7952f5fd44ee0be3d7062863bb72
7
+ data.tar.gz: fa0b5bb262e1b5f2c8b46bf0aee195cf8bd044f73458cd0a739e3c6005131a3ea8f95dbb91ef3723e9d59d014d34dc37abae3a62bff64f9558b4654aadfba90e
@@ -130,8 +130,10 @@ window.extractAndInsertForm = (url, target)->
130
130
  container.trigger "polymorphic_has_many_form:inserted", [form]
131
131
 
132
132
  window.loadErrors = (target) ->
133
- $(target).off('ajax:success') # unbind successfull action for json form
134
- $(target).trigger('submit.rails').on 'ajax:success', (event, data, result) ->
133
+ $(target).off('ajax:success').off('ajaxBeforeSend')
134
+ $(target).on 'ajax:beforeSend', (event, xhr, setting) ->
135
+ xhr.setRequestHeader 'Accept', 'text/html'
136
+ .trigger('submit.rails').on 'ajax:success', (event, data, result) ->
135
137
  # duplicates method above. refactor using callbacks
136
138
  elements = $(data)
137
139
  form = $('#main_content form', elements).first()
@@ -139,30 +141,27 @@ window.loadErrors = (target) ->
139
141
  $(form).on 'submit', -> return false
140
142
 
141
143
  $(target).replaceWith(form)
144
+ container = $(form).closest '.polymorphic_has_many_container'
145
+ container.trigger "polymorphic_has_many_form:inserted", [ form ]
142
146
 
143
147
  window.remoteSubmit = (target, callback)->
148
+ action = $(target).attr('action')
144
149
  $(target).data('remote', true)
145
150
  $(target).removeAttr('novalidate')
146
- action = $(target).attr('action')
147
151
  $(target).find("input[type=file]").remove()
148
- # we gonna burn in hell for that
149
- # perhaps we can use ajax:before callback
150
- # to set type json
151
- action_with_json = action + '.json'
152
- $(target).attr('action', action_with_json)
153
152
 
154
153
  # unbind callbacks action for form if it was submitted before
155
- $(target).off('ajax:success').off('ajax:aborted:file').off('ajax:error')
154
+ $(target).off('ajax:success').off('ajax:aborted:file').off('ajax:error').off 'ajax:beforeSend'
156
155
 
157
- $(target).trigger('submit.rails')
156
+ $(target).on 'ajax:beforeSend', (event, xhr, setting) ->
157
+ xhr.setRequestHeader 'Accept', 'application/json'
158
+ .trigger('submit.rails')
158
159
  .on 'ajax:aborted:file', (inputs) ->
159
160
  false
160
161
  .on 'ajax:error', (event, response, status)->
161
- $(target).attr('action', action)
162
162
  if response.status == 422
163
163
  loadErrors(target)
164
164
  .on 'ajax:success', (event, object, status, response) ->
165
- $(target).attr('action', action)
166
165
  unless $(target).next().find('input:first').val() # create
167
166
  $(target).next().find('input:first').val(object.id)
168
167
  # replace new form with edit form
@@ -1,3 +1,3 @@
1
1
  module ActiveadminPolymorphic
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
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.2.1
4
+ version: 0.2.2
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-09-22 00:00:00.000000000 Z
12
+ date: 2015-10-07 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
@@ -28,7 +28,7 @@ files:
28
28
  - Rakefile
29
29
  - activeadmin_polymorphic.gemspec
30
30
  - app/assets/javascripts/activeadmin_polymorphic.js.coffee
31
- - app/assets/stylesheets/activeadmin_polymorphic.css.sass
31
+ - app/assets/stylesheets/activeadmin_polymorphic.sass
32
32
  - lib/activeadmin_polymorphic.rb
33
33
  - lib/activeadmin_polymorphic/engine.rb
34
34
  - lib/activeadmin_polymorphic/form_builder.rb