activeadmin_addons 0.8.0 → 0.9.0

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: 194d9de88fe5940c6cbc4f265c2305c933902947
4
- data.tar.gz: 4ec014fa892d8c74b36c9592fc9fef5e7255d6ba
3
+ metadata.gz: 339767451d690dce0857728e0b000055c3d20a3e
4
+ data.tar.gz: 33a38a21e81194a21ba00d9ab5d0d4d148dcec37
5
5
  SHA512:
6
- metadata.gz: 0d69cd52613779c4dfa329c7af454768c170b03fb82a1524ace4250aafaa7b5997fe803f1e4caec67d286fdd3effb4801c3afece683d5b184a7097995c0c62fe
7
- data.tar.gz: a77db23a54d74544dbec1b164c2070982838e4ba11d8c9392802b49cfcda889bdc4b054749a57f3af35f2815c80c4a83dc12f4c2b4c7f625584b4a1868bc0500
6
+ metadata.gz: 4f5b389bc1614ba65c83aa4393541981fd6b8731b8b45f629b5491515c89ec34a9ab723c21a8d883c9ce5d5d7a9d0048c3770f806c09cf0d5c6f76dbc241bdf2
7
+ data.tar.gz: 2a8036767416393893109731f0062ef18039585cafff10c2c4e0556f2cec35ffc4076b1a9d059db6ae71b266cc7f9fe410d42b3aeb3371254e01991173ba56d8
@@ -65,6 +65,7 @@ $(function() {
65
65
  var displayName = $(el).data('display_name');
66
66
  var parent = $(el).data('parent');
67
67
  var model = $(el).data('model');
68
+ var responseRoot = $(el).data('response_root');
68
69
  var collection = $(el).data('collection');
69
70
  var minimumInputLength = $(el).data('minimum_input_length');
70
71
  var order = fields[0] + '_desc';
@@ -96,6 +97,10 @@ $(function() {
96
97
  return query;
97
98
  },
98
99
  results: function(data, page) {
100
+ if(data.constructor == Object) {
101
+ data = data[responseRoot];
102
+ }
103
+
99
104
  return {
100
105
  results: jQuery.map(data, function(resource) {
101
106
  return {
@@ -75,6 +75,7 @@ class NestedSelectInput < Formtastic::Inputs::StringInput
75
75
 
76
76
  opts["id"] = build_select_id(attribute)
77
77
  opts["data-url"] = get_option(level, :url, build_url(attribute))
78
+ opts["data-response_root"] = (level[:response_root] || opts["data-url"].to_s.split('/').last)
78
79
  opts["data-selected"] = instance.try(opts["data-display_name"])
79
80
 
80
81
  opts.merge(select_html_parent_options(level[:parent_attribute]))
@@ -5,6 +5,7 @@ class SearchSelectInput < Formtastic::Inputs::StringInput
5
5
  opts[:class] = ['select2-ajax'].concat([@options[:class]] || []).join(' ')
6
6
  opts["data-fields"] = (@options[:fields] || []).to_json
7
7
  opts["data-url"] = @options[:url] || ""
8
+ opts["data-response_root"] = @options[:response_root] || @options[:url].to_s.split('/').last
8
9
  opts["data-display_name"] = @options[:display_name] || "name"
9
10
  opts["data-minimum_input_length"] = @options[:minimum_input_length] || 1
10
11
  opts["data-selected"] = relation.try(opts["data-display_name"].to_sym)
@@ -1,3 +1,3 @@
1
1
  module ActiveadminAddons
2
- VERSION = "0.8.0"
2
+ VERSION = "0.9.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_addons
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Platanus