templus_models 2.0.9 → 2.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/crud_controller.rb +14 -6
- data/app/views/crud/listing.pdf.erb +15 -20
- data/app/views/crud/printing.pdf.erb +19 -25
- data/lib/templus_models/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dfa4871df0259f538bedc70333fd4d51f8b997d
|
4
|
+
data.tar.gz: b4745585cf0769114562a7bd6b9a0ecb070ff4e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3fb34a5a5bbc3885e10f6be6807daadbe955ec77aa61e76d70ce129d8082c035cc8065b1f5eeb9dba6829c41ab08d48ea9ab6e76aa79ffa86510adb1d1c7715e
|
7
|
+
data.tar.gz: b86b4f0ec6bef0c25abb8b1f344927e3d98d56f193ad56a81c2fadfe214d58f94bba386fedde6b4677d79f158d56de57ecf73e86d1328b62cbe66b94331a2e04
|
@@ -60,7 +60,7 @@ class CrudController < ApplicationController
|
|
60
60
|
else
|
61
61
|
flash.now[:error] = I18n.t("mensagem_erro_action", acao: params[:acao])
|
62
62
|
end
|
63
|
-
redirect_to
|
63
|
+
redirect_to @url
|
64
64
|
else
|
65
65
|
@titulo = @record.to_s
|
66
66
|
@texto = params[:acao]
|
@@ -83,7 +83,7 @@ class CrudController < ApplicationController
|
|
83
83
|
respond_to do |format|
|
84
84
|
if @saved
|
85
85
|
flash[:success] = params[:id].present? ? I18n.t("updated", model: I18n.t("model.#{@model.name.underscore}")) : I18n.t("created", model: I18n.t("model.#{@model.name.underscore}"))
|
86
|
-
format.html { redirect_to
|
86
|
+
format.html { redirect_to @url }
|
87
87
|
unless params[:render] == 'modal'
|
88
88
|
format.js { render action: :index}
|
89
89
|
else
|
@@ -186,7 +186,7 @@ class CrudController < ApplicationController
|
|
186
186
|
|
187
187
|
|
188
188
|
private
|
189
|
-
|
189
|
+
|
190
190
|
def generate_pdf_report(opts, layout)
|
191
191
|
html = render_to_string(layout)
|
192
192
|
options = {
|
@@ -246,12 +246,16 @@ class CrudController < ApplicationController
|
|
246
246
|
fields << {"#{field[:attribute].to_s.singularize}_ids".to_sym => []}
|
247
247
|
end
|
248
248
|
elsif @model.columns_hash[field[:attribute].to_s]
|
249
|
-
|
249
|
+
if @model.columns_hash[field[:attribute].to_s].cast_type.class == ActiveRecord::Type::Serialized
|
250
|
+
fields << {field[:attribute] => []}
|
251
|
+
else
|
252
|
+
fields << field[:attribute]
|
253
|
+
end
|
250
254
|
end
|
251
255
|
end
|
252
256
|
end
|
253
257
|
#TODO - Deprecated
|
254
|
-
|
258
|
+
@crud_helper.form_groups.each do |key, groups|
|
255
259
|
fields << permitt_group(fields, key, groups[:fields],@model)
|
256
260
|
end
|
257
261
|
#Fim - Deprecated
|
@@ -278,7 +282,11 @@ class CrudController < ApplicationController
|
|
278
282
|
group[chave] << {"#{field[:attribute].to_s.singularize}_ids".to_sym => []}
|
279
283
|
end
|
280
284
|
elsif (modelo.columns_hash[field[:attribute].to_s] || (modelo.respond_to?(:params_permitt) && modelo.params_permitt.include?(field[:attribute].to_sym)))
|
281
|
-
|
285
|
+
if modelo.columns_hash[field[:attribute].to_s].cast_type.class == ActiveRecord::Type::Serialized
|
286
|
+
group[chave] << {field[:attribute] => []}
|
287
|
+
else
|
288
|
+
group[chave] << field[:attribute]
|
289
|
+
end
|
282
290
|
end
|
283
291
|
end
|
284
292
|
end
|
@@ -20,14 +20,9 @@
|
|
20
20
|
<tr>
|
21
21
|
<% @crud_helper.listing_fields.each do |att| %>
|
22
22
|
<% next if att[:sf][:only] == :excel %>
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
<% next %>
|
27
|
-
<% end %>
|
28
|
-
<% end %>
|
29
|
-
<th><%= I18n.t(att[:sf][:label]) %></th>
|
30
|
-
<% end %>
|
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 %>
|
31
26
|
</tr>
|
32
27
|
</thead>
|
33
28
|
<tbody>
|
@@ -35,32 +30,32 @@
|
|
35
30
|
<tr>
|
36
31
|
<% @crud_helper.listing_fields.each do |att| %>
|
37
32
|
<% next if att[:sf][:only] == :excel %>
|
38
|
-
|
39
|
-
|
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" %>
|
40
36
|
<% if @model.columns_hash[att[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[att[:attribute].to_s].type)%>
|
41
37
|
<% if att[:date_format].present?%>
|
42
|
-
|
38
|
+
<%= record.send(att[:attribute]).strftime(att[:date_format]) %>
|
43
39
|
<% else %>
|
44
|
-
|
40
|
+
<%= l record.send(att[:attribute]) %>
|
45
41
|
<% end %>
|
46
42
|
<% elsif array?(record, att[:attribute]) || (association?(@model, att[:attribute]) && !belongs_to_association?(@model, att[:attribute]) && !has_one_association?(@model, att[:attribute])) %>
|
47
|
-
|
43
|
+
<%= record.send(att[:attribute]).map{|rec| rec.to_s}.join(",") %>
|
48
44
|
<% elsif boolean?(record, att[:attribute]) %>
|
49
|
-
|
45
|
+
<%= I18n.t(record.send(att[:attribute]) ? "shared.sim" : "shared.nao") %>
|
50
46
|
<% elsif possui_url?(record, att[:attribute]) %>
|
51
47
|
<% if deve_renderizar_imagem?(att[:sf]) %>
|
52
|
-
|
48
|
+
<%= render_field_file(record.send(att[:attribute])) %>
|
53
49
|
<% else %>
|
54
|
-
|
50
|
+
<%= record.send(att[:attribute]).url %>
|
55
51
|
<% end %>
|
56
52
|
<% elsif att[:sf][:label_method].present? %>
|
57
|
-
|
53
|
+
<%= record.send(att[:attribute]).send(att[:sf][:label_method]).to_s %>
|
58
54
|
<% else %>
|
59
|
-
|
55
|
+
<%= record.send(att[:attribute]).to_s %>
|
60
56
|
<% end %>
|
61
|
-
<% else %>
|
62
|
-
<td></td>
|
63
57
|
<% end %>
|
58
|
+
</td>
|
64
59
|
<% end %>
|
65
60
|
</tr>
|
66
61
|
<% end %>
|
@@ -15,22 +15,20 @@
|
|
15
15
|
</div>
|
16
16
|
</div>
|
17
17
|
|
18
|
-
|
19
18
|
<table class="table table-bordered table-striped">
|
20
19
|
<tbody>
|
21
20
|
<% @crud_helper.printing_fields.each do |field| %>
|
22
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])) %>
|
23
22
|
<tr>
|
24
23
|
<th><%= I18n.t(field[:sf][:label]) %></th>
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
<td>
|
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]) %>
|
34
32
|
<% @record.send(field[:attribute]).each do |rec| %>
|
35
33
|
<li>
|
36
34
|
<% if field[:sf].present? && field[:sf][:label_method].present? %>
|
@@ -52,30 +50,26 @@
|
|
52
50
|
<% end %>
|
53
51
|
</li>
|
54
52
|
<% end %>
|
55
|
-
|
56
|
-
<% elsif array?(@record, field[:attribute]) %>
|
57
|
-
<td>
|
53
|
+
<% elsif array?(@record, field[:attribute]) %>
|
58
54
|
<% @record.send(field[:attribute]).each do |rec| %>
|
59
55
|
<li><%= rec.to_s %></li>
|
60
56
|
<% end %>
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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 %>
|
62
|
+
<% end %>
|
63
|
+
<% elsif boolean?(@record, field[:attribute]) %>
|
64
|
+
<%= I18n.t(@record.send(field[:attribute]) ? "shared.sim" : "shared.nao") %>
|
65
65
|
<% else %>
|
66
|
-
<td><%= @record.send(field[:attribute]).url %></td>
|
67
|
-
<% end %>
|
68
|
-
<% elsif boolean?(@record, field[:attribute]) %>
|
69
|
-
<td><%= I18n.t(@record.send(field[:attribute]) ? "shared.sim" : "shared.nao") %></td>
|
70
|
-
<% else %>
|
71
|
-
<td>
|
72
66
|
<% if field[:sf].present? && field[:sf][:label_method].present? && @record.send(field[:attribute]).present?%>
|
73
67
|
<%= @record.send(field[:attribute]).send(field[:sf][:label_method]) %>
|
74
68
|
<% else %>
|
75
69
|
<%= @record.send(field[:attribute]) %>
|
76
70
|
<% end %>
|
77
|
-
|
78
|
-
|
71
|
+
<% end %>
|
72
|
+
</td>
|
79
73
|
</tr>
|
80
74
|
<% end %>
|
81
75
|
</tbody>
|
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: 2.0.
|
4
|
+
version: 2.0.11
|
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-07-
|
13
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|