activeadmin_polymorphic 0.1.0 → 0.1.1

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: 806875f4dc043b24f94549838a81c5ad6d180e4b
4
- data.tar.gz: 786835f0298f3ce1e08870a9bede6f9ab036d9e6
3
+ metadata.gz: ea40004a0a7bb3aef319d8e0b0d233b3f3321436
4
+ data.tar.gz: a51f08e75f8e5bdc1cfe67d66d9b747668e6859c
5
5
  SHA512:
6
- metadata.gz: 8a5da9426cf627abefc48134e70fc9bea72ebd90de1f8c1e28094e6dc693037609120a1ed514a26a1d5b417ed64a6d558623f8a47ffcab26b0585eee6b60b2e5
7
- data.tar.gz: d8f296a37a267d68ccccf8d9cfea1b8449f7ebe66b3a889e1791ad29126093191a68bde27f27c8834cb093d4aa64a03bd8eff151f36b3c0e2a65bede0e26e666
6
+ metadata.gz: 4b3cb0a0b38df959b3dcd5b26b6508a8b2cf7f3d2984c0f98073a41f4f7b88a5de7cc7c61523a3269ab993bb9035d935754aea040a8e8d2a80762a9cc346840f
7
+ data.tar.gz: c10e8cfd50e7caae2ded2bf30dfa68b1c8914d170ad7bef1a6503f6682b4512802338f09c52bf3e9fc0358f459671ccc4a3ff8d20dbce6335011bed7921411cd
data/README.md CHANGED
@@ -21,20 +21,25 @@ gem "activeadmin_polymorphic"
21
21
 
22
22
  and run `bundle install`.
23
23
 
24
- Include assets in js and css manifests
24
+ Include assets in JS and CSS manifests
25
25
 
26
+ JS:
26
27
  ```
27
28
  #= require activeadmin_polymorphic
29
+ ```
30
+
31
+ CSS:
32
+ ```
28
33
  @import "activeadmin_polymorphic";
29
34
  ```
30
35
 
31
36
  # Usage
32
37
 
33
- To use gem, your model should have related model, which works as a proxy to polymorphic relations.
38
+ To use the gem, your model should have a related model, which works as a proxy to polymorphic relations.
34
39
 
35
40
  ![](https://s3.amazonaws.com/f.cl.ly/items/2Z3M2V0b3Z342L2Z2R0N/Screen%20Shot%202015-02-05%20at%2013.37.36.png)
36
41
 
37
- Gem extrands activeadmin's form builder, so to enable `has_many_polymorphic` method you need to override form builder using `builder` option:
42
+ The gem extends activeadmin's form builder, so to enable the `has_many_polymorphic` method you need to override form builder using the `builder` option:
38
43
 
39
44
  ```
40
45
  ...
@@ -47,38 +52,38 @@ end
47
52
  ```
48
53
 
49
54
  There are few options available:
50
- * first option is a name of polymorphic has_many association
51
- * second option referes to polymorphied version of association name (sectionable_id and sectaionable_type for example)
55
+ * first option, the name of polymorphic has_many association
56
+ * second option, referes to polymorphied version of an association name (sectionable_id and sectaionable_type for example)
52
57
  * `types` - list of related models you want to use
53
- * `allow_destroy` - weather or not to allow to destroy related objects
58
+ * `allow_destroy` - whether or not to allow destroying related objects
54
59
  * `sortable` - enables drag'n'drop for nested forms, accepts sortable column name, for example `sortable: :priority`
55
60
 
56
- Subforms for polymorphic relations are forms which you define in your ActiveAdmin. Gem fetches and submits them using some ajax magic.
61
+ Subforms for polymorphic relations are forms which you define in your ActiveAdmin. The gem fetches and submits them using some ajax magic.
57
62
 
58
63
  # Under the hood
59
64
 
60
- This gem is a set of dirty hacks and tricks. Calling `polymorphic_has_many` makes it to do the following things:
65
+ This gem is a set of dirty hacks and tricks. Calling `polymorphic_has_many` makes it do the following things:
61
66
 
62
- * for new records it generates dropdown with polymorphic types
63
- * for exising records it generates two hidden fields with id and type
64
- * then the real javascript starts, it extracts whole forms from polymorphic models new or edit pages, strips form actions, and inserts that forms right into parent form
65
- * when you try to submit forms, javascripts submit subforms first; if subforms are invalid, it reloads them with erros and interupts main form submission process
66
- * after all sub forms successfully saved, it strips them (because forms nested into other forms are simantically invalid, right?) and submits parent form
67
+ * for new records it generates a dropdown with polymorphic types
68
+ * for exising records it generates two hidden fields with `id` and `type`
69
+ * then the real JavaScript starts, it extracts whole forms from polymorphic models new or edit pages, strips form actions, and inserts those forms right into the parent form
70
+ * when you try to submit forms, JavaScript submits subforms first; if subforms are invalid, it reloads them with erros and interupts the main form's submission process
71
+ * after all subforms have been successfully saved, it strips them (because forms nested into other forms are simantically invalid, right?) and submits the parent form
67
72
 
68
73
  # File uploads in subforms
69
74
 
70
- Gem relies on [rails ajax](https://github.com/rails/jquery-rails) form submissions, which doesn't allow to submit files directly. Workaround for it is asynchronous file submission using for example [remotipart](https://github.com/JangoSteve/remotipart) for CarrierWave or [refile](https://github.com/elabs/refile) with [refile-input](https://github.com/hyperoslo/refile-input). Note: before subforms submissions javascript strips all file inputs from forms.
75
+ The gem relies on [rails ajax](https://github.com/rails/jquery-rails)'s form submissions, which doesn't allow to submit files directly. Workaround for this is asynchronous file submission using, for example [remotipart](https://github.com/JangoSteve/remotipart) for CarrierWave, or [refile](https://github.com/elabs/refile) with [refile-input](https://github.com/hyperoslo/refile-input). Note: before subforms submissions JavaScript strips all file inputs from the forms.
71
76
 
72
77
  # Testing
73
78
 
74
- Tests stucture is mostly copied from original ActiveAdmin.
79
+ Test's stucture is mostly copied from the original ActiveAdmin.
75
80
 
76
- Install development dependencies with `bundle install`. To setup test suit run `rake test`. Run tests with `bundle exec guard`. There aren't many of them, let's say there are quite a few.
81
+ Install development dependencies with `bundle install`. To setup the test suit run `rake test`. Run tests with `bundle exec guard`. There aren't many of them, let's say there are quite a few.
77
82
 
78
83
  # In plan
79
84
 
80
85
  * allow to reuse existing polymorphic objects
81
- * check who it works with models under sertain namespace
86
+ * check who it works with: models under a certain namespace
82
87
  * improve tests
83
88
 
84
89
  # License
@@ -51,7 +51,11 @@ module ActiveadminPolymorphic
51
51
  contents << has_many_form.input(builder_options[:sortable], as: :hidden)
52
52
 
53
53
  contents << template.content_tag(:li, class: 'handle') do
54
- ::ActiveAdmin::Iconic.icon :move_vertical
54
+ '''
55
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Layer_1" x="0px" y="0px" width="30px" height="25px" viewBox="0 0 550 550" enable-background="new 0 0 550 550" xml:space="preserve">
56
+ <path d="M418.909,456.728h-93.091v-288l-93.091,93.091V139.637L372.363,0L512,139.637v122.182l-93.091-93.091V456.728z M93.091,84.363h93.091v288l93.091-93.091v122.182L139.637,541.091L0,401.454V279.272l93.091,93.091V84.363z"></path>
57
+ </svg>
58
+ '''.html_safe
55
59
  end
56
60
  end
57
61
 
@@ -1,3 +1,3 @@
1
1
  module ActiveadminPolymorphic
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
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.1.0
4
+ version: 0.1.1
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-02-05 00:00:00.000000000 Z
12
+ date: 2015-04-20 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
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  version: '0'
75
75
  requirements: []
76
76
  rubyforge_project:
77
- rubygems_version: 2.2.2
77
+ rubygems_version: 2.4.5
78
78
  signing_key:
79
79
  specification_version: 4
80
80
  summary: HasMany polymoprhic support for active admin.