templus_models 3.0.6 → 3.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 113c5743e7d0a89db83a873c296d5bc7794afbc1
4
- data.tar.gz: a4dd2f51ef7f9ea9fbad36c01c412f88652b7772
3
+ metadata.gz: 8a7986658883e7bee0507408a87a9941a7c0efee
4
+ data.tar.gz: 77d54cfcbf307318b3e2a3b7cfb846abf9350730
5
5
  SHA512:
6
- metadata.gz: 289b16d543ffe6b79d7580749ebae633c3c397bd67bcdffa69a61c747001e34794db6f6c031e6a7be3e66c5f667428ab50dfdfb4abe0fa1a12b8d62c86d8e62f
7
- data.tar.gz: fa73fdebf8f701a4a232b13c6ab5892508e7e7d9477342550ad159d44f749b08a6f88ba417bed7958606672e7e881515b7763a3fcaffecfd912f82b5a970a19d
6
+ metadata.gz: 61b363865c81485b63d11eb0ef0353b302614076a2f28fe7fd84c4bde300f91e60472ce4d40ef8386c8f18578ce4d08c7f9a400085f96cfd94aaf4c8d1d7ae18
7
+ data.tar.gz: 9cbfb68fe1561d2040b115158e86065ddbd9244a97b564a3f59d24a02a349f0107acd1b437c68db1b3cf429959c861802ef84a5c888fda73f4349c1be5b6f544
@@ -1,28 +1,7 @@
1
1
  class CrudController < ApplicationController
2
2
  before_action :setup, except: :autocomplete
3
3
 
4
- private
5
- def setup
6
- if params[:associacao]
7
- @crud_associacao = Module.const_get("#{params[:model].to_s.singularize}_crud".camelize)
8
- @model = Module.const_get(params[:model].camelize).find(params[:id]).send(params[:associacao])
9
- c_helper = Module.const_get(params[:model].camelize).reflect_on_association(params[:associacao]).class_name
10
- @crud_helper = Module.const_get("#{c_helper}Crud") unless params[:render] == "modal" and params[:action] == "new"
11
- @url = crud_associacao_models_path(model: params[:model], id: params[:id], associacao: params[:associacao], page: params[:page], q: params[:q])
12
- @clean_url = crud_associacao_models_path(model: params[:model], id: params[:id], associacao: params[:associacao])
13
- @model_permission = c_helper.constantize
14
- @id = params[:associacao_id] if params[:associacao_id]
15
- else
16
- @model = Module.const_get(params[:model].camelize)
17
- @model_permission = @model
18
- @crud_helper = Module.const_get("#{params[:model]}_crud".camelize) unless params[:render] == "modal" and params[:action] == "new"
19
- @url = crud_models_path(model: params[:model], page: params[:page], q: params[:q])
20
- @clean_url = crud_models_path(model: params[:model])
21
- @id = params[:id] if params[:id]
22
- end
23
- end
24
4
 
25
- public
26
5
  def index
27
6
  authorize! :read, @model_permission if respond_to?(:current_usuario)
28
7
  if params[:scope].present?
@@ -180,18 +159,7 @@ class CrudController < ApplicationController
180
159
  end
181
160
  report_name = "#{@crud_helper.title}_#{DateTime.now.strftime('%Y%m%d')}"
182
161
  respond_to do |format|
183
- format.xls {headers["Content-Disposition"] = "attachment; filename=#{report_name}.xls"}
184
- format.pdf do
185
- pdf = WickedPdf.new.pdf_from_string(
186
- render_to_string('crud/listing.pdf.erb'),
187
- encoding: 'UTF-8',
188
- page_size: 'A4',
189
- show_as_html: params[:debug],
190
- margin: { top: 20, bottom: 20 }
191
- )
192
- send_data(pdf, filename: "#{report_name}.pdf", type: "application/pdf", disposition: "inline")
193
- end
194
- format.html
162
+ format.xls { headers["Content-Disposition"] = "attachment; filename=#{report_name}.xls" }
195
163
  end
196
164
  end
197
165
 
@@ -214,7 +182,29 @@ class CrudController < ApplicationController
214
182
  end
215
183
  end
216
184
 
185
+
217
186
  private
187
+
188
+ def setup
189
+ if params[:associacao]
190
+ @crud_associacao = Module.const_get("#{params[:model].to_s.singularize}_crud".camelize)
191
+ @model = Module.const_get(params[:model].camelize).find(params[:id]).send(params[:associacao])
192
+ c_helper = Module.const_get(params[:model].camelize).reflect_on_association(params[:associacao]).class_name
193
+ @crud_helper = Module.const_get("#{c_helper}Crud") unless params[:render] == "modal" and params[:action] == "new"
194
+ @url = crud_associacao_models_path(model: params[:model], id: params[:id], associacao: params[:associacao], page: params[:page], q: params[:q])
195
+ @clean_url = crud_associacao_models_path(model: params[:model], id: params[:id], associacao: params[:associacao])
196
+ @model_permission = c_helper.constantize
197
+ @id = params[:associacao_id] if params[:associacao_id]
198
+ else
199
+ @model = Module.const_get(params[:model].camelize)
200
+ @model_permission = @model
201
+ @crud_helper = Module.const_get("#{params[:model]}_crud".camelize) unless params[:render] == "modal" and params[:action] == "new"
202
+ @url = crud_models_path(model: params[:model], page: params[:page], q: params[:q])
203
+ @clean_url = crud_models_path(model: params[:model])
204
+ @id = params[:id] if params[:id]
205
+ end
206
+ end
207
+
218
208
  def params_permitt
219
209
  params.require(@model.name.underscore.to_sym).permit(fields_model)
220
210
  end
@@ -198,43 +198,37 @@ module CrudHelper
198
198
  end
199
199
 
200
200
  #Permissions
201
- def should_view?(crud_helper,record)
201
+ def should_view?(crud_helper, record)
202
202
  return false unless can?(:read, record)
203
203
  return true if crud_helper.condition_view_action.nil?
204
204
  crud_helper.condition_view_action.call(record)
205
205
  end
206
206
 
207
- def should_edit?(crud_helper,record)
207
+ def should_edit?(crud_helper, record)
208
208
  return false unless can?(:update, record)
209
209
  return true if crud_helper.condition_edit_action.nil?
210
210
  crud_helper.condition_edit_action.call(record)
211
211
  end
212
212
 
213
- def should_destroy?(crud_helper,record)
213
+ def should_destroy?(crud_helper, record)
214
214
  return false unless can?(:destroy, record)
215
215
  return true if crud_helper.condition_destroy_action.nil?
216
216
  crud_helper.condition_destroy_action.call(record)
217
217
  end
218
218
 
219
- def should_listing?(crud_helper,model)
219
+ def should_listing?(crud_helper, model)
220
220
  return false unless can?(:read, model)
221
221
  return true if crud_helper.condition_listing_action.nil?
222
222
  crud_helper.condition_listing_action.call(model)
223
223
  end
224
224
 
225
- def should_listing_excel?(crud_helper,model)
225
+ def should_listing_excel?(crud_helper, model)
226
226
  return false unless can?(:read, model)
227
227
  return true if crud_helper.condition_listing_excel.nil?
228
228
  crud_helper.condition_listing_excel.call(model)
229
229
  end
230
230
 
231
- def should_listing_pdf?(crud_helper,model)
232
- return false unless can?(:read, model)
233
- return true if crud_helper.condition_listing_pdf.nil?
234
- crud_helper.condition_listing_pdf.call(model)
235
- end
236
-
237
- def should_printing?(crud_helper,record)
231
+ def can_print_pdf?(crud_helper, record)
238
232
  return false unless can?(:read, record)
239
233
  return true if crud_helper.condition_printing_action.nil?
240
234
  crud_helper.condition_printing_action.call(record)
@@ -129,11 +129,11 @@ class RaroCrud
129
129
  end
130
130
 
131
131
  def self.top_links
132
- (@@top_links[self.to_s.to_sym]) ? @@top_links[self.to_s.to_sym] : []
132
+ @@top_links[self.to_s.to_sym] || []
133
133
  end
134
134
 
135
135
  def self.index_fields
136
- (@@index_fields[self.to_s.to_sym]) ? @@index_fields[self.to_s.to_sym] : []
136
+ @@index_fields[self.to_s.to_sym] || []
137
137
  end
138
138
 
139
139
  def self.order_field
@@ -145,51 +145,51 @@ class RaroCrud
145
145
  end
146
146
 
147
147
  def self.actions
148
- (@@actions[self.to_s.to_sym]) ? @@actions[self.to_s.to_sym] : []
148
+ @@actions[self.to_s.to_sym] || []
149
149
  end
150
150
 
151
151
  def self.actions_links
152
- (@@links[self.to_s.to_sym]) ? @@links[self.to_s.to_sym] : []
152
+ @@links[self.to_s.to_sym] || []
153
153
  end
154
154
 
155
155
  def self.options_link
156
- (@@options_link[self.to_s.to_sym]) ? @@options_link[self.to_s.to_sym] : []
156
+ @@options_link[self.to_s.to_sym] || []
157
157
  end
158
158
 
159
159
  def self.form_fields
160
- (@@form_fields[self.to_s.to_sym]) ? @@form_fields[self.to_s.to_sym] : []
160
+ @@form_fields[self.to_s.to_sym] || []
161
161
  end
162
162
 
163
163
  def self.form_groups
164
- (@@form_group[self.to_s.to_sym]) ? @@form_group[self.to_s.to_sym] : []
164
+ @@form_group[self.to_s.to_sym] || []
165
165
  end
166
166
 
167
167
  def self.form_scripts
168
- (@@form_scripts[self.to_s.to_sym]) ? @@form_scripts[self.to_s.to_sym] : []
168
+ @@form_scripts[self.to_s.to_sym] || []
169
169
  end
170
170
 
171
171
  def self.view_fields
172
- (@@view_fields[self.to_s.to_sym]) ? @@view_fields[self.to_s.to_sym] : []
172
+ @@view_fields[self.to_s.to_sym] || []
173
173
  end
174
174
 
175
175
  def self.listing_fields
176
- (@@listing_fields[self.to_s.to_sym]) ? @@listing_fields[self.to_s.to_sym] : []
176
+ @@listing_fields[self.to_s.to_sym] || []
177
177
  end
178
178
 
179
179
  def self.printing_fields
180
- (@@printing_fields[self.to_s.to_sym]) ? @@printing_fields[self.to_s.to_sym] : []
180
+ @@printing_fields[self.to_s.to_sym] || []
181
181
  end
182
182
 
183
183
  def self.search_fields
184
- (@@search_fields[self.to_s.to_sym]) ? @@search_fields[self.to_s.to_sym] : []
184
+ @@search_fields[self.to_s.to_sym] || []
185
185
  end
186
186
 
187
187
  def self.test_fields
188
- (@@test_fields[self.to_s.to_sym]) ? @@test_fields[self.to_s.to_sym] : []
188
+ @@test_fields[self.to_s.to_sym] || []
189
189
  end
190
190
 
191
191
  def self.scopes
192
- (@@scopes[self.to_s.to_sym]) ? @@scopes[self.to_s.to_sym] : []
192
+ @@scopes[self.to_s.to_sym] || []
193
193
  end
194
194
 
195
195
  def self.add_menus(menu)
@@ -200,132 +200,8 @@ class RaroCrud
200
200
  @@menus
201
201
  end
202
202
 
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]
248
- opts = set_default_label nome, opts
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
262
- end
263
-
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]
203
+ def self.campo_visualizacao(nome, opts = {})
204
+ @@view_fields[self.to_s.to_sym] ||= []
329
205
  opts = set_default_label nome, opts
330
206
  @@view_fields[self.to_s.to_sym].push(
331
207
  {
@@ -334,8 +210,8 @@ class RaroCrud
334
210
  )
335
211
  end
336
212
 
337
- def self.campo_busca nome, opts = {}
338
- @@search_fields[self.to_s.to_sym] = [] unless @@search_fields[self.to_s.to_sym]
213
+ def self.campo_busca(nome, opts = {})
214
+ @@search_fields[self.to_s.to_sym] ||= []
339
215
  opts = set_default_label nome, opts
340
216
  @@search_fields[self.to_s.to_sym].push(
341
217
  {
@@ -344,24 +220,22 @@ class RaroCrud
344
220
  )
345
221
  end
346
222
 
347
- def self.campo_listagem nome, opts = {}
348
- @@listing_fields[self.to_s.to_sym] = [] unless @@listing_fields[self.to_s.to_sym]
223
+ def self.relatorio_listagem(nome, opts = {})
224
+ @@listing_fields[self.to_s.to_sym] ||= []
349
225
  opts = set_default_label nome, opts
350
- @@listing_fields[self.to_s.to_sym].push(
351
- {
352
- attribute: nome
353
- }.merge({sf: opts})
354
- )
226
+ @@listing_fields[self.to_s.to_sym].push({
227
+ attribute: nome,
228
+ sf: opts
229
+ })
355
230
  end
356
231
 
357
- def self.campo_impressao nome, opts = {}
358
- @@printing_fields[self.to_s.to_sym] = [] unless @@printing_fields[self.to_s.to_sym]
232
+ def self.relatorio_impressao(nome, opts = {})
233
+ @@printing_fields[self.to_s.to_sym] ||= []
359
234
  opts = set_default_label nome, opts
360
- @@printing_fields[self.to_s.to_sym].push(
361
- {
362
- attribute: nome
363
- }.merge({sf: opts})
364
- )
235
+ @@printing_fields[self.to_s.to_sym].push({
236
+ attribute: nome,
237
+ sf: opts
238
+ })
365
239
  end
366
240
 
367
241
  def self.sem_visualizacao
@@ -492,4 +366,125 @@ class RaroCrud
492
366
  @@form_scripts[self.to_s.to_sym] << script.to_s
493
367
  end
494
368
 
369
+
370
+ private
371
+
372
+ def self.modelo
373
+ self.to_s.underscore.gsub("_crud", "")
374
+ end
375
+
376
+ def self.titulo str
377
+ @@title[self.to_s.to_sym] = str
378
+ end
379
+
380
+ def self.subtitulo(str,type)
381
+ case type
382
+ when :index
383
+ @@subtitle_index[self.to_s.to_sym] = str
384
+ end
385
+ end
386
+
387
+ def self.descricao(str,type)
388
+ case type
389
+ when :index
390
+ @@description_index[self.to_s.to_sym] = str
391
+ end
392
+ end
393
+
394
+ def self.link_superior opts={}
395
+ @@top_links[self.to_s.to_sym] = [] unless @@top_links[self.to_s.to_sym]
396
+ @@top_links[self.to_s.to_sym].push(
397
+ {
398
+ text: opts[:nome],
399
+ modelo: self.modelo,
400
+ id: opts[:id],
401
+ data: {push: 'partial', target: '#form'},
402
+ icon: "fa fa-#{opts[:icon]}",
403
+ class: 'btn btn-small btn-primary btn-rounded',
404
+ link: opts[:link],
405
+ url: opts[:url],
406
+ can: opts[:can],
407
+ partial: opts[:partial]
408
+ }
409
+ )
410
+ end
411
+
412
+ def self.campo_tabela nome, opts={}
413
+ @@index_fields[self.to_s.to_sym] = [] unless @@index_fields[self.to_s.to_sym]
414
+ opts = set_default_label nome, opts
415
+ @@index_fields[self.to_s.to_sym].push(
416
+ {
417
+ attribute: nome
418
+ }.merge(opts)
419
+ )
420
+ end
421
+
422
+ def self.ordenar_por nome
423
+ @@order_field[self.to_s.to_sym] = nome
424
+ end
425
+
426
+ def self.itens_por_pagina qtd
427
+ @@per_page[self.to_s.to_sym] = qtd
428
+ end
429
+
430
+ def self.campo_teste nome, opts = {}
431
+ @@test_fields[self.to_s.to_sym] = [] unless @@test_fields[self.to_s.to_sym]
432
+ @@test_fields[self.to_s.to_sym].push(
433
+ {
434
+ attribute: nome
435
+ }.merge({sf: opts})
436
+ )
437
+ end
438
+
439
+ def self.campo_formulario nome, opts={}
440
+ @@form_fields[self.to_s.to_sym] = [] unless @@form_fields[self.to_s.to_sym]
441
+ opts = set_default_label nome, opts
442
+ if opts.present? && opts[:autocomplete].present?
443
+ opts[:as] = :autocomplete
444
+ label_method = opts[:autocomplete][:label_method] || opts[:autocomplete][:campo]
445
+ opts[:url] = Rails.application.routes.url_helpers.autocomplete_crud_path(model: opts[:autocomplete][:classe], campo: opts[:autocomplete][:campo], tipo: "start", label: label_method)
446
+ name = "#{opts[:autocomplete][:campo]}_#{opts[:autocomplete][:classe]}"
447
+ opts[:input_html] = {name: name, id: name}
448
+ opts[:id_element] = "##{self.modelo}_#{nome}_id"
449
+ end
450
+ if opts.present? && opts[:grupo].present?
451
+ opts[:fields] = []
452
+ opts[:grupo].each do |field|
453
+ attribute = field[:campo]
454
+ field.delete(:campo)
455
+ add_group_formulario(field) if field[:grupo].present?
456
+ opts[:fields].push({attribute: attribute,sf: field})
457
+ end
458
+ opts[:grupo] = true if opts[:grupo].present?
459
+ end
460
+ if @agrupamento.present?
461
+ opts[:agrupamento] = @agrupamento
462
+ end
463
+ @@form_fields[self.to_s.to_sym].push(
464
+ {
465
+ attribute: nome
466
+ }.merge({sf: opts})
467
+ )
468
+ if opts.present? && opts[:autocomplete].present?
469
+ campo_formulario(nome, {as: :hidden})
470
+ end
471
+ end
472
+
473
+ def self.add_group_formulario(field)
474
+ field[:fields] = []
475
+ field[:grupo].each do |f|
476
+ attribute = f[:campo]
477
+ f.delete(:campo)
478
+ add_group_formulario(f) if f[:grupo].present?
479
+ field[:fields].push({attribute: attribute, sf: f})
480
+ end
481
+ field[:grupo] = true
482
+ end
483
+
484
+ def self.set_default_label nome, opts
485
+ unless opts[:label].present?
486
+ opts[:label] = "simple_form.labels.#{self.modelo.underscore}.#{nome}"
487
+ end
488
+ opts
489
+ end
495
490
  end
@@ -1,59 +1,59 @@
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
- <% if att[:sort_field] == :false %>
18
- <%= I18n.t(att[:label]) %>
19
- <% else %>
20
- <%= sort_link @q, att[:sort_field], I18n.t(att[:label]), {},data: {push: 'partial', target: "#form"}%>
21
- <% end %>
22
- <% else %>
23
- <%= sort_link @q, att[:attribute], I18n.t(att[:label]), {},data: {push: 'partial', target: "#form"}%>
24
- <% end %>
25
- </th>
26
- <%end%>
27
- <%if @crud_helper.view_action || @crud_helper.edit_action || @crud_helper.destroy_action || @crud_helper.actions.present?%>
28
- <td><%= I18n.t("simple_form.index.options") %></td>
29
- <% end %>
30
- </tr>
31
- </thead>
32
- <tbody id="records-body">
33
- <% @records.each do |record| %>
34
- <%= render '/crud/record', record: record %>
35
- <% end %>
36
- </tbody>
37
- </table>
38
- <%= paginate @records, target: '#form', theme: 'templus'%>
39
- </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
+ <% if att[:sort_field] == :false %>
18
+ <%= I18n.t(att[:label]) %>
19
+ <% else %>
20
+ <%= sort_link @q, att[:sort_field], I18n.t(att[:label]), {},data: {push: 'partial', target: "#form"}%>
21
+ <% end %>
22
+ <% else %>
23
+ <%= sort_link @q, att[:attribute], I18n.t(att[:label]), {},data: {push: 'partial', target: "#form"}%>
24
+ <% end %>
25
+ </th>
26
+ <% end %>
27
+ <% if @crud_helper.view_action || @crud_helper.edit_action || @crud_helper.destroy_action || @crud_helper.actions.present? %>
28
+ <td><%= I18n.t("simple_form.index.options") %></td>
29
+ <% end %>
30
+ </tr>
31
+ </thead>
32
+ <tbody id="records-body">
33
+ <% @records.each do |record| %>
34
+ <%= render '/crud/record', record: record %>
35
+ <% end %>
36
+ </tbody>
37
+ </table>
38
+ <%= paginate @records, target: '#form', theme: 'templus'%>
39
+ </div>
40
40
  <% end %>
41
41
  <script type="text/javascript">
42
- var theadtxt = [];
43
- var headers = document.querySelectorAll("thead");
44
- var tablebody = document.querySelectorAll("tbody");
45
- for (var x = 0; x < headers.length; x++) {
46
- theadtxt[x]=[];
47
- for (var j = 0, headrow; headrow = headers[x].rows[0].cells[j]; j++) {
48
- var current = headrow;
49
- theadtxt[x].push(current.innerHTML);
50
- }
51
- }
52
- for (var v = 0, tbody; tbody = tablebody[v]; v++) {
53
- for (var x = 0, row; row = tbody.rows[x]; x++) {
54
- for (var j = 0, col; col = row.cells[j]; j++) {
42
+ var theadtxt = [];
43
+ var headers = document.querySelectorAll("thead");
44
+ var tablebody = document.querySelectorAll("tbody");
45
+ for (var x = 0; x < headers.length; x++) {
46
+ theadtxt[x]=[];
47
+ for (var j = 0, headrow; headrow = headers[x].rows[0].cells[j]; j++) {
48
+ var current = headrow;
49
+ theadtxt[x].push(current.innerHTML);
50
+ }
51
+ }
52
+ for (var v = 0, tbody; tbody = tablebody[v]; v++) {
53
+ for (var x = 0, row; row = tbody.rows[x]; x++) {
54
+ for (var j = 0, col; col = row.cells[j]; j++) {
55
55
  col.insertAdjacentHTML('afterbegin', '<div class="col-xs-3 no-padding">' + theadtxt[v][j] + '</div>');
56
- }
57
- }
58
- }
56
+ }
57
+ }
58
+ }
59
59
  </script>
@@ -1,30 +1,30 @@
1
1
  <div class="modal inmodal" id="modal_search" tabindex="-1" role="dialog" aria-hidden="true">
2
- <div class="modal-dialog modal-lg">
3
- <div class="modal-content animated bounceInRight">
4
- <div class="modal-header">
5
- <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"><%= I18n.t("close") %></span></button>
6
- <i class="fa fa-search modal-icon"></i>
7
- <h4 class="modal-title"><%= I18n.t("search") %></h4>
8
- <small class="font-bold"></small>
9
- </div>
10
- <div class="modal-body">
11
- <% if @crud_associacao.present? %>
12
- <% url = query_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao]) %>
13
- <% else %>
14
- <% url = query_crud_path(model: @model.name.underscore) %>
15
- <% end %>
16
- <%=raro_search_form(@model, 'records','records', url) do%>
17
- <%raro_group "#{@crud_helper.title}"%>
18
- <%@crud_helper.search_fields.each do |att| %>
19
- <% if att[:sf].present? && !att[:sf][:visible_if].nil?%>
20
- <% if ((att[:sf][:visible_if].class == Proc && !att[:sf][:visible_if].call(att)) || (att[:sf][:visible_if].class != Proc && !att[:sf][:visible_if])) %>
21
- <% next %>
22
- <% end %>
23
- <% end %>
24
- <%raro_field att[:attribute], att[:sf]%>
25
- <%end%>
26
- <%end%>
27
- </div>
28
- </div>
29
- </div>
2
+ <div class="modal-dialog modal-lg">
3
+ <div class="modal-content animated bounceInRight">
4
+ <div class="modal-header">
5
+ <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"><%= I18n.t("close") %></span></button>
6
+ <i class="fa fa-search modal-icon"></i>
7
+ <h4 class="modal-title"><%= I18n.t("search") %></h4>
8
+ <small class="font-bold"></small>
9
+ </div>
10
+ <div class="modal-body">
11
+ <% if @crud_associacao.present? %>
12
+ <% url = query_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao]) %>
13
+ <% else %>
14
+ <% url = query_crud_path(model: @model.name.underscore) %>
15
+ <% end %>
16
+ <%= raro_search_form(@model, 'records','records', url) do %>
17
+ <% raro_group "#{@crud_helper.title}" %>
18
+ <%@crud_helper.search_fields.each do |att| %>
19
+ <% if att[:sf].present? && !att[:sf][:visible_if].nil? %>
20
+ <% if ((att[:sf][:visible_if].class == Proc && !att[:sf][:visible_if].call(att)) || (att[:sf][:visible_if].class != Proc && !att[:sf][:visible_if])) %>
21
+ <% next %>
22
+ <% end %>
23
+ <% end %>
24
+ <%raro_field att[:attribute], att[:sf]%>
25
+ <%end%>
26
+ <%end%>
27
+ </div>
28
+ </div>
29
+ </div>
30
30
  </div>
@@ -1,124 +1,119 @@
1
- <%unless params[:render] == 'modal'%>
1
+ <% unless params[:render] == 'modal' %>
2
2
  <div class="wrapper wrapper-content animated fadeInRight">
3
- <div class="row">
4
- <div class="col-lg-12">
5
- <div class="ibox float-e-margins">
6
- <div class="ibox-title">
7
- <% if content_for?(:ibox_title) %>
8
- <%= yield :ibox_title %>
9
- <% elsif is_action_edit? && @model.present?%>
10
- <h5>
11
- <%= I18n.t("edit") %>
12
- <small style="margin-left: 2px;"><%= @record.to_s %> - #<%= @record.id %></small>
13
- </h5>
14
- <% elsif (is_action_create? || is_action_new?) && @model.present? %>
15
- <h5><%= I18n.t("new", model: I18n.t("model.#{@model.name.underscore}")) %></h5>
16
- <% elsif @record.present? && !@record.new_record? %>
17
- <h5>
18
- <%= @record.to_s %>
19
- <small style="margin-left: 2px;">#<%= @record.id %></small>
20
- </h5>
21
- <% elsif @crud_helper.present? %>
22
- <h5>
23
- <%= @crud_helper.subtitle(:index) %>
24
- <small><%= @crud_helper.description(:index) %></small>
25
- </h5>
26
- <% end %>
27
- <% if (@crud_helper.present? && (is_action_index? || is_action_query?))%>
28
- <div class="pull-right actions">
29
- <% @crud_helper.top_links.each do |link| %>
30
- <% if link[:can].present? %>
31
- <%=render_link(link,@clean_url) if self.instance_eval &link[:can]%>
32
- <% else %>
33
- <%=render_link(link,@clean_url)%>
34
- <% end %>
35
- <%end%>
36
- <% if params[:associacao] %>
37
- <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model_permission) %>
38
- <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
39
- <%= I18n.t("devise.reports.excel").html_safe %>
40
- <% end if should_listing_excel?(@crud_helper, @model_permission) %>
41
- <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], q: params[:q], format: :pdf), class: "btn btn-success btn-rounded", target: '_blank' do %>
42
- <%= I18n.t("devise.reports.pdf").html_safe %>
43
- <% end if should_listing_pdf?(@crud_helper, @model_permission) %>
44
- <% end %>
45
- <% else %>
46
- <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model) %>
47
- <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
48
- <%= I18n.t("devise.reports.excel").html_safe %>
49
- <% end if should_listing_excel?(@crud_helper, @model) %>
50
- <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], target: '_blank', format: :pdf), class: "btn btn-success btn-rounded", target: '_blank' do %>
51
- <%= I18n.t("devise.reports.pdf").html_safe %>
52
- <% end if should_listing_pdf?(@crud_helper, @model) %>
53
- <% end %>
54
- <% end %>
55
- <% if @crud_helper.search_fields.present? %>
56
- <button id="button_search_<%=@model.name.underscore%>" class="btn btn-warning btn-rounded" data-toggle="modal" data-target="#modal_search">
57
- <i class="fa fa-search"></i>
58
- </button>
59
- <% end %>
60
- </div>
61
- <% elsif is_action_show? %>
62
- <% @crud_helper.actions_links.each do |name, options| %>
63
- <% unless (options[:can].present? && !@record.instance_eval(&options[:can])) %>
64
- <% if options[:url].present? %>
65
- <% url = options[:url] %>
66
- <% if options[:id] %>
67
- <% url += options[:url].include?("?") ? "&id=#{@record.id}" : "?id=#{@record.id}" %>
68
- <% else url.include?(":id") %>
69
- <% url = url.gsub(":id", "#{@record.id}") %>
70
- <% end %>
71
- <% if options[:wiselink].present? && options[:wiselink] %>
72
- <a href="<%= url %>" class="btn btn-success btn-xs pull-right m-l-xs" data-push="partial" data-target="#form">
73
- <%= I18n.t(name) %>
74
- </a>
75
- <% else %>
76
- <a href="<%= url %>" class="btn btn-success btn-xs pull-right m-l-xs">
77
- <%= I18n.t(name) %>
78
- </a>
79
- <% end %>
80
- <% elsif options[:partial].present? %>
81
- <div class="pull-right m-l-xs">
82
- <%= render options[:partial], record: @record, action: :show %>
83
- </div>
84
- <% end %>
85
- <% end %>
86
- <% end %>
3
+ <div class="row">
4
+ <div class="col-lg-12">
5
+ <div class="ibox float-e-margins">
6
+ <div class="ibox-title">
7
+ <% if content_for?(:ibox_title) %>
8
+ <%= yield :ibox_title %>
9
+ <% elsif is_action_edit? && @model.present?%>
10
+ <h5>
11
+ <%= I18n.t("edit") %>
12
+ <small style="margin-left: 2px;"><%= @record.to_s %> - #<%= @record.id %></small>
13
+ </h5>
14
+ <% elsif (is_action_create? || is_action_new?) && @model.present? %>
15
+ <h5><%= I18n.t("new", model: I18n.t("model.#{@model.name.underscore}")) %></h5>
16
+ <% elsif @record.present? && !@record.new_record? %>
17
+ <h5>
18
+ <%= @record.to_s %>
19
+ <small style="margin-left: 2px;">#<%= @record.id %></small>
20
+ </h5>
21
+ <% elsif @crud_helper.present? %>
22
+ <h5>
23
+ <%= @crud_helper.subtitle(:index) %>
24
+ <small><%= @crud_helper.description(:index) %></small>
25
+ </h5>
26
+ <% end %>
87
27
 
88
- <% if (@crud_helper.present? && @crud_helper.destroy_action) && should_destroy?(@crud_helper, @record) %>
89
- <% if @crud_associacao.present? %>
90
- <%= link_to I18n.t("destroy"), destroy_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-danger btn-xs pull-right m-l-xs', data: {method: 'delete', confirm: I18n.t('mensagem_confirm_destroy')} %>
91
- <% else %>
92
- <%= link_to I18n.t("destroy"), destroy_crud_path(model: @model.name.underscore, id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-danger btn-xs pull-right m-l-xs', data: {method: 'delete', confirm: I18n.t('mensagem_confirm_destroy')} %>
93
- <% end %>
94
- <% end %>
95
- <% if (@crud_helper.present? && @crud_helper.edit_action) && should_edit?(@crud_helper, @record) %>
96
- <% if @crud_associacao.present? %>
97
- <%= link_to I18n.t("edit"), edit_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs pull-right m-l-xs', data: {push: 'partial', target: '#form'} %>
98
- <% else %>
99
- <%= link_to I18n.t("edit"), edit_crud_path(model: @model.name.underscore, id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs pull-right m-l-xs', data: {push: 'partial', target: '#form'} %>
100
- <% end %>
101
- <% end %>
102
- <% if @crud_helper.printing_fields.present? && should_printing?(@crud_helper, @record) %>
103
- <% if @crud_associacao.present? %>
104
- <%= link_to printing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: @record.id, page: params[:page], q: params[:q], format: :pdf), class: "btn btn-success btn-xs pull-right m-l-xs", target: "_blank" do %>
105
- <%= I18n.t("devise.printing").html_safe %>
106
- <% end %>
107
- <% else %>
108
- <%= link_to printing_crud_path(model: @model.name.underscore, id: @record.id, page: params[:page], q: params[:q], format: :pdf), class: "btn btn-success btn-xs pull-right m-l-xs", target: "_blank" do %>
109
- <%= I18n.t("devise.printing").html_safe %>
110
- <% end %>
111
- <% end %>
112
- <% end %>
113
- <% end %>
114
- </div>
115
- <div class="ibox-content">
116
- <% block.call %>
117
- </div>
118
- </div>
119
- </div>
120
- </div>
28
+
29
+ <% if @crud_helper.present? && (is_action_index? || is_action_query?) %>
30
+ <div class="pull-right actions">
31
+ <% @crud_helper.top_links.each do |link| %>
32
+ <% if link[:can].present? %>
33
+ <%= render_link(link,@clean_url) if self.instance_eval &link[:can] %>
34
+ <% else %>
35
+ <%= render_link(link,@clean_url) %>
36
+ <% end %>
37
+ <% end %>
38
+ <% if params[:associacao] %>
39
+ <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model_permission) && should_listing_excel?(@crud_helper, @model_permission) %>
40
+ <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
41
+ <%= I18n.t("devise.reports.excel").html_safe %>
42
+ <% end %>
43
+ <% end %>
44
+ <% else %>
45
+ <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model) && should_listing_excel?(@crud_helper, @model) %>
46
+ <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
47
+ <%= I18n.t("devise.reports.excel").html_safe %>
48
+ <% end %>
49
+ <% end %>
50
+ <% end %>
51
+ <% if @crud_helper.search_fields.present? %>
52
+ <button id="button_search_<%=@model.name.underscore%>" class="btn btn-warning btn-rounded" data-toggle="modal" data-target="#modal_search">
53
+ <i class="fa fa-search"></i>
54
+ </button>
55
+ <% end %>
56
+ </div>
57
+
58
+ <% elsif is_action_show? %>
59
+ <% @crud_helper.actions_links.each do |name, options| %>
60
+ <% unless (options[:can].present? && !@record.instance_eval(&options[:can])) %>
61
+ <% if options[:url].present? %>
62
+ <% url = options[:url] %>
63
+ <% if options[:id] %>
64
+ <% url += options[:url].include?("?") ? "&id=#{@record.id}" : "?id=#{@record.id}" %>
65
+ <% else url.include?(":id") %>
66
+ <% url = url.gsub(":id", "#{@record.id}") %>
67
+ <% end %>
68
+ <% if options[:wiselink].present? && options[:wiselink] %>
69
+ <%= link_to t('name'), url, class: 'btn btn-success btn-xs pull-right m-l-xs', data: { push: 'partial', target: '#form' } %>
70
+ <% else %>
71
+ <%= link_to t(name), url, class: 'btn btn-success btn-xs pull-right m-l-xs' %>
72
+ <% end %>
73
+ <% elsif options[:partial].present? %>
74
+ <div class="pull-right m-l-xs">
75
+ <%= render options[:partial], record: @record, action: :show %>
76
+ </div>
77
+ <% end %>
78
+ <% end %>
79
+ <% end %>
80
+
81
+ <% if (@crud_helper.present? && @crud_helper.destroy_action) && should_destroy?(@crud_helper, @record) %>
82
+ <% if @crud_associacao.present? %>
83
+ <%= link_to I18n.t("destroy"), destroy_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-danger btn-xs pull-right m-l-xs', data: {method: 'delete', confirm: I18n.t('mensagem_confirm_destroy')} %>
84
+ <% else %>
85
+ <%= link_to I18n.t("destroy"), destroy_crud_path(model: @model.name.underscore, id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-danger btn-xs pull-right m-l-xs', data: {method: 'delete', confirm: I18n.t('mensagem_confirm_destroy')} %>
86
+ <% end %>
87
+ <% end %>
88
+
89
+ <% if (@crud_helper.present? && @crud_helper.edit_action) && should_edit?(@crud_helper, @record) %>
90
+ <% if @crud_associacao.present? %>
91
+ <%= link_to I18n.t("edit"), edit_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs pull-right m-l-xs', data: {push: 'partial', target: '#form'} %>
92
+ <% else %>
93
+ <%= link_to I18n.t("edit"), edit_crud_path(model: @model.name.underscore, id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs pull-right m-l-xs', data: {push: 'partial', target: '#form'} %>
94
+ <% end %>
95
+ <% end %>
96
+
97
+ <% if @crud_helper.printing_fields.present? && can_print_pdf?(@crud_helper, @record) %>
98
+ <% if @crud_associacao.present? %>
99
+ <%= link_to printing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: @record.id, page: params[:page], q: params[:q], format: :pdf), class: "btn btn-success btn-xs pull-right m-l-xs", target: "_blank" do %>
100
+ <%= I18n.t("devise.printing").html_safe %>
101
+ <% end %>
102
+ <% else %>
103
+ <%= link_to printing_crud_path(model: @model.name.underscore, id: @record.id, page: params[:page], q: params[:q], format: :pdf), class: "btn btn-success btn-xs pull-right m-l-xs", target: "_blank" do %>
104
+ <%= I18n.t("devise.printing").html_safe %>
105
+ <% end %>
106
+ <% end %>
107
+ <% end %>
108
+ <% end %>
109
+ </div>
110
+ <div class="ibox-content">
111
+ <% block.call %>
112
+ </div>
113
+ </div>
114
+ </div>
115
+ </div>
121
116
  </div>
122
117
  <% else %>
123
- <% block.call %>
118
+ <% block.call %>
124
119
  <% end %>
@@ -7,7 +7,7 @@ xmlns:html="http://www.w3.org/TR/REC-html40">
7
7
  <Worksheet ss:Name="<%= @crud_helper.title %>">
8
8
  <Table>
9
9
  <Row>
10
- <% @crud_helper.listing_fields.each do |att|%>
10
+ <% @crud_helper.listing_fields.each do |att| %>
11
11
  <% if !att[:visible_if].nil?%>
12
12
  <% if ((att[:visible_if].class == Proc && !att[:visible_if].call(att)) || (att[:visible_if].class != Proc && !att[:visible_if])) %>
13
13
  <% next %>
@@ -18,7 +18,7 @@ xmlns:html="http://www.w3.org/TR/REC-html40">
18
18
  </Row>
19
19
  <% @records.each do |record| %>
20
20
  <Row>
21
- <%@crud_helper.listing_fields.each do |att| %>
21
+ <% @crud_helper.listing_fields.each do |att| %>
22
22
  <% if record.send(att[:attribute]).present? or record.send(att[:attribute]).to_s == "false"%>
23
23
  <% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type)%>
24
24
  <% if att[:date_format].present?%>
@@ -13,7 +13,7 @@
13
13
  </div>
14
14
  <table class="table table-bordered table-striped">
15
15
  <tbody>
16
- <% @crud_helper.view_fields.each do |field|%>
16
+ <% @crud_helper.printing_fields.each do |field| %>
17
17
  <tr>
18
18
  <% if field[:sf].present? && !field[:sf][:visible_if].nil?%>
19
19
  <% if ((field[:sf][:visible_if].class == Proc && !field[:sf][:visible_if].call(@record)) || (field[:sf][:visible_if].class != Proc && !field[:sf][:visible_if])) %>
@@ -1,3 +1,3 @@
1
1
  module TemplusModels
2
- VERSION = "3.0.6"
2
+ VERSION = "3.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: templus_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.6
4
+ version: 3.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Sol
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-03-21 00:00:00.000000000 Z
13
+ date: 2017-03-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -174,7 +174,6 @@ files:
174
174
  - app/views/crud/create.js.erb
175
175
  - app/views/crud/edit.html.erb
176
176
  - app/views/crud/index.html.erb
177
- - app/views/crud/listing.pdf.erb
178
177
  - app/views/crud/listing.xls.erb
179
178
  - app/views/crud/mensagens/_avisos.html.erb
180
179
  - app/views/crud/mensagens/_erros_formulario.html.erb
@@ -1,76 +0,0 @@
1
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
2
-
3
- <div class="widget-box" id="relatorio">
4
- <div class="widget-body">
5
- <div class="widget-main">
6
- <div class="profile-element">
7
- <div class="header">
8
- <h1><%= @crud_helper.title %></h1>
9
- </div>
10
- </div>
11
- <table class="table table-bordered table-striped">
12
- <thead>
13
- <tr>
14
- <% @crud_helper.listing_fields.each do |att|%>
15
- <% if !att[:visible_if].nil?%>
16
- <% if ((att[:visible_if].class == Proc && !att[:visible_if].call(att)) || (att[:visible_if].class != Proc && !att[:visible_if])) %>
17
- <% next %>
18
- <% end %>
19
- <% end %>
20
- <% if att[:sf].present? && att[:sf][:label].present? %>
21
- <th><%= att[:sf][:label].to_s.mb_chars.upcase.to_s %></th>
22
- <% else %>
23
- <th><%= I18n.t(att[:sf][:label]) %></th>
24
- <% end %>
25
- <% end %>
26
- </tr>
27
- </thead>
28
- <tbody>
29
- <% @records.each do |record| %>
30
- <tr>
31
- <%@crud_helper.listing_fields.each do |att| %>
32
- <% if record.send(att[:attribute]).present? or record.send(att[:attribute]).to_s == "false"%>
33
- <% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type)%>
34
- <% if att[:date_format].present?%>
35
- <td><%= record.send(att[:attribute]).strftime(att[:date_format]) %></td>
36
- <% else %>
37
- <td><%= l record.send(att[:attribute]) %></td>
38
- <% end %>
39
- <% elsif ((@model.reflect_on_association(att[:attribute]) && @model.reflect_on_association(att[:attribute]).macro != :belongs_to && @model.reflect_on_association(att[:attribute]).macro != :has_one) || record.send(att[:attribute]).class == Array)%>
40
- <td><%= record.send(att[:attribute]).map{|rec| rec.to_s}.join(",") %></td>
41
- <% else %>
42
- <% if record.send(att[:attribute]).to_s == "false" or record.send(att[:attribute]).to_s == "true" %>
43
- <td><%= I18n.t(record.send(att[:attribute]) ? "shared.sim" : "shared.nao") %></td>
44
- <% elsif att[:sf][:label_method].present? %>
45
- <td><%= record.send(att[:attribute]).send(att[:sf][:label_method]).to_s %></td>
46
- <% else %>
47
- <td><%= record.send(att[:attribute]).to_s %></td>
48
- <% end %>
49
- <% end %>
50
- <% else %>
51
- <td></td>
52
- <% end %>
53
- <% end %>
54
- </tr>
55
- <% end %>
56
- </tbody>
57
- </table>
58
- </div>
59
- </div>
60
- </div>
61
- <style>
62
- #relatorio {
63
- clear: both;
64
- page-break-inside: avoid;
65
- }
66
- .header {
67
- float: left;
68
- }
69
- table {
70
- font-size: 0.75em;
71
- }
72
- thead { display: table-header-group }
73
- tfoot { display: table-row-group }
74
- tr { page-break-inside: avoid }
75
- h1 { padding-bottom: 20px; }
76
- </style>