slash_admin 1.2.2 → 1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e66e9b9e6805d1fb3ec19320396a23fd20ef8b507454a5db7bdf050cecae62b8
4
- data.tar.gz: dca2545beaa1f2eab78ba42d73bed449d20cc375a447e6220673f9402d87a74e
3
+ metadata.gz: b630d2ae3de110061ec7538dc87dad3adbcc395f1bf1e166d3e3d351e583abe1
4
+ data.tar.gz: 2b3745532e3152208abd1a454b6b5ad34d429a9527d1ee6f3be84b66ddb82636
5
5
  SHA512:
6
- metadata.gz: c38c8045cf5f05aaddf69cecf1dd3e9b353301133ef0ff107ad420d314ebf70ed8e90e11d8fd0880264d44a9bd553f8279c4c6b372299ecd56eabebfd6b1fbe4
7
- data.tar.gz: 1d653ff1d25dfcf05029ba458ba6f811e5d1ce7fca1198e2cd39df7e222bda029c83405e5c94cd7b24ee53324fbf4b34bd0b23ce5977494ef098ef3c7286f740
6
+ metadata.gz: 53e00bfbf7c89933d68b9c3a9bd0d08ab4279b30d577ba20f9c36a3f579af0945021b0aa4b79a078834a7ec6ee4c5a78eb9c4257eaedd3281d8390f1045ae61d
7
+ data.tar.gz: 7367cda7b8e2fc74cd52944c39e83574562a6f70aa26d2beac0f8caf5b0f03d6eeaf1da1b33d53b6fa26608abf9b596342f4c1db01b3101700e27256ce116b9d
@@ -1,5 +1,5 @@
1
1
  //= require js-routes
2
- //= require i18n
2
+ //= require i18n.js
3
3
  //= require i18n/translations
4
4
  //= require jquery3
5
5
  //= require jquery_ujs
@@ -40,7 +40,7 @@ function init() {
40
40
  Pagy.init();
41
41
  $('[data-toggle="tooltip"]').tooltip();
42
42
 
43
- $('.page-sidebar a[href$="#"]').on("click", function(e) {
43
+ $('.page-sidebar a[href$="#"]').on("click", function (e) {
44
44
  e.preventDefault();
45
45
  });
46
46
 
@@ -51,7 +51,7 @@ function init() {
51
51
 
52
52
  // Scroll to top
53
53
  var offset = 250;
54
- $(window).scroll(function() {
54
+ $(window).scroll(function () {
55
55
  if ($(this).scrollTop() > offset) {
56
56
  $(".scroll-to-top").fadeIn("slow");
57
57
  } else {
@@ -59,22 +59,22 @@ function init() {
59
59
  }
60
60
  });
61
61
 
62
- $(".scroll-to-top").click(function(event) {
63
- $("html, body").animate({ scrollTop: 0 }, 300);
62
+ $(".scroll-to-top").click(function (event) {
63
+ $("html, body").animate({scrollTop: 0}, 300);
64
64
  });
65
65
 
66
66
  // Automatic hide alert
67
- window.setTimeout(function() {
67
+ window.setTimeout(function () {
68
68
  $(".alert")
69
69
  .fadeTo(500, 0)
70
- .slideUp(500, function() {
70
+ .slideUp(500, function () {
71
71
  $(this).remove();
72
72
  });
73
73
  }, 1500);
74
74
 
75
75
  // clearForm
76
- $.fn.clearForm = function() {
77
- return this.each(function() {
76
+ $.fn.clearForm = function () {
77
+ return this.each(function () {
78
78
  var type = this.type,
79
79
  tag = this.tagName.toLowerCase();
80
80
  if (tag === "form") return $(":input", this).clearForm();
@@ -86,20 +86,20 @@ function init() {
86
86
  };
87
87
 
88
88
  // CounterUp plugin
89
- $("[data-counter='counterup']").each(function() {
89
+ $("[data-counter='counterup']").each(function () {
90
90
  var $this = $(this),
91
91
  countTo = $this.attr("data-value");
92
- $({ countNum: $this.text() }).animate(
92
+ $({countNum: $this.text()}).animate(
93
93
  {
94
94
  countNum: countTo
95
95
  },
96
96
  {
97
97
  duration: 1500,
98
98
  easing: "linear",
99
- step: function() {
99
+ step: function () {
100
100
  $this.text(Math.floor(this.countNum));
101
101
  },
102
- complete: function() {
102
+ complete: function () {
103
103
  $this.text(this.countNum);
104
104
  }
105
105
  }
@@ -113,9 +113,9 @@ function init() {
113
113
  .addClass("active");
114
114
 
115
115
  // BULK ACTIONS
116
- $(".toggle-all").on("change", function() {
116
+ $(".toggle-all").on("change", function () {
117
117
  var checked = this.checked;
118
- $('.table-data-list tbody input[type="checkbox"]').each(function(
118
+ $('.table-data-list tbody input[type="checkbox"]').each(function (
119
119
  index,
120
120
  item
121
121
  ) {
@@ -123,14 +123,14 @@ function init() {
123
123
  });
124
124
  });
125
125
 
126
- $('.table-data-list input[type="checkbox"]').on("change", function() {
126
+ $('.table-data-list input[type="checkbox"]').on("change", function () {
127
127
  var length = $('.table-data-list tbody input[type="checkbox"]:checked')
128
128
  .length;
129
129
  $(".batch-current-selected").html(length);
130
130
  });
131
131
 
132
132
  // Delete button protection sweetalert
133
- $(".single-delete").on("click", function(e) {
133
+ $(".single-delete").on("click", function (e) {
134
134
  e.preventDefault();
135
135
  var target = $(this).attr("href");
136
136
  var current = window.location.href;
@@ -148,11 +148,11 @@ function init() {
148
148
  closeOnConfirm: false,
149
149
  showLoaderOnConfirm: true
150
150
  },
151
- function() {
151
+ function () {
152
152
  $.ajax({
153
153
  url: target,
154
154
  method: "DELETE"
155
- }).done(function() {
155
+ }).done(function () {
156
156
  window.location.href = current;
157
157
  });
158
158
  }
@@ -160,14 +160,14 @@ function init() {
160
160
  });
161
161
 
162
162
  // Batch action
163
- $(".batch-action").on("click", function(e) {
163
+ $(".batch-action").on("click", function (e) {
164
164
  e.preventDefault();
165
165
  var target = $(this).data("action");
166
166
  var message = $(this).data("message");
167
167
  var current = window.location.href;
168
168
  var ids = [];
169
169
 
170
- $('.table-data-list tbody input[type="checkbox"]:checked').each(function(
170
+ $('.table-data-list tbody input[type="checkbox"]:checked').each(function (
171
171
  index,
172
172
  checkbox
173
173
  ) {
@@ -188,14 +188,14 @@ function init() {
188
188
  closeOnConfirm: false,
189
189
  showLoaderOnConfirm: true
190
190
  },
191
- function() {
191
+ function () {
192
192
  $.ajax({
193
193
  url: target,
194
194
  method: "post",
195
195
  data: {
196
196
  ids: ids
197
197
  }
198
- }).done(function() {
198
+ }).done(function () {
199
199
  window.location.href = current;
200
200
  });
201
201
  }
@@ -203,29 +203,68 @@ function init() {
203
203
  }
204
204
  });
205
205
 
206
- $(".select2-single, .select2-multiple").select2({});
207
-
208
- $(".select2-model-multiple, .select2-model-single").select2({
209
- ajax: {
210
- url: Routes.slash_admin_remote_select_path({
211
- format: "json"
212
- }),
213
- dataType: "json",
214
- data: function (params) {
215
- var model = $(this).attr("data-model");
216
- var fields = $(this).attr("data-fields");
217
- return {
218
- model_class: model,
219
- q: params.term,
220
- fields: fields.split(" "),
221
- };
222
- },
223
- processResults: function (data) {
224
- return {
225
- results: data
226
- };
206
+
207
+ $(".select2-single, .select2-multiple").each (function() {
208
+ let initialPlaceholder = $(this).attr('placeholder');
209
+ $(this).select2({
210
+ placeholder: initialPlaceholder,
211
+ allowClear: true,
212
+ theme: 'bootstrap4',
213
+ debug: true,
214
+ }).on("select2:unselecting", function (e) {
215
+ $(this).data('state', 'unselected');
216
+ }).on("select2:open", function (e) {
217
+ if ($(this).data('state') === 'unselected') {
218
+ $(this).removeData('state');
219
+
220
+ var self = $(this);
221
+ setTimeout(function () {
222
+ self.select2('close');
223
+ }, 1);
227
224
  }
228
- }
225
+ });
226
+ });
227
+
228
+ $(".select2-model-multiple, .select2-model-single").each(function() {
229
+ let initialPlaceholder = $(this).attr('data-placeholder') || I18n.t('slash_admin.view.select');
230
+
231
+ $(this).select2({
232
+ placeholder: initialPlaceholder,
233
+ allowClear: true,
234
+ theme: 'bootstrap4',
235
+ debug: true,
236
+ ajax: {
237
+ url: Routes.slash_admin_remote_select_path({
238
+ format: "json"
239
+ }),
240
+ dataType: "json",
241
+ data: function (params) {
242
+ var model = $(this).attr("data-model");
243
+ var fields = $(this).attr("data-fields");
244
+ return {
245
+ model_class: model,
246
+ q: params.term,
247
+ fields: fields.split(" "),
248
+ };
249
+ },
250
+ processResults: function (data) {
251
+ return {
252
+ results: data
253
+ };
254
+ }
255
+ }
256
+ }).on("select2:unselecting", function (e) {
257
+ $(this).data('state', 'unselected');
258
+ }).on("select2:open", function (e) {
259
+ if ($(this).data('state') === 'unselected') {
260
+ $(this).removeData('state');
261
+
262
+ var self = $(this);
263
+ setTimeout(function () {
264
+ self.select2('close');
265
+ }, 1);
266
+ }
267
+ });
229
268
  });
230
269
 
231
270
  $(".bootstrap-datepicker").datepicker({
@@ -254,7 +293,7 @@ function init() {
254
293
 
255
294
  $(".colorpicker").minicolors();
256
295
 
257
- $("#reset-filters").on("click", function(e) {
296
+ $("#reset-filters").on("click", function (e) {
258
297
  e.preventDefault();
259
298
 
260
299
  $("input[name*='filters']").val("");
@@ -266,10 +305,10 @@ function init() {
266
305
 
267
306
  // Handle create belongs to
268
307
  $("#create-belongs-to-form")
269
- .on("ajax:success", function(e, data, status, xhr) {
308
+ .on("ajax:success", function (e, data, status, xhr) {
270
309
  $("#create-belongs-to-form").text("Done.");
271
310
  })
272
- .on("ajax:error", function(e, xhr, status, error) {
311
+ .on("ajax:error", function (e, xhr, status, error) {
273
312
  $("#create-belongs-to-form").text("Failed.");
274
313
  });
275
314
  }
@@ -15,6 +15,7 @@
15
15
  *= require jquery.nestable
16
16
  *= require sweetalert
17
17
  *= require select2.min
18
+ *= require select2-bootstrap4
18
19
  *= require bootstrap-datepicker.min
19
20
  *= require bootstrap-material-datetimepicker
20
21
  *= require jquery.tagsinput-revisited.min
@@ -148,42 +149,70 @@ p[data-f-id="pbf"] {
148
149
  padding: 8px 10px;
149
150
  }
150
151
 
151
- .select2-results__option[aria-disabled="true"] {
152
- background: $textColorHover !important;
152
+ .input-group-text {
153
+ background: $input;
154
+ border-color: $border;
155
+ }
156
+
157
+ .select2-container--bootstrap4 .select2-results__option--highlighted,
158
+ .select2-container--bootstrap4 .select2-results__option--highlighted.select2-results__option[aria-selected=true] {
159
+ background-color: $primary;
160
+ color: white;
161
+ }
162
+
163
+ .select2-container--bootstrap4 .select2-selection__clear {
164
+ background: $primary;
165
+ margin-left: 0.5rem;
166
+
167
+ &:hover {
168
+ background: $secondary;
169
+ }
153
170
  }
154
171
 
155
172
  .select2-container {
156
173
  width: 100% !important;
157
174
  }
158
175
 
176
+ .select2-dropdown {
177
+ border-color: $border;
178
+ background: $input;
179
+ }
180
+
181
+ .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice {
182
+ word-break: break-all;
183
+ background: white;
184
+ }
185
+
159
186
  .select2-container .select2-results__option--highlighted,
160
- .select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true] {
187
+ .select2-container .select2-results__option--highlighted.select2-results__option[aria-selected=true],
188
+ .select2-container--bootstrap4 .select2-dropdown .select2-results__option[aria-selected=true] {
161
189
  background-color: $primary;
162
190
  color: white;
163
191
  }
164
192
 
165
- .select2-container--default.select2-container--focus .select2-selection--multiple,
166
- .select2-container--default.select2-container--focus .select2-selection--single {
193
+ .select2-container--bootstrap4.select2-container--focus .select2-selection--multiple,
194
+ .select2-container--bootstrap4.select2-container--focus .select2-selection--single {
167
195
  border: 1px solid $border;
196
+ background: $input;
168
197
  }
169
198
 
170
- .select2-container--default .select2-selection--multiple,
171
- .select2-container--default .select2-selection--single {
199
+ .select2-container--bootstrap4 .select2-selection--multiple,
200
+ .select2-container--bootstrap4 .select2-selection--single {
172
201
  border: 1px solid $border;
202
+ background: $input;
203
+ }
204
+
205
+ .select2-container--bootstrap4 .select2-selection--multiple {
206
+ min-height: calc(1.25rem + 2px) !important;
173
207
  border-radius: 0;
174
- height: calc(1.5em + 0.75rem + 2px);
175
- padding: 0.375rem 0.75rem;
176
208
  }
177
209
 
178
- .select2-container--default .select2-selection--single .select2-selection__rendered,
179
- .select2-container--default .select2-selection--multiple .select2-selection__rendered, {
180
- padding: 0;
181
- line-height: 21px;
210
+ .select2-container .select2-search--inline .select2-search__field {
211
+ background: none;
182
212
  }
183
213
 
184
- .select2-container--default .select2-selection--single .select2-selection__arrow,
185
- .select2-container--default .select2-selection--single .select2-selection__arrow {
186
- height: 32px;
214
+ .select2-container--bootstrap4 .select2-search--dropdown .select2-search__field {
215
+ border-color: $border;
187
216
  }
188
217
 
189
218
  .nested-fields {
@@ -315,6 +344,7 @@ p[data-f-id="pbf"] {
315
344
  .form-control {
316
345
  transition: all ease 0.6s;
317
346
  border: 1px solid $border;
347
+ background: $input;
318
348
 
319
349
  &:focus {
320
350
  border-color: $primary;
@@ -839,7 +869,7 @@ p[data-f-id="pbf"] {
839
869
  display: none;
840
870
  padding: 9px 15px;
841
871
 
842
- tr {
872
+ tr, a {
843
873
  color: $textColor;
844
874
  transition: all .6s ease;
845
875
  cursor: pointer;
@@ -1055,20 +1085,10 @@ p[data-f-id="pbf"] {
1055
1085
  margin-top: 0.5rem;
1056
1086
  }
1057
1087
 
1058
- .select2-container--default .select2-selection--multiple,
1059
- .select2-container--default .select2-selection--single {
1060
- height: initial;
1061
- padding: 0 4px;
1062
- }
1063
-
1064
- .select2-container--default .select2-selection--single .select2-selection__arrow,
1065
- .select2-container--default .select2-selection--single .select2-selection__arrow {
1066
- height: initial;
1067
- }
1068
-
1069
- .select2-container--default .select2-selection--single .select2-selection__arrow,
1070
- .select2-container--default .select2-selection--single .select2-selection__arrow {
1071
- height: initial;
1088
+ .select2-container--bootstrap4 .select2-selection--single .select2-selection__choice,
1089
+ .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice {
1090
+ display: flex;
1091
+ clear: both;
1072
1092
  }
1073
1093
 
1074
1094
  .form-control {
@@ -17,4 +17,5 @@ $sidebar: #fefefe;
17
17
  $textColor: #afaec3;
18
18
  $textColorHover: #15152d;
19
19
 
20
- $border: rgba($textColor, .4);
20
+ $input: #f9faff;
21
+ $border: #e3e9fc;
@@ -37,7 +37,7 @@
37
37
  <% elsif @belongs_to_fields.include?(attr) || @has_one_fields.include?(attr) %>
38
38
  <% if "SlashAdmin::Models::#{attr.to_s.classify.pluralize}Controller".constantize.new.autocomplete_params.present? %>
39
39
  <td>
40
- <select name="filters[<%= attr %>][]" class="select2-model-multiple form-control-sm" multiple data-model="<%= attr.to_s.classify.constantize.model_name.to_s.underscore %>" data-fields='<%= "SlashAdmin::Models::#{attr.to_s.classify.pluralize}Controller".constantize.new.autocomplete_params.join(' ') %>' placeholder="<%= t('slash_admin.view.select_model', model_name: attr.to_s.classify.constantize.model_name.human.downcase) %>">
40
+ <select name="filters[<%= attr %>][]" class="select2-model-multiple form-control-sm" multiple data-model="<%= attr.to_s.classify.constantize.model_name.to_s.underscore %>" data-fields='<%= "SlashAdmin::Models::#{attr.to_s.classify.pluralize}Controller".constantize.new.autocomplete_params.join(' ') %>' data-placeholder="<%= t('slash_admin.view.select_model', model_name: attr.to_s.classify.constantize.model_name.human.downcase) %>">
41
41
  <% if params[:filters].present? && params[:filters][attr].present? %>
42
42
  <% params[:filters][attr].each do |value| %>
43
43
  <option value="<%= value %>" selected><%= attr.to_s.classify.constantize.find(value).name %></option>
@@ -1,10 +1,9 @@
1
1
  <%= f.label a, class: "form-control-label #{required?(f.object, a).present? ? 'required' : ''}" %>
2
2
  <%= render 'slash_admin/shared/tooltip', a: a %>
3
3
  <%= f.collection_select a.to_s + '_id',
4
- class_name_from_association(f.object, a).constantize.all.order(f.object.send(a).present? ? "CASE WHEN id = #{f.object.send(a).try(:id)} THEN 1 ELSE 0 END DESC" : "id DESC").limit(20), :id, object_label(class_name_from_association(f.object, a)),
5
- {
6
- prompt: t('slash_admin.view.select_model', model_name: class_name_from_association(f.object, a).constantize.model_name.human.downcase),
7
- },
8
- 'data-model': class_name_from_association(f.object, a).constantize.model_name.to_s.underscore,
9
- 'data-fields': "SlashAdmin::Models::#{class_name_from_association(f.object, a).classify.pluralize}Controller".constantize.new.autocomplete_params.join(' '),
10
- class: 'form-control select2-model-single', required: required?(f.object, a).present? %>
4
+ class_name_from_association(f.object, a).constantize.all.order(f.object.send(a).present? ? "CASE WHEN id = #{f.object.send(a).try(:id)} THEN 1 ELSE 0 END DESC" : "id DESC").limit(20), :id, object_label(class_name_from_association(f.object, a)),
5
+ {},
6
+ 'data-placeholder': t('slash_admin.view.select_model', model_name: class_name_from_association(f.object, a).constantize.model_name.human.downcase),
7
+ 'data-model': class_name_from_association(f.object, a).constantize.model_name.to_s.underscore,
8
+ 'data-fields': "SlashAdmin::Models::#{class_name_from_association(f.object, a).classify.pluralize}Controller".constantize.new.autocomplete_params.join(' '),
9
+ class: 'form-control select2-model-single', required: required?(f.object, a).present? %>
@@ -1,10 +1,9 @@
1
1
  <%= f.label a, class: "form-control-label #{required?(f.object, a).present? ? 'required' : ''}" %>
2
2
  <%= render 'slash_admin/shared/tooltip', a: a %>
3
3
  <%= f.select a.to_s,
4
- class_name_from_association(f.object, a).constantize.all.order(f.object.send(a).present? ? "CASE WHEN id = #{f.object.send(a).try(:id)} THEN 1 ELSE 0 END DESC" : "id DESC").limit(20).collect { |assoc| [assoc.send(object_label(class_name_from_association(f.object, a))), assoc.id] },
5
- {
6
- prompt: t('slash_admin.view.select_model', model_name: class_name_from_association(f.object, a).constantize.model_name.human.downcase),
7
- },
8
- 'data-model': class_name_from_association(f.object, a).constantize.model_name.to_s.underscore,
9
- 'data-fields': "SlashAdmin::Models::#{class_name_from_association(f.object, a).classify.pluralize}Controller".constantize.new.autocomplete_params.join(' '),
10
- class: 'form-control select2-model-single', required: required?(f.object, a).present? %>
4
+ class_name_from_association(f.object, a).constantize.all.order(f.object.send(a).present? ? "CASE WHEN id = #{f.object.send(a).try(:id)} THEN 1 ELSE 0 END DESC" : "id DESC").limit(20).collect { |assoc| [assoc.send(object_label(class_name_from_association(f.object, a))), assoc.id] },
5
+ {},
6
+ 'data-placeholder': t('slash_admin.view.select_model', model_name: class_name_from_association(f.object, a).constantize.model_name.human.downcase),
7
+ 'data-model': class_name_from_association(f.object, a).constantize.model_name.to_s.underscore,
8
+ 'data-fields': "SlashAdmin::Models::#{class_name_from_association(f.object, a).classify.pluralize}Controller".constantize.new.autocomplete_params.join(' '),
9
+ class: 'form-control select2-model-single', required: required?(f.object, a).present? %>
@@ -2,19 +2,18 @@
2
2
  <%= render 'slash_admin/shared/tooltip', a: a %>
3
3
  <% class_name_from_association = class_name_from_association(f.object, a) %>
4
4
  <%= f.collection_select a.to_s + '_id',
5
- class_name_from_association.constantize.all.order(f.object.send(a).present? ? "CASE WHEN id = #{f.object.send(a).try(:id)} THEN 1 ELSE 0 END DESC" : "id DESC").limit(20), :id, object_label(a),
6
- {
7
- prompt: t('slash_admin.view.select_model', model_name: class_name_from_association.constantize.model_name.human.downcase),
8
- },
9
- 'data-model': class_name_from_association.constantize.model_name.to_s.underscore,
10
- 'data-fields': "SlashAdmin::Models::#{a.to_s.classify.pluralize}Controller".constantize.new.autocomplete_params.join(' '),
11
- class: "form-control select2-model-single #{a.to_s}_id", required: required?(f.object, a).present? %>
5
+ class_name_from_association.constantize.all.order(f.object.send(a).present? ? "CASE WHEN id = #{f.object.send(a).try(:id)} THEN 1 ELSE 0 END DESC" : "id DESC").limit(20), :id, object_label(a),
6
+ {},
7
+ 'data-placeholder': t('slash_admin.view.select_model', model_name: class_name_from_association.constantize.model_name.human.downcase),
8
+ 'data-model': class_name_from_association.constantize.model_name.to_s.underscore,
9
+ 'data-fields': "SlashAdmin::Models::#{a.to_s.classify.pluralize}Controller".constantize.new.autocomplete_params.join(' '),
10
+ class: "form-control select2-model-single #{a.to_s}_id", required: required?(f.object, a).present? %>
12
11
 
13
12
  <a href="#" class="add-belongs-to" style="font-size: .9em;"><%= t('slash_admin.view.add', model_name: class_name_from_association.constantize.model_name.human.downcase) %></a>
14
13
 
15
14
  <script type="text/javascript">
16
- $(function() {
17
- $('.add-belongs-to').on('click', function(e) {
15
+ $(function () {
16
+ $('.add-belongs-to').on('click', function (e) {
18
17
  e.preventDefault();
19
18
  $('.modal-belongs-to').html();
20
19
  $('.modal-belongs-to').html("<%= escape_javascript(render 'slash_admin/base/data_belongs_to', f: f, a: a) %>");
@@ -29,29 +28,29 @@ class: "form-control select2-model-single #{a.to_s}_id", required: required?(f.o
29
28
  }
30
29
 
31
30
  $(id)
32
- .on('ajax:complete', function(xhr, status) {
33
- // console.log(status);
34
- })
35
- .on('ajax:error', function(xhr, status, err) {
36
- console.log(status);
37
- console.log(err);
38
- })
39
- .on("ajax:success", function(xhr, data, status) {
40
- if (data.errors) {
41
- var errors_html = "";
42
- data.errors.map(function(item, index) {
43
- errors_html += item + '<br />';
44
- });
45
- $('.errors-json').html(errors_html)
46
- } else {
47
- toastr.success("<%= t('slash_admin.view.create_success', model_name: class_name_from_association(f.object, a).constantize.model_name.human) %>");
48
- $(id).trigger("reset");
49
- closeModals();
50
- var select = $('.<%= a.to_s + '_id' %>')[0];
51
- var newOption = new Option(data.name, data.id, false, true);
52
- select.prepend(newOption).trigger('change');
53
- }
54
- });
31
+ .on('ajax:complete', function (xhr, status) {
32
+ // console.log(status);
33
+ })
34
+ .on('ajax:error', function (xhr, status, err) {
35
+ console.log(status);
36
+ console.log(err);
37
+ })
38
+ .on("ajax:success", function (xhr, data, status) {
39
+ if (data.errors) {
40
+ var errors_html = "";
41
+ data.errors.map(function (item, index) {
42
+ errors_html += item + '<br />';
43
+ });
44
+ $('.errors-json').html(errors_html)
45
+ } else {
46
+ toastr.success("<%= t('slash_admin.view.create_success', model_name: class_name_from_association(f.object, a).constantize.model_name.human) %>");
47
+ $(id).trigger("reset");
48
+ closeModals();
49
+ var select = $('.<%= a.to_s + '_id' %>')[0];
50
+ var newOption = new Option(data.name, data.id, false, true);
51
+ select.prepend(newOption).trigger('change');
52
+ }
53
+ });
55
54
  });
56
55
  });
57
56
  </script>
@@ -19,11 +19,11 @@
19
19
  </li>
20
20
  <% end %>
21
21
  <% if params[:action] == 'new' %>
22
- <li class="breadcrumb-item"><%= t('relax_admin.view.new', model_name: @model_class.model_name.human.pluralize.capitalize) %></li>
22
+ <li class="breadcrumb-item"><%= t('slash_admin.view.new', model_name: @model_class.model_name.human.pluralize.capitalize) %></li>
23
23
  <% elsif params[:action] == 'edit' %>
24
- <li class="breadcrumb-item"><%= t('relax_admin.view.edit', model_name: @model_class.model_name.human.pluralize.capitalize) %></li>
24
+ <li class="breadcrumb-item"><%= t('slash_admin.view.edit', model_name: @model_class.model_name.human.pluralize.capitalize) %></li>
25
25
  <% elsif params[:action] == 'show' %>
26
- <li class="breadcrumb-item"><%= t('relax_admin.view.show', model_name: @model_class.model_name.human.pluralize.capitalize) %></li>
26
+ <li class="breadcrumb-item"><%= t('slash_admin.view.show', model_name: @model_class.model_name.human.pluralize.capitalize) %></li>
27
27
  <% end %>
28
28
  </ol>
29
29
  </nav>
@@ -28,12 +28,16 @@
28
28
  data-href="<%= sub[:path] %>"
29
29
  data-blank="<%= s[:blank].present? ? 'true' : 'false' %>">
30
30
  <td>
31
- <% if sub[:icon] %>
32
- <i class="<%= sub[:icon] %>"></i>
33
- <% end %>
31
+ <a href="<%= sub[:path] %>" class="<%= request.fullpath == sub[:path] ? 'active' : '' %>" target="<%= s[:blank].present? ? '_blank' : '_self' %>">
32
+ <% if sub[:icon] %>
33
+ <i class="<%= sub[:icon] %>"></i>
34
+ <% end %>
35
+ </a>
34
36
  </td>
35
37
  <td>
36
- <span class="title"><%= sub[:title] %></span>
38
+ <a href="<%= sub[:path] %>" class="<%= request.fullpath == sub[:path] ? 'active' : '' %>" target="<%= s[:blank].present? ? '_blank' : '_self' %>">
39
+ <span class="title"><%= sub[:title] %></span>
40
+ </a>
37
41
  </td>
38
42
  </tr>
39
43
  <% else %>
@@ -42,12 +46,16 @@
42
46
  data-href="<%= polymorphic_url([:slash_admin, sub[:model]]) %>"
43
47
  data-blank="<%= s[:blank].present? ? 'true' : 'false' %>">
44
48
  <td>
49
+ <a class="<%= controller.controller_name == sub[:model].name.split('::').last.tableize ? 'active' : '' %>" href="<%= polymorphic_url([:slash_admin, sub[:model]]) %>" target="<%= s[:blank].present? ? '_blank' : '_self' %>">
45
50
  <% if sub[:icon] %>
46
51
  <i class="<%= sub[:icon] %>"></i>
47
52
  <% end %>
53
+ </a>
48
54
  </td>
49
55
  <td>
50
- <span class="title"><%= sub[:model].model_name.human(count: 2) %></span>
56
+ <a class="<%= controller.controller_name == sub[:model].name.split('::').last.tableize ? 'active' : '' %>" href="<%= polymorphic_url([:slash_admin, sub[:model]]) %>" target="<%= s[:blank].present? ? 'true' : '_self' %>">
57
+ <span class="title"><%= sub[:model].model_name.human(count: 2) %></span>
58
+ </a>
51
59
  </td>
52
60
  </tr>
53
61
  <% end %>
@@ -48,6 +48,7 @@ en:
48
48
  filter: Filter
49
49
  reset: Reset
50
50
  select_model: "Select a %{model_name}"
51
+ select: "Select..."
51
52
  list: "%{model_name} list"
52
53
  return_to_list: Return to list
53
54
  no_image: No image
@@ -50,6 +50,7 @@ fr:
50
50
  filter: Filtrer
51
51
  reset: Réinit.
52
52
  select_model: "Sélectionner un(e) %{model_name}"
53
+ select: "Sélectionner..."
53
54
  list: "Liste des %{model_name}"
54
55
  return_to_list: Retour à la liste
55
56
  no_image: Aucune Image
@@ -1,3 +1,3 @@
1
1
  module SlashAdmin
2
- VERSION = "1.2.2"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -0,0 +1,163 @@
1
+ .select2-container--bootstrap4 .select2-selection--single {
2
+ height: calc(2.25rem + 2px) !important; }
3
+ .select2-container--bootstrap4 .select2-selection--single .select2-selection__placeholder {
4
+ color: #757575;
5
+ line-height: 2.25rem; }
6
+ .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow {
7
+ position: absolute;
8
+ top: 50%;
9
+ right: 3px;
10
+ width: 20px; }
11
+ .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow b {
12
+ top: 60%;
13
+ border-color: #343a40 transparent transparent transparent;
14
+ border-style: solid;
15
+ border-width: 5px 4px 0 4px;
16
+ width: 0;
17
+ height: 0;
18
+ left: 50%;
19
+ margin-left: -4px;
20
+ margin-top: -2px;
21
+ position: absolute; }
22
+ .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
23
+ line-height: 2.25rem; }
24
+
25
+ .select2-search--dropdown .select2-search__field {
26
+ border: 1px solid #ced4da;
27
+ border-radius: 0.25rem; }
28
+
29
+ .select2-results__message {
30
+ color: #6c757d; }
31
+
32
+ .select2-container--bootstrap4 .select2-selection--multiple {
33
+ min-height: calc(2.25rem + 2px) !important; }
34
+ .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__rendered {
35
+ -webkit-box-sizing: border-box;
36
+ box-sizing: border-box;
37
+ list-style: none;
38
+ margin: 0;
39
+ padding: 0 5px;
40
+ width: 100%; }
41
+ .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice {
42
+ color: #343a40;
43
+ border: 1px solid #bdc6d0;
44
+ border-radius: 0.2rem;
45
+ padding: 0;
46
+ padding-right: 5px;
47
+ cursor: pointer;
48
+ float: left;
49
+ margin-top: 0.3em;
50
+ margin-right: 5px; }
51
+ .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove {
52
+ color: #bdc6d0;
53
+ font-weight: bold;
54
+ margin-left: 3px;
55
+ margin-right: 1px;
56
+ padding-right: 3px;
57
+ padding-left: 3px;
58
+ float: left; }
59
+ .select2-container--bootstrap4 .select2-selection--multiple .select2-selection__choice__remove:hover {
60
+ color: #343a40; }
61
+
62
+ .select2-container {
63
+ display: block; }
64
+ .select2-container *:focus {
65
+ outline: 0; }
66
+
67
+ .input-group .select2-container--bootstrap4 {
68
+ -webkit-box-flex: 1;
69
+ -ms-flex-positive: 1;
70
+ flex-grow: 1; }
71
+
72
+ .input-group-prepend ~ .select2-container--bootstrap4 .select2-selection {
73
+ border-top-left-radius: 0;
74
+ border-bottom-left-radius: 0; }
75
+
76
+ .input-group > .select2-container--bootstrap4:not(:last-child) .select2-selection {
77
+ border-top-right-radius: 0;
78
+ border-bottom-right-radius: 0; }
79
+
80
+ .select2-container--bootstrap4 .select2-selection {
81
+ background-color: #fff;
82
+ border: 1px solid #ced4da;
83
+ border-radius: 0.25rem;
84
+ -webkit-transition: border-color 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
85
+ transition: border-color 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
86
+ transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
87
+ transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
88
+ width: 100%; }
89
+ @media screen and (prefers-reduced-motion: reduce) {
90
+ .select2-container--bootstrap4 .select2-selection {
91
+ -webkit-transition: none;
92
+ transition: none; } }
93
+
94
+ .select2-container--bootstrap4.select2-container--focus .select2-selection {
95
+ border-color: #80bdff;
96
+ -webkit-box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
97
+ box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25); }
98
+
99
+ .select2-container--bootstrap4.select2-container--focus.select2-container--open .select2-selection {
100
+ border-bottom: none;
101
+ border-bottom-left-radius: 0;
102
+ border-bottom-right-radius: 0; }
103
+
104
+ .select2-container--bootstrap4.select2-container--disabled .select2-selection, .select2-container--bootstrap4.select2-container--disabled.select2-container--focus .select2-selection {
105
+ background-color: #e9ecef;
106
+ cursor: not-allowed;
107
+ border-color: #ced4da;
108
+ -webkit-box-shadow: none;
109
+ box-shadow: none; }
110
+
111
+ .select2-container--bootstrap4.select2-container--disabled .select2-search__field, .select2-container--bootstrap4.select2-container--disabled.select2-container--focus .select2-search__field {
112
+ background-color: transparent; }
113
+
114
+ select.is-invalid ~ .select2-container--bootstrap4 .select2-selection,
115
+ form.was-validated select:invalid ~ .select2-container--bootstrap4 .select2-selection {
116
+ border-color: #dc3545; }
117
+
118
+ select.is-valid ~ .select2-container--bootstrap4 .select2-selection,
119
+ form.was-validated select:valid ~ .select2-container--bootstrap4 .select2-selection {
120
+ border-color: #28a745; }
121
+
122
+ .select2-container--bootstrap4 .select2-dropdown {
123
+ border-color: #ced4da;
124
+ border-top: none;
125
+ border-top-left-radius: 0;
126
+ border-top-right-radius: 0; }
127
+ .select2-container--bootstrap4 .select2-dropdown.select2-dropdown--above {
128
+ border-top: 1px solid #ced4da;
129
+ border-top-left-radius: 0.25rem;
130
+ border-top-right-radius: 0.25rem; }
131
+ .select2-container--bootstrap4 .select2-dropdown .select2-results__option[aria-selected=true] {
132
+ background-color: #e9ecef; }
133
+
134
+ .select2-container--bootstrap4 .select2-results__option--highlighted,
135
+ .select2-container--bootstrap4 .select2-results__option--highlighted.select2-results__option[aria-selected=true] {
136
+ background-color: #007bff;
137
+ color: #f8f9fa; }
138
+
139
+ .select2-container--bootstrap4 .select2-results__option[role=group] {
140
+ padding: 0; }
141
+
142
+ .select2-container--bootstrap4 .select2-results > .select2-results__options {
143
+ max-height: 15em;
144
+ overflow-y: auto; }
145
+
146
+ .select2-container--bootstrap4 .select2-results__group {
147
+ padding: 6px;
148
+ display: list-item;
149
+ color: #6c757d; }
150
+
151
+ .select2-container--bootstrap4 .select2-selection__clear {
152
+ width: 1.2em;
153
+ height: 1.2em;
154
+ line-height: 1.15em;
155
+ padding-left: 0.3em;
156
+ margin-top: 0.5em;
157
+ border-radius: 100%;
158
+ background-color: #6c757d;
159
+ color: #f8f9fa;
160
+ float: right;
161
+ margin-right: 0.3em; }
162
+ .select2-container--bootstrap4 .select2-selection__clear:hover {
163
+ background-color: #343a40; }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slash_admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - KOVACS Nicolas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-02 00:00:00.000000000 Z
11
+ date: 2020-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -430,6 +430,7 @@ files:
430
430
  - vendor/assets/stylesheets/codemirror/theme/relax-seti.css
431
431
  - vendor/assets/stylesheets/jquery.nestable.css
432
432
  - vendor/assets/stylesheets/jquery.tagsinput-revisited.min.css
433
+ - vendor/assets/stylesheets/select2-bootstrap4.css
433
434
  - vendor/assets/stylesheets/select2.min.css
434
435
  - vendor/assets/stylesheets/sweetalert.css
435
436
  - vendor/assets/stylesheets/toastr.css