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,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, params[:scope]) 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,109 +1,98 @@
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
-
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) %>
40
-
41
- <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], scope: params[:scope], q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
42
- <%= I18n.t("devise.reports.excel").html_safe %>
43
- <% end if should_listing_excel?(@crud_helper, @model_permission) %>
44
-
45
- <%= link_to listing_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], q: params[:q], scope: params[:scope], format: :pdf), class: "btn btn-success btn-rounded", target: '_blank' do %>
46
- <%= I18n.t("devise.reports.pdf").html_safe %>
47
- <% end if should_listing_pdf?(@crud_helper, @model_permission) %>
48
-
49
- <% end %>
50
- <% else %>
51
- <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model) %>
52
-
53
- <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], scope: params[:scope], format: :xls), class: "btn btn-success btn-rounded" do %>
54
- <%= I18n.t("devise.reports.excel").html_safe %>
55
- <% end if should_listing_excel?(@crud_helper, @model) %>
56
-
57
- <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], scope: params[:scope], target: '_blank', format: :pdf), class: "btn btn-success btn-rounded", target: '_blank' do %>
58
- <%= I18n.t("devise.reports.pdf").html_safe %>
59
- <% end if should_listing_pdf?(@crud_helper, @model) %>
60
-
61
- <% end %>
62
- <% end %>
63
- <% if @crud_helper.search_fields.present? %>
64
- <button id="button_search_<%= @model.name.underscore %>" class="btn btn-warning btn-rounded" data-toggle="modal" data-target="#modal_search">
65
- <i class="fa fa-search"></i>
66
- </button>
67
- <% end %>
68
- </div>
69
-
70
- <% elsif is_action_show? %>
71
- <% if (@crud_helper.present? && @crud_helper.destroy_action) && should_destroy?(@crud_helper, @record) %>
72
- <% if @crud_associacao.present? %>
73
- <%= 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')} %>
74
- <% else %>
75
- <%= 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')} %>
76
- <% end %>
77
- <% end %>
78
-
79
- <% if (@crud_helper.present? && @crud_helper.edit_action) && should_edit?(@crud_helper, @record) %>
80
- <% if @crud_associacao.present? %>
81
- <%= 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'} %>
82
- <% else %>
83
- <%= 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'} %>
84
- <% end %>
85
- <% end %>
86
-
87
- <% if @crud_helper.printing_fields.present? && can_print_pdf?(@crud_helper, @record) %>
88
- <% if @crud_associacao.present? %>
89
- <%= 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 %>
90
- <%= I18n.t("devise.printing").html_safe %>
91
- <% end %>
92
- <% else %>
93
- <%= 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 %>
94
- <%= I18n.t("devise.printing").html_safe %>
95
- <% end %>
96
- <% end %>
97
- <% end %>
98
- <% end %>
99
- </div>
100
- <div class="ibox-content">
101
- <% block.call %>
102
- </div>
103
- </div>
104
- </div>
105
- </div>
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
+ <% if (@crud_helper.present? && @crud_helper.destroy_action) && should_destroy?(@crud_helper, @record) %>
63
+ <% if @crud_associacao.present? %>
64
+ <%= 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')} %>
65
+ <% else %>
66
+ <%= 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')} %>
67
+ <% end %>
68
+ <% end %>
69
+ <% if (@crud_helper.present? && @crud_helper.edit_action) && should_edit?(@crud_helper, @record) %>
70
+ <% if @crud_associacao.present? %>
71
+ <%= 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'} %>
72
+ <% else %>
73
+ <%= 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'} %>
74
+ <% end %>
75
+ <% end %>
76
+ <% if @crud_helper.printing_fields.present? && should_printing?(@crud_helper, @record) %>
77
+ <% if @crud_associacao.present? %>
78
+ <%= 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 %>
79
+ <%= I18n.t("devise.printing").html_safe %>
80
+ <% end %>
81
+ <% else %>
82
+ <%= 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 %>
83
+ <%= I18n.t("devise.printing").html_safe %>
84
+ <% end %>
85
+ <% end %>
86
+ <% end %>
87
+ <% end %>
88
+ </div>
89
+ <div class="ibox-content">
90
+ <% block.call %>
91
+ </div>
92
+ </div>
93
+ </div>
94
+ </div>
106
95
  </div>
107
96
  <% else %>
108
- <% block.call %>
97
+ <% block.call %>
109
98
  <% end %>
@@ -3,68 +3,61 @@
3
3
  <div class="widget-box" id="relatorio">
4
4
  <div class="widget-body">
5
5
  <div class="widget-main">
6
-
7
- <% unless @crud_helper.setup_report_listing[:header].present? %>
8
- <div class="row">
9
- <div class="col-lg-12">
10
- <h2>
11
- <small><%= @crud_helper.title %></small><br />
12
- </h2>
13
- </div>
6
+ <div class="profile-element">
7
+ <div class="header">
8
+ <h1><%= @crud_helper.title %></h1>
14
9
  </div>
15
- <% end %>
16
-
17
-
10
+ </div>
18
11
  <table class="table table-bordered table-striped">
19
12
  <thead>
20
13
  <tr>
21
- <% @crud_helper.listing_fields.each do |att| %>
22
- <% next if att[:sf][:only] == :excel %>
23
- <% next if !att[:sf][:visible_if].nil? && ((att[:sf][:visible_if].class == Proc && !att[:sf][:visible_if].call(att)) || (att[:sf][:visible_if].class != Proc && !att[:sf][:visible_if])) %>
24
- <th><%= I18n.t(att[:sf][:label]) %></th>
25
- <% end %>
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
26
  </tr>
27
27
  </thead>
28
28
  <tbody>
29
29
  <% @records.each do |record| %>
30
- <tr>
31
- <% @crud_helper.listing_fields.each do |att| %>
32
- <% next if att[:sf][:only] == :excel %>
33
- <% next if !att[:sf][:visible_if].nil? && ((att[:sf][:visible_if].class == Proc && !att[:sf][:visible_if].call(att)) || (att[:sf][:visible_if].class != Proc && !att[:sf][:visible_if])) %>
34
- <td width="<%= att[:sf][:width] if att[:sf][:width].present? %>" height="<%= att[:sf][:height] if att[:sf][:height].present? %>">
35
- <% if record.send(att[:attribute]).present? || record.send(att[:attribute]).to_s == "false" %>
36
- <% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type)%>
37
- <% if att[:date_format].present?%>
38
- <%= record.send(att[:attribute]).strftime(att[:date_format]) %>
39
- <% else %>
40
- <%= l record.send(att[:attribute]) %>
41
- <% end %>
42
- <% elsif array?(record, att[:attribute]) || (association?(@model, att[:attribute]) && !belongs_to_association?(@model, att[:attribute]) && !has_one_association?(@model, att[:attribute])) %>
43
- <%= record.send(att[:attribute]).map{|rec| rec.to_s}.join(",") %>
44
- <% elsif boolean?(record, att[:attribute]) %>
45
- <%= I18n.t(record.send(att[:attribute]) ? "shared.sim" : "shared.nao") %>
46
- <% elsif possui_url?(record, att[:attribute]) %>
47
- <% if deve_renderizar_imagem?(att[:sf]) %>
48
- <%= render_field_file(record.send(att[:attribute])) %>
49
- <% else %>
50
- <%= record.send(att[:attribute]).url %>
51
- <% end %>
52
- <% elsif att[:sf][:label_method].present? %>
53
- <%= record.send(att[:attribute]).send(att[:sf][:label_method]).to_s %>
54
- <% else %>
55
- <%= record.send(att[:attribute]).to_s %>
56
- <% end %>
57
- <% end %>
58
- </td>
59
- <% end %>
60
- </tr>
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>
61
55
  <% end %>
62
56
  </tbody>
63
57
  </table>
64
58
  </div>
65
59
  </div>
66
60
  </div>
67
-
68
61
  <style>
69
62
  #relatorio {
70
63
  clear: both;
@@ -5,49 +5,44 @@ xmlns:x="urn:schemas-microsoft-com:office:excel"
5
5
  xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
6
6
  xmlns:html="http://www.w3.org/TR/REC-html40">
7
7
  <Worksheet ss:Name="<%= @crud_helper.title %>">
8
- <Table>
9
- <Row>
10
- <% @crud_helper.listing_fields.each do |att| %>
11
- <% next if att[:sf][:only] == :pdf %>
12
-
13
- <% if !att[:visible_if].nil?%>
14
- <% if ((att[:visible_if].class == Proc && !att[:visible_if].call(att)) || (att[:visible_if].class != Proc && !att[:visible_if])) %>
15
- <% next %>
16
- <% end %>
17
- <% end %>
18
- <Cell><Data ss:Type="String"><%= I18n.t(att[:sf][:label]) %></Data></Cell>
19
- <% end %>
20
- </Row>
21
- <% @records.each do |record| %>
22
- <Row>
23
- <% @crud_helper.listing_fields.each do |att| %>
24
- <% next if att[:sf][:only] == :pdf %>
25
-
26
- <% if record.send(att[:attribute]).present? || record.send(att[:attribute]).to_s == "false" %>
27
- <% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type) %>
28
- <% if att[:date_format].present?%>
29
- <Cell><Data ss:Type="String"><%= record.send(att[:attribute]).strftime(att[:date_format]) %></Data></Cell>
30
- <% else %>
31
- <Cell><Data ss:Type="String"><%= l record.send(att[:attribute]) %></Data></Cell>
32
- <% end %>
33
- <% elsif array?(record, att[:attribute]) || (association?(@model, att[:attribute]) && !belongs_to_association?(@model, att[:attribute]) && !has_one_association?(@model, att[:attribute])) %>
34
- <%# binding.pry %>
35
- <Cell><Data ss:Type="String"><%= record.send(att[:attribute]).map{ |rec| rec.to_s }.join(",") %></Data></Cell>
36
- <% elsif boolean?(record, att[:attribute]) %>
37
- <Cell><Data ss:Type="String"><%= I18n.t(record.send(att[:attribute]) ? "shared.sim" : "shared.nao") %></Data></Cell>
38
- <% elsif possui_url?(record, att[:attribute]) %>
39
- <Cell><Data ss:Type="String"><%= record.send(att[:attribute]).url %></Data></Cell>
40
- <% elsif att[:sf][:label_method].present? %>
41
- <Cell><Data ss:Type="String"><%= record.send(att[:attribute]).send(att[:sf][:label_method]).to_s %></Data></Cell>
42
- <% else %>
43
- <Cell><Data ss:Type="String"><%= record.send(att[:attribute]).to_s %></Data></Cell>
44
- <% end %>
45
- <% else %>
46
- <Cell><Data ss:Type="String"></Data></Cell>
47
- <% end %>
48
- <% end %>
49
- </Row>
50
- <% end %>
51
- </Table>
8
+ <Table>
9
+ <Row>
10
+ <% @crud_helper.listing_fields.each do |att|%>
11
+ <% if !att[:visible_if].nil?%>
12
+ <% if ((att[:visible_if].class == Proc && !att[:visible_if].call(att)) || (att[:visible_if].class != Proc && !att[:visible_if])) %>
13
+ <% next %>
14
+ <% end %>
15
+ <% end %>
16
+ <Cell><Data ss:Type="String"><%= I18n.t(att[:sf][:label]) %></Data></Cell>
17
+ <% end %>
18
+ </Row>
19
+ <% @records.each do |record| %>
20
+ <Row>
21
+ <%@crud_helper.listing_fields.each do |att| %>
22
+ <% if record.send(att[:attribute]).present? or record.send(att[:attribute]).to_s == "false"%>
23
+ <% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type)%>
24
+ <% if att[:date_format].present?%>
25
+ <Cell><Data ss:Type="String"><%= record.send(att[:attribute]).strftime(att[:date_format]) %></Data></Cell>
26
+ <% else %>
27
+ <Cell><Data ss:Type="String"><%= l record.send(att[:attribute]) %></Data></Cell>
28
+ <% end %>
29
+ <% 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)%>
30
+ <Cell><Data ss:Type="String"><%= record.send(att[:attribute]).map{|rec| rec.to_s}.join(",") %></Data></Cell>
31
+ <% else %>
32
+ <% if record.send(att[:attribute]).to_s == "false" or record.send(att[:attribute]).to_s == "true" %>
33
+ <Cell><Data ss:Type="String"><%= I18n.t(record.send(att[:attribute]) ? "shared.sim" : "shared.nao") %></Data></Cell>
34
+ <% elsif att[:sf][:label_method].present? %>
35
+ <Cell><Data ss:Type="String"><%= record.send(att[:attribute]).send(att[:sf][:label_method]).to_s %></Data></Cell>
36
+ <% else %>
37
+ <Cell><Data ss:Type="String"><%= record.send(att[:attribute]).to_s %></Data></Cell>
38
+ <% end %>
39
+ <% end %>
40
+ <% else %>
41
+ <Cell><Data ss:Type="String"></Data></Cell>
42
+ <% end %>
43
+ <% end %>
44
+ </Row>
45
+ <% end %>
46
+ </Table>
52
47
  </Worksheet>
53
48
  </Workbook>
@@ -3,73 +3,78 @@
3
3
  <div class="widget-box" id="relatorio">
4
4
  <div class="widget-body">
5
5
  <div class="widget-main">
6
-
7
- <div class="row">
8
- <div class="col-lg-12">
9
- <h2>
10
- <% unless @crud_helper.setup_report_printing[:header].present? %>
11
- <small><%= @crud_helper.title %></small><br />
12
- <% end %>
6
+ <div class="profile-element">
7
+ <div class="header">
8
+ <h1>
9
+ <small><%= @crud_helper.title %></small><br />
13
10
  <%= @record.to_s %>
14
- </h2>
11
+ </h1>
15
12
  </div>
16
13
  </div>
17
-
18
14
  <table class="table table-bordered table-striped">
19
15
  <tbody>
20
- <% @crud_helper.printing_fields.each do |field| %>
21
- <% next if field[:sf].present? && !field[:sf][:visible_if].nil? && ((field[:sf][:visible_if].class == Proc && !field[:sf][:visible_if].call(@record)) || (field[:sf][:visible_if].class != Proc && !field[:sf][:visible_if])) %>
16
+ <% @crud_helper.view_fields.each do |field|%>
22
17
  <tr>
23
- <th><%= I18n.t(field[:sf][:label]) %></th>
24
- <td width="<%= field[:sf][:width] if field[:sf][:width].present? %>" height="<%= field[:sf][:height] if field[:sf][:height].present? %>">
25
- <% if @model.columns_hash[field[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[field[:attribute].to_s].type) %>
26
- <% if field[:date_format].present?%>
27
- <%= l @record.send(field[:attribute]).strftime(field[:date_format]) if @record.send(field[:attribute]).present? %>
28
- <% else %>
29
- <%= l @record.send(field[:attribute]) if @record.send(field[:attribute]).present? %>
30
- <% end %>
31
- <% elsif association?(@model, field[:attribute]) && !belongs_to_association?(@model, field[:attribute]) && !has_one_association?(@model, field[:attribute]) %>
18
+ <% if field[:sf].present? && !field[:sf][:visible_if].nil?%>
19
+ <% if ((field[:sf][:visible_if].class == Proc && !field[:sf][:visible_if].call(@record)) || (field[:sf][:visible_if].class != Proc && !field[:sf][:visible_if])) %>
20
+ <% next %>
21
+ <% end %>
22
+ <% end %>
23
+ <% if field[:sf].present? && field[:sf][:label].present? %>
24
+ <th><%= field[:sf][:label].to_s.mb_chars.upcase.to_s %></th>
25
+ <% else %>
26
+ <th><%= I18n.t("simple_form.labels.#{@model.name.underscore}.#{field[:attribute]}") %></th>
27
+ <% end %>
28
+
29
+ <% if @model.columns_hash[field[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[field[:attribute].to_s].type)%>
30
+ <% if field[:date_format].present?%>
31
+ <td><%= l @record.send(field[:attribute]).strftime(field[:date_format]) if @record.send(field[:attribute]).present?%></td>
32
+ <% else %>
33
+ <td><%= l @record.send(field[:attribute]) if @record.send(field[:attribute]).present?%></td>
34
+ <% end %>
35
+ <% elsif @model.reflect_on_association(field[:attribute]) && @model.reflect_on_association(field[:attribute]).macro != :belongs_to && @model.reflect_on_association(field[:attribute]).macro != :has_one%>
36
+ <td>
32
37
  <% @record.send(field[:attribute]).each do |rec| %>
33
- <li>
34
- <% if field[:sf].present? && field[:sf][:label_method].present? %>
35
- <% if possui_url?(rec, field[:sf][:label_method]) && deve_renderizar_imagem?(field[:sf]) %>
36
- <% if deve_renderizar_imagem?(field[:sf]) %>
37
- <%= render_field_file(rec.send(field[:sf][:label_method])) %>
38
- <% else %>
39
- <%= rec.send(field[:sf][:label_method]).url %>
40
- <% end %>
41
- <% else %>
42
- <%= rec.send(field[:sf][:label_method]) %>
43
- <% end %>
38
+ <li>
39
+ <% if field[:sf].present? && field[:sf][:label_method].present? %>
40
+ <% if rec.send(field[:sf][:label_method]).respond_to?(:url) %>
41
+ <%= render_field_file(rec.send(field[:sf][:label_method])) %>
44
42
  <% else %>
45
- <% if rec.respond_to?(:url) && deve_renderizar_imagem?(field[:sf]) %>
46
- <%= render_field_file(rec.to_s) %>
47
- <% else %>
48
- <%= rec.to_s %>
49
- <% end %>
43
+ <%= rec.send(field[:sf][:label_method]) %>
50
44
  <% end %>
51
- </li>
45
+ <% else %>
46
+ <% if rec.to_s.respond_to?(:url) %>
47
+ <%= render_field_file(rec.to_s) %>
48
+ <% else %>
49
+ <%= rec.to_s %>
50
+ <% end %>
51
+ <% end %>
52
+ </li>
52
53
  <% end %>
53
- <% elsif array?(@record, field[:attribute]) %>
54
+ </td>
55
+ <% elsif @record.send(field[:attribute]).class == Array %>
56
+ <td>
54
57
  <% @record.send(field[:attribute]).each do |rec| %>
55
- <li><%= rec.to_s %></li>
56
- <% end %>
57
- <% elsif possui_url?(@record, field[:attribute]) %>
58
- <% if deve_renderizar_imagem?(field[:sf]) %>
59
- <%= render_field_file(@record.send(field[:attribute])) %>
60
- <% else %>
61
- <%= @record.send(field[:attribute]).url %>
58
+ <li>
59
+ <%= rec.to_s %>
60
+ </li>
62
61
  <% end %>
63
- <% elsif boolean?(@record, field[:attribute]) %>
64
- <%= I18n.t(@record.send(field[:attribute]) ? "shared.sim" : "shared.nao") %>
65
- <% else %>
62
+ </td>
63
+ <% elsif @record.send(field[:attribute]).respond_to?(:url) %>
64
+ <td>
65
+ <%= render_field_file(@record.send(field[:attribute])) %>
66
+ </td>
67
+ <% elsif ["false","true"].include? @record.send(field[:attribute]).to_s %>
68
+ <td><%= I18n.t(@record.send(field[:attribute]) ? "shared.sim" : "shared.nao") %></td>
69
+ <% else %>
70
+ <td>
66
71
  <% if field[:sf].present? && field[:sf][:label_method].present? && @record.send(field[:attribute]).present?%>
67
72
  <%= @record.send(field[:attribute]).send(field[:sf][:label_method]) %>
68
73
  <% else %>
69
74
  <%= @record.send(field[:attribute]) %>
70
75
  <% end %>
71
- <% end %>
72
- </td>
76
+ </td>
77
+ <% end %>
73
78
  </tr>
74
79
  <% end %>
75
80
  </tbody>