slash_admin 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +95 -0
  3. data/app/assets/config/relax_admin_manifest.js +2 -0
  4. data/app/assets/images/slash_admin/en.png +0 -0
  5. data/app/assets/images/slash_admin/favicon.png +0 -0
  6. data/app/assets/images/slash_admin/fr.png +0 -0
  7. data/app/assets/javascripts/slash_admin/application.js +344 -0
  8. data/app/assets/javascripts/slash_admin/custom.js +0 -0
  9. data/app/assets/stylesheets/slash_admin/alert.scss +29 -0
  10. data/app/assets/stylesheets/slash_admin/application.scss +1469 -0
  11. data/app/assets/stylesheets/slash_admin/colors.scss +17 -0
  12. data/app/assets/stylesheets/slash_admin/custom.scss +0 -0
  13. data/app/controllers/slash_admin/application_controller.rb +17 -0
  14. data/app/controllers/slash_admin/base_controller.rb +45 -0
  15. data/app/controllers/slash_admin/batch_actions_controller.rb +17 -0
  16. data/app/controllers/slash_admin/dashboard_controller.rb +11 -0
  17. data/app/controllers/slash_admin/models_controller.rb +325 -0
  18. data/app/controllers/slash_admin/security/sessions_controller.rb +29 -0
  19. data/app/controllers/slash_admin/selectize_controller.rb +49 -0
  20. data/app/helpers/slash_admin/application_helper.rb +212 -0
  21. data/app/helpers/slash_admin/menu_helper.rb +14 -0
  22. data/app/helpers/slash_admin/widgets_helper.rb +7 -0
  23. data/app/jobs/slash_admin/application_job.rb +4 -0
  24. data/app/mailers/slash_admin/application_mailer.rb +6 -0
  25. data/app/models/slash_admin/admin.rb +46 -0
  26. data/app/models/slash_admin/admin_ability.rb +11 -0
  27. data/app/models/slash_admin/application_record.rb +5 -0
  28. data/app/views/layouts/slash_admin/admin_user.html.erb +16 -0
  29. data/app/views/layouts/slash_admin/application.html.erb +40 -0
  30. data/app/views/slash_admin/base/_data_belongs_to.html.erb +37 -0
  31. data/app/views/slash_admin/base/_data_list.html.erb +276 -0
  32. data/app/views/slash_admin/base/_data_nestable.html.erb +33 -0
  33. data/app/views/slash_admin/base/_data_new.html.erb +16 -0
  34. data/app/views/slash_admin/base/_data_show.html.erb +72 -0
  35. data/app/views/slash_admin/base/_filters.html.erb +60 -0
  36. data/app/views/slash_admin/base/_translatable_fields.html.erb +23 -0
  37. data/app/views/slash_admin/base/edit.html.erb +26 -0
  38. data/app/views/slash_admin/base/index.html.erb +47 -0
  39. data/app/views/slash_admin/base/index.xls.erb +27 -0
  40. data/app/views/slash_admin/base/nestable.html.erb +28 -0
  41. data/app/views/slash_admin/base/new.html.erb +26 -0
  42. data/app/views/slash_admin/base/show.html.erb +22 -0
  43. data/app/views/slash_admin/custom_fields/_color.html.erb +2 -0
  44. data/app/views/slash_admin/custom_fields/_email.html.erb +2 -0
  45. data/app/views/slash_admin/custom_fields/_google_map.html.erb +72 -0
  46. data/app/views/slash_admin/custom_fields/_nested_belongs_to.html.erb +55 -0
  47. data/app/views/slash_admin/custom_fields/_password.html.erb +2 -0
  48. data/app/views/slash_admin/custom_fields/_select.html.erb +2 -0
  49. data/app/views/slash_admin/custom_fields/_tags.html.erb +2 -0
  50. data/app/views/slash_admin/custom_fields/_wysiwyg.html.erb +2 -0
  51. data/app/views/slash_admin/dashboard/home.html.erb +5 -0
  52. data/app/views/slash_admin/dashboard/widgets/_statistic_chart.html.erb +0 -0
  53. data/app/views/slash_admin/dashboard/widgets/_statistic_progress_tile.html.erb +29 -0
  54. data/app/views/slash_admin/fields/_belongs_to.html.erb +9 -0
  55. data/app/views/slash_admin/fields/_boolean.html.erb +2 -0
  56. data/app/views/slash_admin/fields/_carrierwave.html.erb +15 -0
  57. data/app/views/slash_admin/fields/_date.html.erb +2 -0
  58. data/app/views/slash_admin/fields/_decimal.html.erb +2 -0
  59. data/app/views/slash_admin/fields/_form_group.html.erb +12 -0
  60. data/app/views/slash_admin/fields/_has_many.html.erb +12 -0
  61. data/app/views/slash_admin/fields/_has_many_row.html.erb +18 -0
  62. data/app/views/slash_admin/fields/_has_one.html.erb +24 -0
  63. data/app/views/slash_admin/fields/_integer.html.erb +2 -0
  64. data/app/views/slash_admin/fields/_json.html.erb +14 -0
  65. data/app/views/slash_admin/fields/_nested_has_many.html.erb +14 -0
  66. data/app/views/slash_admin/fields/_number.html.erb +2 -0
  67. data/app/views/slash_admin/fields/_string.html.erb +2 -0
  68. data/app/views/slash_admin/fields/_text.html.erb +2 -0
  69. data/app/views/slash_admin/security/sessions/new.html.erb +30 -0
  70. data/app/views/slash_admin/shared/_batch_actions.html.erb +21 -0
  71. data/app/views/slash_admin/shared/_better_paginate.html.erb +30 -0
  72. data/app/views/slash_admin/shared/_breadcrumb.html.erb +30 -0
  73. data/app/views/slash_admin/shared/_debug.html.erb +24 -0
  74. data/app/views/slash_admin/shared/_errors_data_new.html.erb +12 -0
  75. data/app/views/slash_admin/shared/_header.html.erb +38 -0
  76. data/app/views/slash_admin/shared/_menu.html.erb +57 -0
  77. data/app/views/slash_admin/shared/_new_form_buttons.html.erb +9 -0
  78. data/app/views/slash_admin/shared/_sub_header.html.erb +11 -0
  79. data/config/initializers/validators.rb +13 -0
  80. data/config/locales/slash_admin.en.yml +67 -0
  81. data/config/locales/slash_admin.fr.yml +72 -0
  82. data/config/routes.rb +16 -0
  83. data/db/migrate/20170512104248_create_slash_admin_admins.rb +19 -0
  84. data/lib/batch_translation.rb +19 -0
  85. data/lib/generators/slash_admin/controllers/controllers_generator.rb +16 -0
  86. data/lib/generators/slash_admin/controllers/templates/controllers.erb +9 -0
  87. data/lib/generators/slash_admin/install/install_generator.rb +13 -0
  88. data/lib/generators/slash_admin/install/templates/install.erb +14 -0
  89. data/lib/generators/slash_admin/override_admin/override_admin_generator.rb +13 -0
  90. data/lib/generators/slash_admin/override_admin/templates/admin.erb +46 -0
  91. data/lib/generators/slash_admin/override_session/override_session_generator.rb +13 -0
  92. data/lib/generators/slash_admin/override_session/templates/session.erb +27 -0
  93. data/lib/generators/slash_admin/permissions/permissions_generator.rb +13 -0
  94. data/lib/generators/slash_admin/permissions/templates/permissions.erb +11 -0
  95. data/lib/slash_admin.rb +29 -0
  96. data/lib/slash_admin/engine.rb +8 -0
  97. data/lib/slash_admin/version.rb +3 -0
  98. data/lib/tasks/slash_admin_tasks.rake +4 -0
  99. data/vendor/assets/javascripts/bootstrap-material-datetimepicker.js +1295 -0
  100. data/vendor/assets/javascripts/codemirror/codemirror.js +9657 -0
  101. data/vendor/assets/javascripts/codemirror/lint/json-lint.js +37 -0
  102. data/vendor/assets/javascripts/codemirror/lint/jsonlint.js +432 -0
  103. data/vendor/assets/javascripts/codemirror/lint/lint.js +252 -0
  104. data/vendor/assets/javascripts/codemirror/mode/javascript.js +865 -0
  105. data/vendor/assets/javascripts/jquery.nestable.js +910 -0
  106. data/vendor/assets/javascripts/jquery.tagsinput-revisited.min.js +5 -0
  107. data/vendor/assets/javascripts/toastr.js +6 -0
  108. data/vendor/assets/stylesheets/animate.css +1579 -0
  109. data/vendor/assets/stylesheets/bootstrap-material-datetimepicker.css +82 -0
  110. data/vendor/assets/stylesheets/codemirror/codemirror.css +346 -0
  111. data/vendor/assets/stylesheets/codemirror/lint/lint.css +73 -0
  112. data/vendor/assets/stylesheets/codemirror/theme/relax-seti.css +41 -0
  113. data/vendor/assets/stylesheets/jquery.nestable.css +121 -0
  114. data/vendor/assets/stylesheets/jquery.tagsinput-revisited.min.css +1 -0
  115. data/vendor/assets/stylesheets/sweetalert.css +935 -0
  116. data/vendor/assets/stylesheets/toastr.css +1 -0
  117. metadata +509 -0
@@ -0,0 +1,276 @@
1
+ <div class="block head-data-list">
2
+ <div class="fix-block-head"></div>
3
+ <%= render 'slash_admin/shared/better_paginate' %>
4
+ <%= render 'slash_admin/shared/batch_actions' %>
5
+ </div>
6
+
7
+ <form name="order" id="order" method="GET">
8
+ <input type="hidden" name="order_field" value="<%= params[:order_field] %>"/>
9
+ <input type="hidden" name="order" value="<%= params[:order] %>"/>
10
+ </form>
11
+
12
+ <%= form_for :filters, url: '', method: 'GET', html: {id: 'filters'} do |form| %>
13
+ <table class="table table-striped table-bordered table-hover table-data-list">
14
+ <thead>
15
+ <tr role="row" class="heading">
16
+ <th>
17
+ <input type="checkbox" class="toggle-all"/>
18
+ </th>
19
+ <th
20
+ data-order-field="id"
21
+ <% if params[:order_field].to_s == 'id' %>
22
+ class="ordered <%= params[:order].downcase %>"
23
+ data-order="<%= params[:order] %>"
24
+ <% else %>
25
+ class="ordered"
26
+ <% end %>
27
+ >#
28
+ </th>
29
+ <% list_params.each do |attr| %>
30
+ <% if attr.is_a?(Hash) %>
31
+ <th><%= @model_class.human_attribute_name(attr.keys.first) %></th>
32
+ <% else %>
33
+ <th
34
+ <% if orderable?(@model_class, attr) %>
35
+ data-order-field="<%= attr %>"
36
+ <% if params[:order_field].to_s == attr.to_s %>
37
+ class="ordered <%= params[:order].downcase %>"
38
+ data-order="<%= params[:order] %>"
39
+ <% else %>
40
+ class="ordered"
41
+ <% end %>
42
+ <% end %>>
43
+ <%= @model_class.human_attribute_name(attr) %>
44
+ </th>
45
+ <% end %>
46
+ <% end %>
47
+ <th class="text-center"><%= t('slash_admin.view.actions') %></th>
48
+ </tr>
49
+
50
+ <%= render 'filters', model: @model_class %>
51
+ </thead>
52
+
53
+ <tbody>
54
+ <% @models.each do |m| %>
55
+ <tr>
56
+ <td class="fit"><input type="checkbox" name="<%= @model_name.pluralize.downcase %>[] %>" value="<%= m.id %>"></td>
57
+ <td class="fit"><%= m.id %></td>
58
+ <% list_params.each do |attr| %>
59
+ <% if attr.is_a?(Hash) %>
60
+ <% if attr[attr.keys.first][:type].to_s == 'image' %>
61
+ <td class="text-center">
62
+ <% if m.send(attr.keys.first).present? %>
63
+ <img src="<%= m.send(attr.keys.first) %>" class="img-fluid"/>
64
+ <% else %>
65
+ <em><%= t('slash_admin.view.no_image') %></em>
66
+ <% end %>
67
+ </td>
68
+ <% else %>
69
+ <td>
70
+ <%= render attr.keys.first.to_s, model: m %>
71
+ </td>
72
+ <% end %>
73
+ <% else %>
74
+ <% if m.send(attr).is_a?(TrueClass) || m.send(attr).is_a?(FalseClass) %>
75
+ <td class="text-center">
76
+ <span class="tag tag-<%= m.send(attr) ? 'sucess' : 'danger' %> tag-boolean"><%= m.send(attr) ? 'Oui' : 'Non' %></span>
77
+ </td>
78
+ <% elsif @belongs_to_fields.include?(attr) || @has_one_fields.include?(attr) %>
79
+ <td>
80
+ <%= link_to(edit_polymorphic_url([:slash_admin, m.send(attr)]), class: 'link', target: '_blank') do %>
81
+ <%= show_object(m.send(attr)) %>
82
+ <% end rescue nil %>
83
+ </td>
84
+ <% elsif @has_many_fields.include?(attr) %>
85
+ <td>
86
+ <button type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#modal-see-assoc-<%= attr.to_s %>-<%= m.id %>">
87
+ <i class="fa fa-list"></i> <%= t('slash_admin.view.see') %>
88
+ </button>
89
+ <div class="modal fade" id="modal-see-assoc-<%= attr.to_s %>-<%= m.id %>" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true">
90
+ <div class="modal-dialog" role="document">
91
+ <div class="modal-content">
92
+ <div class="modal-header">
93
+ <h5 class="modal-title" id="exampleModalLabel"><%= t('slash_admin.view.associations') %></h5>
94
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close">
95
+ <span aria-hidden="true">&times;</span>
96
+ </button>
97
+ </div>
98
+ <div class="modal-body">
99
+ <% if m.send(attr).length == 0 %>
100
+ <%= t('slash_admin.view.no_associations') %>
101
+ <% else %>
102
+ <% m.send(attr).each do |a| %>
103
+ <%= link_to(edit_polymorphic_url([:slash_admin, a]), class: 'link', target: '_blank') do %>
104
+ <%= show_object(a) %><br />
105
+ <% end rescue nil %>
106
+ <% end %>
107
+ <% end %>
108
+ </div>
109
+ <div class="modal-footer">
110
+ <button type="button" class="btn btn-secondary" data-dismiss="modal"><%= t('slash_admin.view.close') %></button>
111
+ </div>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ </td>
116
+ <% else %>
117
+ <td>
118
+ <%= m.send(attr) %>
119
+ </td>
120
+ <% end %>
121
+ <% end %>
122
+ <% end %>
123
+ <td class="actions fit">
124
+ <div class="btn-group">
125
+ <% if can? :show, @model_class %>
126
+ <%= link_to(polymorphic_url([:slash_admin, m]), class: 'btn btn-primary btn-sm') do %>
127
+ <i class="icon-magnifier"></i>
128
+ <% end rescue nil %>
129
+ <% end %>
130
+ <% if can? :edit, @model_class %>
131
+ <%= link_to(edit_polymorphic_url([:slash_admin, m]), class: 'btn btn-warning btn-sm') do %>
132
+ <i class="icon-note"></i>
133
+ <% end rescue nil %>
134
+ <% end %>
135
+ <% if can? :destroy, @model_class %>
136
+ <%= link_to(polymorphic_url([:slash_admin, m]), class: 'single-delete btn btn-danger btn-sm') do %>
137
+ <i class="icon-trash"></i>
138
+ <% end rescue nil %>
139
+ <% end %>
140
+ </div>
141
+ </td>
142
+ </tr>
143
+ <% end %>
144
+ </tbody>
145
+ </table>
146
+ <% end %>
147
+
148
+ <%= render 'slash_admin/shared/better_paginate' %>
149
+
150
+ <script type="text/javascript">
151
+ $(document).on('turbolinks:load', function() {
152
+ $('.bootstrap-datepicker').datepicker({
153
+ language: '<%= I18n.locale.to_s %>',
154
+ format: "YYYY-MM-DD",
155
+ templates: {
156
+ leftArrow: '<i class="icon-arrow-left"></i>',
157
+ rightArrow: '<i class="icon-arrow-right"></i>'
158
+ }
159
+ });
160
+
161
+ // handle Sort
162
+ $('.ordered').on('click', function() {
163
+ var field = $(this).data('order-field');
164
+
165
+ if (field) {
166
+ var order_direction = $(this).data('order');
167
+ if (!order_direction) {
168
+ order_direction = 'DESC';
169
+ } else {
170
+ order_direction = toggle_order(order_direction);
171
+ }
172
+ handle_form(field, order_direction);
173
+
174
+ // change order field should reset pagination
175
+ $('.admin-pagination input').val(1);
176
+ $('.admin-pagination option:first').prop('selected',true);
177
+ handleFiltersAndLocation();
178
+ }
179
+ });
180
+
181
+ function toggle_order(order_direction) {
182
+ return order_direction == 'DESC' ? 'ASC' : 'DESC';
183
+ }
184
+
185
+ function handle_form(field, order_direction) {
186
+ $('input[name="order_field"]').val(field);
187
+ $('input[name="order"]').val(order_direction);
188
+ }
189
+
190
+ // Pagination
191
+ var delimiter = false;
192
+
193
+ // Only integer in text field for page number
194
+ $('.integer').keypress(function (e) {
195
+ var a = [];
196
+ var k = e.which;
197
+ var val = $(this).val();
198
+
199
+ // Allow Backspace
200
+ a.push(8);
201
+
202
+ // Allow Enter
203
+ a.push(13);
204
+
205
+ // Allow number
206
+ for (i = 48; i < 58; i++)
207
+ a.push(i);
208
+
209
+ if (!(a.indexOf(k) >= 0)) {
210
+ e.preventDefault();
211
+ }
212
+ });
213
+
214
+ // Select range value per
215
+ $('select[name="per"]').on('change', function () {
216
+ $('select[name="per"]').val($(this).val());
217
+ $('input[name="page"]').val(1);
218
+ });
219
+
220
+ $('.prev-page, .next-page').on('click', function (e) {
221
+ e.preventDefault();
222
+ var disabled = $(this).attr('disabled');
223
+ if (!disabled) {
224
+ var page = parseInt(<%= params[:page] %>);
225
+ if ($(this).hasClass('prev-page')) {
226
+ page--;
227
+ } else {
228
+ page++;
229
+ }
230
+ $('.admin-pagination').find('input[name="page"]').val(page).change();
231
+ }
232
+ });
233
+
234
+ $('.admin-pagination').on('change', function () {
235
+ if (!delimiter) {
236
+ delimiter = true;
237
+ var last_page = parseInt(<%= @models.total_pages %>);
238
+ var val = $(this).find('input[name="page"]').val();
239
+
240
+ if (val > 0 && val <= last_page) {
241
+ handleFiltersAndLocation();
242
+ }
243
+ }
244
+ });
245
+
246
+ $('#reset-filters').on('click', function(e) {
247
+ e.preventDefault();
248
+
249
+ $("input[name*='filters']").val('');
250
+ $("select[name*='filters'] option:first").prop('selected',true);
251
+
252
+ $('#filters').trigger('submit');
253
+ });
254
+
255
+
256
+ // Handle Both form
257
+ function handleFiltersAndLocation() {
258
+ var url = window.location.href.split("?")[0];
259
+
260
+ var filtersParams = $('#filters').serialize();
261
+ var paginationParams = $('.admin-pagination').first().serialize();
262
+ var orderParams = $('#order').serialize();
263
+
264
+ parameters = '';
265
+ $.each([filtersParams, paginationParams, orderParams], function(index, params) {
266
+ if (index != 0) {
267
+ parameters += '&' + params;
268
+ } else {
269
+ parameters += params;
270
+ }
271
+ });
272
+
273
+ window.location.href = url + '?' + parameters;
274
+ }
275
+ });
276
+ </script>
@@ -0,0 +1,33 @@
1
+ <div class="dd">
2
+ <ol class="dd-list">
3
+ <% if @ancestry_field.present? %>
4
+ <% else %>
5
+ <% @model_class.all.order("#{@position_field} ASC").each do |m| %>
6
+ <li class="dd-item" data-id="<%= m.id %>">
7
+ <div class="dd-handle"><%= show_object(m) %></div>
8
+ </li>
9
+ <% end %>
10
+ <% end %>
11
+ </ol>
12
+ </div>
13
+
14
+ <br />
15
+
16
+ <%= form_tag('', method: 'post') do %>
17
+ <%= hidden_field(:nestable, :data) %>
18
+
19
+ <%= button_tag(type: 'submit', class: 'btn btn btn-success', name: 'submit_redirect') do %>
20
+ <i class="fa fa-save"></i> <i class="icon-action-undo"></i> <%= t('slash_admin.view.save_and_return_html') %>
21
+ <% end %>
22
+ <button type="submit" class="btn btn-primary pull-right">
23
+ <i class="fa fa-save"></i> <%= t('slash_admin.view.save') %>
24
+ </button>
25
+ <% end %>
26
+
27
+ <script type="text/javascript">
28
+ $('.dd').nestable({
29
+ maxDepth: <%= @max_depth %>
30
+ }).on('change', function() {
31
+ $('#nestable_data').val(JSON.stringify($('.dd').nestable('serialize')));
32
+ });
33
+ </script>
@@ -0,0 +1,16 @@
1
+ <%= form_for [:slash_admin, @model] do |f| %>
2
+ <%#= render 'slash_admin/shared/debug', params: params %>
3
+
4
+ <%= render 'slash_admin/shared/errors_data_new' %>
5
+
6
+ <% params.each do |a| %>
7
+ <%# <strong><%= @model_class.type_for_attribute(a).type.to_s </strong> %>
8
+ <%= render 'slash_admin/fields/form_group', f: f, a: a %>
9
+ <% end %>
10
+
11
+ <%= render 'slash_admin/base/translatable_fields', f: f %>
12
+
13
+ <%= render 'slash_admin/shared/new_form_buttons' %>
14
+ <% end %>
15
+
16
+ <div class="modal-belongs-to modal"></div>
@@ -0,0 +1,72 @@
1
+ <% show_params.each do |a| %>
2
+ <% if @belongs_to_fields.include?(a.to_sym) %>
3
+ <div class="row line-show">
4
+ <div class="col-sm-12">
5
+ <span class="show-attr-title"><%= @model_class.human_attribute_name(a) %></span>
6
+ <%= show_object(@model.send(a)) %>
7
+ </div>
8
+ </div>
9
+ <% elsif @has_many_fields.include?(a.to_sym) %>
10
+ <div class="row line-show">
11
+ <div class="col-sm-12">
12
+ <span class="show-attr-title"><%= @model_class.human_attribute_name(a) %></span>
13
+ <%= @model.send(a) %>
14
+ </div>
15
+ </div>
16
+ <% elsif @model.send(a).class <= CarrierWave::Uploader::Base %>
17
+ <div class="row line-show">
18
+ <div class="col-sm-12">
19
+ <span class="show-attr-title"><%= @model_class.human_attribute_name(a) %></span>
20
+ <% if @model.send(a).present? %>
21
+ <br/>
22
+ <img src="<%= @model.send(a) %>" class="img-fluid background-default"/>
23
+ <% end %>
24
+ </div>
25
+ </div>
26
+ <% else %>
27
+ <% case guess_field_type(@model, a)
28
+ when 'string' %>
29
+ <div class="row line-show">
30
+ <div class="col-sm-12">
31
+ <span class="show-attr-title"><%= @model_class.human_attribute_name(a) %></span>
32
+ <%= @model.send(a) %>
33
+ </div>
34
+ </div>
35
+ <% when 'text' %>
36
+ <div class="row line-show">
37
+ <div class="col-sm-12">
38
+ <span class="show-attr-title"><%= @model_class.human_attribute_name(a) %></span>
39
+ <%= @model.send(a) %>
40
+ </div>
41
+ </div>
42
+ <% when 'integer' %>
43
+ <div class="row line-show">
44
+ <div class="col-sm-12">
45
+ <span class="show-attr-title"><%= @model_class.human_attribute_name(a) %></span>
46
+ <%= @model.send(a) %>
47
+ </div>
48
+ </div>
49
+ <% when 'number', 'decimal' %>
50
+ <div class="row line-show">
51
+ <div class="col-sm-12">
52
+ <span class="show-attr-title"><%= @model_class.human_attribute_name(a) %></span>
53
+ <%= @model.send(a) %>
54
+ </div>
55
+ </div>
56
+ <% when 'boolean' %>
57
+ <div class="row line-show">
58
+ <div class="col-sm-12">
59
+ <span class="show-attr-title"><%= @model_class.human_attribute_name(a) %></span>
60
+ <%= @model.send(a) ? t('slash_admin.view.yes') : t('slash_admin.view.no') %>
61
+ </div>
62
+ </div>
63
+ <% when 'date', 'datetime' %>
64
+ <div class="row line-show">
65
+ <div class="col-sm-12">
66
+ <span class="show-attr-title"><%= @model_class.human_attribute_name(a) %></span>
67
+ <%= @model.send(a) %>
68
+ </div>
69
+ </div>
70
+ <% end %>
71
+ <% end %>
72
+ <% end %>
@@ -0,0 +1,60 @@
1
+ <tr role="row" class="filters">
2
+ <td>&nbsp;</td>
3
+ <td class="fit">
4
+ <input type="text" name="filters[id]" value="<%= params[:filters]['id'] rescue nil %>" class="form-control form-control-sm fix-id-search"/>
5
+ </td>
6
+ <% list_params.each do |attr| %>
7
+ <% if !attr.is_a?(Hash) && sortable?(model, attr) %>
8
+ <td>
9
+ <% case guess_field_type(model, attr)
10
+ when 'string', 'text' %>
11
+ <input type="text" name="filters[<%= attr %>]" value="<%= params[:filters][attr] rescue nil %>" class="form-control form-control-sm"/>
12
+ <% when 'integer', 'number', 'decimal' %>
13
+ <input type="text" name="filters[<%= attr %>][from]" value="<%= params[:filters][attr]['from'] rescue nil %>" class="form-control form-control-sm" placeholder="De"/>
14
+ <input type="text" name="filters[<%= attr %>][to]" value="<%= params[:filters][attr]['to'] rescue nil %>" class="form-control form-control-sm" placeholder="À"/>
15
+ <% when 'date', 'datetime' %>
16
+ <div class="input-group">
17
+ <input type="text" name="filters[<%= attr %>][from]" value="<%= params[:filters][attr]['from'] rescue nil %>" class="form-control form-control-sm bootstrap-datepicker" placeholder="Du"/>
18
+ <span class="input-group-addon"><i class="icon-calendar"></i></span>
19
+ </div>
20
+ <div class="input-group">
21
+ <input type="text" name="filters[<%= attr %>][to]" value="<%= params[:filters][attr]['to'] rescue nil %>" class="form-control form-control-sm bootstrap-datepicker" placeholder="Au"/>
22
+ <span class="input-group-addon"><i class="icon-calendar"></i></span>
23
+ </div>
24
+ <% when 'boolean' %>
25
+ <select name="filters[<%= attr %>]" class="form-control form-control-sm">
26
+ <option value="" <%= params[:filters][attr] == '' ? 'selected' : nil rescue nil %>></option>
27
+ <option value="true" <%= params[:filters][attr] == 'true' ? 'selected' : nil rescue nil %>>Oui</option>
28
+ <option value="false" <%= params[:filters][attr] == 'false' ? 'selected' : nil rescue nil %>>Non</option>
29
+ </select>
30
+ <% end %>
31
+ </td>
32
+ <% elsif @belongs_to_fields.include?(attr) || @has_one_fields.include?(attr) %>
33
+ <% if "SlashAdmin::Models::#{attr.to_s.classify.pluralize}Controller".constantize.new.autocomplete_params.present? %>
34
+ <td>
35
+ <select name="filters[<%= attr %>][]" class="selectize-model-multiple" 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) %>">
36
+ <% attr.to_s.classify.constantize.all.limit(20).each do |model_row| %>
37
+ <% if params[:filter].present? %>
38
+ <% if params[:filters][attr]&.include? model_row.id.to_s %>
39
+ <option value="<%= model_row.id %>" selected><%= show_object(model_row) %></option>
40
+ <% else %>
41
+ <option value="<%= model_row.id %>"><%= show_object(model_row) %></option>
42
+ <% end %>
43
+ <% else %>
44
+ <option value="<%= model_row.id %>"><%= show_object(model_row) %></option>
45
+ <% end %>
46
+ <% end %>
47
+ </select>
48
+ </td>
49
+ <% else %>
50
+ <td>&nbsp;</td>
51
+ <% end %>
52
+ <% else %>
53
+ <td>&nbsp;</td>
54
+ <% end %>
55
+ <% end %>
56
+ <td>
57
+ <button type="submit" class="btn btn-sm btn-block btn-primary"><i class='fa fa-filter'></i> <%= t('slash_admin.view.filter') %></button>
58
+ <button id="reset-filters" class="btn btn-sm btn-block btn-secondary"><i class='fa fa-times'></i> <%= t('slash_admin.view.reset') %></button>
59
+ </td>
60
+ </tr>