rails_admin_simple_has_many 0.0.4 → 0.0.5

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: 3d03b57d1e997ab136a6dec10636e1f51f63b8d9
4
- data.tar.gz: 58cdf59ac8e3b01429f2e3e6e8a60c8f4396fa51
3
+ metadata.gz: 09754e273f85cad65bad14be44440bd1c39f3f14
4
+ data.tar.gz: 0edad1c5974c18a10ebae41e9deb4606213f10dc
5
5
  SHA512:
6
- metadata.gz: 517b0156dc2b565bb618a6ac872177b02b2e87579b5b855d692d77a849bce160bca5be6b8b87a6edffc41242537f6bfebc719387d451dcfd7fbdc3fe6f92add5
7
- data.tar.gz: 3b8903f8e6210489dd346fc4c0337abb38161fc7c7a4e76ad0097120917334c903467ed763b1fc313cb4e46211328567686791d72baa734aa44b6fe8649c998c
6
+ metadata.gz: d536e6b92584a4fafab58c8633e489ef605e18b4df25f11abb691a31e5a6209bd4cc48912ffce0660827d0b9b1248ba2d48e7431ad03d10e0bc3d6131e3aa0a9
7
+ data.tar.gz: 8005af6eb9bed6b05bac286f50b902f0df539a0cea5823b763f8f9dceae9d5d2b87b62ace342d87c429406e458bf526dd9509f19c071190a14aceb55d9d7a677
@@ -40,9 +40,16 @@
40
40
  this.selection = $('<select class="form-control ra-multiselect-selection" multiple="multiple"></select>');
41
41
  this.columns.right.append(this.selection);
42
42
  this.selection.wrap('<div class="wrapper"/>');
43
- this.remove = $('<br/><a style="margin-left:10px; margin-top:5px;" href="#" class="ra-multiselect-item-remove btn btn-danger"><i class=\"icon-plus icon-minus\"></i></a>');
43
+ this.remove = $('<br/><a style="margin-left:10px; margin-top:5px;" href="#" class="ra-multiselect-item-remove btn btn-sm btn-danger"><i class=\"icon-plus icon-minus\"></i></a>');
44
44
  help_block = this.wrapper.parent().find('.help-block')[0];
45
45
  this.remove.insertBefore(help_block)
46
+ if (this.options.sortable) {
47
+ this.up = $('<br/><a href="#" style="margin-left:10px; margin-top:5px;" class="ra-multiselect-item-up btn btn-default btn-xs"><span class="glyphicon glyphicon-arrow-up"></span></a>');
48
+ this.down = $('<br/><a href="#" style="margin-left:10px; margin-top:5px;" class="ra-multiselect-item-down btn btn-default btn-xs"><span class="glyphicon glyphicon-arrow-down"></span></a>');
49
+ this.up.insertBefore(help_block)
50
+ this.down.insertBefore(help_block)
51
+ }
52
+
46
53
  this.element.css({display: "none"});
47
54
  this.tooManyObjectsPlaceholder = $('<option disabled="disabled" />').text(RailsAdmin.I18n.t("too_many_objects"));
48
55
  this.noObjectsPlaceholder = $('<option disabled="disabled" />').text(RailsAdmin.I18n.t("no_objects"))
@@ -69,6 +76,20 @@
69
76
  _bindEvents: function() {
70
77
  var widget = this;
71
78
 
79
+ if(this.options.sortable) {
80
+ /* Move selection up */
81
+ this.up.click(function(e){
82
+ widget._move('up', $(':selected', widget.selection));
83
+ e.preventDefault();
84
+ });
85
+
86
+ /* Move selection down */
87
+ this.down.click(function(e){
88
+ widget._move('down', $(':selected', widget.selection));
89
+ e.preventDefault();
90
+ });
91
+ }
92
+
72
93
  this.remove.click(function(e){
73
94
  if ($(':selected', widget.selection).length == 0)
74
95
  return
@@ -99,6 +120,32 @@
99
120
  }.bind(this));
100
121
  },
101
122
 
123
+ _move: function(direction, options) {
124
+ var widget = this;
125
+ if(direction == 'up') {
126
+ options.each(function(i, option) {
127
+ var prev = $(option).prev();
128
+ if (prev.length > 0) {
129
+ var el = widget.element.find('option[value="' + option.value + '"]');
130
+ var el_prev = widget.element.find('option[value="' + prev[0].value + '"]');
131
+ el_prev.before(el);
132
+ prev.before($(option));
133
+ }
134
+ });
135
+ } else {
136
+ $.fn.reverse = [].reverse; // needed to lower last items first
137
+ options.reverse().each(function(i, option) {
138
+ var next = $(option).next();
139
+ if (next.length > 0) {
140
+ var el = widget.element.find('option[value="' + option.value + '"]');
141
+ var el_next = widget.element.find('option[value="' + next[0].value + '"]');
142
+ el_next.after(el);
143
+ next.after($(option));
144
+ }
145
+ });
146
+ }
147
+ },
148
+
102
149
  _deSelect: function(options) {
103
150
  var widget = this;
104
151
  options.each(function(i, option) {
@@ -38,13 +38,13 @@
38
38
  down: t("admin.misc.down")
39
39
  }
40
40
  }
41
-
41
+ %link{:rel => :stylesheet, :type => :"text/css", :href => "//maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"}
42
42
  %input{name: form.dom_name(field), type: "hidden", value: ""}
43
43
  - selected_ids = (hdv = field.form_default_value).nil? ? selected_ids : hdv
44
44
  = form.select field.method_name, collection, { selected: selected_ids, object: form.object }, field.html_attributes.reverse_merge({data: { simplehasmany: true, options: js_data.to_json }, multiple: true})
45
45
  - if authorized?(:new, config.abstract_model) && field.inline_add
46
46
  - path_hash = { model_name: config.abstract_model.to_param, modal: true }
47
47
  - path_hash.merge!({ associations: { field.inverse_of => (form.object.persisted? ? form.object.id : 'new') } }) if field.inverse_of
48
- = link_to "<i class=\"icon-plus icon-white\"></i> ".html_safe, '#', data: { link: new_path(path_hash) }, class: "create btn btn-info", style: 'margin-left:10px'
48
+ = link_to "<i class=\"icon-plus icon-white\"></i> ".html_safe, '#', data: { link: new_path(path_hash) }, class: "create btn btn-info btn-sm", style: 'margin-left:10px'
49
49
  = javascript_include_tag "rails_admin/routes"
50
50
  = javascript_include_tag "rails_admin/ra.simple-has-many"
@@ -1,3 +1,3 @@
1
1
  module RailsAdminSimpleHasMany
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_admin_simple_has_many
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aiman Najjar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-13 00:00:00.000000000 Z
11
+ date: 2016-03-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails