templus_models 1.3.7 → 1.3.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/raro_crud.js +4 -2
- data/app/controllers/crud_controller.rb +41 -19
- data/app/raro_crud/raro_crud.rb +43 -17
- data/app/views/crud/_form.html.erb +10 -35
- data/app/views/crud/_form_group.html.erb +38 -0
- data/app/views/crud/_record.html.erb +6 -1
- data/app/views/crud/_scopes.html.erb +5 -1
- data/app/views/crud/_show.html.erb +3 -3
- data/lib/templus_models/version.rb +1 -1
- data/test/dummy/app/models/contato.rb +5 -0
- data/test/dummy/app/models/telefone.rb +3 -0
- data/test/dummy/app/models/usuario.rb +6 -0
- data/test/dummy/app/raro_crud/teste_crud.rb +5 -1
- data/test/dummy/app/raro_crud/usuario_crud.rb +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20150813125909_create_contatos.rb +11 -0
- data/test/dummy/db/migrate/20150813125926_create_telefones.rb +10 -0
- data/test/dummy/db/migrate/20150813200710_add_novo_papel_id_to_usuarios.rb +5 -0
- data/test/dummy/db/schema.rb +23 -2
- data/test/dummy/test/fixtures/contatos.yml +9 -0
- data/test/dummy/test/fixtures/telefones.yml +9 -0
- data/test/dummy/test/models/contato_test.rb +7 -0
- data/test/dummy/test/models/telefone_test.rb +7 -0
- metadata +21 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28d3a455c28b41654369312ed6014300fe3dc8bc
|
4
|
+
data.tar.gz: 996142cde911189c50002f296e13837456e7cc72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2d5e917161cc7b28cb02f61546982772daad1b3fba5f3190fa9d9d4e079b433bfbaed3c64e748f5302931f2a0937e229780a55f02d36c15a7c7608b89b71e68
|
7
|
+
data.tar.gz: e6a791963701601dad16721f905e5b4157015159460603bd9b59c77d415711101ff213c6d3616fe300ca3d8606936ba7020d69a7a3e6aec0c63d51a151e4a027
|
@@ -1,5 +1,7 @@
|
|
1
1
|
function new_record(id,name,model_name){
|
2
|
-
model_name = name.split("[")
|
2
|
+
model_name = name.split("[")
|
3
|
+
class_name = model_name[0]
|
4
|
+
model_name = model_name[model_name.length - 1].split("_id]")[0];
|
3
5
|
|
4
6
|
$('#modal_new_record').attr("class","modal inmodal")
|
5
7
|
$('#modal_new_record').addClass(model_name);
|
@@ -7,7 +9,7 @@ function new_record(id,name,model_name){
|
|
7
9
|
var model_target = "#modal_new_record." + model_name;
|
8
10
|
|
9
11
|
|
10
|
-
var url = "/crud/" +
|
12
|
+
var url = "/crud/" + class_name + "/new.js?render=modal&attribute="+ model_name;
|
11
13
|
var jqxhr = $.ajax(url)
|
12
14
|
.done(function(result) {
|
13
15
|
$(model_target).attr('data-source',id);
|
@@ -31,6 +31,14 @@ class CrudController < ApplicationController
|
|
31
31
|
|
32
32
|
def new
|
33
33
|
authorize! :create, @model if respond_to?(:current_usuario)
|
34
|
+
if params[:render] == "modal"
|
35
|
+
if @model.reflect_on_association(params[:attribute].to_s).present?
|
36
|
+
@model = @model.reflect_on_association(params[:attribute].to_s).class_name.constantize
|
37
|
+
else
|
38
|
+
@model = params[:attribute].to_s.camelcase.constantize
|
39
|
+
end
|
40
|
+
end
|
41
|
+
@crud_helper = Module.const_get("#{@model}Crud".camelize)
|
34
42
|
@record = @model.new
|
35
43
|
end
|
36
44
|
|
@@ -149,21 +157,41 @@ class CrudController < ApplicationController
|
|
149
157
|
def fields_model
|
150
158
|
fields = []
|
151
159
|
@crud_helper.form_fields.each do |field|
|
152
|
-
if
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
160
|
+
if field[:sf].present? && field[:sf][:grupo].present?
|
161
|
+
fields << permitt_group(fields, field[:attribute], field[:sf][:fields],@model)
|
162
|
+
else
|
163
|
+
if @model.reflect_on_association(field[:attribute])
|
164
|
+
if @model.reflect_on_association(field[:attribute]).macro == :belongs_to
|
165
|
+
fields << @model.reflect_on_association(field[:attribute]).foreign_key
|
166
|
+
else
|
167
|
+
fields << {"#{field[:attribute].to_s.singularize}_ids".to_sym => []}
|
168
|
+
end
|
169
|
+
elsif @model.columns_hash[field[:attribute].to_s]
|
170
|
+
fields << field[:attribute]
|
157
171
|
end
|
158
|
-
elsif @model.columns_hash[field[:attribute].to_s]
|
159
|
-
fields << field[:attribute]
|
160
172
|
end
|
161
173
|
end
|
174
|
+
#TODO - Deprecated
|
162
175
|
@crud_helper.form_groups.each do |key, groups|
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
176
|
+
fields << permitt_group(fields, key, groups[:fields],@model)
|
177
|
+
end
|
178
|
+
#Fim - Deprecated
|
179
|
+
if @model.respond_to?(:params_permitt)
|
180
|
+
@model.params_permitt.each do |field|
|
181
|
+
fields << field
|
182
|
+
end
|
183
|
+
end
|
184
|
+
fields
|
185
|
+
end
|
186
|
+
|
187
|
+
def permitt_group(fields, key, groups,mod)
|
188
|
+
chave = "#{key}_attributes"
|
189
|
+
group = {chave => [:id, :_destroy]}
|
190
|
+
groups.each do |field|
|
191
|
+
if field[:sf].present? && field[:sf][:grupo].present?
|
192
|
+
group[chave] << permitt_group(fields, field[:attribute], field[:sf][:fields], key.to_s.camelcase.singularize.constantize)
|
193
|
+
else
|
194
|
+
modelo = mod.reflect_on_association(key.to_s).class_name.constantize
|
167
195
|
if modelo.reflect_on_association(field[:attribute])
|
168
196
|
if modelo.reflect_on_association(field[:attribute]).macro == :belongs_to
|
169
197
|
group[chave] << "#{field[:attribute]}_id".to_sym
|
@@ -173,14 +201,8 @@ class CrudController < ApplicationController
|
|
173
201
|
elsif (modelo.columns_hash[field[:attribute].to_s] || (modelo.respond_to?(:params_permitt) && modelo.params_permitt.include?(field[:attribute].to_sym)))
|
174
202
|
group[chave] << field[:attribute]
|
175
203
|
end
|
176
|
-
|
177
|
-
fields << group
|
204
|
+
end
|
178
205
|
end
|
179
|
-
|
180
|
-
@model.params_permitt.each do |field|
|
181
|
-
fields << field
|
182
|
-
end
|
183
|
-
end
|
184
|
-
fields
|
206
|
+
group
|
185
207
|
end
|
186
208
|
end
|
data/app/raro_crud/raro_crud.rb
CHANGED
@@ -233,7 +233,16 @@ class RaroCrud
|
|
233
233
|
opts[:input_html] = {name: name, id: name}
|
234
234
|
opts[:id_element] = "##{self.modelo}_#{nome}_id"
|
235
235
|
end
|
236
|
-
|
236
|
+
if opts.present? && opts[:grupo].present?
|
237
|
+
opts[:fields] = []
|
238
|
+
opts[:grupo].each do |field|
|
239
|
+
attribute = field[:campo]
|
240
|
+
field.delete(:campo)
|
241
|
+
add_group_formulario(field) if field[:grupo].present?
|
242
|
+
opts[:fields].push({attribute: attribute,sf: field})
|
243
|
+
end
|
244
|
+
opts[:grupo] = true if opts[:grupo].present?
|
245
|
+
end
|
237
246
|
@@form_fields[self.to_s.to_sym].push(
|
238
247
|
{
|
239
248
|
attribute: nome
|
@@ -242,8 +251,21 @@ class RaroCrud
|
|
242
251
|
if opts.present? && opts[:autocomplete].present?
|
243
252
|
campo_formulario(nome, {as: :hidden})
|
244
253
|
end
|
245
|
-
end
|
254
|
+
end
|
255
|
+
|
256
|
+
private
|
257
|
+
def self.add_group_formulario(field)
|
258
|
+
field[:fields] = []
|
259
|
+
field[:grupo].each do |f|
|
260
|
+
attribute = f[:campo]
|
261
|
+
f.delete(:campo)
|
262
|
+
add_group_formulario(f) if f[:grupo].present?
|
263
|
+
field[:fields].push({attribute: attribute, sf: f})
|
264
|
+
end
|
265
|
+
field[:grupo] = true
|
266
|
+
end
|
246
267
|
|
268
|
+
public
|
247
269
|
def self.campo_visualizacao nome, opts = nil
|
248
270
|
@@view_fields[self.to_s.to_sym] = [] unless @@view_fields[self.to_s.to_sym]
|
249
271
|
@@view_fields[self.to_s.to_sym].push(
|
@@ -305,9 +327,13 @@ class RaroCrud
|
|
305
327
|
@@scopes[self.to_s.to_sym] = scopes
|
306
328
|
end
|
307
329
|
|
308
|
-
def self.grupo_formulario(attribute,fields)
|
330
|
+
def self.grupo_formulario(attribute,name,fields=nil)
|
331
|
+
if fields.nil?
|
332
|
+
fields = name
|
333
|
+
name = attribute.to_s.singularize.titleize
|
334
|
+
end
|
309
335
|
@@form_group[self.to_s.to_sym] ||= {}
|
310
|
-
@@form_group[self.to_s.to_sym][attribute]
|
336
|
+
@@form_group[self.to_s.to_sym][attribute] = {label: name, fields: []}
|
311
337
|
fields.each do |field|
|
312
338
|
value = {}
|
313
339
|
field.each do |atr|
|
@@ -318,13 +344,14 @@ class RaroCrud
|
|
318
344
|
value[:sf][atr[0]] = atr[1]
|
319
345
|
end
|
320
346
|
end
|
321
|
-
@@form_group[self.to_s.to_sym][attribute].push({attribute: value[:attribute],sf: value[:sf]})
|
347
|
+
@@form_group[self.to_s.to_sym][attribute][:fields].push({attribute: value[:attribute],sf: value[:sf]})
|
322
348
|
end
|
323
349
|
end
|
324
350
|
|
325
351
|
def self.adicionar_endereco
|
326
|
-
@@
|
327
|
-
|
352
|
+
@@form_fields[self.to_s.to_sym] = [] unless @@form_fields[self.to_s.to_sym]
|
353
|
+
opts = {}
|
354
|
+
opts[:fields] = []
|
328
355
|
[
|
329
356
|
{campo: :cep, label: "CEP"},
|
330
357
|
{campo: :logradouro, label: "Endereço"},
|
@@ -334,17 +361,16 @@ class RaroCrud
|
|
334
361
|
{campo: :estado, label: "Estado", collection: Estado.order(:sigla).pluck(:sigla)},
|
335
362
|
{campo: :cidade_id, label: "Cidade", collection_if: Proc.new{|f| f.try(:object).try(:estado).try(:present?) ? (f.try(:object).try(:estado).try(:cidades) || []) : []}}
|
336
363
|
].each do |field|
|
337
|
-
|
338
|
-
field.
|
339
|
-
|
340
|
-
value[:attribute] = atr[1]
|
341
|
-
else
|
342
|
-
value[:sf] ||= {}
|
343
|
-
value[:sf][atr[0]] = atr[1]
|
344
|
-
end
|
345
|
-
end
|
346
|
-
@@form_group[self.to_s.to_sym][:endereco].push({attribute: value[:attribute],sf: value[:sf]})
|
364
|
+
attribute = field[:campo]
|
365
|
+
field.delete(:campo)
|
366
|
+
opts[:fields].push({attribute: attribute,sf: field})
|
347
367
|
end
|
368
|
+
opts[:grupo] = true
|
369
|
+
@@form_fields[self.to_s.to_sym].push(
|
370
|
+
{
|
371
|
+
attribute: :endereco
|
372
|
+
}.merge({sf: opts})
|
373
|
+
)
|
348
374
|
@@form_scripts[self.to_s.to_sym] ||= []
|
349
375
|
@@form_scripts[self.to_s.to_sym] << "cidade_estado"
|
350
376
|
end
|
@@ -20,43 +20,18 @@
|
|
20
20
|
<%= simple_nested_form_for @record, remote: remote_form, html: {class: "form-horizontal"}, url: url do |f| %>
|
21
21
|
<%= flash_messages_error(@record.errors) %>
|
22
22
|
<%@crud_helper.form_fields.each do |field|%>
|
23
|
-
<% if
|
24
|
-
|
25
|
-
<%else%>
|
26
|
-
|
27
|
-
|
23
|
+
<% if field[:sf].present? && field[:sf][:grupo].present? %>
|
24
|
+
<%= render "/crud/form_group", f: f, key: field[:attribute], groups: field[:sf] %>
|
25
|
+
<% else %>
|
26
|
+
<% if @model.reflect_on_association(field[:attribute]).class == ActiveRecord::Reflection::BelongsToReflection && is_raro_crud(@model.reflect_on_association(field[:attribute]).class_name) && field[:sf][:add_registro].nil?%>
|
27
|
+
<%= render_plus_button(field,f,@model,@record) %>
|
28
|
+
<%else%>
|
29
|
+
<%= render_field(field,f,@model,@record) %>
|
30
|
+
<%end%>
|
31
|
+
<% end %>
|
28
32
|
<% end %>
|
29
33
|
<%@crud_helper.form_groups.each do |key, groups|%>
|
30
|
-
|
31
|
-
<% if @record.present? && !@record.send(key).present? %>
|
32
|
-
<% if [:has_many,:has_and_belongs_to_many].include?(@model.reflect_on_association(key).macro) %>
|
33
|
-
<% @record.send(key).build %>
|
34
|
-
<% else %>
|
35
|
-
<% @record.send("build_#{key}") %>
|
36
|
-
<% end %>
|
37
|
-
<% end %>
|
38
|
-
<%= f.simple_fields_for key do |g| %>
|
39
|
-
<div class="col-sm-12">
|
40
|
-
<h3 class="col-sm-2"><%= key.to_s.singularize.titleize %></h3>
|
41
|
-
</div>
|
42
|
-
<% groups.each do |field| %>
|
43
|
-
<%= render_field(field,g,modelo,@record) %>
|
44
|
-
<% end %>
|
45
|
-
<% if [:has_many,:has_and_belongs_to_many].include?(@model.reflect_on_association(key).macro) %>
|
46
|
-
<div class="form-group">
|
47
|
-
<div class="col-sm-10 col-sm-offset-2">
|
48
|
-
<%= g.link_to_remove "Remover #{key.to_s.singularize}" %>
|
49
|
-
</div>
|
50
|
-
</div>
|
51
|
-
<% end %>
|
52
|
-
<% end %>
|
53
|
-
<% if [:has_many,:has_and_belongs_to_many].include?(@model.reflect_on_association(key).macro) %>
|
54
|
-
<div class="form-group">
|
55
|
-
<div class="col-sm-12">
|
56
|
-
<%= f.link_to_add "Adicionar #{key.to_s.singularize}", key %>
|
57
|
-
</div>
|
58
|
-
</div>
|
59
|
-
<% end %>
|
34
|
+
<%= render "/crud/form_group", f: f, key: key, groups: groups %>
|
60
35
|
<% end %>
|
61
36
|
<div class="form-group">
|
62
37
|
<div class="col-sm-4 col-sm-offset-2">
|
@@ -0,0 +1,38 @@
|
|
1
|
+
<% modelo = f.object.class.reflect_on_association(key.to_s).class_name.constantize %>
|
2
|
+
<% if f.object.present? && !f.object.send(key).present? %>
|
3
|
+
<% if [:has_many,:has_and_belongs_to_many].include?(f.object.class.reflect_on_association(key).macro) %>
|
4
|
+
<% f.object.send(key).build %>
|
5
|
+
<% else %>
|
6
|
+
<% f.object.send("build_#{key}") %>
|
7
|
+
<% end %>
|
8
|
+
<% end %>
|
9
|
+
<%= f.simple_fields_for key do |g| %>
|
10
|
+
<div class="col-sm-12">
|
11
|
+
<h3><%= groups[:label] %></h3>
|
12
|
+
</div>
|
13
|
+
<% groups[:fields].each do |field| %>
|
14
|
+
<% if field[:sf].present? && field[:sf][:grupo].present? %>
|
15
|
+
<%= render "/crud/form_group", f: g, key: field[:attribute], groups: field[:sf] %>
|
16
|
+
<% else %>
|
17
|
+
<% if modelo.reflect_on_association(field[:attribute]).class == ActiveRecord::Reflection::BelongsToReflection && is_raro_crud(modelo.reflect_on_association(field[:attribute]).class_name) && field[:sf][:add_registro].nil?%>
|
18
|
+
<%= render_plus_button(field,g,modelo,f.object) %>
|
19
|
+
<%else%>
|
20
|
+
<%= render_field(field,g,modelo,f.object) %>
|
21
|
+
<%end%>
|
22
|
+
<% end %>
|
23
|
+
<% end %>
|
24
|
+
<% if [:has_many,:has_and_belongs_to_many].include?(f.object.class.reflect_on_association(key).macro) %>
|
25
|
+
<div class="form-group">
|
26
|
+
<div class="col-sm-10 col-sm-offset-2">
|
27
|
+
<%= g.link_to_remove "Remover #{groups[:label].downcase}" %>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
<% end %>
|
31
|
+
<% end %>
|
32
|
+
<% if [:has_many,:has_and_belongs_to_many].include?(f.object.class.reflect_on_association(key).macro) %>
|
33
|
+
<div class="form-group">
|
34
|
+
<div class="col-sm-12">
|
35
|
+
<%= f.link_to_add "Adicionar #{groups[:label].downcase}", key %>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
<% end %>
|
@@ -1,7 +1,7 @@
|
|
1
1
|
<%= content_tag :tr, id: "record-#{record.id}" do %>
|
2
2
|
<%@crud_helper.index_fields.each do |att| %>
|
3
3
|
<% if !att[:visible_if].nil?%>
|
4
|
-
<% if ((att[:visible_if].class == Proc && !att[:visible_if].call(
|
4
|
+
<% if ((att[:visible_if].class == Proc && !att[:visible_if].call(record)) || (att[:visible_if].class != Proc && !att[:visible_if])) %>
|
5
5
|
<% next %>
|
6
6
|
<% end %>
|
7
7
|
<% end %>
|
@@ -42,6 +42,9 @@
|
|
42
42
|
<% end %>
|
43
43
|
<%@crud_helper.actions_links.each do |name, options|%>
|
44
44
|
<% if options[:url].present? %>
|
45
|
+
<% if options[:id] %>
|
46
|
+
<% options[:url] += options[:url].include?("?") ? "&id=#{record.id}" : "?id=#{record.id}" %>
|
47
|
+
<% end %>
|
45
48
|
<% if options[:wiselink].present? && options[:wiselink] %>
|
46
49
|
<a href="<%= options[:url] %>" class="btn btn-success btn-xs" data-push="partial" data-target="#form">
|
47
50
|
<%=name%>
|
@@ -55,6 +58,8 @@
|
|
55
58
|
<a href="/crud/<%= options[:associacao].to_s.singularize %>/query?model=<%= options[:associacao].to_s.singularize.camelcase.constantize %>&partial=records&var=records&q[<%= @model.name.underscore %>_id_eq]=<%= record.id %>" class="btn btn-success btn-xs">
|
56
59
|
<%=name%>
|
57
60
|
</a>
|
61
|
+
<% elsif options[:partial].present? %>
|
62
|
+
<%= render options[:partial], record: record %>
|
58
63
|
<% end %>
|
59
64
|
<% end %>
|
60
65
|
<%if @crud_helper.view_action && shold_view?(@crud_helper, record)%>
|
@@ -7,7 +7,11 @@
|
|
7
7
|
<h3 class="font-bold">
|
8
8
|
<%= escopo[1] %>
|
9
9
|
<span class="label label-success pull-right" style="margin-left: 10px;">
|
10
|
-
|
10
|
+
<% if current_usuario.present? %>
|
11
|
+
<%= @model.send(escopo[0]).accessible_by(current_ability, :read).count %>
|
12
|
+
<% else %>
|
13
|
+
<%= @model.send(escopo[0]).count %>
|
14
|
+
<% end %>
|
11
15
|
</span>
|
12
16
|
</h3>
|
13
17
|
</div>
|
@@ -7,14 +7,14 @@
|
|
7
7
|
<% @crud_helper.view_fields.each do |field|%>
|
8
8
|
<tr>
|
9
9
|
<% if field[:sf].present? && !field[:sf][:visible_if].nil?%>
|
10
|
-
<% if ((field[:sf][:visible_if].class == Proc && !field[:sf][:visible_if].call(
|
10
|
+
<% if ((field[:sf][:visible_if].class == Proc && !field[:sf][:visible_if].call(@record)) || (field[:sf][:visible_if].class != Proc && !field[:sf][:visible_if])) %>
|
11
11
|
<% next %>
|
12
12
|
<% end %>
|
13
13
|
<% end %>
|
14
14
|
<% if field[:sf].present? && field[:sf][:label].present? %>
|
15
|
-
<th><%= field[:sf][:label].upcase.to_s %></th>
|
15
|
+
<th><%= field[:sf][:label].to_s.mb_chars.upcase.to_s %></th>
|
16
16
|
<% else %>
|
17
|
-
<th><%= field[:attribute].upcase.to_s %></th>
|
17
|
+
<th><%= field[:attribute].to_s.mb_chars.upcase.to_s %></th>
|
18
18
|
<% end %>
|
19
19
|
<% if @model.columns_hash[field[:attribute].to_s].present? && [:date, :datetime].include?(@model.columns_hash[field[:attribute].to_s].type)%>
|
20
20
|
<% if field[:date_format].present?%>
|
@@ -6,7 +6,13 @@ class Usuario < ActiveRecord::Base
|
|
6
6
|
|
7
7
|
# belongs_to :papel
|
8
8
|
belongs_to :perfil, :class_name => "Papel", :foreign_key => "papel_id"
|
9
|
+
belongs_to :novo_papel, :class_name => "Papel", :foreign_key => "novo_papel_id"
|
9
10
|
validates_presence_of :nome, :email
|
11
|
+
has_many :contatos
|
12
|
+
|
13
|
+
accepts_nested_attributes_for :contatos, :allow_destroy => true
|
14
|
+
|
15
|
+
|
10
16
|
|
11
17
|
def to_s
|
12
18
|
nome
|
@@ -18,8 +18,12 @@ class TesteCrud < RaroCrud
|
|
18
18
|
|
19
19
|
campo_formulario :nome, label: "Nome"
|
20
20
|
campo_formulario :nome, label: "Nome", if: Proc.new{|o| o.try(:nome) == "Leonardo Raro" || o.new_record?}, value: Proc.new{|o| o.object.try(:teste1).try(:descricao)}
|
21
|
+
campo_formulario :teste1, label: "Formulário Teste Grupo", grupo: [
|
22
|
+
{campo: :descricao, label: "Descrição"},
|
23
|
+
{campo: :descricao, label: "Descrição2"}
|
24
|
+
]
|
21
25
|
grupo_formulario :teste1, [
|
22
|
-
{campo: :descricao, label: "Descrição"}
|
26
|
+
{campo: :descricao, label: "Descrição"},
|
23
27
|
]
|
24
28
|
|
25
29
|
|
@@ -18,6 +18,10 @@ class UsuarioCrud < RaroCrud
|
|
18
18
|
campo_formulario :password, label: "Senha", default_test: "12345678", edit: false
|
19
19
|
campo_formulario :password_confirmation, label: "Confirmação Senha", default_test: "12345678", edit: false
|
20
20
|
campo_formulario :perfil, label: "Perfil", label_method: :descricao, input_html: {class: "chosen" , "data-placeholder" => "Escolha o perfil..."}, if: Proc.new {|obj| Usuario.current.root? }
|
21
|
+
campo_formulario :novo_papel, label: "Novo Papel", label_method: :descricao, input_html: {class: "chosen" , "data-placeholder" => "Escolha o papel..."}, if: Proc.new {|obj| Usuario.current.root? }
|
22
|
+
campo_formulario :contatos, label: "Contatos", grupo: [{campo: :nome, label: "Nome"},
|
23
|
+
{campo: :email, label: "Email"},
|
24
|
+
{campo: :telefones, label: "Telefones do contato", grupo: [{campo: :numero, label: "Número"}]}]
|
21
25
|
|
22
26
|
campo_visualizacao :nome, label: "Nome"
|
23
27
|
campo_visualizacao :email, label: "email"
|
Binary file
|
data/test/dummy/db/schema.rb
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
#
|
12
12
|
# It's strongly recommended that you check this file into your version control system.
|
13
13
|
|
14
|
-
ActiveRecord::Schema.define(version:
|
14
|
+
ActiveRecord::Schema.define(version: 20150813200710) do
|
15
15
|
|
16
16
|
create_table "cidades", force: :cascade do |t|
|
17
17
|
t.string "nome"
|
@@ -22,6 +22,16 @@ ActiveRecord::Schema.define(version: 20150422191007) do
|
|
22
22
|
|
23
23
|
add_index "cidades", ["estado_id"], name: "index_cidades_on_estado_id"
|
24
24
|
|
25
|
+
create_table "contatos", force: :cascade do |t|
|
26
|
+
t.string "nome"
|
27
|
+
t.string "email"
|
28
|
+
t.integer "usuario_id"
|
29
|
+
t.datetime "created_at", null: false
|
30
|
+
t.datetime "updated_at", null: false
|
31
|
+
end
|
32
|
+
|
33
|
+
add_index "contatos", ["usuario_id"], name: "index_contatos_on_usuario_id"
|
34
|
+
|
25
35
|
create_table "enderecos", force: :cascade do |t|
|
26
36
|
t.string "cep"
|
27
37
|
t.string "logradouro"
|
@@ -67,6 +77,15 @@ ActiveRecord::Schema.define(version: 20150422191007) do
|
|
67
77
|
|
68
78
|
add_index "permissoes", ["papel_id"], name: "index_permissoes_on_papel_id"
|
69
79
|
|
80
|
+
create_table "telefones", force: :cascade do |t|
|
81
|
+
t.string "numero"
|
82
|
+
t.integer "contato_id"
|
83
|
+
t.datetime "created_at", null: false
|
84
|
+
t.datetime "updated_at", null: false
|
85
|
+
end
|
86
|
+
|
87
|
+
add_index "telefones", ["contato_id"], name: "index_telefones_on_contato_id"
|
88
|
+
|
70
89
|
create_table "teste1s", force: :cascade do |t|
|
71
90
|
t.string "descricao"
|
72
91
|
t.integer "teste_id"
|
@@ -77,7 +96,7 @@ ActiveRecord::Schema.define(version: 20150422191007) do
|
|
77
96
|
add_index "teste1s", ["teste_id"], name: "index_teste1s_on_teste_id"
|
78
97
|
|
79
98
|
create_table "testes", force: :cascade do |t|
|
80
|
-
t.string "nome"
|
99
|
+
t.string "nome"
|
81
100
|
t.datetime "created_at"
|
82
101
|
t.datetime "updated_at"
|
83
102
|
end
|
@@ -97,9 +116,11 @@ ActiveRecord::Schema.define(version: 20150422191007) do
|
|
97
116
|
t.datetime "locked_at"
|
98
117
|
t.integer "papel_id"
|
99
118
|
t.boolean "root", default: false
|
119
|
+
t.integer "referencia_id"
|
100
120
|
t.string "nome"
|
101
121
|
t.datetime "created_at"
|
102
122
|
t.datetime "updated_at"
|
123
|
+
t.integer "novo_papel_id"
|
103
124
|
end
|
104
125
|
|
105
126
|
add_index "usuarios", ["email"], name: "index_usuarios_on_email", unique: true
|
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: 1.3.
|
4
|
+
version: 1.3.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rodrigo Sol
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-08-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -144,6 +144,7 @@ files:
|
|
144
144
|
- app/views/crud/_default_actions_crud.html.erb
|
145
145
|
- app/views/crud/_edit.html.erb
|
146
146
|
- app/views/crud/_form.html.erb
|
147
|
+
- app/views/crud/_form_group.html.erb
|
147
148
|
- app/views/crud/_links.html.erb
|
148
149
|
- app/views/crud/_new.html.erb
|
149
150
|
- app/views/crud/_record.html.erb
|
@@ -321,11 +322,13 @@ files:
|
|
321
322
|
- test/dummy/app/helpers/menu_helper.rb
|
322
323
|
- test/dummy/app/models/ability.rb
|
323
324
|
- test/dummy/app/models/cidade.rb
|
325
|
+
- test/dummy/app/models/contato.rb
|
324
326
|
- test/dummy/app/models/endereco.rb
|
325
327
|
- test/dummy/app/models/estado.rb
|
326
328
|
- test/dummy/app/models/papel.rb
|
327
329
|
- test/dummy/app/models/permissao.rb
|
328
330
|
- test/dummy/app/models/reference_observer.rb
|
331
|
+
- test/dummy/app/models/telefone.rb
|
329
332
|
- test/dummy/app/models/templus.rb
|
330
333
|
- test/dummy/app/models/teste.rb
|
331
334
|
- test/dummy/app/models/teste1.rb
|
@@ -388,6 +391,9 @@ files:
|
|
388
391
|
- test/dummy/db/migrate/20150422182314_create_estados.rb
|
389
392
|
- test/dummy/db/migrate/20150422182356_create_cidades.rb
|
390
393
|
- test/dummy/db/migrate/20150422191007_create_enderecos.rb
|
394
|
+
- test/dummy/db/migrate/20150813125909_create_contatos.rb
|
395
|
+
- test/dummy/db/migrate/20150813125926_create_telefones.rb
|
396
|
+
- test/dummy/db/migrate/20150813200710_add_novo_papel_id_to_usuarios.rb
|
391
397
|
- test/dummy/db/schema.rb
|
392
398
|
- test/dummy/db/seeds.rb
|
393
399
|
- test/dummy/lib/generators/branco/USAGE
|
@@ -400,8 +406,12 @@ files:
|
|
400
406
|
- test/dummy/public/500.html
|
401
407
|
- test/dummy/public/favicon.ico
|
402
408
|
- test/dummy/test/controllers/home_controller_test.rb
|
409
|
+
- test/dummy/test/fixtures/contatos.yml
|
410
|
+
- test/dummy/test/fixtures/telefones.yml
|
403
411
|
- test/dummy/test/fixtures/teste1s.yml
|
404
412
|
- test/dummy/test/fixtures/testes.yml
|
413
|
+
- test/dummy/test/models/contato_test.rb
|
414
|
+
- test/dummy/test/models/telefone_test.rb
|
405
415
|
- test/dummy/test/models/teste1_test.rb
|
406
416
|
- test/dummy/test/models/teste_test.rb
|
407
417
|
- test/dummy/vendor/assets/images/animated-overlay.gif
|
@@ -1094,11 +1104,13 @@ test_files:
|
|
1094
1104
|
- test/dummy/app/helpers/menu_helper.rb
|
1095
1105
|
- test/dummy/app/models/ability.rb
|
1096
1106
|
- test/dummy/app/models/cidade.rb
|
1107
|
+
- test/dummy/app/models/contato.rb
|
1097
1108
|
- test/dummy/app/models/endereco.rb
|
1098
1109
|
- test/dummy/app/models/estado.rb
|
1099
1110
|
- test/dummy/app/models/papel.rb
|
1100
1111
|
- test/dummy/app/models/permissao.rb
|
1101
1112
|
- test/dummy/app/models/reference_observer.rb
|
1113
|
+
- test/dummy/app/models/telefone.rb
|
1102
1114
|
- test/dummy/app/models/templus.rb
|
1103
1115
|
- test/dummy/app/models/teste.rb
|
1104
1116
|
- test/dummy/app/models/teste1.rb
|
@@ -1161,6 +1173,9 @@ test_files:
|
|
1161
1173
|
- test/dummy/db/migrate/20150422182314_create_estados.rb
|
1162
1174
|
- test/dummy/db/migrate/20150422182356_create_cidades.rb
|
1163
1175
|
- test/dummy/db/migrate/20150422191007_create_enderecos.rb
|
1176
|
+
- test/dummy/db/migrate/20150813125909_create_contatos.rb
|
1177
|
+
- test/dummy/db/migrate/20150813125926_create_telefones.rb
|
1178
|
+
- test/dummy/db/migrate/20150813200710_add_novo_papel_id_to_usuarios.rb
|
1164
1179
|
- test/dummy/db/schema.rb
|
1165
1180
|
- test/dummy/db/seeds.rb
|
1166
1181
|
- test/dummy/lib/generators/branco/branco_generator.rb
|
@@ -1175,8 +1190,12 @@ test_files:
|
|
1175
1190
|
- test/dummy/Rakefile
|
1176
1191
|
- test/dummy/README.rdoc
|
1177
1192
|
- test/dummy/test/controllers/home_controller_test.rb
|
1193
|
+
- test/dummy/test/fixtures/contatos.yml
|
1194
|
+
- test/dummy/test/fixtures/telefones.yml
|
1178
1195
|
- test/dummy/test/fixtures/teste1s.yml
|
1179
1196
|
- test/dummy/test/fixtures/testes.yml
|
1197
|
+
- test/dummy/test/models/contato_test.rb
|
1198
|
+
- test/dummy/test/models/telefone_test.rb
|
1180
1199
|
- test/dummy/test/models/teste1_test.rb
|
1181
1200
|
- test/dummy/test/models/teste_test.rb
|
1182
1201
|
- test/dummy/vendor/assets/images/animated-overlay.gif
|