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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 872ddd9090321dc9cb61eb0813bde103169ce3e4
4
- data.tar.gz: 6fd45c48c159edc1891fc63d9e0249593d0a8f61
3
+ metadata.gz: 0dfa4871df0259f538bedc70333fd4d51f8b997d
4
+ data.tar.gz: b4745585cf0769114562a7bd6b9a0ecb070ff4e0
5
5
  SHA512:
6
- metadata.gz: 2fe91b7d4f1f96c87787a26c4fedf70a50a1c489d6369d12bdd398664497b65ddd24691217d250982d5429c2573cbdb1d8e33cce7a23b9375d2f27786d484d52
7
- data.tar.gz: be8bb80479a4ce137a56e28315268e0cad502e3127d4a1eb2cabe7f30c8f488c3d27c9ae0d48cb141d8322e7c204cedad417d76e68766398e268e86562b1bf5d
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 "#{@url}?page=#{params[:page]}"
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 "#{@url}?page=#{params[:page]}" }
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
- fields << field[:attribute]
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
- @crud_helper.form_groups.each do |key, groups|
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
- group[chave] << field[:attribute]
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
- <% if !att[:visible_if].nil? %>
25
- <% if ((att[:visible_if].class == Proc && !att[:visible_if].call(att)) || (att[:visible_if].class != Proc && !att[:visible_if])) %>
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
- <% if record.send(att[:attribute]).present? || record.send(att[:attribute]).to_s == "false" %>
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
- <td><%= record.send(att[:attribute]).strftime(att[:date_format]) %></td>
38
+ <%= record.send(att[:attribute]).strftime(att[:date_format]) %>
43
39
  <% else %>
44
- <td><%= l record.send(att[:attribute]) %></td>
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
- <td><%= record.send(att[:attribute]).map{|rec| rec.to_s}.join(",") %></td>
43
+ <%= record.send(att[:attribute]).map{|rec| rec.to_s}.join(",") %>
48
44
  <% elsif boolean?(record, att[:attribute]) %>
49
- <td><%= I18n.t(record.send(att[:attribute]) ? "shared.sim" : "shared.nao") %></td>
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
- <td><%= render_field_file(record.send(att[:attribute])) %></td>
48
+ <%= render_field_file(record.send(att[:attribute])) %>
53
49
  <% else %>
54
- <td><%= record.send(att[:attribute]).url %></td>
50
+ <%= record.send(att[:attribute]).url %>
55
51
  <% end %>
56
52
  <% elsif att[:sf][:label_method].present? %>
57
- <td><%= record.send(att[:attribute]).send(att[:sf][:label_method]).to_s %></td>
53
+ <%= record.send(att[:attribute]).send(att[:sf][:label_method]).to_s %>
58
54
  <% else %>
59
- <td><%= record.send(att[:attribute]).to_s %></td>
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
- <% if @model.columns_hash[field[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[field[:attribute].to_s].type) %>
27
- <% if field[:date_format].present?%>
28
- <td><%= l @record.send(field[:attribute]).strftime(field[:date_format]) if @record.send(field[:attribute]).present? %></td>
29
- <% else %>
30
- <td><%= l @record.send(field[:attribute]) if @record.send(field[:attribute]).present? %></td>
31
- <% end %>
32
- <% elsif association?(@model, field[:attribute]) && !belongs_to_association?(@model, field[:attribute]) && !has_one_association?(@model, field[:attribute]) %>
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
- </td>
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
- </td>
62
- <% elsif possui_url?(@record, field[:attribute]) %>
63
- <% if deve_renderizar_imagem?(field[:sf]) %>
64
- <td><%= render_field_file(@record.send(field[:attribute])) %></td>
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
- </td>
78
- <% end %>
71
+ <% end %>
72
+ </td>
79
73
  </tr>
80
74
  <% end %>
81
75
  </tbody>
@@ -1,3 +1,3 @@
1
1
  module TemplusModels
2
- VERSION = "2.0.9"
2
+ VERSION = "2.0.11"
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: 2.0.9
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-25 00:00:00.000000000 Z
13
+ date: 2017-07-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails