templus_models 1.6.9 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/crud_controller.rb +48 -53
  3. data/app/helpers/crud_helper.rb +27 -3
  4. data/app/helpers/search_helper.rb +25 -20
  5. data/app/raro_crud/raro_crud.rb +66 -20
  6. data/app/views/crud/_default_actions_crud.html.erb +2 -2
  7. data/app/views/crud/_form.html.erb +5 -5
  8. data/app/views/crud/_form_group.html.erb +3 -3
  9. data/app/views/crud/_record.html.erb +46 -43
  10. data/app/views/crud/_records.html.erb +12 -12
  11. data/app/views/crud/_scopes.html.erb +4 -5
  12. data/app/views/crud/_search.html.erb +3 -3
  13. data/app/views/crud/_shared.html.erb +31 -18
  14. data/app/views/crud/_show.html.erb +8 -7
  15. data/app/views/crud/listing.pdf.erb +21 -19
  16. data/app/views/crud/listing.xls.erb +2 -2
  17. data/app/views/crud/printing.pdf.erb +100 -0
  18. data/app/views/kaminari/templus/_first_page.html.erb +1 -1
  19. data/app/views/kaminari/templus/_gap.html.erb +1 -1
  20. data/app/views/kaminari/templus/_last_page.html.erb +1 -1
  21. data/app/views/kaminari/templus/_next_page.html.erb +1 -1
  22. data/app/views/kaminari/templus/_paginator.html.erb +2 -2
  23. data/app/views/kaminari/templus/_prev_page.html.erb +1 -1
  24. data/app/views/layouts/_menu_crud.html.erb +1 -1
  25. data/app/views/layouts/_template_raro_crud.html.erb +1 -1
  26. data/config/initializers/simple_form.rb +2 -5
  27. data/config/routes.rb +32 -25
  28. data/lib/templus_models/configuration.rb +14 -0
  29. data/lib/templus_models/version.rb +1 -1
  30. data/lib/templus_models.rb +29 -1
  31. data/test/dummy/app/helpers/menu_helper.rb +17 -17
  32. data/test/dummy/app/models/templus.rb +4 -4
  33. data/test/dummy/app/raro_crud/endereco_crud.rb +1 -1
  34. data/test/dummy/app/raro_crud/papel_crud.rb +1 -1
  35. data/test/dummy/app/raro_crud/teste1_crud.rb +1 -1
  36. data/test/dummy/app/raro_crud/teste_crud.rb +1 -1
  37. data/test/dummy/app/raro_crud/usuario_crud.rb +6 -3
  38. data/test/dummy/config/locales/pt-BR.yml +25 -31
  39. data/test/dummy/config/locales/simple_form.pt-BR.yml +2 -0
  40. data/test/dummy/db/development.sqlite3 +0 -0
  41. metadata +627 -625
@@ -6,20 +6,16 @@
6
6
  <% end %>
7
7
  <% end %>
8
8
  <% if record.send(att[:attribute]).present? or record.send(att[:attribute]).to_s == "false"%>
9
- <% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type)%>
10
- <% if att[:date_format].present?%>
11
- <td class="row">
12
- <div class="col-xs-9">
13
- <%= record.send(att[:attribute]).strftime(att[:date_format]) %>
14
- </div>
15
- </td>
16
- <% else %>
17
- <td class="row">
18
- <div class="col-xs-9">
19
- <%= l record.send(att[:attribute]) %>
20
- </div>
21
- </td>
22
- <% end %>
9
+ <% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :time, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type)%>
10
+ <td class="row">
11
+ <div class="col-xs-9">
12
+ <% if att[:date_format].present?%>
13
+ <%= I18n.l(record.send(att[:attribute]), format: att[:date_format]) %>
14
+ <% else %>
15
+ <%= I18n.l(record.send(att[:attribute])) %>
16
+ <% end %>
17
+ </div>
18
+ </td>
23
19
  <% 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%>
24
20
  <td class="row">
25
21
  <% record.send(att[:attribute]).each do |rec| %>
@@ -42,13 +38,13 @@
42
38
  <% if record.send(att[:attribute]).to_s == "false" or record.send(att[:attribute]).to_s == "true" %>
43
39
  <td class="row">
44
40
  <div class="col-xs-9">
45
- <%= record.send(att[:attribute]) ? "Sim" : "Não" %>
41
+ <%= record.send(att[:attribute]) ? "Sim" : "Não" %>
46
42
  </div>
47
43
  </td>
48
44
  <% else %>
49
45
  <td class="row">
50
46
  <div class="col-xs-9">
51
- <%= record.send(att[:attribute]).to_s %>
47
+ <%= record.send(att[:attribute]).to_s %>
52
48
  </div>
53
49
  </td>
54
50
  <% end %>
@@ -61,49 +57,56 @@
61
57
  <div class="col-xs-9">
62
58
  <%@crud_helper.actions.each do |a|%>
63
59
  <% if ((a[2].present? && a[2].call(record)) || !a[2].present?) %>
64
- <%= link_to a[1], action_crud_path(model: @model.name.underscore, id: record.id, acao: a[0], page: params[:page], q: params[:q]), class: "btn btn-primary btn-xs", data: {push: "partial", target: "#form"}%>
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"}%>
65
61
  <% end %>
66
62
  <% end %>
67
63
  <%@crud_helper.actions_links.each do |name, options|%>
68
- <% if options[:url].present? %>
69
- <% url = options[:url] %>
70
- <% if options[:id] %>
71
- <% url += options[:url].include?("?") ? "&id=#{record.id}" : "?id=#{record.id}" %>
72
- <% end %>
73
- <% if options[:wiselink].present? && options[:wiselink] %>
74
- <a href="<%= url %>" class="btn btn-success btn-xs" data-push="partial" data-target="#form">
75
- <%=name%>
76
- </a>
77
- <% else %>
78
- <a href="<%= url %>" class="btn btn-success btn-xs">
79
- <%=name%>
80
- </a>
64
+ <% unless (options[:can].present? && !record.instance_eval(&options[:can])) %>
65
+ <% if options[:url].present? %>
66
+ <% url = options[:url] %>
67
+ <% if options[:id] %>
68
+ <% url += options[:url].include?("?") ? "&id=#{record.id}" : "?id=#{record.id}" %>
69
+ <% else url.include?(":id") %>
70
+ <% url = url.gsub(":id", "#{record.id}") %>
71
+ <% end %>
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>
76
+ <% else %>
77
+ <a href="<%= url %>" class="btn btn-success btn-xs">
78
+ <%=I18n.t(name)%>
79
+ </a>
80
+ <% end %>
81
+ <% elsif options[:associacao].present? %>
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"} %>
83
+ <% elsif options[:partial].present? %>
84
+ <%= render options[:partial], record: record %>
81
85
  <% end %>
82
- <% elsif options[:associacao].present? %>
83
- <%= 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: true, crumb: "wielka"} %>
84
- <% elsif options[:partial].present? %>
85
- <%= render options[:partial], record: record %>
86
86
  <% end %>
87
87
  <% end %>
88
- <%if @crud_helper.view_action && should_view?(@crud_helper, record)%>
88
+ <% if @crud_helper.view_action && should_view?(@crud_helper, record) %>
89
+ <% link_text = TemplusModels.configuration.usar_icones ? "<i class='fa fa-eye'></i>".html_safe : I18n.t("view") %>
89
90
  <% if @crud_associacao.present? %>
90
- <%= link_to "Visualizar", crud_associacao_model_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', data: {push: 'partial', target: '#form'} %>
91
+ <%= link_to link_text, crud_associacao_model_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', data: {push: 'partial', target: '#form'} %>
91
92
  <% else %>
92
- <%= link_to "Visualizar", crud_model_path(model: @model.name.underscore, id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs', data: {push: 'partial', target: '#form'} %>
93
+ <%= link_to link_text, crud_model_path(model: @model.name.underscore, id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs', data: {push: 'partial', target: '#form'} %>
93
94
  <% end %>
94
95
  <% end %>
95
- <%if @crud_helper.edit_action && should_edit?(@crud_helper, record) %>
96
+ <% if @crud_helper.edit_action && should_edit?(@crud_helper, record) %>
97
+ <% link_text = TemplusModels.configuration.usar_icones ? "<i class='fa fa-edit'></i>".html_safe : I18n.t("edit") %>
96
98
  <% if @crud_associacao.present? %>
97
- <%= link_to "Editar", 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', data: {push: 'partial', target: '#form'} %>
99
+ <%= link_to link_text, 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', data: {push: 'partial', target: '#form'} %>
98
100
  <% else %>
99
- <%= link_to "Editar", edit_crud_path(model: @model.name.underscore, id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs', data: {push: 'partial', target: '#form'} %>
101
+ <%= link_to link_text, edit_crud_path(model: @model.name.underscore, id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs', data: {push: 'partial', target: '#form'} %>
100
102
  <% end %>
101
103
  <% end %>
102
- <%if @crud_helper.destroy_action && should_destroy?(@crud_helper, record)%>
104
+ <% if @crud_helper.destroy_action && should_destroy?(@crud_helper, record) %>
105
+ <% link_text = TemplusModels.configuration.usar_icones ? "<i class='fa fa-trash'></i>".html_safe : I18n.t("destroy") %>
103
106
  <% if @crud_associacao.present? %>
104
- <%= link_to "Excluir", 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', data: {method: 'delete', confirm: 'Você tem certeza?'} %>
107
+ <%= link_to link_text, 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', data: {method: 'delete', confirm: I18n.t('mensagem_confirm_destroy')} %>
105
108
  <% else %>
106
- <%= link_to "Excluir", destroy_crud_path(model: @model.name.underscore, id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-danger btn-xs', data: {method: 'delete', confirm: 'Você tem certeza?'} %>
109
+ <%= link_to link_text, destroy_crud_path(model: @model.name.underscore, id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-danger btn-xs', data: {method: 'delete', confirm: I18n.t('mensagem_confirm_destroy')} %>
107
110
  <% end %>
108
111
  <% end %>
109
112
  </div>
@@ -7,21 +7,21 @@
7
7
  <thead>
8
8
  <tr>
9
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 %>
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 %>
13
14
  <% end %>
14
- <% end %>
15
- <th>
16
- <% if att[:sort_field].present? %>
17
- <%= sort_link @q, att[:sort_field], att[:label], {},data: {push: 'partial', target: "#form"}%>
18
- <% else %>
19
- <%= sort_link @q, att[:attribute], att[:label], {},data: {push: 'partial', target: "#form"}%>
20
- <% end %>
21
- </th>
15
+ <th>
16
+ <% if att[:sort_field].present? %>
17
+ <%= sort_link @q, att[:sort_field], I18n.t("simple_form.labels.#{@model.name.underscore}.#{att[:attribute]}"), {},data: {push: 'partial', target: "#form"}%>
18
+ <% else %>
19
+ <%= sort_link @q, att[:attribute], I18n.t("simple_form.labels.#{@model.name.underscore}.#{att[:attribute]}"), {},data: {push: 'partial', target: "#form"}%>
20
+ <% end %>
21
+ </th>
22
22
  <%end%>
23
23
  <%if @crud_helper.view_action || @crud_helper.edit_action || @crud_helper.destroy_action || @crud_helper.actions.present?%>
24
- <td>Opções</td>
24
+ <td><%= I18n.t("simple_form.index.options") %></td>
25
25
  <% end %>
26
26
  </tr>
27
27
  </thead>
@@ -1,13 +1,12 @@
1
1
  <% if @crud_helper.scopes.present? %>
2
2
  <% if @crud_helper.scopes.class == Array %>
3
3
  <% @crud_helper.scopes.each do |escopo| %>
4
- <% url = params[:associacao].present? ? crud_associacao_models_path(model: params[:model], id: params[:id], associacao: params[:associacao], scope: escopo[0]) : crud_models_path(model: @model.name.underscore, scope: escopo[0])%>
5
- <%= link_to url, id: "#{escopo[0]}", data: {push: true, crumb: 'wielka'} do%>
6
- <div style="float: left; margin-left: 10px; ">
7
- <div class="widget style1 gray-bg" style="padding: 15px 10px!important;">
4
+ <%= link_to crud_models_path(model: @model.name.underscore, scope: escopo[0]), id: "#{escopo[0]}", data: {push: true, crumb: 'wielka'} do%>
5
+ <div style="float: left; margin-left: 10px;">
6
+ <div class="widget style1 gray-bg" style="padding: 15px 10px !important;">
8
7
  <div class="row vertical-align text-center" style="margin:0!important;">
9
8
  <h3 class="font-bold" style="width:100%;">
10
- <%= escopo[1] %>
9
+ <%= I18n.t(escopo[1]) %>
11
10
  <span class="label label-success pull-right" style="margin-left: 10px;">
12
11
  <% if current_usuario.present? %>
13
12
  <%= @model.send(escopo[0]).accessible_by(current_ability, :read).count %>
@@ -2,9 +2,9 @@
2
2
  <div class="modal-dialog modal-lg">
3
3
  <div class="modal-content animated bounceInRight">
4
4
  <div class="modal-header">
5
- <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Fechar</span></button>
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
6
  <i class="fa fa-search modal-icon"></i>
7
- <h4 class="modal-title">Pesquisa</h4>
7
+ <h4 class="modal-title"><%= I18n.t("search") %></h4>
8
8
  <small class="font-bold"></small>
9
9
  </div>
10
10
  <div class="modal-body">
@@ -21,7 +21,7 @@
21
21
  <% next %>
22
22
  <% end %>
23
23
  <% end %>
24
- <%raro_field att[:attribute],att[:sf]%>
24
+ <%raro_field att[:attribute], att[:sf]%>
25
25
  <%end%>
26
26
  <%end%>
27
27
  </div>
@@ -4,13 +4,15 @@
4
4
  <div class="col-lg-12">
5
5
  <div class="ibox float-e-margins">
6
6
  <div class="ibox-title">
7
- <% if is_action_edit? && @model.present?%>
7
+ <% if content_for?(:ibox_title) %>
8
+ <%= yield :ibox_title %>
9
+ <% elsif is_action_edit? && @model.present?%>
8
10
  <h5>
9
- Editar
11
+ <%= I18n.t("edit") %>
10
12
  <small style="margin-left: 2px;"><%= @record.to_s %> - #<%= @record.id %></small>
11
13
  </h5>
12
- <% elsif is_action_create? && @model.present? %>
13
- <h5>Cadastrar</h5>
14
+ <% elsif (is_action_create? || is_action_new?) && @model.present? %>
15
+ <h5><%= I18n.t("new", model: I18n.t("model.#{@model.name.underscore}")) %></h5>
14
16
  <% elsif @record.present? && !@record.new_record? %>
15
17
  <h5>
16
18
  <%= @record.to_s %>
@@ -34,20 +36,20 @@
34
36
  <% if params[:associacao] %>
35
37
  <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model_permission) %>
36
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 %>
37
- <i class="fa fa-file-excel-o"></i>
38
- <% end %>
39
- <%= 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" do %>
40
- <i class="fa fa-file-pdf-o"></i>
41
- <% end %>
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) %>
42
44
  <% end %>
43
45
  <% else %>
44
46
  <% if @crud_helper.listing_fields.present? && should_listing?(@crud_helper, @model) %>
45
47
  <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], format: :xls), class: "btn btn-success btn-rounded" do %>
46
- <i class="fa fa-file-excel-o"></i>
47
- <% end %>
48
- <%= link_to listing_crud_path(model: @model.name.underscore, q: params[:q], format: :pdf), class: "btn btn-success btn-rounded" do %>
49
- <i class="fa fa-file-pdf-o"></i>
50
- <% end %>
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) %>
51
53
  <% end %>
52
54
  <% end %>
53
55
  <% if @crud_helper.search_fields.present? %>
@@ -59,18 +61,29 @@
59
61
  <% elsif is_action_show? %>
60
62
  <% if (@crud_helper.present? && @crud_helper.destroy_action) && should_destroy?(@crud_helper, @record) %>
61
63
  <% if @crud_associacao.present? %>
62
- <%= link_to "Excluir", 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: 'Você tem certeza?'} %>
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')} %>
63
65
  <% else %>
64
- <%= link_to "Excluir", 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: 'Você tem certeza?'} %>
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')} %>
65
67
  <% end %>
66
68
  <% end %>
67
69
  <% if (@crud_helper.present? && @crud_helper.edit_action) && should_edit?(@crud_helper, @record) %>
68
70
  <% if @crud_associacao.present? %>
69
- <%= link_to "Editar", 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'} %>
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'} %>
70
72
  <% else %>
71
- <%= link_to "Editar", 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'} %>
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'} %>
72
74
  <% end %>
73
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 %>
74
87
  <% end %>
75
88
  </div>
76
89
  <div class="ibox-content">
@@ -14,8 +14,9 @@
14
14
  <% if field[:sf].present? && field[:sf][:label].present? %>
15
15
  <th><%= field[:sf][:label].to_s.mb_chars.upcase.to_s %></th>
16
16
  <% else %>
17
- <th><%= field[:attribute].to_s.mb_chars.upcase.to_s %></th>
17
+ <th><%= I18n.t("simple_form.labels.#{@model.name.underscore}.#{field[:attribute]}") %></th>
18
18
  <% end %>
19
+
19
20
  <% if @model.columns_hash[field[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[field[:attribute].to_s].type)%>
20
21
  <% if field[:date_format].present?%>
21
22
  <td><%= l @record.send(field[:attribute]).strftime(field[:date_format]) if @record.send(field[:attribute]).present?%></td>
@@ -35,9 +36,9 @@
35
36
  <% else %>
36
37
  <% if rec.to_s.respond_to?(:url) %>
37
38
  <%= render_field_file(rec.to_s) %>
38
- <% else %>
39
- <%= rec.to_s %>
40
- <% end %>
39
+ <% else %>
40
+ <%= rec.to_s %>
41
+ <% end %>
41
42
  <% end %>
42
43
  </li>
43
44
  <% end %>
@@ -59,9 +60,9 @@
59
60
  <% else %>
60
61
  <td>
61
62
  <% if field[:sf].present? && field[:sf][:label_method].present? && @record.send(field[:attribute]).present?%>
62
- <%= @record.send(field[:attribute]).send(field[:sf][:label_method]) %>
63
+ <%= @record.send(field[:attribute]).send(field[:sf][:label_method]) %>
63
64
  <% else %>
64
- <%= @record.send(field[:attribute]) %>
65
+ <%= @record.send(field[:attribute]) %>
65
66
  <% end %>
66
67
  </td>
67
68
  <% end %>
@@ -73,5 +74,5 @@
73
74
  </div>
74
75
  </div>
75
76
  <hr>
76
- <%= link_to "Voltar", @url ,class: 'btn btn-default', data: {push: 'partial', target: "#form"} %>
77
+ <%= link_to I18n.t("undo"), "#{@url}" ,class: 'btn btn-default', data: {push: 'partial', target: "#form"} %>
77
78
  <% end %>
@@ -1,12 +1,14 @@
1
- <div class="profile-element">
2
- <div class="header">
3
- <h1>Listagem de <%= @crud_helper.title %></h1>
4
- </div>
5
- </div>
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
+
6
3
  <div class="widget-box" id="relatorio">
7
4
  <div class="widget-body">
8
5
  <div class="widget-main">
9
- <table class="table table-bordered table-striped" style="border: 1px solid black;">
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">
10
12
  <thead>
11
13
  <tr>
12
14
  <% @crud_helper.listing_fields.each do |att|%>
@@ -18,7 +20,7 @@
18
20
  <% if att[:sf].present? && att[:sf][:label].present? %>
19
21
  <th><%= att[:sf][:label].to_s.mb_chars.upcase.to_s %></th>
20
22
  <% else %>
21
- <th><%= att[:attribute].to_s.mb_chars.upcase.to_s %></th>
23
+ <th><%= I18n.t("simple_form.labels.#{@model.name.underscore}.#{att[:attribute]}") %></th>
22
24
  <% end %>
23
25
  <% end %>
24
26
  </tr>
@@ -30,7 +32,7 @@
30
32
  <% if record.send(att[:attribute]).present? or record.send(att[:attribute]).to_s == "false"%>
31
33
  <% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type)%>
32
34
  <% if att[:date_format].present?%>
33
- <td><%= record.send(att[:attribute]).strftime(att[:date_format]) %></td>
35
+ <td><%= record.send(att[:attribute]).strftime(att[:date_format]) %></td>
34
36
  <% else %>
35
37
  <td><%= l record.send(att[:attribute]) %></td>
36
38
  <% end %>
@@ -38,11 +40,11 @@
38
40
  <td><%= record.send(att[:attribute]).map{|rec| rec.to_s}.join(",") %></td>
39
41
  <% else %>
40
42
  <% if record.send(att[:attribute]).to_s == "false" or record.send(att[:attribute]).to_s == "true" %>
41
- <td><%= record.send(att[:attribute]) ? "Sim" : "Não" %></td>
43
+ <td><%= record.send(att[:attribute]) ? "Sim" : "Não" %></td>
42
44
  <% elsif att[:sf][:label_method].present? %>
43
- <td><%= record.send(att[:attribute]).send(att[:sf][:label_method]).to_s %></td>
45
+ <td><%= record.send(att[:attribute]).send(att[:sf][:label_method]).to_s %></td>
44
46
  <% else %>
45
- <td><%= record.send(att[:attribute]).to_s %></td>
47
+ <td><%= record.send(att[:attribute]).to_s %></td>
46
48
  <% end %>
47
49
  <% end %>
48
50
  <% else %>
@@ -57,18 +59,18 @@
57
59
  </div>
58
60
  </div>
59
61
  <style>
60
- table, tr, td, th, tbody, thead, tfoot {
61
- page-break-inside: avoid !important;
62
- }
63
- table, th, td {
64
- border-collapse: collapse;
65
- border: 1px solid black;
66
- }
67
62
  #relatorio {
68
- padding-top: 40px;
69
63
  clear: both;
64
+ page-break-inside: avoid;
70
65
  }
71
66
  .header {
72
67
  float: left;
73
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; }
74
76
  </style>
@@ -4,7 +4,7 @@ xmlns:o="urn:schemas-microsoft-com:office:office"
4
4
  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
- <Worksheet ss:Name="Listagem de <%= @crud_helper.title %>">
7
+ <Worksheet ss:Name="<%= @crud_helper.title %>">
8
8
  <Table>
9
9
  <Row>
10
10
  <% @crud_helper.listing_fields.each do |att|%>
@@ -16,7 +16,7 @@ xmlns:html="http://www.w3.org/TR/REC-html40">
16
16
  <% if att[:sf].present? && att[:sf][:label].present? %>
17
17
  <Cell><Data ss:Type="String"><%= att[:sf][:label].to_s.mb_chars.upcase.to_s %></Data></Cell>
18
18
  <% else %>
19
- <Cell><Data ss:Type="String"><%= att[:attribute].to_s.mb_chars.upcase.to_s %></Data></Cell>
19
+ <Cell><Data ss:Type="String"><%= I18n.t("simple_form.labels.#{@model.name.underscore}.#{att[:attribute]}") %></Data></Cell>
20
20
  <% end %>
21
21
  <% end %>
22
22
  </Row>
@@ -0,0 +1,100 @@
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>
9
+ <small><%= @crud_helper.title %></small><br />
10
+ <%= @record.to_s %>
11
+ </h1>
12
+ </div>
13
+ </div>
14
+ <table class="table table-bordered table-striped">
15
+ <tbody>
16
+ <% @crud_helper.view_fields.each do |field|%>
17
+ <tr>
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>
37
+ <% @record.send(field[:attribute]).each do |rec| %>
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])) %>
42
+ <% else %>
43
+ <%= rec.send(field[:sf][:label_method]) %>
44
+ <% end %>
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>
53
+ <% end %>
54
+ </td>
55
+ <% elsif @record.send(field[:attribute]).class == Array %>
56
+ <td>
57
+ <% @record.send(field[:attribute]).each do |rec| %>
58
+ <li>
59
+ <%= rec.to_s %>
60
+ </li>
61
+ <% end %>
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><%= @record.send(field[:attribute]) ? "Sim" : "Não" %></td>
69
+ <% else %>
70
+ <td>
71
+ <% if field[:sf].present? && field[:sf][:label_method].present? && @record.send(field[:attribute]).present?%>
72
+ <%= @record.send(field[:attribute]).send(field[:sf][:label_method]) %>
73
+ <% else %>
74
+ <%= @record.send(field[:attribute]) %>
75
+ <% end %>
76
+ </td>
77
+ <% end %>
78
+ </tr>
79
+ <% end %>
80
+ </tbody>
81
+ </table>
82
+ </div>
83
+ </div>
84
+ </div>
85
+ <style>
86
+ #relatorio {
87
+ clear: both;
88
+ page-break-inside: avoid;
89
+ }
90
+ .header {
91
+ float: left;
92
+ }
93
+ table {
94
+ font-size: 0.75em;
95
+ }
96
+ thead { display: table-header-group }
97
+ tfoot { display: table-row-group }
98
+ tr { page-break-inside: avoid }
99
+ h1 { padding-bottom: 20px; }
100
+ </style>
@@ -1,3 +1,3 @@
1
1
  <li>
2
- <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, {:remote => remote, data: {push: 'partial', target: (!local_assigns[:target].nil? and target) ? target : '.wiselinks-partial'}} %>
2
+ <%= link_to_unless current_page.first?, raw(I18n.t('views.pagination.first')), url, {:remote => remote, data: {push: 'partial', target: (!local_assigns[:target].nil? and target) ? target : '.wiselinks-partial'}} %>
3
3
  </li>
@@ -1,3 +1,3 @@
1
1
  <li class="disabled">
2
- <%= link_to raw(t 'views.pagination.truncate'), '#' %>
2
+ <%= link_to raw(I18n.t('views.pagination.truncate')), '#' %>
3
3
  </li>
@@ -1,3 +1,3 @@
1
1
  <li>
2
- <%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote, data: {push: 'partial', target: (!local_assigns[:target].nil? and target) ? target : '.wiselinks-partial'}} %>
2
+ <%= link_to_unless current_page.last?, raw(I18n.t('views.pagination.last')), url, {:remote => remote, data: {push: 'partial', target: (!local_assigns[:target].nil? and target) ? target : '.wiselinks-partial'}} %>
3
3
  </li>
@@ -1,3 +1,3 @@
1
1
  <li>
2
- <%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, {:rel => 'next', :remote => remote, data: {push: 'partial', target: (!local_assigns[:target].nil? and target) ? target : '.wiselinks-partial'}} %>
2
+ <%= link_to_unless current_page.last?, raw(I18n.t('views.pagination.next')), url, {:rel => 'next', :remote => remote, data: {push: 'partial', target: (!local_assigns[:target].nil? and target) ? target : '.wiselinks-partial'}} %>
3
3
  </li>
@@ -12,8 +12,8 @@
12
12
  <% else %>
13
13
  <% fim = @options[:current_page].number * @options[:per_page] %>
14
14
  <% end %>
15
- Exibindo <%= inicio %> - <%= fim %> de um total de <%= @options[:total_count] %>
16
- </div>
15
+ <%= I18n.t("views.pagination.text", inicio: inicio, fim: fim, total: @options[:total_count]) %>
16
+ </div>
17
17
  </div>
18
18
  <div class="col-xs-12 col-md-8">
19
19
  <div class="dataTables_paginate paging_simple_numbers">
@@ -1,3 +1,3 @@
1
1
  <li>
2
- <%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, {:rel => 'prev', :remote => remote, data: {push: 'partial', target: (!local_assigns[:target].nil? and target) ? target : '.wiselinks-partial'}} %>
2
+ <%= link_to_unless current_page.first?, raw(I18n.t('views.pagination.previous')), url, {:rel => 'prev', :remote => remote, data: {push: 'partial', target: (!local_assigns[:target].nil? and target) ? target : '.wiselinks-partial'}} %>
3
3
  </li>
@@ -1,4 +1,4 @@
1
- <%= menu_parent(raro_models, lista_menus_crud(raro_models), "Cadastros", 'fa fa-book', true) do %>
1
+ <%= menu_parent(raro_models, lista_menus_crud(raro_models), I18n.t("views.menu.entitys"), 'fa fa-book', true) do %>
2
2
  <% raro_models.each do |modelo| %>
3
3
  <%= menu_crud_helper("#{modelo.name.underscore}_crud".camelize.constantize.title, modelo) %>
4
4
  <% end %>
@@ -9,7 +9,7 @@
9
9
  <ol class="breadcrumb">
10
10
  <li>
11
11
  <%= link_to root_path do %>
12
- Home
12
+ <%= I18n.t("home") %>
13
13
  <% end %>
14
14
  </li>
15
15
  <% if content_for? :breadcumb %>
@@ -144,7 +144,7 @@ SimpleForm.setup do |config|
144
144
  b.use :html5
145
145
  b.wrapper :tag => 'div', :class => 'form-group' do |ba|
146
146
  ba.use :label, :class => 'col-sm-2 control-label'
147
- ba.wrapper :tag => 'div', :class => 'col-sm-9 col-xs-9' do |ba2|
147
+ ba.wrapper :tag => 'div', :class => 'col-sm-9' do |ba2|
148
148
  ba2.use :input, :class => 'form-control'
149
149
  ba2.use :error, :wrap_with => { :tag => 'span', :class => 'help-block m-b-none text-danger' }
150
150
  ba2.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block text-muted' }
@@ -162,12 +162,9 @@ SimpleForm.setup do |config|
162
162
  ba2.use :hint, :wrap_with => { :tag => 'span', :class => 'help-block text-muted' }
163
163
  end
164
164
  ba.wrapper :tag => 'a', :class => "btn btn-success crud-new-record" do |ba2|
165
- ba2.wrapper :tag => 'i', :class => "fa fa-plus" do
165
+ ba2.wrapper :tag => 'i' , :class => "fa fa-plus" do
166
166
  end
167
167
  end
168
168
  end
169
169
  end
170
-
171
-
172
-
173
170
  end