templus_models 1.6.9 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/crud_controller.rb +48 -53
- data/app/helpers/crud_helper.rb +27 -3
- data/app/helpers/search_helper.rb +25 -20
- data/app/raro_crud/raro_crud.rb +66 -20
- data/app/views/crud/_default_actions_crud.html.erb +2 -2
- data/app/views/crud/_form.html.erb +5 -5
- data/app/views/crud/_form_group.html.erb +3 -3
- data/app/views/crud/_record.html.erb +46 -43
- data/app/views/crud/_records.html.erb +12 -12
- data/app/views/crud/_scopes.html.erb +4 -5
- data/app/views/crud/_search.html.erb +3 -3
- data/app/views/crud/_shared.html.erb +31 -18
- data/app/views/crud/_show.html.erb +8 -7
- data/app/views/crud/listing.pdf.erb +21 -19
- data/app/views/crud/listing.xls.erb +2 -2
- data/app/views/crud/printing.pdf.erb +100 -0
- data/app/views/kaminari/templus/_first_page.html.erb +1 -1
- data/app/views/kaminari/templus/_gap.html.erb +1 -1
- data/app/views/kaminari/templus/_last_page.html.erb +1 -1
- data/app/views/kaminari/templus/_next_page.html.erb +1 -1
- data/app/views/kaminari/templus/_paginator.html.erb +2 -2
- data/app/views/kaminari/templus/_prev_page.html.erb +1 -1
- data/app/views/layouts/_menu_crud.html.erb +1 -1
- data/app/views/layouts/_template_raro_crud.html.erb +1 -1
- data/config/initializers/simple_form.rb +2 -5
- data/config/routes.rb +32 -25
- data/lib/templus_models/configuration.rb +14 -0
- data/lib/templus_models/version.rb +1 -1
- data/lib/templus_models.rb +29 -1
- data/test/dummy/app/helpers/menu_helper.rb +17 -17
- data/test/dummy/app/models/templus.rb +4 -4
- data/test/dummy/app/raro_crud/endereco_crud.rb +1 -1
- data/test/dummy/app/raro_crud/papel_crud.rb +1 -1
- data/test/dummy/app/raro_crud/teste1_crud.rb +1 -1
- data/test/dummy/app/raro_crud/teste_crud.rb +1 -1
- data/test/dummy/app/raro_crud/usuario_crud.rb +6 -3
- data/test/dummy/config/locales/pt-BR.yml +25 -31
- data/test/dummy/config/locales/simple_form.pt-BR.yml +2 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- metadata +627 -625
data/config/routes.rb
CHANGED
@@ -1,27 +1,34 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
|
-
# Routes for RaroCrud
|
3
|
-
get '/crud/:model' => "crud#index", as: :crud_models
|
4
|
-
get '/crud/:model/:id/edit' => "crud#edit", as: :edit_crud
|
5
|
-
delete '/crud/:model/:id/destroy' => "crud#destroy", as: :destroy_crud
|
6
|
-
get '/crud/:model/new' => "crud#new", as: :new_crud
|
7
|
-
get '/crud/:model/query' => "crud#query", as: :query_crud
|
8
|
-
get '/crud/:model/autocomplete' => "crud#autocomplete", as: :autocomplete_crud
|
9
|
-
post '/crud/:model/create' => "crud#create", as: :create_crud
|
10
|
-
get '/crud/:model/listing' => "crud#listing", as: :listing_crud
|
11
|
-
patch '/crud/:model/:id/create' => "crud#create", as: :update_crud
|
12
|
-
get '/crud/:model/:id/acao/:acao' => "crud#action", as: :action_crud
|
13
|
-
get '/crud/:model/:id' => "crud#show", as: :crud_model
|
14
2
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
3
|
+
if TemplusModels::Routes.registrar
|
4
|
+
scope "(:locale)" do
|
5
|
+
# Routes for RaroCrud
|
6
|
+
get '/crud/:model' => "crud#index", as: :crud_models
|
7
|
+
get '/crud/:model/:id/edit' => "crud#edit", as: :edit_crud
|
8
|
+
delete '/crud/:model/:id/destroy' => "crud#destroy", as: :destroy_crud
|
9
|
+
get '/crud/:model/new' => "crud#new", as: :new_crud
|
10
|
+
get '/crud/:model/query' => "crud#query", as: :query_crud
|
11
|
+
get '/crud/:model/autocomplete' => "crud#autocomplete", as: :autocomplete_crud
|
12
|
+
post '/crud/:model/create' => "crud#create", as: :create_crud
|
13
|
+
get '/crud/:model/listing' => "crud#listing", as: :listing_crud
|
14
|
+
get '/crud/:model/:id/printing' => "crud#printing", as: :printing_crud
|
15
|
+
patch '/crud/:model/:id/create' => "crud#create", as: :update_crud
|
16
|
+
get '/crud/:model/:id/acao/:acao' => "crud#action", as: :action_crud
|
17
|
+
get '/crud/:model/:id' => "crud#show", as: :crud_model
|
18
|
+
|
19
|
+
#Routes for RaroCrud Associations
|
20
|
+
get '/crud/:model/:id/:associacao' => "crud#index", as: :crud_associacao_models
|
21
|
+
get '/crud/:model/:id/:associacao/:associacao_id/edit' => "crud#edit", as: :edit_crud_associacao
|
22
|
+
delete '/crud/:model/:id/:associacao/:associacao_id/destroy' => "crud#destroy", as: :destroy_crud_associacao
|
23
|
+
get '/crud/:model/:id/:associacao/new' => "crud#new", as: :new_crud_associacao
|
24
|
+
get '/crud/:model/:id/:associacao/query' => "crud#query", as: :query_crud_associacao
|
25
|
+
get '/crud/:model/:id/:associacao/autocomplete' => "crud#autocomplete", as: :autocomplete_crud_associacao
|
26
|
+
post '/crud/:model/:id/:associacao/create' => "crud#create", as: :create_crud_associacao
|
27
|
+
get '/crud/:model/:id/:associacao/listing' => "crud#listing", as: :listing_crud_associacao
|
28
|
+
get '/crud/:model/:id/:associacao/printing' => "crud#printing", as: :printing_crud_associacao
|
29
|
+
patch '/crud/:model/:id/:associacao/:associacao_id/create' => "crud#create", as: :update_crud_associacao
|
30
|
+
get '/crud/:model/:id/:associacao/:associacao_id/acao/:acao' => "crud#action", as: :action_crud_associacao
|
31
|
+
get '/crud/:model/:id/:associacao/:associacao_id' => "crud#show", as: :crud_associacao_model
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/templus_models.rb
CHANGED
@@ -6,5 +6,33 @@ require "simple_form"
|
|
6
6
|
require "nested_form"
|
7
7
|
require "rails-jquery-autocomplete"
|
8
8
|
|
9
|
+
require 'templus_models/configuration'
|
10
|
+
|
9
11
|
module TemplusModels
|
10
|
-
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def configure
|
15
|
+
if block_given?
|
16
|
+
yield(Configuration.instance)
|
17
|
+
else
|
18
|
+
Configuration.instance
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def configuration
|
23
|
+
Configuration.instance
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
module Routes
|
28
|
+
@@registrar = true
|
29
|
+
|
30
|
+
def self.registrar
|
31
|
+
@@registrar
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.registrar=(value)
|
35
|
+
@@registrar = value
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
module MenuHelper
|
2
2
|
def is_active(controller_name, action_name)
|
3
|
-
(params[:controller] == controller_name && params[:action] == action_name) ? "active" : ""
|
4
|
-
end
|
3
|
+
return (params[:controller].singularize == controller_name.singularize && params[:action] == action_name) ? "active" : ""
|
4
|
+
end
|
5
5
|
|
6
6
|
def is_active_crud(modelo)
|
7
|
-
(controller.controller_name == 'crud' && params[:model] == modelo) ? "active" :
|
8
|
-
end
|
9
|
-
|
7
|
+
(controller.controller_name == 'crud' && params[:model] == modelo) ? "active" : nil
|
8
|
+
end
|
9
|
+
|
10
10
|
def is_active_parent(controllers)
|
11
11
|
controllers.each do |name|
|
12
|
-
if (params[:controller] == name[0] && (params[:action] == name[1] || params[:model] == name[1]))
|
12
|
+
if (params[:controller].singularize == name[0] && (params[:action] == name[1] || params[:model] == name[1]))
|
13
13
|
return "active"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
return ""
|
17
17
|
end
|
18
|
-
|
18
|
+
|
19
19
|
def is_can?(tipo, modelos)
|
20
20
|
modelos.each do |m|
|
21
21
|
if can?(tipo, m)
|
@@ -24,13 +24,13 @@ module MenuHelper
|
|
24
24
|
end
|
25
25
|
return false
|
26
26
|
end
|
27
|
-
|
28
|
-
def menu_crud_helper(nome, classe, icon='', parent=false)
|
27
|
+
|
28
|
+
def menu_crud_helper(nome, classe, icon='', parent=false, controllers = {})
|
29
29
|
if can?(:read, classe)
|
30
30
|
modelo = classe.name.underscore
|
31
|
-
url =
|
31
|
+
url = crud_models_path(model: modelo)
|
32
32
|
buffer = ""
|
33
|
-
buffer << "<li class='menu #{is_active_crud(modelo)}'>"
|
33
|
+
buffer << "<li class='menu #{is_active_crud(modelo) || is_active_parent(controllers)}'>"
|
34
34
|
if parent
|
35
35
|
buffer << link_to("<i class='#{icon}'></i> <span>#{nome}</span>".html_safe, url, data: {push: true, crumb: 'wielka'})
|
36
36
|
else
|
@@ -40,11 +40,11 @@ module MenuHelper
|
|
40
40
|
buffer.html_safe
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
43
|
+
|
44
44
|
def menu_helper(classe, controller, action, url, nome, icone='', parent=false)
|
45
|
-
|
45
|
+
if can?(:read, classe)
|
46
46
|
buffer = ""
|
47
|
-
|
47
|
+
buffer << "<li class='menu #{is_active(controller, action)}'>"
|
48
48
|
if parent
|
49
49
|
buffer << link_to("<i class='#{icone}'></i> <span>#{nome}</span>".html_safe, url, data: {push: true, crumb: 'wielka'})
|
50
50
|
else
|
@@ -52,9 +52,9 @@ module MenuHelper
|
|
52
52
|
end
|
53
53
|
buffer << "</li>"
|
54
54
|
buffer.html_safe
|
55
|
-
|
55
|
+
end
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
def menu_parent(modelos, controllers, nome, icone='', parent=false, &block)
|
59
59
|
if is_can?(:read, modelos)
|
60
60
|
buffer = ""
|
@@ -84,4 +84,4 @@ module MenuHelper
|
|
84
84
|
buffer.html_safe
|
85
85
|
end
|
86
86
|
end
|
87
|
-
end
|
87
|
+
end
|
@@ -17,17 +17,17 @@ class Templus
|
|
17
17
|
def self.logo
|
18
18
|
@@logo
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def self.logo_rodape
|
22
22
|
@@logo_rodape
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def self.logo_landpage
|
26
26
|
@@logo_landpage
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
def self.paragrafo_login
|
30
30
|
@@paragrafo_login
|
31
31
|
end
|
32
32
|
|
33
|
-
end
|
33
|
+
end
|
@@ -4,7 +4,7 @@ class EnderecoCrud < RaroCrud
|
|
4
4
|
subtitulo "Subtitulo", :index
|
5
5
|
descricao "Descrição do Cadastro", :index
|
6
6
|
|
7
|
-
link_superior "Novo Endereco", id: "novo-button", icon: "plus", link: "new"
|
7
|
+
link_superior nome: "Novo Endereco", id: "novo-button", icon: "plus", link: "new"
|
8
8
|
|
9
9
|
ordenar_por :created_at
|
10
10
|
itens_por_pagina 20
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class Teste1Crud < RaroCrud
|
2
2
|
|
3
3
|
titulo "Teste1"
|
4
|
-
link_superior "Novo Teste1", id: "novo-button", icon: "plus", link: "new"
|
4
|
+
link_superior nome: "Novo Teste1", id: "novo-button", icon: "plus", link: "new"
|
5
5
|
|
6
6
|
acoes :associar, "Definir permissões", Proc.new {|p| Usuario.current.ability.can?(:create,p)}
|
7
7
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
class TesteCrud < RaroCrud
|
2
2
|
titulo "Testes"
|
3
3
|
|
4
|
-
link_superior "Novo Teste", id: "novo-button", icon: "plus", link: "new", can: Proc.new {|obj| Usuario.current.ability.can?(:create, obj)}
|
4
|
+
link_superior nome: "Novo Teste", id: "novo-button", icon: "plus", link: "new", can: Proc.new {|obj| Usuario.current.ability.can?(:create, obj)}
|
5
5
|
|
6
6
|
ordenar_por :created_at
|
7
7
|
itens_por_pagina 20
|
@@ -1,9 +1,9 @@
|
|
1
1
|
class UsuarioCrud < RaroCrud
|
2
2
|
titulo "Usuários"
|
3
3
|
|
4
|
-
link_superior "Novo Usuário", id: "novo-button", icon: "plus", link: "new"
|
5
|
-
link_superior "Inicio", id: "novo-button", icon: "", url: :busca_api_cidades
|
6
|
-
link_superior "Novo", partial: "/usuarios/actions"
|
4
|
+
link_superior nome: "Novo Usuário", id: "novo-button", icon: "plus", link: "new"
|
5
|
+
link_superior nome: "Inicio", id: "novo-button", icon: "", url: :busca_api_cidades
|
6
|
+
link_superior nome: "Novo", partial: "/usuarios/actions"
|
7
7
|
|
8
8
|
ordenar_por :nome
|
9
9
|
edicao Proc.new {|obj| !obj.root? }
|
@@ -31,4 +31,7 @@ class UsuarioCrud < RaroCrud
|
|
31
31
|
campo_busca :email, label: "email"
|
32
32
|
campo_busca :papel_id, label: "Papel", visible_if: Proc.new {Usuario.current.root? }
|
33
33
|
|
34
|
+
campo_listagem :nome, label: "nome"
|
35
|
+
campo_listagem :email, label: "email"
|
36
|
+
|
34
37
|
end
|
@@ -1,28 +1,22 @@
|
|
1
1
|
"pt-BR":
|
2
2
|
mensagem_confirm: "Deseja apagar %{model}?"
|
3
|
-
|
4
|
-
|
3
|
+
mensagem_confirm_destroy: "Você tem certeza que deseja apagar esse registro?"
|
4
|
+
mensagem_action: "Ação %{acao} efetuada com sucesso."
|
5
|
+
mensagem_erro_action: "Erro ao tentar executar a ação %{acao}."
|
5
6
|
created: "%{model} criado(a) com sucesso."
|
6
7
|
updated: "%{model} atualizado(a) com sucesso."
|
7
8
|
destroyed: "%{model} apagado(a) com sucesso."
|
8
|
-
sucesso_lance_fixo: "Lance realizado com sucesso! Aguarde aprovação do embarcador."
|
9
|
-
sucesso_lance_lance: "Lance realizado com sucesso!"
|
10
|
-
error_lances: "Não é possível realizar o lance."
|
11
9
|
new: "Novo(a) %{model}"
|
12
10
|
cancel: "Cancelar"
|
13
11
|
edit: "Editar"
|
14
12
|
destroy: "Apagar"
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
cancelar_lance: "Deseja realmente cancelar este lance?"
|
23
|
-
aprovar_lance: "Realmente deseja aprovar o lance de %{valor} feito pela empresa %{nome_empresa}?"
|
24
|
-
lance_aguardando: "deseja realizar o frete #%{url} com destino: %{destino}. Você aceita?"
|
25
|
-
cancelar_demanda_e_lances: "Deseja cancelar esta demanda?"
|
13
|
+
view: "Visualizar"
|
14
|
+
undo: "Voltar"
|
15
|
+
save: "Salvar"
|
16
|
+
home: "Home"
|
17
|
+
search: "Pesquisar"
|
18
|
+
close: "Fechar"
|
19
|
+
sign_out: "Sair"
|
26
20
|
number:
|
27
21
|
# Used in number_with_delimiter()
|
28
22
|
# These are also the defaults for 'currency', 'percentage', 'precision', and 'human'
|
@@ -132,11 +126,26 @@
|
|
132
126
|
prompt: "Por favor selecione"
|
133
127
|
views:
|
134
128
|
pagination:
|
129
|
+
text: "Exibindo %{inicio} - %{fim} de um total de %{total}"
|
135
130
|
first: "Primeiro"
|
136
131
|
last: "Último"
|
137
132
|
previous: "Anterior"
|
138
133
|
next: "Próximo"
|
139
134
|
truncate: "..."
|
135
|
+
search:
|
136
|
+
choice: "Escolha..."
|
137
|
+
equal: "Igual"
|
138
|
+
different: "Diferente"
|
139
|
+
great: "Maior"
|
140
|
+
less: "Menor"
|
141
|
+
great_then: "Maior ou Igual"
|
142
|
+
less_then: "Menor ou Igual"
|
143
|
+
contains: "Contém"
|
144
|
+
not_contains: "Não Contém"
|
145
|
+
begins: "Começa"
|
146
|
+
ends: "Termina"
|
147
|
+
menu:
|
148
|
+
entitys: "Cadastros"
|
140
149
|
true: Sim
|
141
150
|
false: Não
|
142
151
|
date:
|
@@ -344,24 +353,9 @@
|
|
344
353
|
short: ! '%d/%m/%Y, %H:%M h'
|
345
354
|
short_b: ! '%d %B %Y'
|
346
355
|
pm: ''
|
347
|
-
# remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository
|
348
356
|
activemodel:
|
349
357
|
errors:
|
350
358
|
<<: *errors
|
351
359
|
activerecord:
|
352
|
-
attributes:
|
353
|
-
produto:
|
354
|
-
ws_codigo: "Código"
|
355
|
-
ws_descricao: "Produto"
|
356
|
-
ws_razao_fornecedor: "Fornecedor"
|
357
|
-
ws_produto_fornecedor: "Código no Fornecedor"
|
358
|
-
ws_referencia: "Referência"
|
359
|
-
ws_sigla_fornecedor: "Sigla Fornecedor"
|
360
|
-
ws_ncm: "NCM"
|
361
|
-
ws_cst: "CST"
|
362
|
-
ws_fator_conversao: "Fator Conversão"
|
363
|
-
models:
|
364
|
-
produto: "Produto"
|
365
|
-
veiculo: "Veículo"
|
366
360
|
errors:
|
367
361
|
<<: *errors
|
Binary file
|