templus_models 2.0.16 → 3.0.4

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.
@@ -1,4 +1,5 @@
1
1
  class RaroCrud
2
+ @agrupamento = nil
2
3
  @@order_field = {}
3
4
  @@per_page = {}
4
5
  @@index_fields = {}
@@ -7,8 +8,6 @@ class RaroCrud
7
8
  @@form_scripts = {}
8
9
  @@view_fields = {}
9
10
  @@listing_fields = {}
10
- @@setup_report_listing = {}
11
- @@setup_report_printing = {}
12
11
  @@printing_fields = {}
13
12
  @@search_fields = {}
14
13
  @@test_fields = {}
@@ -27,7 +26,7 @@ class RaroCrud
27
26
  @@condition_listing_action = {}
28
27
  @@condition_listing_excel = {}
29
28
  @@condition_listing_pdf = {}
30
- @@condition_printing_action = {}
29
+ @@condition_printing_action = {}
31
30
  @@options_link = {}
32
31
  @@scopes = {}
33
32
  @@menus = []
@@ -130,11 +129,11 @@ class RaroCrud
130
129
  end
131
130
 
132
131
  def self.top_links
133
- @@top_links[self.to_s.to_sym] || []
132
+ (@@top_links[self.to_s.to_sym]) ? @@top_links[self.to_s.to_sym] : []
134
133
  end
135
134
 
136
135
  def self.index_fields
137
- @@index_fields[self.to_s.to_sym] || []
136
+ (@@index_fields[self.to_s.to_sym]) ? @@index_fields[self.to_s.to_sym] : []
138
137
  end
139
138
 
140
139
  def self.order_field
@@ -146,59 +145,51 @@ class RaroCrud
146
145
  end
147
146
 
148
147
  def self.actions
149
- @@actions[self.to_s.to_sym] || []
148
+ (@@actions[self.to_s.to_sym]) ? @@actions[self.to_s.to_sym] : []
150
149
  end
151
150
 
152
151
  def self.actions_links
153
- @@links[self.to_s.to_sym] || []
152
+ (@@links[self.to_s.to_sym]) ? @@links[self.to_s.to_sym] : []
154
153
  end
155
154
 
156
155
  def self.options_link
157
- @@options_link[self.to_s.to_sym] || []
156
+ (@@options_link[self.to_s.to_sym]) ? @@options_link[self.to_s.to_sym] : []
158
157
  end
159
158
 
160
159
  def self.form_fields
161
- @@form_fields[self.to_s.to_sym] || []
160
+ (@@form_fields[self.to_s.to_sym]) ? @@form_fields[self.to_s.to_sym] : []
162
161
  end
163
162
 
164
163
  def self.form_groups
165
- @@form_group[self.to_s.to_sym] || []
164
+ (@@form_group[self.to_s.to_sym]) ? @@form_group[self.to_s.to_sym] : []
166
165
  end
167
166
 
168
167
  def self.form_scripts
169
- @@form_scripts[self.to_s.to_sym] || []
168
+ (@@form_scripts[self.to_s.to_sym]) ? @@form_scripts[self.to_s.to_sym] : []
170
169
  end
171
170
 
172
171
  def self.view_fields
173
- @@view_fields[self.to_s.to_sym] || []
172
+ (@@view_fields[self.to_s.to_sym]) ? @@view_fields[self.to_s.to_sym] : []
174
173
  end
175
174
 
176
175
  def self.listing_fields
177
- @@listing_fields[self.to_s.to_sym] || []
178
- end
179
-
180
- def self.setup_report_listing
181
- @@setup_report_listing[self.to_s.to_sym] || {}
182
- end
183
-
184
- def self.setup_report_printing
185
- @@setup_report_printing[self.to_s.to_sym] || {}
176
+ (@@listing_fields[self.to_s.to_sym]) ? @@listing_fields[self.to_s.to_sym] : []
186
177
  end
187
178
 
188
179
  def self.printing_fields
189
- @@printing_fields[self.to_s.to_sym] || []
180
+ (@@printing_fields[self.to_s.to_sym]) ? @@printing_fields[self.to_s.to_sym] : []
190
181
  end
191
182
 
192
183
  def self.search_fields
193
- @@search_fields[self.to_s.to_sym] || []
184
+ (@@search_fields[self.to_s.to_sym]) ? @@search_fields[self.to_s.to_sym] : []
194
185
  end
195
186
 
196
187
  def self.test_fields
197
- @@test_fields[self.to_s.to_sym] || []
188
+ (@@test_fields[self.to_s.to_sym]) ? @@test_fields[self.to_s.to_sym] : []
198
189
  end
199
190
 
200
191
  def self.scopes
201
- @@scopes[self.to_s.to_sym] || []
192
+ (@@scopes[self.to_s.to_sym]) ? @@scopes[self.to_s.to_sym] : []
202
193
  end
203
194
 
204
195
  def self.add_menus(menu)
@@ -209,60 +200,168 @@ class RaroCrud
209
200
  @@menus
210
201
  end
211
202
 
212
- def self.campo_visualizacao(nome, opts = {})
213
- @@view_fields[self.to_s.to_sym] ||= []
203
+
204
+ private
205
+
206
+ def self.modelo
207
+ self.to_s.underscore.gsub("_crud", "")
208
+ end
209
+
210
+ def self.titulo str
211
+ @@title[self.to_s.to_sym] = str
212
+ end
213
+
214
+ def self.subtitulo(str,type)
215
+ case type
216
+ when :index
217
+ @@subtitle_index[self.to_s.to_sym] = str
218
+ end
219
+ end
220
+
221
+ def self.descricao(str,type)
222
+ case type
223
+ when :index
224
+ @@description_index[self.to_s.to_sym] = str
225
+ end
226
+ end
227
+
228
+ def self.link_superior opts={}
229
+ @@top_links[self.to_s.to_sym] = [] unless @@top_links[self.to_s.to_sym]
230
+ @@top_links[self.to_s.to_sym].push(
231
+ {
232
+ text: opts[:nome],
233
+ modelo: self.modelo,
234
+ id: opts[:id],
235
+ data: {push: 'partial', target: '#form'},
236
+ icon: "fa fa-#{opts[:icon]}",
237
+ class: 'btn btn-small btn-primary btn-rounded',
238
+ link: opts[:link],
239
+ url: opts[:url],
240
+ can: opts[:can],
241
+ partial: opts[:partial]
242
+ }
243
+ )
244
+ end
245
+
246
+ def self.campo_tabela nome, opts={}
247
+ @@index_fields[self.to_s.to_sym] = [] unless @@index_fields[self.to_s.to_sym]
214
248
  opts = set_default_label nome, opts
215
- @@view_fields[self.to_s.to_sym].push({
216
- attribute: nome,
217
- sf: opts
218
- })
249
+ @@index_fields[self.to_s.to_sym].push(
250
+ {
251
+ attribute: nome
252
+ }.merge(opts)
253
+ )
254
+ end
255
+
256
+ def self.ordenar_por nome
257
+ @@order_field[self.to_s.to_sym] = nome
258
+ end
259
+
260
+ def self.itens_por_pagina qtd
261
+ @@per_page[self.to_s.to_sym] = qtd
219
262
  end
220
263
 
221
- def self.campo_busca(nome, opts = {})
222
- @@search_fields[self.to_s.to_sym] ||= []
264
+ def self.campo_teste nome, opts = {}
265
+ @@test_fields[self.to_s.to_sym] = [] unless @@test_fields[self.to_s.to_sym]
266
+ @@test_fields[self.to_s.to_sym].push(
267
+ {
268
+ attribute: nome
269
+ }.merge({sf: opts})
270
+ )
271
+ end
272
+
273
+ def self.campo_formulario nome, opts={}
274
+ @@form_fields[self.to_s.to_sym] = [] unless @@form_fields[self.to_s.to_sym]
275
+ opts = set_default_label nome, opts
276
+ if opts.present? && opts[:autocomplete].present?
277
+ opts[:as] = :autocomplete
278
+ label_method = opts[:autocomplete][:label_method] || opts[:autocomplete][:campo]
279
+ opts[:url] = Rails.application.routes.url_helpers.autocomplete_crud_path(model: opts[:autocomplete][:classe], campo: opts[:autocomplete][:campo], tipo: "start", label: label_method)
280
+ name = "#{opts[:autocomplete][:campo]}_#{opts[:autocomplete][:classe]}"
281
+ opts[:input_html] = {name: name, id: name}
282
+ opts[:id_element] = "##{self.modelo}_#{nome}_id"
283
+ end
284
+ if opts.present? && opts[:grupo].present?
285
+ opts[:fields] = []
286
+ opts[:grupo].each do |field|
287
+ attribute = field[:campo]
288
+ field.delete(:campo)
289
+ add_group_formulario(field) if field[:grupo].present?
290
+ opts[:fields].push({attribute: attribute,sf: field})
291
+ end
292
+ opts[:grupo] = true if opts[:grupo].present?
293
+ end
294
+ if @agrupamento.present?
295
+ opts[:agrupamento] = @agrupamento
296
+ end
297
+ @@form_fields[self.to_s.to_sym].push(
298
+ {
299
+ attribute: nome
300
+ }.merge({sf: opts})
301
+ )
302
+ if opts.present? && opts[:autocomplete].present?
303
+ campo_formulario(nome, {as: :hidden})
304
+ end
305
+ end
306
+
307
+ private
308
+ def self.add_group_formulario(field)
309
+ field[:fields] = []
310
+ field[:grupo].each do |f|
311
+ attribute = f[:campo]
312
+ f.delete(:campo)
313
+ add_group_formulario(f) if f[:grupo].present?
314
+ field[:fields].push({attribute: attribute, sf: f})
315
+ end
316
+ field[:grupo] = true
317
+ end
318
+
319
+ def self.set_default_label nome, opts
320
+ unless opts[:label].present?
321
+ opts[:label] = "simple_form.labels.#{self.modelo.underscore}.#{nome}"
322
+ end
323
+ opts
324
+ end
325
+
326
+ public
327
+ def self.campo_visualizacao nome, opts = {}
328
+ @@view_fields[self.to_s.to_sym] = [] unless @@view_fields[self.to_s.to_sym]
329
+ opts = set_default_label nome, opts
330
+ @@view_fields[self.to_s.to_sym].push(
331
+ {
332
+ attribute: nome
333
+ }.merge({sf: opts})
334
+ )
335
+ end
336
+
337
+ def self.campo_busca nome, opts = {}
338
+ @@search_fields[self.to_s.to_sym] = [] unless @@search_fields[self.to_s.to_sym]
223
339
  opts = set_default_label nome, opts
224
- @@search_fields[self.to_s.to_sym].push({
225
- attribute: nome,
226
- sf: opts
227
- })
340
+ @@search_fields[self.to_s.to_sym].push(
341
+ {
342
+ attribute: nome
343
+ }.merge({sf: opts})
344
+ )
228
345
  end
229
346
 
230
- def self.relatorio_listagem(nome, opts = {})
231
- @@listing_fields[self.to_s.to_sym] ||= []
347
+ def self.campo_listagem nome, opts = {}
348
+ @@listing_fields[self.to_s.to_sym] = [] unless @@listing_fields[self.to_s.to_sym]
232
349
  opts = set_default_label nome, opts
233
- @@listing_fields[self.to_s.to_sym].push({
234
- attribute: nome,
235
- sf: opts
236
- })
237
- end
238
-
239
- def self.setup_relatorio_listagem(options = {})
240
- @@setup_report_listing[self.to_s.to_sym] = {
241
- top: options[:top] || 20,
242
- bottom: options[:bottom] || 20,
243
- orientation: options[:orientation] || 'Portrait',
244
- header: options[:header],
245
- footer: options[:footer]
246
- }
247
- end
248
-
249
- def self.setup_relatorio_impressao(options = {})
250
- @@setup_report_printing[self.to_s.to_sym] = {
251
- top: options[:top] || 20,
252
- bottom: options[:bottom] || 20,
253
- orientation: options[:orientation] || 'Portrait',
254
- header: options[:header],
255
- footer: options[:footer]
256
- }
257
- end
258
-
259
- def self.relatorio_impressao(nome, opts = {})
260
- @@printing_fields[self.to_s.to_sym] ||= []
350
+ @@listing_fields[self.to_s.to_sym].push(
351
+ {
352
+ attribute: nome
353
+ }.merge({sf: opts})
354
+ )
355
+ end
356
+
357
+ def self.campo_impressao nome, opts = {}
358
+ @@printing_fields[self.to_s.to_sym] = [] unless @@printing_fields[self.to_s.to_sym]
261
359
  opts = set_default_label nome, opts
262
- @@printing_fields[self.to_s.to_sym].push({
263
- attribute: nome,
264
- sf: opts
265
- })
360
+ @@printing_fields[self.to_s.to_sym].push(
361
+ {
362
+ attribute: nome
363
+ }.merge({sf: opts})
364
+ )
266
365
  end
267
366
 
268
367
  def self.sem_visualizacao
@@ -305,9 +404,9 @@ class RaroCrud
305
404
  @@condition_printing_action[self.to_s.to_sym] = condicao
306
405
  end
307
406
 
308
- def self.acoes(method, desc, proc = nil, options = {})
407
+ def self.acoes(method,desc,proc = nil)
309
408
  @@actions[self.to_s.to_sym] = [] unless @@actions[self.to_s.to_sym]
310
- @@actions[self.to_s.to_sym].push([method, desc, proc, options])
409
+ @@actions[self.to_s.to_sym].push([method,desc,proc])
311
410
  end
312
411
 
313
412
  def self.links(name,options)
@@ -324,6 +423,20 @@ class RaroCrud
324
423
  @@scopes[self.to_s.to_sym] = scopes
325
424
  end
326
425
 
426
+ def self.agrupar_campos(attribute, opts = {}, &block)
427
+ if opts[:label]
428
+ @agrupamento = opts[:label]
429
+ else
430
+ @agrupamento = "simple_form.labels.#{self.modelo.underscore}.#{attribute}"
431
+ end
432
+ block.call
433
+ @agrupamento = nil
434
+ end
435
+
436
+ def self.separar_formulario
437
+ @@form_fields[self.to_s.to_sym].last[:sf][:separador] = true
438
+ end
439
+
327
440
  def self.grupo_formulario(attribute,name,fields=nil)
328
441
  if fields.nil?
329
442
  fields = name
@@ -379,121 +492,4 @@ class RaroCrud
379
492
  @@form_scripts[self.to_s.to_sym] << script.to_s
380
493
  end
381
494
 
382
- private
383
-
384
- def self.modelo
385
- self.to_s.underscore.gsub("_crud", "")
386
- end
387
-
388
- def self.titulo str
389
- @@title[self.to_s.to_sym] = str
390
- end
391
-
392
- def self.subtitulo(str,type)
393
- case type
394
- when :index
395
- @@subtitle_index[self.to_s.to_sym] = str
396
- end
397
- end
398
-
399
- def self.descricao(str,type)
400
- case type
401
- when :index
402
- @@description_index[self.to_s.to_sym] = str
403
- end
404
- end
405
-
406
- def self.link_superior opts={}
407
- @@top_links[self.to_s.to_sym] = [] unless @@top_links[self.to_s.to_sym]
408
- @@top_links[self.to_s.to_sym].push(
409
- {
410
- text: opts[:nome],
411
- modelo: self.modelo,
412
- id: opts[:id],
413
- data: {push: 'partial', target: '#form'},
414
- icon: "fa fa-#{opts[:icon]}",
415
- class: 'btn btn-small btn-primary btn-rounded',
416
- link: opts[:link],
417
- url: opts[:url],
418
- can: opts[:can],
419
- partial: opts[:partial]
420
- }
421
- )
422
- end
423
-
424
- def self.campo_tabela nome, opts={}
425
- @@index_fields[self.to_s.to_sym] = [] unless @@index_fields[self.to_s.to_sym]
426
- opts = set_default_label nome, opts
427
- @@index_fields[self.to_s.to_sym].push(
428
- {
429
- attribute: nome
430
- }.merge(opts)
431
- )
432
- end
433
-
434
- def self.ordenar_por nome
435
- @@order_field[self.to_s.to_sym] = nome
436
- end
437
-
438
- def self.itens_por_pagina qtd
439
- @@per_page[self.to_s.to_sym] = qtd
440
- end
441
-
442
- def self.campo_teste nome, opts = {}
443
- @@test_fields[self.to_s.to_sym] = [] unless @@test_fields[self.to_s.to_sym]
444
- @@test_fields[self.to_s.to_sym].push(
445
- {
446
- attribute: nome
447
- }.merge({sf: opts})
448
- )
449
- end
450
-
451
- def self.campo_formulario nome, opts={}
452
- @@form_fields[self.to_s.to_sym] = [] unless @@form_fields[self.to_s.to_sym]
453
- opts = set_default_label nome, opts
454
- if opts.present? && opts[:autocomplete].present?
455
- opts[:as] = :autocomplete
456
- label_method = opts[:autocomplete][:label_method] || opts[:autocomplete][:campo]
457
- opts[:url] = Rails.application.routes.url_helpers.autocomplete_crud_path(model: opts[:autocomplete][:classe], campo: opts[:autocomplete][:campo], tipo: "start", label: label_method)
458
- name = "#{opts[:autocomplete][:campo]}_#{opts[:autocomplete][:classe]}"
459
- opts[:input_html] = {name: name, id: name}
460
- opts[:id_element] = "##{self.modelo}_#{nome}_id"
461
- end
462
- if opts.present? && opts[:grupo].present?
463
- opts[:fields] = []
464
- opts[:grupo].each do |field|
465
- attribute = field[:campo]
466
- field.delete(:campo)
467
- add_group_formulario(field) if field[:grupo].present?
468
- opts[:fields].push({attribute: attribute,sf: field})
469
- end
470
- opts[:grupo] = true if opts[:grupo].present?
471
- end
472
- @@form_fields[self.to_s.to_sym].push(
473
- {
474
- attribute: nome
475
- }.merge({sf: opts})
476
- )
477
- if opts.present? && opts[:autocomplete].present?
478
- campo_formulario(nome, {as: :hidden})
479
- end
480
- end
481
-
482
- def self.add_group_formulario(field)
483
- field[:fields] = []
484
- field[:grupo].each do |f|
485
- attribute = f[:campo]
486
- f.delete(:campo)
487
- add_group_formulario(f) if f[:grupo].present?
488
- field[:fields].push({attribute: attribute, sf: f})
489
- end
490
- field[:grupo] = true
491
- end
492
-
493
- def self.set_default_label nome, opts
494
- unless opts[:label].present?
495
- opts[:label] = "simple_form.labels.#{self.modelo.underscore}.#{nome}"
496
- end
497
- opts
498
- end
499
495
  end
@@ -31,11 +31,16 @@
31
31
  <%end%>
32
32
  <%= simple_nested_form_for @record, remote: remote_form, html: {class: "form-horizontal"}, url: url do |f| %>
33
33
  <%= flash_messages_error(@record.errors) %>
34
- <%@crud_helper.form_fields.each do |field|%>
35
- <% if field[:sf].present? && field[:sf][:if].present? %>
34
+ <% @crud_helper.form_fields.each_with_index do |field, index| %>
35
+ <% if field[:sf][:agrupamento].present? && (index == 0 || @crud_helper.form_fields[index - 1][:sf][:agrupamento] != field[:sf][:agrupamento]) %>
36
+ <div class="col-sm-12">
37
+ <h3><%= I18n.t(field[:sf][:agrupamento]) %></h3>
38
+ </div>
39
+ <% end %>
40
+ <% if field[:sf][:if].present? %>
36
41
  <% next unless field[:sf][:if].call(f.object) %>
37
42
  <% end %>
38
- <% if field[:sf].present? && field[:sf][:grupo].present? %>
43
+ <% if field[:sf][:grupo].present? %>
39
44
  <%= render "/crud/form_group", f: f, key: field[:attribute], groups: field[:sf] %>
40
45
  <% else %>
41
46
  <% if @model.reflect_on_association(field[:attribute]).try(:macro) == :belongs_to && is_raro_crud(@model.reflect_on_association(field[:attribute]).class_name) && field[:sf][:add_registro].nil?%>
@@ -44,6 +49,9 @@
44
49
  <%= render_field(field,f,@model,@record) %>
45
50
  <%end%>
46
51
  <% end %>
52
+ <% if field[:sf][:separador].present? %>
53
+ <hr>
54
+ <% end %>
47
55
  <% end %>
48
56
  <%@crud_helper.form_groups.each do |key, groups|%>
49
57
  <%= render "/crud/form_group", f: f, key: key, groups: groups %>
@@ -38,7 +38,7 @@
38
38
  <% if record.send(att[:attribute]).to_s == "false" or record.send(att[:attribute]).to_s == "true" %>
39
39
  <td class="row">
40
40
  <div class="col-xs-9">
41
- <%= I18n.t(record.send(att[:attribute]) ? "shared.sim" : "shared.nao") %>
41
+ <%= I18n.t(record.send(att[:attribute]) ? "shared.sim" : "shared.nao") %>
42
42
  </div>
43
43
  </td>
44
44
  <% else %>
@@ -55,47 +55,31 @@
55
55
  <%end%>
56
56
  <td class="row">
57
57
  <div class="col-xs-9">
58
- <% @crud_helper.actions.each do |a| %>
59
- <% if !a[2].present? || a[2].call(record) %>
60
-
61
- <% if a[3][:class] %>
62
- <% link_class = 'btn btn-xs ' + a[3][:class] %>
63
- <% else %>
64
- <% link_class = 'btn btn-primary btn-xs' %>
65
- <% end %>
66
-
67
- <%= link_to I18n.t(a[1]), action_crud_path(model: @model.name.underscore, id: record.id, acao: a[0]), class: link_class, data: {push: "partial", target: "#form"}%>
58
+ <%@crud_helper.actions.each do |a|%>
59
+ <% if ((a[2].present? && a[2].call(record)) || !a[2].present?) %>
60
+ <%= link_to I18n.t(a[1]), action_crud_path(model: @model.name.underscore, id: record.id, acao: a[0]), class: "btn btn-primary btn-xs", data: {push: "partial", target: "#form"}%>
68
61
  <% end %>
69
62
  <% end %>
70
- <% @crud_helper.actions_links.each do |name, options| %>
71
- <% unless options[:can].present? && !record.instance_eval(&options[:can]) %>
63
+ <%@crud_helper.actions_links.each do |name, options|%>
64
+ <% unless (options[:can].present? && !record.instance_eval(&options[:can])) %>
72
65
  <% if options[:url].present? %>
73
66
  <% url = options[:url] %>
74
-
75
67
  <% if options[:id] %>
76
68
  <% url += options[:url].include?("?") ? "&id=#{record.id}" : "?id=#{record.id}" %>
77
69
  <% else url.include?(":id") %>
78
70
  <% url = url.gsub(":id", "#{record.id}") %>
79
71
  <% end %>
80
-
81
- <% if options[:class] %>
82
- <% link_class = 'btn btn-xs ' + options[:class] %>
83
- <% else %>
84
- <% link_class = 'btn btn-success btn-xs' %>
85
- <% end %>
86
-
87
- <% if options[:wiselink] %>
88
- <%= link_to t(name), url, class: link_class, data: { push: 'partial', target: '#form' } %>
72
+ <% if options[:wiselink].present? && options[:wiselink] %>
73
+ <a href="<%= url %>" class="btn btn-success btn-xs" data-push="partial" data-target="#form">
74
+ <%=I18n.t(name)%>
75
+ </a>
89
76
  <% else %>
90
- <%= link_to t(name), url, class: link_class %>
77
+ <a href="<%= url %>" class="btn btn-success btn-xs">
78
+ <%=I18n.t(name)%>
79
+ </a>
91
80
  <% end %>
92
-
93
81
  <% elsif options[:associacao].present? %>
94
- <% if options[:wiselink] %>
95
- <%= link_to I18n.t(name), crud_associacao_models_path(model: @model.name.underscore, id: record.id, associacao: options[:associacao].to_s), class: "btn btn-success btn-xs", data: {push: true, crumb: "wielka"} %>
96
- <% else %>
97
- <%= link_to I18n.t(name), crud_associacao_models_path(model: @model.name.underscore, id: record.id, associacao: options[:associacao].to_s), class: "btn btn-success btn-xs" %>
98
- <% end %>
82
+ <%= link_to name, crud_associacao_models_path(model: @model.name.underscore, id: record.id, associacao: options[:associacao].to_s), class: "btn btn-success btn-xs", data: {push: "partial", target: "#form"} %>
99
83
  <% elsif options[:partial].present? %>
100
84
  <%= render options[:partial], record: record %>
101
85
  <% end %>
@@ -1,55 +1,55 @@
1
1
  <%= render_crud do %>
2
- <div>
3
- <%= render "/crud/links" %>
4
- </div>
5
- <div class="dataTables_wrapper form-inline">
6
- <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
7
- <thead>
8
- <tr>
9
- <% @crud_helper.index_fields.each do |att| %>
10
- <% if !att[:visible_if].nil?%>
11
- <% if ((att[:visible_if].class == Proc && !att[:visible_if].call(att)) || (att[:visible_if].class != Proc && !att[:visible_if])) %>
12
- <% next %>
13
- <% end %>
14
- <% end %>
15
- <th>
16
- <% if att[:sort_field].present? %>
17
- <%= sort_link @q, att[:sort_field], I18n.t(att[:label]), {},data: {push: 'partial', target: "#form"}%>
18
- <% else %>
19
- <%= sort_link @q, att[:attribute], I18n.t(att[:label]), {},data: {push: 'partial', target: "#form"}%>
20
- <% end %>
21
- </th>
22
- <%end%>
23
- <%if @crud_helper.view_action || @crud_helper.edit_action || @crud_helper.destroy_action || @crud_helper.actions.present?%>
24
- <td><%= I18n.t("simple_form.index.options") %></td>
25
- <% end %>
26
- </tr>
27
- </thead>
28
- <tbody id="records-body">
29
- <% @records.each do |record| %>
30
- <%= render '/crud/record', record: record %>
31
- <% end %>
32
- </tbody>
33
- </table>
34
- <%= paginate @records, target: '#form', theme: 'templus'%>
35
- </div>
2
+ <div>
3
+ <%= render "/crud/links" %>
4
+ </div>
5
+ <div class="dataTables_wrapper form-inline">
6
+ <table class="table table-striped table-bordered table-hover dataTables-example dataTable">
7
+ <thead>
8
+ <tr>
9
+ <%@crud_helper.index_fields.each do |att| %>
10
+ <% if !att[:visible_if].nil?%>
11
+ <% if ((att[:visible_if].class == Proc && !att[:visible_if].call(att)) || (att[:visible_if].class != Proc && !att[:visible_if])) %>
12
+ <% next %>
13
+ <% end %>
14
+ <% end %>
15
+ <th>
16
+ <% if att[:sort_field].present? %>
17
+ <%= sort_link @q, att[:sort_field], I18n.t(att[:label]), {},data: {push: 'partial', target: "#form"}%>
18
+ <% else %>
19
+ <%= sort_link @q, att[:attribute], I18n.t(att[:label]), {},data: {push: 'partial', target: "#form"}%>
20
+ <% end %>
21
+ </th>
22
+ <%end%>
23
+ <%if @crud_helper.view_action || @crud_helper.edit_action || @crud_helper.destroy_action || @crud_helper.actions.present?%>
24
+ <td><%= I18n.t("simple_form.index.options") %></td>
25
+ <% end %>
26
+ </tr>
27
+ </thead>
28
+ <tbody id="records-body">
29
+ <% @records.each do |record| %>
30
+ <%= render '/crud/record', record: record %>
31
+ <% end %>
32
+ </tbody>
33
+ </table>
34
+ <%= paginate @records, target: '#form', theme: 'templus'%>
35
+ </div>
36
36
  <% end %>
37
37
  <script type="text/javascript">
38
- var theadtxt = [];
39
- var headers = document.querySelectorAll("thead");
40
- var tablebody = document.querySelectorAll("tbody");
41
- for (var x = 0; x < headers.length; x++) {
42
- theadtxt[x]=[];
43
- for (var j = 0, headrow; headrow = headers[x].rows[0].cells[j]; j++) {
44
- var current = headrow;
45
- theadtxt[x].push(current.innerHTML);
46
- }
47
- }
48
- for (var v = 0, tbody; tbody = tablebody[v]; v++) {
49
- for (var x = 0, row; row = tbody.rows[x]; x++) {
50
- for (var j = 0, col; col = row.cells[j]; j++) {
38
+ var theadtxt = [];
39
+ var headers = document.querySelectorAll("thead");
40
+ var tablebody = document.querySelectorAll("tbody");
41
+ for (var x = 0; x < headers.length; x++) {
42
+ theadtxt[x]=[];
43
+ for (var j = 0, headrow; headrow = headers[x].rows[0].cells[j]; j++) {
44
+ var current = headrow;
45
+ theadtxt[x].push(current.innerHTML);
46
+ }
47
+ }
48
+ for (var v = 0, tbody; tbody = tablebody[v]; v++) {
49
+ for (var x = 0, row; row = tbody.rows[x]; x++) {
50
+ for (var j = 0, col; col = row.cells[j]; j++) {
51
51
  col.insertAdjacentHTML('afterbegin', '<div class="col-xs-3 no-padding">' + theadtxt[v][j] + '</div>');
52
- }
53
- }
54
- }
55
- </script>
52
+ }
53
+ }
54
+ }
55
+ </script>