templus_models 1.2.7 → 1.2.8
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 +1 -1
- data/app/helpers/crud_helper.rb +20 -0
- data/app/raro_crud/raro_crud.rb +10 -0
- data/app/views/crud/_default_actions_crud.html.erb +2 -0
- data/app/views/crud/_record.html.erb +26 -9
- data/app/views/crud/_shared.html.erb +2 -6
- data/app/views/crud/action.html.erb +7 -0
- data/app/views/layouts/_menu_crud.html.erb +5 -8
- data/lib/templus_models/version.rb +1 -1
- data/test/dummy/app/models/teste1.rb +3 -0
- data/test/dummy/app/raro_crud/papel_crud.rb +1 -0
- data/test/dummy/app/raro_crud/teste1_crud.rb +7 -2
- data/test/dummy/app/raro_crud/teste_crud.rb +7 -7
- data/test/dummy/app/views/papeis/_associar.html.erb +7 -5
- data/test/dummy/db/development.sqlite3 +0 -0
- metadata +4 -4
- data/test/dummy/app/views/papeis/associar.html.erb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 759ecb2091ecb46592842147c492c33579b3fed3
|
4
|
+
data.tar.gz: 95f467af12abf3685f4ebdd3d52a3efec0a1ed24
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d58cebd1912b024a6572d326cf895d7dd38ffda8f746258b534609dd6b7aa0f65029d8b2476c72a29d439e33429348bd04d8e6ece04ca10a36ad888ec12e01d7
|
7
|
+
data.tar.gz: cf43149dbe763d0ddbb9da5d5d50b98a2ef9a17f2411ae1a93999c050537c1c671ed021ed2d4b10e8ee02ce332740248e9aa73e79097dc8d9cfba4aa7c20784b
|
@@ -57,7 +57,7 @@ class CrudController < ApplicationController
|
|
57
57
|
else
|
58
58
|
@titulo = @record.to_s
|
59
59
|
@texto = params[:acao]
|
60
|
-
render partial: "/#{@model.name.underscore.pluralize}/#{params[:acao]}"
|
60
|
+
render partial: "/#{@model.name.underscore.pluralize}/#{params[:acao]}" if request.respond_to?(:wiselinks_partial?) && request.wiselinks_partial?
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
data/app/helpers/crud_helper.rb
CHANGED
@@ -17,6 +17,14 @@ module CrudHelper
|
|
17
17
|
return @@cruds.include?(attribute.to_s)
|
18
18
|
end
|
19
19
|
|
20
|
+
def lista_menus_crud(raro_models)
|
21
|
+
menus = []
|
22
|
+
raro_models.each do |modelo|
|
23
|
+
menus << ['crud', "#{modelo.name.underscore}"]
|
24
|
+
end
|
25
|
+
menus
|
26
|
+
end
|
27
|
+
|
20
28
|
def menu_helper_crud(modelo, url, nome, classe, icon='')
|
21
29
|
if can?(:read, classe)
|
22
30
|
buffer = ""
|
@@ -42,6 +50,14 @@ module CrudHelper
|
|
42
50
|
def is_action_new?
|
43
51
|
params[:action] == "new"
|
44
52
|
end
|
53
|
+
|
54
|
+
def is_action_index?
|
55
|
+
params[:action] == "index"
|
56
|
+
end
|
57
|
+
|
58
|
+
def is_action_query?
|
59
|
+
params[:action] == "query"
|
60
|
+
end
|
45
61
|
|
46
62
|
|
47
63
|
def render_link(link)
|
@@ -147,4 +163,8 @@ module CrudHelper
|
|
147
163
|
def render_crud(&block)
|
148
164
|
render "/crud/shared", block: block
|
149
165
|
end
|
166
|
+
|
167
|
+
def render_default_actions_crud
|
168
|
+
render "default_actions_crud"
|
169
|
+
end
|
150
170
|
end
|
data/app/raro_crud/raro_crud.rb
CHANGED
@@ -13,6 +13,7 @@ class RaroCrud
|
|
13
13
|
@@subtitle_index = {}
|
14
14
|
@@description_index = {}
|
15
15
|
@@actions = {}
|
16
|
+
@@links = {}
|
16
17
|
@@edit_action = {}
|
17
18
|
@@destroy_action = {}
|
18
19
|
@@view_action = {}
|
@@ -95,6 +96,10 @@ class RaroCrud
|
|
95
96
|
(@@actions[self.to_s.to_sym]) ? @@actions[self.to_s.to_sym] : []
|
96
97
|
end
|
97
98
|
|
99
|
+
def self.actions_links
|
100
|
+
(@@links[self.to_s.to_sym]) ? @@links[self.to_s.to_sym] : []
|
101
|
+
end
|
102
|
+
|
98
103
|
def self.options_link
|
99
104
|
(@@options_link[self.to_s.to_sym]) ? @@options_link[self.to_s.to_sym] : []
|
100
105
|
end
|
@@ -257,6 +262,11 @@ class RaroCrud
|
|
257
262
|
@@actions[self.to_s.to_sym].push([method,desc,proc])
|
258
263
|
end
|
259
264
|
|
265
|
+
def self.links(name,options)
|
266
|
+
@@links[self.to_s.to_sym] = [] unless @@links[self.to_s.to_sym]
|
267
|
+
@@links[self.to_s.to_sym].push([name,options])
|
268
|
+
end
|
269
|
+
|
260
270
|
def self.opcoes(link,desc,proc = nil)
|
261
271
|
@@options_link[self.to_s.to_sym] = [] unless @@options_link[self.to_s.to_sym]
|
262
272
|
@@options_link[self.to_s.to_sym].push([link,desc,proc])
|
@@ -29,23 +29,40 @@
|
|
29
29
|
<% end %>
|
30
30
|
<%end%>
|
31
31
|
<td>
|
32
|
+
<%@crud_helper.actions.each do |a|%>
|
33
|
+
<% if ((a[2].present? && a[2].call(record)) || !a[2].present?) %>
|
34
|
+
<a href="/crud/<%=@model.name.underscore%>/<%=record.id%>/acao/<%=a[0]%>"
|
35
|
+
class="btn btn-primary btn-xs" data-push="partial" data-target="#form"><%=a[1]%></a>
|
36
|
+
<% end %>
|
37
|
+
<% end %>
|
38
|
+
<%@crud_helper.actions_links.each do |name, options|%>
|
39
|
+
<% if options[:url].present? %>
|
40
|
+
<% if options[:wiselink].present? && options[:wiselink] %>
|
41
|
+
<a href="<%= options[:url] %>" class="btn btn-success btn-xs" data-push="partial" data-target="#form">
|
42
|
+
<%=name%>
|
43
|
+
</a>
|
44
|
+
<% else %>
|
45
|
+
<a href="<%= options[:url] %>" class="btn btn-success btn-xs">
|
46
|
+
<%=name%>
|
47
|
+
</a>
|
48
|
+
<% end %>
|
49
|
+
<% elsif options[:associacao].present? %>
|
50
|
+
<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">
|
51
|
+
<%=name%>
|
52
|
+
</a>
|
53
|
+
<% end %>
|
54
|
+
<% end %>
|
32
55
|
<%if @crud_helper.view_action%>
|
33
56
|
<a href="/crud/<%=@model.name.underscore%>/<%=record.id%>"
|
34
57
|
class="btn btn-primary btn-xs" data-push="partial" data-target="#form">Visualizar</a>
|
35
|
-
<%end%>
|
58
|
+
<% end %>
|
36
59
|
<%if @crud_helper.edit_action%>
|
37
60
|
<a href="/crud/<%=@model.name.underscore%>/<%=record.id%>/edit"
|
38
61
|
class="btn btn-primary btn-xs" data-push="partial" data-target="#form">Editar</a>
|
39
|
-
<%end%>
|
62
|
+
<% end %>
|
40
63
|
<%if @crud_helper.destroy_action%>
|
41
64
|
<a href="/crud/<%=@model.name.underscore%>/<%=record.id%>/destroy"
|
42
65
|
class="btn btn-danger btn-xs" data-push="partial" data-target="#form" data-method="delete">Excluir</a>
|
43
|
-
<%end%>
|
44
|
-
<%@crud_helper.actions.each do |a|%>
|
45
|
-
<% if ((a[2].present? && a[2].call(record)) || !a[2].present?) %>
|
46
|
-
<a href="/crud/<%=@model.name.underscore%>/<%=record.id%>/acao/<%=a[0]%>"
|
47
|
-
class="btn btn-primary btn-xs" data-push="partial" data-target="#form"><%=a[1]%></a>
|
48
|
-
<%end %>
|
49
|
-
<%end %>
|
66
|
+
<% end %>
|
50
67
|
</td>
|
51
68
|
<% end %>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
</h5>
|
11
11
|
<% elsif is_action_create? && @model.present? %>
|
12
12
|
<h5>Cadastrar</h5>
|
13
|
-
<% elsif
|
13
|
+
<% elsif @record.present? %>
|
14
14
|
<h5>
|
15
15
|
<%= @record.to_s %>
|
16
16
|
<small style="margin-left: 2px;">#<%= @record.id %></small>
|
@@ -21,11 +21,7 @@
|
|
21
21
|
<small><%= @crud_helper.description(:index) %></small>
|
22
22
|
</h5>
|
23
23
|
<% end %>
|
24
|
-
<% if
|
25
|
-
<% elsif is_action_edit? %>
|
26
|
-
<% elsif is_action_create? %>
|
27
|
-
<% elsif is_action_new? %>
|
28
|
-
<% else %>
|
24
|
+
<% if is_action_index? || is_action_query?%>
|
29
25
|
<div class="pull-right actions">
|
30
26
|
<% @crud_helper.top_links.each do |link| %>
|
31
27
|
<% if link[:can].present? %>
|
@@ -1,8 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
<% end %>
|
7
|
-
</ul>
|
8
|
-
</li>
|
1
|
+
<%= menu_parent(raro_models, lista_menus_crud(raro_models), "Cadastros", 'fa fa-book', true) do %>
|
2
|
+
<% raro_models.each do |modelo| %>
|
3
|
+
<%= menu_crud_helper("#{modelo.name.underscore}_crud".camelize.constantize.title, modelo) %>
|
4
|
+
<% end %>
|
5
|
+
<% end %>
|
@@ -16,6 +16,7 @@ class PapelCrud < RaroCrud
|
|
16
16
|
|
17
17
|
campo_visualizacao :nome, label: "Nome"
|
18
18
|
campo_visualizacao :descricao, label: "Descrição"
|
19
|
+
campo_visualizacao :permissoes, label: "Permissões"
|
19
20
|
|
20
21
|
campo_busca :nome, label: "Nome"
|
21
22
|
campo_busca :descricao, label: "Descrição"
|
@@ -3,12 +3,17 @@ class Teste1Crud < RaroCrud
|
|
3
3
|
titulo "Teste1"
|
4
4
|
link_superior "Novo Teste1", id: "novo-button", icon: "plus", link: "new"
|
5
5
|
|
6
|
+
acoes :associar, "Definir permissões", Proc.new {|p| Usuario.current.ability.can?(:create,p)}
|
7
|
+
|
8
|
+
campo_tabela :descricao, label: "Descrição"
|
6
9
|
campo_tabela :teste, label: "Nome", sort_field: :teste_nome
|
7
10
|
|
8
11
|
grupo_formulario :teste, [
|
9
12
|
{campo: :nome, label: "Nome"}
|
10
13
|
]
|
11
|
-
campo_visualizacao :
|
12
|
-
|
14
|
+
campo_visualizacao :descricao, label: "Descrição"
|
15
|
+
campo_visualizacao :teste, label: "Teste"
|
13
16
|
|
17
|
+
campo_busca :descricao, label: "Descrição"
|
18
|
+
campo_busca :nome, label: "Teste", model: "Teste", full_name: "teste_nome", dont_assoc: true
|
14
19
|
end
|
@@ -6,17 +6,16 @@ class TesteCrud < RaroCrud
|
|
6
6
|
ordenar_por :created_at
|
7
7
|
itens_por_pagina 20
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
links "Permissão", url: "/crud/papel"
|
10
|
+
links "Permissão Wiselink", url: "/crud/papel", wiselink: true
|
11
|
+
links "Testes1", associacao: :teste1
|
11
12
|
|
12
|
-
|
13
|
-
#Campos mostrados na index
|
13
|
+
|
14
14
|
campo_tabela :nome, label: "Nome"
|
15
|
-
campo_tabela :created_at, label: "Created at"
|
15
|
+
campo_tabela :created_at, label: "Created at", date_format: "%d/%m/%Y"
|
16
16
|
campo_tabela :updated_at, label: "Updated at"
|
17
17
|
|
18
|
-
|
19
|
-
#Campos mostrados no formulários de cadastro
|
18
|
+
|
20
19
|
campo_formulario :nome, label: "Nome"
|
21
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)}
|
22
21
|
grupo_formulario :teste1, [
|
@@ -28,6 +27,7 @@ class TesteCrud < RaroCrud
|
|
28
27
|
campo_visualizacao :nome, label: "Nome"
|
29
28
|
campo_visualizacao :created_at, label: "Created at"
|
30
29
|
campo_visualizacao :updated_at, label: "Updated at"
|
30
|
+
campo_visualizacao :teste1, label: "Teste1"
|
31
31
|
|
32
32
|
|
33
33
|
#Campos mostrados na busca
|
@@ -1,3 +1,4 @@
|
|
1
|
+
<%= render_crud do %>
|
1
2
|
<div class="widget-box">
|
2
3
|
<div class="widget-body">
|
3
4
|
<div class="widget-main">
|
@@ -16,9 +17,9 @@
|
|
16
17
|
<tbody>
|
17
18
|
<% raro_permissions.each_with_index do |menu, i| %>
|
18
19
|
<% val = nil %>
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
<% if @record.permissoes.present? %>
|
21
|
+
<% val = @record.permissoes.select {|c| c.klass.to_s == menu.to_s }[0] %>
|
22
|
+
<% end %>
|
22
23
|
<tr>
|
23
24
|
<td><%= menu.titleize %></td>
|
24
25
|
<td>
|
@@ -54,8 +55,8 @@
|
|
54
55
|
<%= hidden_field_tag :papel_id, @record.id %>
|
55
56
|
<div class="form-group">
|
56
57
|
<div class="col-sm-12">
|
57
|
-
<div class="col-sm-offset-2">
|
58
|
-
<%=
|
58
|
+
<div class="col-sm-offset-2 pull-right">
|
59
|
+
<%= render_default_actions_crud %>
|
59
60
|
</div>
|
60
61
|
</div>
|
61
62
|
</div>
|
@@ -63,6 +64,7 @@
|
|
63
64
|
</div>
|
64
65
|
</div>
|
65
66
|
</div>
|
67
|
+
<% end %>
|
66
68
|
<% content_for :javascript do %>
|
67
69
|
<script type="text/javascript">
|
68
70
|
$(function() {
|
Binary file
|
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.2.
|
4
|
+
version: 1.2.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-07-
|
12
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -141,6 +141,7 @@ files:
|
|
141
141
|
- app/helpers/search_helper.rb
|
142
142
|
- app/raro_crud/raro_crud.rb
|
143
143
|
- app/views/crud/_crud_template.html.erb
|
144
|
+
- app/views/crud/_default_actions_crud.html.erb
|
144
145
|
- app/views/crud/_edit.html.erb
|
145
146
|
- app/views/crud/_form.html.erb
|
146
147
|
- app/views/crud/_links.html.erb
|
@@ -151,6 +152,7 @@ files:
|
|
151
152
|
- app/views/crud/_search.html.erb
|
152
153
|
- app/views/crud/_shared.html.erb
|
153
154
|
- app/views/crud/_show.html.erb
|
155
|
+
- app/views/crud/action.html.erb
|
154
156
|
- app/views/crud/create.js.erb
|
155
157
|
- app/views/crud/edit.html.erb
|
156
158
|
- app/views/crud/index.html.erb
|
@@ -345,7 +347,6 @@ files:
|
|
345
347
|
- test/dummy/app/views/layouts/login2.html.erb
|
346
348
|
- test/dummy/app/views/layouts/wiselinks.html.erb
|
347
349
|
- test/dummy/app/views/papeis/_associar.html.erb
|
348
|
-
- test/dummy/app/views/papeis/associar.html.erb
|
349
350
|
- test/dummy/app/views/usuarios/_edit.html.erb
|
350
351
|
- test/dummy/app/views/usuarios/_form.html.erb
|
351
352
|
- test/dummy/app/views/usuarios/edit.html.erb
|
@@ -1118,7 +1119,6 @@ test_files:
|
|
1118
1119
|
- test/dummy/app/views/layouts/login2.html.erb
|
1119
1120
|
- test/dummy/app/views/layouts/wiselinks.html.erb
|
1120
1121
|
- test/dummy/app/views/papeis/_associar.html.erb
|
1121
|
-
- test/dummy/app/views/papeis/associar.html.erb
|
1122
1122
|
- test/dummy/app/views/usuarios/_edit.html.erb
|
1123
1123
|
- test/dummy/app/views/usuarios/_form.html.erb
|
1124
1124
|
- test/dummy/app/views/usuarios/edit.html.erb
|