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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ace2c1dcd823a618e48d541ad998f26667c4a6f2183d1f75d6c25d3e7f89beb2
4
- data.tar.gz: de0589831c1b141f10f82f62fa68ebe9f22458c47c3b54c9eda86d9b67ae8a11
3
+ metadata.gz: c7f20e36d72c19d59070aba940459cb56cfddcd16af746989beec6708046c078
4
+ data.tar.gz: 1bb9176840752dbfce4b6a496ee7df30ab988b6c86231248f5c122db64793fb7
5
5
  SHA512:
6
- metadata.gz: 4246af8a4ef3d62c7f16fe7d469709af964a5b1a970081934878772ad4c49d1c1e05b9d7dca1c0819ea512f39691a8220f47ed314561e3a6ee6200fdd55cf103
7
- data.tar.gz: 2c7f98551629a20741ab75ce0b7aef0c6262798b379e5133c39551b91450c2ec436e443222268fa8a121753bc50f3e2118a235cd66382727f23c192d21e84203
6
+ metadata.gz: 5dd3d16f8d641e05332f0b3165c053fd9b1cbca0f56cb441cc69cb3f2d334c999c96917d1f0e691f4e98ee489d57677189c67d746adf492065947c3a548a6b19
7
+ data.tar.gz: d280467a06ec12655983eeb7171849a9daceee2dcee989c5573ef4af1a29713f792e28917051cb540b0454da86be9f07e075caf1424ca44073d669d6c62e6e41
@@ -9,7 +9,6 @@
9
9
  //= require 'rails_admin/popper'
10
10
  //= require 'rails_admin/bootstrap'
11
11
 
12
- //= require 'rails_admin/abstract-select'
13
12
  //= require 'rails_admin/filter-box'
14
13
  //= require 'rails_admin/filtering-multiselect'
15
14
  //= require 'rails_admin/filtering-select'
@@ -19,8 +18,10 @@
19
18
  //= require 'rails_admin/widgets'
20
19
  //= require 'rails_admin/sidescroll'
21
20
  //= require 'rails_admin/ui'
21
+ //= require 'rails_admin/custom/abstract-select'
22
+ //= require 'rails_admin/custom/filter-box'
23
+ //= require 'rails_admin/custom/filtering-multiselect'
22
24
  //= require 'rails_admin/custom/filtering-select'
23
- //= require 'rails_admin/custom/sidescroll'
24
25
  //= require 'rails_admin/custom/ui'
25
26
 
26
27
  <% if defined?(ActiveStorage::Engine) %>
@@ -0,0 +1,30 @@
1
+ import jQuery from "jquery";
2
+ import "jquery-ui/ui/widget.js";
3
+
4
+ (function ($) {
5
+ "use strict";
6
+
7
+ $.widget("ra.abstractSelect", {
8
+ options: {
9
+ createQuery: function (query) {
10
+ if ($.isEmptyObject(this.scopeBy)) {
11
+ return { query: query };
12
+ } else {
13
+ const filterQuery = {};
14
+ for (var field in this.scopeBy) {
15
+ const targetField = this.scopeBy[field];
16
+ const targetValue = $(`[name$="[${field}]"]`).val();
17
+ if (!filterQuery[targetField]) {
18
+ filterQuery[targetField] = [];
19
+ }
20
+ filterQuery[targetField].push(
21
+ targetValue ? { o: "is", v: targetValue } : { o: "_blank" }
22
+ );
23
+ }
24
+ return { query: query, f: filterQuery };
25
+ }
26
+ },
27
+ scopeBy: {},
28
+ },
29
+ });
30
+ })(jQuery);
@@ -0,0 +1,363 @@
1
+ import jQuery from "jquery";
2
+ import I18n from "./i18n";
3
+ import flatpickr from "flatpickr";
4
+
5
+ (function ($) {
6
+ var filters;
7
+
8
+ $.filters = filters = {
9
+ append: function (options) {
10
+ var field_label = options["label"];
11
+ var field_name = options["name"];
12
+ var field_type = options["type"];
13
+ var field_value = options["value"] || "";
14
+ var field_operator = options["operator"];
15
+ var operators = options["operators"];
16
+ var index = options["index"];
17
+ var value_name = "f[" + field_name + "][" + index + "][v]";
18
+ var operator_name = "f[" + field_name + "][" + index + "][o]";
19
+ var control = null;
20
+ var additional_control = null;
21
+
22
+ if (operators.length > 0) {
23
+ control = $(
24
+ '<select class="form-control form-select form-select-sm"></select>'
25
+ ).prop("name", operator_name);
26
+
27
+ operators.forEach((operator) => {
28
+ var element = this.build_operator(operator, options);
29
+ if (!element) {
30
+ return;
31
+ }
32
+ if (element.prop("value") === field_operator) {
33
+ element.prop("selected", true);
34
+ }
35
+ control.append(element);
36
+ });
37
+
38
+ if (control.find("[data-additional-fieldset]").length > 0) {
39
+ control.addClass("switch-additional-fieldsets");
40
+ }
41
+ }
42
+
43
+ switch (field_type) {
44
+ case "boolean":
45
+ control &&
46
+ control
47
+ .prop("name", value_name)
48
+ .find("option")
49
+ .each(function () {
50
+ if ($(this).attr("value") === field_value)
51
+ $(this).attr("selected", true);
52
+ });
53
+ break;
54
+ case "date":
55
+ case "datetime":
56
+ case "timestamp":
57
+ case "time":
58
+ additional_control = $.map(
59
+ [undefined, "-∞", "∞"],
60
+ function (placeholder, index) {
61
+ var visible =
62
+ index == 0
63
+ ? !field_operator || field_operator == "default"
64
+ : field_operator == "between";
65
+ return $('<span class="additional-fieldset"></span>')
66
+ .addClass(index == 0 ? "default" : "between")
67
+ .css("display", visible ? "inline-block" : "none")
68
+ .html(
69
+ $(
70
+ '<input class="input-sm form-control form-control-sm" type="text" />'
71
+ )
72
+ .addClass(field_type == "date" ? "date" : "datetime")
73
+ .prop("name", value_name + "[]")
74
+ .prop("value", field_value[index] || "")
75
+ .prop(
76
+ "size",
77
+ field_type == "date" || field_type == "time" ? 20 : 25
78
+ )
79
+ .prop("placeholder", placeholder)
80
+ );
81
+ }
82
+ );
83
+ break;
84
+ case "enum":
85
+ if (control) {
86
+ var multiple = field_value instanceof Array;
87
+ control = control
88
+ .prop("name", multiple ? value_name + "[]" : value_name)
89
+ .prop("multiple", multiple)
90
+ .add(
91
+ $('<a href="#" class="switch-select"></a>').append(
92
+ $("<i></i>").addClass(
93
+ "fas fa-" + (multiple ? "minus" : "plus")
94
+ )
95
+ )
96
+ );
97
+ control.find("option").each(function () {
98
+ const value = $(this).attr("value");
99
+ if (
100
+ multiple ? field_value.includes(value) : value === field_value
101
+ )
102
+ $(this).attr("selected", true);
103
+ });
104
+ if (multiple)
105
+ control.find("option[value^=_],option[disabled]").hide();
106
+ }
107
+ break;
108
+ case "citext":
109
+ case "string":
110
+ case "text":
111
+ case "belongs_to_association":
112
+ case "has_one_association":
113
+ additional_control = $(
114
+ '<input class="additional-fieldset form-control form-control-sm" type="text" />'
115
+ )
116
+ .css(
117
+ "display",
118
+ field_operator == "_present" || field_operator == "_blank"
119
+ ? "none"
120
+ : "inline-block"
121
+ )
122
+ .prop("name", value_name)
123
+ .prop("value", field_value);
124
+ break;
125
+ case "integer":
126
+ case "decimal":
127
+ case "float":
128
+ additional_control = $(
129
+ '<input class="additional-fieldset default form-control form-control-sm" type="text" />'
130
+ )
131
+ .css(
132
+ "display",
133
+ !field_operator || field_operator == "default"
134
+ ? "inline-block"
135
+ : "none"
136
+ )
137
+ .prop("type", field_type)
138
+ .prop("name", value_name + "[]")
139
+ .prop("value", field_value[0] || "")
140
+ .add(
141
+ $(
142
+ '<input placeholder="-∞" class="additional-fieldset between form-control form-control-sm" />'
143
+ )
144
+ .css(
145
+ "display",
146
+ field_operator == "between" ? "inline-block" : "none"
147
+ )
148
+ .prop("type", field_type)
149
+ .prop("name", value_name + "[]")
150
+ .prop("value", field_value[1] || "")
151
+ )
152
+ .add(
153
+ $(
154
+ '<input placeholder="∞" class="additional-fieldset between form-control form-control-sm" />'
155
+ )
156
+ .css(
157
+ "display",
158
+ field_operator == "between" ? "inline-block" : "none"
159
+ )
160
+ .prop("type", field_type)
161
+ .prop("name", value_name + "[]")
162
+ .prop("value", field_value[2] || "")
163
+ );
164
+ break;
165
+ default:
166
+ control = $(
167
+ '<input type="text" class="form-control form-control-sm" />'
168
+ )
169
+ .prop("name", value_name)
170
+ .prop("value", field_value);
171
+ break;
172
+ }
173
+
174
+ var filterContainerId = field_name + "-" + index + "-filter-container";
175
+ $("#" + filterContainerId).remove();
176
+
177
+ var $content = $("<div>")
178
+ .attr("id", filterContainerId)
179
+ .addClass("filter d-flex align-items-center gap-3 mb-3")
180
+ .append(
181
+ $(
182
+ "<div></div>"
183
+ )
184
+ .append(document.createTextNode(field_label))
185
+ )
186
+ .append(control)
187
+ .append(additional_control)
188
+ .append(
189
+ $(
190
+ '<button type="button" class="btn btn-white btn-sm delete"></button>'
191
+ )
192
+ .append('<i class="fas fa-times"></i>')
193
+ );
194
+
195
+ $("#filters_box").append($content);
196
+
197
+ $content.find(".date, .datetime").each(function () {
198
+ flatpickr(
199
+ this,
200
+ $.extend(
201
+ {
202
+ dateFormat: "Y-m-dTH:i:S",
203
+ altInput: true,
204
+ locale: I18n.locale,
205
+ },
206
+ options["datetimepicker_options"]
207
+ )
208
+ );
209
+ });
210
+
211
+ $("hr.filters_box:hidden").show("slow");
212
+ },
213
+ build_operator: function (operator, options) {
214
+ if (operator instanceof Object) {
215
+ var element = $("<option></option>");
216
+ element.text(operator.label);
217
+ delete operator.label;
218
+ for (const key in operator) {
219
+ element.attr(key, operator[key]);
220
+ }
221
+ return element;
222
+ }
223
+ switch (operator) {
224
+ case "_discard":
225
+ return $('<option value="_discard">...</option>');
226
+ case "_separator":
227
+ return $('<option disabled="disabled">---------</option>');
228
+ case "_present":
229
+ return $('<option value="_present"></option>').text(
230
+ I18n.t("is_present")
231
+ );
232
+ case "_blank":
233
+ return $('<option value="_blank"></option>').text(I18n.t("is_blank"));
234
+ case "_not_null":
235
+ return $('<option value="_not_null"></option>').text(
236
+ I18n.t("is_present")
237
+ );
238
+ case "_null":
239
+ return $('<option value="_null"></option>').text(I18n.t("is_blank"));
240
+
241
+ case "true":
242
+ return $('<option value="true"></option>').text(I18n.t("true"));
243
+ case "false":
244
+ return $('<option value="false"></option>').text(I18n.t("false"));
245
+
246
+ case "today":
247
+ return $('<option value="today"></option>').text(I18n.t("today"));
248
+ case "yesterday":
249
+ return $('<option value="yesterday"></option>').text(
250
+ I18n.t("yesterday")
251
+ );
252
+ case "this_week":
253
+ return $('<option value="this_week"></option>').text(
254
+ I18n.t("this_week")
255
+ );
256
+ case "last_week":
257
+ return $('<option value="last_week"></option>').text(
258
+ I18n.t("last_week")
259
+ );
260
+
261
+ case "like":
262
+ return $(
263
+ '<option data-additional-fieldset="additional-fieldset" value="like"></option>'
264
+ ).text(I18n.t("contains"));
265
+ case "not_like":
266
+ return $(
267
+ '<option data-additional-fieldset="additional-fieldset" value="not_like"></option>'
268
+ ).text(I18n.t("does_not_contain"));
269
+ case "is":
270
+ return $(
271
+ '<option data-additional-fieldset="additional-fieldset" value="is"></option>'
272
+ ).text(I18n.t("is_exactly"));
273
+ case "starts_with":
274
+ return $(
275
+ '<option data-additional-fieldset="additional-fieldset" value="starts_with"></option>'
276
+ ).text(I18n.t("starts_with"));
277
+ case "ends_with":
278
+ return $(
279
+ '<option data-additional-fieldset="additional-fieldset" value="ends_with"></option>'
280
+ ).text(I18n.t("ends_with"));
281
+
282
+ case "default":
283
+ var label;
284
+ switch (options.type) {
285
+ case "date":
286
+ case "datetime":
287
+ case "timestamp":
288
+ label = I18n.t("date");
289
+ break;
290
+ case "time":
291
+ label = I18n.t("time");
292
+ break;
293
+ case "integer":
294
+ case "decimal":
295
+ case "float":
296
+ label = I18n.t("number");
297
+ break;
298
+ }
299
+ return $(
300
+ '<option data-additional-fieldset="default" value="default"></option>'
301
+ ).text(label);
302
+ case "between":
303
+ return $(
304
+ '<option data-additional-fieldset="between" value="between"></option>'
305
+ ).text(I18n.t("between_and_"));
306
+
307
+ default:
308
+ return null;
309
+ }
310
+ },
311
+ };
312
+
313
+ $(document).on("click", "#filters a", function (e) {
314
+ e.preventDefault();
315
+ $.filters.append(
316
+ $.extend(
317
+ { index: $.now().toString().slice(6, 11) },
318
+ $(this).data("options")
319
+ )
320
+ );
321
+ });
322
+
323
+ $(document).on("click", "#filters_box .delete", function (e) {
324
+ e.preventDefault();
325
+ var form = $(this).parents("form");
326
+ $(this).parents(".filter").remove();
327
+ !$("#filters_box").children().length &&
328
+ $("hr.filters_box:visible").hide("slow");
329
+ });
330
+
331
+ $(document).on("click", "#filters_box .switch-select", function (e) {
332
+ e.preventDefault();
333
+ var select = $(this).siblings("select");
334
+ select.attr("multiple", !select.attr("multiple"));
335
+ select.attr(
336
+ "name",
337
+ select.attr("multiple")
338
+ ? select.attr("name") + "[]"
339
+ : select.attr("name").replace(/\[\]$/, "")
340
+ );
341
+ select.find("option[value^=_],option[disabled]").toggle();
342
+ $(this).find("i").toggleClass("fa-plus fa-minus");
343
+ });
344
+
345
+ $(document).on(
346
+ "change",
347
+ "#filters_box .switch-additional-fieldsets",
348
+ function (e) {
349
+ var selected_option = $(this).find("option:selected");
350
+ var klass = $(selected_option).data("additional-fieldset");
351
+ if (klass) {
352
+ $(this)
353
+ .siblings(".additional-fieldset:not(." + klass + ")")
354
+ .hide("slow");
355
+ $(this)
356
+ .siblings("." + klass)
357
+ .show("slow");
358
+ } else {
359
+ $(this).siblings(".additional-fieldset").hide("slow");
360
+ }
361
+ }
362
+ );
363
+ })(jQuery);