swop 0.1.0 → 0.1.1

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.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/rails_admin/application.js.erb +3 -2
  3. data/app/assets/javascripts/rails_admin/custom/abstract-select.js +30 -0
  4. data/app/assets/javascripts/rails_admin/custom/filter-box.js +363 -0
  5. data/app/assets/javascripts/rails_admin/custom/filtering-multiselect.js +387 -0
  6. data/app/assets/javascripts/rails_admin/custom/filtering-select.js +1 -1
  7. data/app/assets/stylesheets/rails_admin/application.scss.erb +19 -33
  8. data/app/assets/stylesheets/rails_admin/{custom → themes}/base/base.scss +4 -0
  9. data/app/assets/stylesheets/rails_admin/themes/base/bootstrap-variables.scss +252 -0
  10. data/app/assets/stylesheets/rails_admin/{custom → themes}/base/mixins.scss +0 -16
  11. data/app/assets/stylesheets/rails_admin/themes/base/theming.scss +22 -0
  12. data/app/assets/stylesheets/rails_admin/themes/base/variables.scss +71 -0
  13. data/app/assets/stylesheets/rails_admin/themes/simple/base/typography.scss +22 -0
  14. data/app/assets/stylesheets/rails_admin/themes/simple/base/variables-dark.scss +74 -0
  15. data/app/assets/stylesheets/rails_admin/themes/simple/base/variables-light.scss +77 -0
  16. data/app/assets/stylesheets/rails_admin/themes/simple/base/variables-navy.scss +74 -0
  17. data/app/assets/stylesheets/rails_admin/themes/simple/base/variables.scss +129 -0
  18. data/app/assets/stylesheets/rails_admin/themes/simple/components/alerts.scss +88 -0
  19. data/app/assets/stylesheets/rails_admin/themes/simple/components/breadcrumbs.scss +44 -0
  20. data/app/assets/stylesheets/rails_admin/themes/simple/components/buttons.scss +138 -0
  21. data/app/assets/stylesheets/rails_admin/themes/simple/components/containers.scss +15 -0
  22. data/app/assets/stylesheets/rails_admin/themes/simple/components/dropdowns.scss +12 -0
  23. data/app/assets/stylesheets/rails_admin/themes/simple/components/filter-box.scss +8 -0
  24. data/app/assets/stylesheets/rails_admin/themes/simple/components/filtering-multiselect.scss +40 -0
  25. data/app/assets/stylesheets/rails_admin/themes/simple/components/filtering-select.scss +42 -0
  26. data/app/assets/stylesheets/rails_admin/{custom → themes/simple}/components/forms.scss +4 -2
  27. data/app/assets/stylesheets/rails_admin/{custom → themes/simple}/components/images.scss +4 -6
  28. data/app/assets/stylesheets/rails_admin/themes/simple/components/links.scss +25 -0
  29. data/app/assets/stylesheets/rails_admin/themes/simple/components/navs.scss +73 -0
  30. data/app/assets/stylesheets/rails_admin/themes/simple/components/progress.scss +4 -0
  31. data/app/assets/stylesheets/rails_admin/themes/simple/components/sidebar.scss +84 -0
  32. data/app/assets/stylesheets/rails_admin/themes/simple/components/tables.scss +84 -0
  33. data/app/assets/stylesheets/rails_admin/themes/simple/layouts/rows.scss +34 -0
  34. data/app/assets/stylesheets/rails_admin/themes/simple/light/components/links.scss +15 -0
  35. data/app/assets/stylesheets/rails_admin/themes/simple/light/components/sidebar.scss +25 -0
  36. data/app/assets/stylesheets/rails_admin/themes/simple.scss.erb +37 -0
  37. data/app/helpers/rails_admin/application_helper.rb +34 -46
  38. data/app/helpers/rails_admin/form_builder.rb +166 -0
  39. data/app/views/layouts/rails_admin/_custom_navigation.html.erb +10 -0
  40. data/app/views/layouts/rails_admin/_head.html.erb +32 -0
  41. data/app/views/layouts/rails_admin/_header.html.erb +43 -0
  42. data/app/views/layouts/rails_admin/_sidebar_navigation.html.erb +3 -1
  43. data/app/views/layouts/rails_admin/application.html.erb +15 -12
  44. data/app/views/layouts/rails_admin/content.html.erb +6 -51
  45. data/app/views/rails_admin/main/_form_polymorphic_association.html.erb +15 -0
  46. data/app/views/rails_admin/main/_submit_buttons.html.erb +22 -18
  47. data/app/views/rails_admin/main/dashboard.html.erb +49 -55
  48. data/app/views/rails_admin/main/export.html.erb +23 -23
  49. data/app/views/rails_admin/main/history.html.erb +87 -0
  50. data/app/views/rails_admin/main/index.html.erb +60 -56
  51. data/app/views/rails_admin/main/show.html.erb +15 -23
  52. data/config/locales/rails_admin.en.yml +158 -0
  53. data/lib/swop/version.rb +1 -1
  54. data/lib/swop.rb +1 -0
  55. metadata +41 -28
  56. data/app/assets/javascripts/rails_admin/custom/sidescroll.js +0 -20
  57. data/app/assets/javascripts/rails_admin/custom/ui.js +0 -11
  58. data/app/assets/stylesheets/rails_admin/custom/base/bootstrap-variables.scss +0 -196
  59. data/app/assets/stylesheets/rails_admin/custom/base/typography.scss +0 -16
  60. data/app/assets/stylesheets/rails_admin/custom/base/variables.scss +0 -86
  61. data/app/assets/stylesheets/rails_admin/custom/components/breadcrumbs.scss +0 -18
  62. data/app/assets/stylesheets/rails_admin/custom/components/buttons.scss +0 -55
  63. data/app/assets/stylesheets/rails_admin/custom/components/dropdowns.scss +0 -40
  64. data/app/assets/stylesheets/rails_admin/custom/components/filtering-select.scss +0 -43
  65. data/app/assets/stylesheets/rails_admin/custom/components/navbar.scss +0 -18
  66. data/app/assets/stylesheets/rails_admin/custom/components/navs.scss +0 -28
  67. data/app/assets/stylesheets/rails_admin/custom/components/offcanvas.scss +0 -18
  68. data/app/assets/stylesheets/rails_admin/custom/components/progress.scss +0 -11
  69. data/app/assets/stylesheets/rails_admin/custom/components/sidebar.scss +0 -115
  70. data/app/assets/stylesheets/rails_admin/custom/components/table.scss +0 -59
  71. data/app/assets/stylesheets/rails_admin/custom/components/tiles.scss +0 -20
  72. data/app/assets/stylesheets/rails_admin/custom/layouts/body.scss +0 -10
  73. data/app/assets/stylesheets/rails_admin/custom/layouts/containers.scss +0 -31
  74. data/app/views/layouts/rails_admin/custom/_nav.html.erb +0 -10
  75. data/app/views/rails_admin/main/delete.html.erb +0 -19
  76. data/app/views/rails_admin/main/edit.html.erb +0 -5
  77. data/app/views/rails_admin/main/new.html.erb +0 -5
@@ -0,0 +1,387 @@
1
+ import jQuery from "jquery";
2
+ import "jquery-ui/ui/widget.js";
3
+ import I18n from "./i18n";
4
+
5
+ (function ($) {
6
+ $.widget("ra.filteringMultiselect", $.ra.abstractSelect, {
7
+ _cache: {},
8
+ options: {
9
+ sortable: false,
10
+ removable: true,
11
+ regional: {
12
+ add: "Add",
13
+ chooseAll: "Choose all",
14
+ clearAll: "Clear all",
15
+ down: "Down",
16
+ remove: "Remove",
17
+ search: "Search",
18
+ up: "Up",
19
+ },
20
+ searchDelay: 400,
21
+ remote_source: null,
22
+ xhr: false,
23
+ },
24
+
25
+ wrapper: null,
26
+ filter: null,
27
+ collection: null,
28
+ addAll: null,
29
+ add: null,
30
+ remove: null,
31
+ up: null,
32
+ down: null,
33
+ selection: null,
34
+ removeAll: null,
35
+
36
+ _create: function () {
37
+ this._cache = {};
38
+ this._build();
39
+ this._buildCache();
40
+ this._bindEvents();
41
+ },
42
+
43
+ _build: function () {
44
+ var i;
45
+
46
+ this.wrapper = this.element.siblings(
47
+ '.ra-multiselect[data-input-for="' + this.element.attr("id") + '"]'
48
+ );
49
+
50
+ // Prevent duplication on browser back
51
+ if (this.wrapper.length > 0) {
52
+ this.filter = this.wrapper.find("input.ra-multiselect-search");
53
+ this.collection = this.wrapper.find("select.ra-multiselect-collection");
54
+ this.addAll = this.wrapper.find("a.ra-multiselect-item-add-all");
55
+ this.add = this.wrapper.find("a.ra-multiselect-item-add");
56
+ this.remove = this.wrapper.find("a.ra-multiselect-item-remove");
57
+ this.up = this.wrapper.find("a.ra-multiselect-item-up");
58
+ this.down = this.wrapper.find("a.ra-multiselect-item-down");
59
+ this.selection = this.wrapper.find("select.ra-multiselect-selection");
60
+ this.removeAll = this.wrapper.find("a.ra-multiselect-item-remove-all");
61
+ return;
62
+ }
63
+
64
+ this.wrapper = $('<div class="ra-multiselect row gy-3">').attr(
65
+ "data-input-for",
66
+ this.element.attr("id")
67
+ );
68
+ this.wrapper.insertAfter(this.element);
69
+ var header = $('<div class="ra-multiselect-header col-24 col-md-16 col-xl-15">');
70
+ this.filter = $(
71
+ '<input type="search" placeholder="' +
72
+ this.options.regional.search +
73
+ '" class="form-control ra-multiselect-search"/>'
74
+ );
75
+ header.append(this.filter);
76
+ this.wrapper.append(header);
77
+
78
+ var columns = {
79
+ left: $('<div class="ra-multiselect-column ra-multiselect-left col col-md-11">'),
80
+ center: $('<div class="ra-multiselect-column ra-multiselect-center col-auto gx-0">'),
81
+ right: $('<div class="ra-multiselect-column ra-multiselect-right col col-md-11">'),
82
+ };
83
+
84
+ for (i in columns) {
85
+ if (columns.hasOwnProperty(i)) {
86
+ this.wrapper.append(columns[i]);
87
+ }
88
+ }
89
+
90
+ this.collection = $('<select multiple="multiple"></select>');
91
+ this.collection.addClass("form-control ra-multiselect-collection");
92
+ this.addAll = $(
93
+ '<a href="#" class="ra-multiselect-item-add-all"><span class="fas fa-chevron-circle-right"></span>' +
94
+ this.options.regional.chooseAll +
95
+ "</a>"
96
+ );
97
+ columns.left.html(this.collection).append(this.addAll);
98
+ this.collection.wrap('<div class="wrapper"/>');
99
+
100
+ this.add = $(
101
+ '<a href="#" class="fas fa-chevron-circle-right ra-multiselect-item-add d-block mb-3 mb-md-4"></a>'
102
+ ).attr("title", this.options.regional.add);
103
+ columns.center.append(this.add);
104
+ if (this.options.removable) {
105
+ this.remove = $(
106
+ '<a href="#" class="fas fa-chevron-circle-left ra-multiselect-item-remove d-block"></a>'
107
+ ).attr("title", this.options.regional.remove);
108
+ columns.center.append(this.remove);
109
+ }
110
+ if (this.options.sortable) {
111
+ this.up = $(
112
+ '<a href="#" class="fas fa-chevron-circle-up ra-multiselect-item-up"></a>'
113
+ ).attr("title", this.options.regional.up);
114
+ this.down = $(
115
+ '<a href="#" class="fas fa-chevron-circle-down ra-multiselect-item-down"></a>'
116
+ ).attr("title", this.options.regional.down);
117
+ columns.center.append(this.up).append(this.down);
118
+ }
119
+
120
+ this.selection = $(
121
+ '<select class="form-control ra-multiselect-selection" multiple="multiple"></select>'
122
+ );
123
+ columns.right.append(this.selection);
124
+ if (this.options.removable) {
125
+ this.removeAll = $(
126
+ '<a href="#" class="ra-multiselect-item-remove-all"><span class="fas fa-chevron-circle-left"></span>' +
127
+ this.options.regional.clearAll +
128
+ "</a>"
129
+ );
130
+ columns.right.append(this.removeAll);
131
+ }
132
+ this.selection.wrap('<div class="wrapper"/>');
133
+
134
+ this.element.css({ display: "none" });
135
+
136
+ this.tooManyObjectsPlaceholder = $('<option disabled="disabled" />').text(
137
+ I18n.t("too_many_objects")
138
+ );
139
+ this.noObjectsPlaceholder = $('<option disabled="disabled" />').text(
140
+ I18n.t("no_objects")
141
+ );
142
+
143
+ if (this.options.xhr) {
144
+ this.collection.append(this.tooManyObjectsPlaceholder);
145
+ }
146
+ },
147
+
148
+ _bindEvents: function () {
149
+ var widget = this;
150
+
151
+ /* Add all to selection */
152
+ this.addAll.click(function (e) {
153
+ widget._select($("option:not(:disabled)", widget.collection));
154
+ e.preventDefault();
155
+ widget.selection.trigger("change");
156
+ });
157
+
158
+ /* Add to selection */
159
+ this.add.click(function (e) {
160
+ widget._select($(":selected", widget.collection));
161
+
162
+ e.preventDefault();
163
+ widget.selection.trigger("change");
164
+ });
165
+
166
+ if (this.options.removable) {
167
+ /* Remove all from selection */
168
+ this.removeAll.click(function (e) {
169
+ widget._deSelect($("option", widget.selection));
170
+ e.preventDefault();
171
+ widget.selection.trigger("change");
172
+ });
173
+
174
+ /* Remove from selection */
175
+ this.remove.click(function (e) {
176
+ widget._deSelect($(":selected", widget.selection));
177
+ e.preventDefault();
178
+ widget.selection.trigger("change");
179
+ });
180
+ }
181
+
182
+ var timeout = null;
183
+ if (this.options.sortable) {
184
+ /* Move selection up */
185
+ this.up.click(function (e) {
186
+ widget._move("up", $(":selected", widget.selection));
187
+ e.preventDefault();
188
+ });
189
+
190
+ /* Move selection down */
191
+ this.down.click(function (e) {
192
+ widget._move("down", $(":selected", widget.selection));
193
+ e.preventDefault();
194
+ });
195
+ }
196
+
197
+ /* Typing to the filter */
198
+ this.filter.bind("keyup click", function (e) {
199
+ if (timeout) {
200
+ clearTimeout(timeout);
201
+ }
202
+ timeout = setTimeout(function () {
203
+ widget._queryFilter(widget.filter.val());
204
+ }, widget.options.searchDelay);
205
+ });
206
+ },
207
+
208
+ _queryFilter: function (val) {
209
+ var widget = this;
210
+ widget._query(val, function (matches) {
211
+ var filtered = [];
212
+ var i;
213
+
214
+ for (i = 0; i < matches.length; i++) {
215
+ if (!widget.selected(matches[i].id)) {
216
+ filtered.push(i);
217
+ }
218
+ }
219
+ if (filtered.length > 0) {
220
+ widget.collection.html("");
221
+ for (i = 0; i < filtered.length; i++) {
222
+ var newOptions = $("<option></option>")
223
+ .prop("value", matches[filtered[i]].id)
224
+ .prop("title", matches[filtered[i]].label)
225
+ .text(matches[filtered[i]].label);
226
+ widget.collection.append(newOptions);
227
+ }
228
+ } else {
229
+ widget.collection.html(widget.noObjectsPlaceholder);
230
+ }
231
+ });
232
+ },
233
+
234
+ /*
235
+ * Cache key is stored in the format `o_<option value>` to avoid JS
236
+ * engine coercing string keys to int keys, and thereby preserving
237
+ * the insertion order. The value for each key is in turn an object
238
+ * that stores the option tag's HTML text and the value. Example:
239
+ * cache = {
240
+ * 'o_271': { id: 271, value: 'CartItem #271'},
241
+ * 'o_270': { id: 270, value: 'CartItem #270'}
242
+ * }
243
+ */
244
+ _buildCache: function (options) {
245
+ var widget = this;
246
+
247
+ this.element.find("option").each(function (i, option) {
248
+ widget._cache["o_" + option.value] = {
249
+ id: option.value,
250
+ value: $(option).text(),
251
+ };
252
+ if (option.selected) {
253
+ $(option)
254
+ .clone()
255
+ .appendTo(widget.selection)
256
+ .prop("selected", false)
257
+ .prop("title", $(option).text());
258
+ } else {
259
+ $(option)
260
+ .clone()
261
+ .appendTo(widget.collection)
262
+ .prop("selected", false)
263
+ .prop("title", $(option).text());
264
+ }
265
+ });
266
+ },
267
+
268
+ _deSelect: function (options) {
269
+ var widget = this;
270
+ options.each(function (i, option) {
271
+ widget.element
272
+ .find('option[value="' + option.value + '"]')
273
+ .prop("selected", false);
274
+ });
275
+ $(options).appendTo(this.collection).prop("selected", false);
276
+ },
277
+
278
+ _query: function (query, success) {
279
+ var i,
280
+ matches = [];
281
+
282
+ if (query === "") {
283
+ if (!this.options.xhr) {
284
+ for (i in this._cache) {
285
+ if (this._cache.hasOwnProperty(i)) {
286
+ var option = this._cache[i];
287
+ matches.push({ id: option.id, label: option.value });
288
+ }
289
+ }
290
+ success.apply(this, [matches]);
291
+ } else {
292
+ this.collection.html(this.tooManyObjectsPlaceholder);
293
+ }
294
+ } else {
295
+ if (this.options.xhr) {
296
+ $.ajax({
297
+ beforeSend: function (xhr) {
298
+ xhr.setRequestHeader("Accept", "application/json");
299
+ },
300
+ url: this.options.remote_source,
301
+ data: this.options.createQuery(query),
302
+ success: success,
303
+ });
304
+ } else {
305
+ query = new RegExp(query + ".*", "i");
306
+
307
+ for (i in this._cache) {
308
+ if (
309
+ this._cache.hasOwnProperty(i) &&
310
+ query.test(this._cache[i]["value"])
311
+ ) {
312
+ var option = this._cache[i];
313
+ matches.push({ id: option.id, label: option.value });
314
+ }
315
+ }
316
+
317
+ success.apply(this, [matches]);
318
+ }
319
+ }
320
+ },
321
+
322
+ _select: function (options) {
323
+ var widget = this;
324
+ options.each(function (i, option) {
325
+ var el = widget.element.find('option[value="' + option.value + '"]');
326
+ if (el.length) {
327
+ el.prop("selected", true);
328
+ } else {
329
+ widget.element.append(
330
+ $("<option></option>")
331
+ .prop("value", option.value)
332
+ .prop("selected", true)
333
+ );
334
+ }
335
+ });
336
+ $(options).appendTo(this.selection).prop("selected", false);
337
+ },
338
+
339
+ _move: function (direction, options) {
340
+ var widget = this;
341
+ if (direction == "up") {
342
+ options.each(function (i, option) {
343
+ var prev = $(option).prev();
344
+ if (prev.length > 0) {
345
+ var el = widget.element.find(
346
+ 'option[value="' + option.value + '"]'
347
+ );
348
+ var el_prev = widget.element.find(
349
+ 'option[value="' + prev[0].value + '"]'
350
+ );
351
+ el_prev.before(el);
352
+ prev.before($(option));
353
+ }
354
+ });
355
+ } else {
356
+ $.fn.reverse = [].reverse; // needed to lower last items first
357
+ options.reverse().each(function (i, option) {
358
+ var next = $(option).next();
359
+ if (next.length > 0) {
360
+ var el = widget.element.find(
361
+ 'option[value="' + option.value + '"]'
362
+ );
363
+ var el_next = widget.element.find(
364
+ 'option[value="' + next[0].value + '"]'
365
+ );
366
+ el_next.after(el);
367
+ next.after($(option));
368
+ }
369
+ });
370
+ }
371
+ },
372
+
373
+ selected: function (value) {
374
+ if (
375
+ this.selection[0].querySelectorAll('option[value="' + value + '"]')[0]
376
+ ) {
377
+ return true;
378
+ }
379
+ },
380
+
381
+ destroy: function () {
382
+ this.wrapper.remove();
383
+ this.element.css({ display: "inline" });
384
+ $.Widget.prototype.destroy.apply(this, arguments);
385
+ },
386
+ });
387
+ })(jQuery);
@@ -153,7 +153,7 @@ import I18n from "./i18n";
153
153
 
154
154
  _buttonField: function () {
155
155
  return $(
156
- '<div class="input-group-btn btn btn-white dropdown-toggle">' +
156
+ '<div class="input-group-btn btn btn-white dropdown-toggle" title="Show All Items" role="button">' +
157
157
  "</div>"
158
158
  );
159
159
  },
@@ -1,17 +1,25 @@
1
1
  @charset "UTF-8";
2
2
 
3
- // Mixins
3
+ // RailsAdmin - Variables
4
+ @import "rails_admin/styles/base/variables";
5
+
6
+ // RailsAdmin - Mixins
4
7
  @import "rails_admin/styles/base/mixins";
5
- @import "rails_admin/custom/base/base";
6
- @import "rails_admin/custom/base/mixins";
7
8
 
8
- // Variables
9
- @import "rails_admin/custom/base/variables";
10
- @import "rails_admin/custom/base/bootstrap-variables";
11
- @import "rails_admin/styles/base/variables";
9
+ // Font Awesome
10
+ @import "font-awesome";
12
11
 
13
- // Bootstrap
14
- @import "rails_admin/bootstrap/bootstrap";
12
+ // Themes - Core
13
+ @import "themes/base/mixins";
14
+
15
+ // Themes - Variables
16
+ @import "themes/base/variables";
17
+
18
+ // Themes - Base
19
+ @import "themes/base/base";
20
+
21
+ // Themes
22
+ @import "themes/simple";
15
23
 
16
24
  // Libraries
17
25
  @import "rails_admin/flatpickr";
@@ -19,33 +27,11 @@
19
27
  @import "rails_admin/styles/filtering-multiselect";
20
28
  @import "rails_admin/styles/widgets";
21
29
 
22
- // Font Awesome
30
+ // Font awesome
23
31
  @import "rails_admin/font-awesome";
24
32
 
25
33
  // RailsAdmin Theming
26
- @import "rails_admin/styles/base/theming";
27
-
28
- // Base
29
- @import "rails_admin/custom/base/typography";
30
-
31
- // Layouts
32
- @import "rails_admin/custom/layouts/body";
33
- @import "rails_admin/custom/layouts/containers";
34
-
35
- // Components
36
- @import "rails_admin/custom/components/breadcrumbs";
37
- @import "rails_admin/custom/components/buttons";
38
- @import "rails_admin/custom/components/dropdowns";
39
- @import "rails_admin/custom/components/filtering-select";
40
- @import "rails_admin/custom/components/forms";
41
- @import "rails_admin/custom/components/images";
42
- @import "rails_admin/custom/components/navbar";
43
- @import "rails_admin/custom/components/navs";
44
- @import "rails_admin/custom/components/offcanvas";
45
- @import "rails_admin/custom/components/progress";
46
- @import "rails_admin/custom/components/sidebar";
47
- @import "rails_admin/custom/components/table";
48
- @import "rails_admin/custom/components/tiles";
34
+ @import "rails_admin/themes/base/theming";
49
35
 
50
36
  <% if defined?(ActionText::Engine) && Rails.gem_version >= Gem::Version.new('7.0') %>
51
37
  @import "trix";
@@ -3,3 +3,7 @@
3
3
  -moz-osx-font-smoothing: grayscale;
4
4
  -webkit-font-smoothing: antialiased;
5
5
  }
6
+
7
+ .z-1 {
8
+ z-index: 1 !important;
9
+ }