templus_models 1.4.4 → 1.5.0
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 +29 -17
- data/app/helpers/crud_helper.rb +4 -3
- data/app/helpers/search_helper.rb +0 -1
- data/app/raro_crud/raro_crud.rb +1 -1
- data/app/views/crud/_crud_template.html.erb +3 -0
- data/app/views/crud/_form.html.erb +3 -3
- data/app/views/crud/_record.html.erb +12 -4
- data/app/views/crud/_scopes.html.erb +4 -4
- data/app/views/crud/_search.html.erb +1 -1
- data/app/views/crud/_shared.html.erb +2 -2
- data/app/views/crud/_show.html.erb +9 -1
- data/config/routes.rb +12 -0
- data/lib/templus_models/version.rb +1 -1
- metadata +2 -6
- data/lib/generators/crud/USAGE +0 -8
- data/lib/generators/crud/crud_generator.rb +0 -10
- data/lib/generators/crud/templates/crud.rb +0 -50
- data/lib/generators/crud/templates/crud2.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 850710051ba1bd533abfb56330174c3424701e91
|
4
|
+
data.tar.gz: 25e863eb9675beeaafedba8101b70a362e0130b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2fe2e5d98f7b3538a784d94ae9667904b4229a4d5e16bbbe8e7b02943bb7ce32933682cd0e4b552f2135c5bfb781a02f9aba34896cfe8f07ec8a67a737cb4e9
|
7
|
+
data.tar.gz: 34e1ac40a0abe89e8dc0aca900a08ecb4c97cf3241cb26b305aca16b3c094643b2c337d56214d8132c3e9a7dfde30380f07fdb56f19d40c91f67af9ac7fa1238
|
@@ -1,6 +1,23 @@
|
|
1
1
|
class CrudController < ApplicationController
|
2
2
|
before_filter :setup, except: :autocomplete
|
3
|
-
|
3
|
+
|
4
|
+
private
|
5
|
+
def setup
|
6
|
+
if params[:associacao]
|
7
|
+
@crud_associacao = Module.const_get("#{params[:model].to_s.singularize}_crud".camelize)
|
8
|
+
@model = Module.const_get(params[:model].camelize).find(params[:id]).send(params[:associacao])
|
9
|
+
@crud_helper = Module.const_get("#{params[:associacao].to_s.singularize}_crud".camelize) unless params[:render] == "modal" and params[:action] == "new"
|
10
|
+
@url = "/crud/#{params[:model]}/#{params[:id]}/#{params[:associacao]}"
|
11
|
+
@id = params[:associacao_id] if params[:associacao_id]
|
12
|
+
else
|
13
|
+
@model = Module.const_get(params[:model].camelize)
|
14
|
+
@crud_helper = Module.const_get("#{params[:model]}_crud".camelize) unless params[:render] == "modal" and params[:action] == "new"
|
15
|
+
@url = "/crud/#{params[:model]}"
|
16
|
+
@id = params[:id] if params[:id]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
public
|
4
21
|
def index
|
5
22
|
authorize! :read, @model if respond_to?(:current_usuario)
|
6
23
|
if params[:scope].present?
|
@@ -23,11 +40,6 @@ class CrudController < ApplicationController
|
|
23
40
|
@titulo = @model.name.pluralize
|
24
41
|
render partial: 'records' if request.respond_to?(:wiselinks_partial?) && request.wiselinks_partial?
|
25
42
|
end
|
26
|
-
|
27
|
-
def setup
|
28
|
-
@model = Module.const_get(params[:model].camelize)
|
29
|
-
@crud_helper = Module.const_get("#{params[:model]}_crud".camelize) unless params[:render] == "modal" and params[:action] == "new"
|
30
|
-
end
|
31
43
|
|
32
44
|
def new
|
33
45
|
if params[:render] == "modal"
|
@@ -36,24 +48,24 @@ class CrudController < ApplicationController
|
|
36
48
|
else
|
37
49
|
@model = params[:attribute].to_s.camelcase.constantize
|
38
50
|
end
|
51
|
+
@crud_helper = Module.const_get("#{@model}Crud".camelize)
|
39
52
|
end
|
40
53
|
authorize! :new, @model if respond_to?(:current_usuario)
|
41
|
-
@crud_helper = Module.const_get("#{@model}Crud".camelize)
|
42
54
|
@record = @model.new
|
43
55
|
end
|
44
56
|
|
45
57
|
def edit
|
46
|
-
@record = @model.find(
|
58
|
+
@record = @model.find(@id)
|
47
59
|
authorize! :edit, @record if respond_to?(:current_usuario)
|
48
60
|
end
|
49
61
|
|
50
62
|
def show
|
51
|
-
@record = @model.find(
|
63
|
+
@record = @model.find(@id)
|
52
64
|
authorize! :read, @record if respond_to?(:current_usuario)
|
53
65
|
end
|
54
66
|
|
55
67
|
def action
|
56
|
-
@record = @model.find(
|
68
|
+
@record = @model.find(@id)
|
57
69
|
authorize! :create_or_update, @record if respond_to?(:current_usuario)
|
58
70
|
if @model.method_defined?(params[:acao])
|
59
71
|
if @record.send(params[:acao])
|
@@ -71,8 +83,8 @@ class CrudController < ApplicationController
|
|
71
83
|
|
72
84
|
def create
|
73
85
|
@saved = false
|
74
|
-
if
|
75
|
-
@record = @model.find(
|
86
|
+
if @id
|
87
|
+
@record = @model.find(@id)
|
76
88
|
authorize! :update, @record if respond_to?(:current_usuario)
|
77
89
|
@saved = @record.update(params_permitt)
|
78
90
|
else
|
@@ -84,7 +96,7 @@ class CrudController < ApplicationController
|
|
84
96
|
respond_to do |format|
|
85
97
|
if @saved
|
86
98
|
flash[:success] = params[:id].present? ? "Cadastro alterado com sucesso." : "Cadastro efetuado com sucesso."
|
87
|
-
format.html { redirect_to "
|
99
|
+
format.html { redirect_to "#{@url}?page=#{params[:page]}" }
|
88
100
|
unless params[:render] == 'modal'
|
89
101
|
format.js { render action: :index}
|
90
102
|
else
|
@@ -99,18 +111,18 @@ class CrudController < ApplicationController
|
|
99
111
|
end
|
100
112
|
|
101
113
|
def destroy
|
102
|
-
@record = @model.find(
|
114
|
+
@record = @model.find(@id)
|
103
115
|
authorize! :destroy, @record if respond_to?(:current_usuario)
|
104
116
|
if @record.destroy
|
105
117
|
respond_to do |format|
|
106
118
|
flash[:success] = "Cadastro removido com sucesso."
|
107
|
-
format.html { redirect_to
|
119
|
+
format.html { redirect_to @url }
|
108
120
|
format.js { render action: :index }
|
109
121
|
end
|
110
122
|
else
|
111
123
|
respond_to do |format|
|
112
124
|
flash[:error] = @record.errors.full_messages.join(", ")
|
113
|
-
format.html { redirect_to
|
125
|
+
format.html { redirect_to @url }
|
114
126
|
format.js { render action: :index }
|
115
127
|
end
|
116
128
|
end
|
@@ -118,7 +130,7 @@ class CrudController < ApplicationController
|
|
118
130
|
|
119
131
|
def query
|
120
132
|
authorize! :read, @model if respond_to?(:current_usuario)
|
121
|
-
@resource =
|
133
|
+
@resource = @model
|
122
134
|
@q = @resource.search(params[:q])
|
123
135
|
@q.sorts = 'updated_at desc' if @q.sorts.empty?
|
124
136
|
if respond_to?(:current_usuario)
|
data/app/helpers/crud_helper.rb
CHANGED
@@ -60,12 +60,13 @@ module CrudHelper
|
|
60
60
|
end
|
61
61
|
|
62
62
|
|
63
|
-
def render_link(link)
|
63
|
+
def render_link(link,url)
|
64
64
|
if link[:partial].present?
|
65
65
|
render link[:partial]
|
66
|
+
elsif link[:link]
|
67
|
+
link_to "#{gen_icon(link[:icon])} #{link[:text]}".html_safe, "#{url}/#{link[:link]}", class: link[:class], data: data(link)
|
66
68
|
else
|
67
|
-
|
68
|
-
link_to "#{gen_icon(link[:icon])} #{link[:text]}".html_safe, url, class: link[:class], data: data(link)
|
69
|
+
link_to "#{gen_icon(link[:icon])} #{link[:text]}".html_safe, link[:url], class: link[:class], data: data(link)
|
69
70
|
end
|
70
71
|
end
|
71
72
|
|
@@ -194,7 +194,6 @@ module SearchHelper
|
|
194
194
|
def raro_before_form(model,partial,var,url,sort)
|
195
195
|
buffer = "<div id='search_box'>"+
|
196
196
|
"<form method='get' class=form-horizontal action='#{url}' data-push='partial' data-target='#form'>" +
|
197
|
-
"<input type='hidden' name='model' value='#{model}'>" +
|
198
197
|
"<input type='hidden' name='partial' value='#{partial}'>" +
|
199
198
|
"<input type='hidden' name='var' value='#{var}'>"
|
200
199
|
if sort
|
data/app/raro_crud/raro_crud.rb
CHANGED
@@ -189,7 +189,7 @@ class RaroCrud
|
|
189
189
|
data: {push: 'partial', target: '#form'},
|
190
190
|
icon: "fa fa-#{opts[:icon]}",
|
191
191
|
class: 'btn btn-small btn-primary btn-rounded',
|
192
|
-
link: "#{
|
192
|
+
link: "#{opts[:link]}",
|
193
193
|
url: opts[:url],
|
194
194
|
can: opts[:can],
|
195
195
|
partial: opts[:partial]
|
@@ -1,5 +1,8 @@
|
|
1
1
|
<%unless params[:render] == 'modal'%>
|
2
2
|
<% content_for :breadcumb do %>
|
3
|
+
<% if @crud_associacao.present? %>
|
4
|
+
<li class=""><%= link_to @crud_associacao.title, @crud_associacao.root_path %></li>
|
5
|
+
<% end %>
|
3
6
|
<li class=""><%= link_to @crud_helper.title, @crud_helper.root_path %></li>
|
4
7
|
<% end %>
|
5
8
|
|
@@ -11,10 +11,10 @@
|
|
11
11
|
</div>
|
12
12
|
</div>
|
13
13
|
<%unless params[:render] == 'modal'%>
|
14
|
-
<% url = "
|
14
|
+
<% url = "#{@url}/#{@record.new_record? ? 'create' : @record.id.to_s+'/create'}?page=#{params[:page]}" %>
|
15
15
|
<% remote_form = false%>
|
16
16
|
<%else%>
|
17
|
-
<% url = "
|
17
|
+
<% url = "#{@url}/#{@record.new_record? ? 'create?render=modal' : @record.id.to_s+'/create?render=modal'}" %>
|
18
18
|
<% remote_form = true%>
|
19
19
|
<%end%>
|
20
20
|
<%= simple_nested_form_for @record, remote: remote_form, html: {class: "form-horizontal"}, url: url do |f| %>
|
@@ -40,7 +40,7 @@
|
|
40
40
|
<div class="col-sm-4 col-sm-offset-2">
|
41
41
|
<%= f.submit "Salvar", class: 'btn btn-primary' %>
|
42
42
|
<%unless params[:render] == 'modal'%>
|
43
|
-
<%= link_to "Voltar", "
|
43
|
+
<%= link_to "Voltar", "#{@url}?page=#{params[:page]}", class: 'btn btn-default', data: {push: 'partial', target: "#form"} %>
|
44
44
|
<% end %>
|
45
45
|
</div>
|
46
46
|
</div>
|
@@ -20,6 +20,14 @@
|
|
20
20
|
</li>
|
21
21
|
<% end %>
|
22
22
|
</td>
|
23
|
+
<% elsif record.send(att[:attribute]).class == Array %>
|
24
|
+
<td>
|
25
|
+
<% record.send(att[:attribute]).each do |rec| %>
|
26
|
+
<li>
|
27
|
+
<%= rec.to_s %>
|
28
|
+
</li>
|
29
|
+
<% end %>
|
30
|
+
</td>
|
23
31
|
<% elsif record.send(att[:attribute]).respond_to?(:url) and record.send(att[:attribute]).url(:thumb) %>
|
24
32
|
<td><%= image_tag(record.send(att[:attribute]).url(:thumb)) %></td>
|
25
33
|
<% else %>
|
@@ -55,7 +63,7 @@
|
|
55
63
|
</a>
|
56
64
|
<% end %>
|
57
65
|
<% elsif options[:associacao].present? %>
|
58
|
-
<a href="/crud/<%=
|
66
|
+
<a href="/crud/<%= @model.name.underscore %>/<%= record.id %>/<%= options[:associacao].to_s %>" class="btn btn-success btn-xs" data-push="partial" data-target="#form">
|
59
67
|
<%=name%>
|
60
68
|
</a>
|
61
69
|
<% elsif options[:partial].present? %>
|
@@ -63,15 +71,15 @@
|
|
63
71
|
<% end %>
|
64
72
|
<% end %>
|
65
73
|
<%if @crud_helper.view_action && shold_view?(@crud_helper, record)%>
|
66
|
-
<a href="
|
74
|
+
<a href="<%= @url %>/<%=record.id%>?page=<%=params[:page]%>"
|
67
75
|
class="btn btn-primary btn-xs" data-push="partial" data-target="#form">Visualizar</a>
|
68
76
|
<% end %>
|
69
77
|
<%if @crud_helper.edit_action && shold_edit?(@crud_helper, record) %>
|
70
|
-
<a href="
|
78
|
+
<a href="<%= @url %>/<%=record.id%>/edit?page=<%=params[:page]%>"
|
71
79
|
class="btn btn-primary btn-xs" data-push="partial" data-target="#form">Editar</a>
|
72
80
|
<% end %>
|
73
81
|
<%if @crud_helper.destroy_action && shold_destroy?(@crud_helper, record)%>
|
74
|
-
<a href="
|
82
|
+
<a href="<%= @url %>/<%=record.id%>/destroy"
|
75
83
|
class="btn btn-danger btn-xs" data-push="partial" data-target="#form" data-method="delete" data-confirm="Você têm certeza?">Excluir</a>
|
76
84
|
<% end %>
|
77
85
|
</td>
|
@@ -2,10 +2,10 @@
|
|
2
2
|
<% if @crud_helper.scopes.class == Array %>
|
3
3
|
<% @crud_helper.scopes.each do |escopo| %>
|
4
4
|
<%= link_to "/crud/#{@model.name.underscore}?scope=#{escopo[0]}", id: "#{escopo[0]}", data: {push: true, crumb: 'wielka'} do%>
|
5
|
-
<div style="float: left; margin-left: 10px; min-width: 100px;">
|
6
|
-
<div class="widget style1 gray-bg">
|
7
|
-
<div class="row vertical-align text-center">
|
8
|
-
<h3 class="font-bold">
|
5
|
+
<div style="float: left; margin-left: 10px; min-width: 100px; position:relative;">
|
6
|
+
<div class="widget style1 gray-bg" style="padding:15px 0px!important;">
|
7
|
+
<div class="row vertical-align text-center" style="margin:0!important;">
|
8
|
+
<h3 class="font-bold" style="width:100%;">
|
9
9
|
<%= escopo[1] %>
|
10
10
|
<span class="label label-success pull-right" style="margin-left: 10px;">
|
11
11
|
<% if current_usuario.present? %>
|
@@ -8,7 +8,7 @@
|
|
8
8
|
<small class="font-bold"></small>
|
9
9
|
</div>
|
10
10
|
<div class="modal-body">
|
11
|
-
<%=raro_search_form(@model, 'records','records',"
|
11
|
+
<%=raro_search_form(@model, 'records','records',"#{@url}/query") do%>
|
12
12
|
<%raro_group "#{@model.name}"%>
|
13
13
|
<%@crud_helper.search_fields.each do |att| %>
|
14
14
|
<% if att[:sf].present? && !att[:sf][:visible_if].nil?%>
|
@@ -26,9 +26,9 @@
|
|
26
26
|
<div class="pull-right actions">
|
27
27
|
<% @crud_helper.top_links.each do |link| %>
|
28
28
|
<% if link[:can].present? %>
|
29
|
-
<%=render_link(link) if self.instance_eval &link[:can]%>
|
29
|
+
<%=render_link(link,@url) if self.instance_eval &link[:can]%>
|
30
30
|
<% else %>
|
31
|
-
<%=render_link(link)%>
|
31
|
+
<%=render_link(link,@url)%>
|
32
32
|
<% end %>
|
33
33
|
<%end%>
|
34
34
|
<% if @crud_helper.search_fields.present? %>
|
@@ -42,6 +42,14 @@
|
|
42
42
|
</li>
|
43
43
|
<% end %>
|
44
44
|
</td>
|
45
|
+
<% elsif @record.send(field[:attribute]).class == Array %>
|
46
|
+
<td>
|
47
|
+
<% @record.send(field[:attribute]).each do |rec| %>
|
48
|
+
<li>
|
49
|
+
<%= rec.to_s %>
|
50
|
+
</li>
|
51
|
+
<% end %>
|
52
|
+
</td>
|
45
53
|
<% elsif @record.send(field[:attribute]).respond_to?(:url) %>
|
46
54
|
<td>
|
47
55
|
<%= render_field_file(@record.send(field[:attribute])) %>
|
@@ -65,5 +73,5 @@
|
|
65
73
|
</div>
|
66
74
|
</div>
|
67
75
|
<hr>
|
68
|
-
<%= link_to "Voltar", "
|
76
|
+
<%= link_to "Voltar", "#{@url}" ,class: 'btn btn-default', data: {push: 'partial', target: "#form"} %>
|
69
77
|
<% end %>
|
data/config/routes.rb
CHANGED
@@ -10,4 +10,16 @@ Rails.application.routes.draw do
|
|
10
10
|
patch '/crud/:model/:id/create' => "crud#create"
|
11
11
|
get '/crud/:model/:id/acao/:acao' => "crud#action"
|
12
12
|
get '/crud/:model/:id' => "crud#show"
|
13
|
+
|
14
|
+
#Routes for RaroCrud Associations
|
15
|
+
get '/crud/:model/:id/:associacao' => "crud#index"
|
16
|
+
get '/crud/:model/:id/:associacao/:associacao_id/edit' => "crud#edit"
|
17
|
+
delete '/crud/:model/:id/:associacao/:associacao_id/destroy' => "crud#destroy"
|
18
|
+
get '/crud/:model/:id/:associacao/new' => "crud#new"
|
19
|
+
get '/crud/:model/:id/:associacao/query' => "crud#query"
|
20
|
+
get '/crud/:model/:id/:associacao/autocomplete' => "crud#autocomplete"
|
21
|
+
post '/crud/:model/:id/:associacao/create' => "crud#create"
|
22
|
+
patch '/crud/:model/:id/:associacao/:associacao_id/create' => "crud#create"
|
23
|
+
get '/crud/:model/:id/:associacao/:associacao_id/acao/:acao' => "crud#action"
|
24
|
+
get '/crud/:model/:id/:associacao/:associacao_id' => "crud#show"
|
13
25
|
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: 1.
|
4
|
+
version: 1.5.0
|
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-10-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -173,10 +173,6 @@ files:
|
|
173
173
|
- config/initializers/raro_search.rb
|
174
174
|
- config/initializers/simple_form.rb
|
175
175
|
- config/routes.rb
|
176
|
-
- lib/generators/crud/USAGE
|
177
|
-
- lib/generators/crud/crud_generator.rb
|
178
|
-
- lib/generators/crud/templates/crud.rb
|
179
|
-
- lib/generators/crud/templates/crud2.rb
|
180
176
|
- lib/tasks/templus_models_tasks.rake
|
181
177
|
- lib/templus_models.rb
|
182
178
|
- lib/templus_models/engine.rb
|
data/lib/generators/crud/USAGE
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
class CrudGenerator < Rails::Generators::NamedBase
|
2
|
-
source_root File.expand_path('../templates', __FILE__)
|
3
|
-
attr_reader :teste
|
4
|
-
|
5
|
-
def copy_initializer_file
|
6
|
-
@model = Module.const_get(file_name.camelize)
|
7
|
-
template 'crud.rb', "app/raro_crud/#{file_name}_crud.rb", @model
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
class <%=@model.name%>Crud < RaroCrud
|
2
|
-
|
3
|
-
titulo "<%=@model.name.pluralize%>"
|
4
|
-
|
5
|
-
link_superior "Novo <%=@model.name%>", id: "novo-button", icon: "plus", link: "new", can: Proc.new {|obj| Usuario.current.ability.can?(:create, obj)}
|
6
|
-
|
7
|
-
ordenar_por :created_at
|
8
|
-
itens_por_pagina 20
|
9
|
-
|
10
|
-
#Exemplo de acao customizada
|
11
|
-
#acoes :associar, "Definir permissões", Proc.new {|p| Usuario.current.ability.can?(:create,p)}
|
12
|
-
|
13
|
-
<%
|
14
|
-
@atributos = @model.attribute_names
|
15
|
-
@atributos.delete("id")
|
16
|
-
@atributos.delete("created_at")
|
17
|
-
@atributos.delete("updated_at")
|
18
|
-
@atributos.map!{|e| e.gsub(/_id/,"")}
|
19
|
-
|
20
|
-
%>
|
21
|
-
#Campos mostrados na index
|
22
|
-
<%@atributos.each do |atributo| %>campo_tabela :<%=atributo.to_sym%>, label: "<%=atributo.humanize%>"<%="\n"%> <%end%>
|
23
|
-
|
24
|
-
#Campos mostrados no formulários de cadastro
|
25
|
-
<%@atributos.each do |atributo| %>campo_formulario :<%=atributo.to_sym%>, label: "<%=atributo.humanize%>"<%="\n"%> <%end%>
|
26
|
-
|
27
|
-
#Campos mostrados na visualizacao
|
28
|
-
<%@atributos.each do |atributo| %>campo_visualizacao :<%=atributo.to_sym%>, label: "<%=atributo.humanize%>"<%="\n"%> <%end%>
|
29
|
-
|
30
|
-
#Campos mostrados na busca
|
31
|
-
<%@atributos.each do |atributo| %>campo_busca :<%=atributo.to_sym%>, label: "<%=atributo.humanize%>"<%="\n"%> <%end%>
|
32
|
-
|
33
|
-
#Exemplos de customizacao
|
34
|
-
# Datepicker
|
35
|
-
# campo_formulario :data, label: "Data", as: :string, input_html: {class: "datepicker"}
|
36
|
-
# Checkbox
|
37
|
-
# campo_formulario :check, label: "Check", input_html: {class: "i-checks"}
|
38
|
-
# upload
|
39
|
-
# campo_formulario :arquivo, label: "Foto", input_html: {class: "ace-input-file"}
|
40
|
-
# Relacionamento
|
41
|
-
# campo_formulario :grupos, label: "Grupos",
|
42
|
-
# label_method: :nome,
|
43
|
-
# as: :check_boxes,
|
44
|
-
# input_html: {class: "i-checks"}
|
45
|
-
# campo_busca :nome, model: 'Grupo', full_name: 'grupos_nome', label: "Nome"
|
46
|
-
# escopos
|
47
|
-
# escopos [[:maiores_que_1000, "Maiores"], [:menores_que_1000, "Menores"], [:ativos, "Ativos"], [:nao_ativos, "Desativos"]]
|
48
|
-
|
49
|
-
|
50
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
class VersionController < ApplicationController
|
2
|
-
VERSION_FILE = '../build-info/version.txt'
|
3
|
-
def display_version
|
4
|
-
path = File.join(RAILS_ROOT, VERSION_FILE)
|
5
|
-
render path
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
class <%=nome%>Crud < RaroCrud
|
10
|
-
titulo "<%nome.pluralize%>"
|
11
|
-
subtitulo "Subtitulo", :index
|
12
|
-
|
13
|
-
descricao "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.", :index
|
14
|
-
|
15
|
-
link_superior "Novo <%=nome%>", id: "novo-button", icon: "plus", link: "new"
|
16
|
-
|
17
|
-
ordenar_por :created_at
|
18
|
-
itens_por_pagina 5
|
19
|
-
|
20
|
-
#Exemplo de acao customizada
|
21
|
-
#acoes :associar, "Definir permissões", Proc.new {|p| Usuario.current.ability.can?(:create,p)}
|
22
|
-
|
23
|
-
#Campos mostrados na index
|
24
|
-
<%campos.each do |campo| %>
|
25
|
-
campo_tabela <%=campo.to_sym%>, label: "<%=campo.humanize%>"
|
26
|
-
<%end
|
27
|
-
|
28
|
-
#Campos mostrados no formulários de cadastro
|
29
|
-
<%campos.each do |campo| %>
|
30
|
-
campo_formulario <%=campo.to_sym%>, label: "<%=campo.humanize%>"
|
31
|
-
<%end
|
32
|
-
|
33
|
-
#Campos mostrados na visualizacao
|
34
|
-
<%campos.each do |campo| %>
|
35
|
-
campo_visualizacao <%=campo.to_sym%>, label: "<%=campo.humanize%>"
|
36
|
-
<%end
|
37
|
-
|
38
|
-
#Campos mostrados na busca
|
39
|
-
<%campos.each do |campo| %>
|
40
|
-
campo_busca <%=campo.to_sym%>, label: "<%=campo.humanize%>"
|
41
|
-
<%end
|
42
|
-
|
43
|
-
#Exemplos de customizacao
|
44
|
-
# Datepicker
|
45
|
-
# campo_formulario :data, label: "Data", as: :string, input_html: {class: "datepicker"}
|
46
|
-
# Checkbox
|
47
|
-
# campo_formulario :check, label: "Check", input_html: {class: "i-checks"}
|
48
|
-
# upload
|
49
|
-
# campo_formulario :arquivo, label: "Foto", input_html: {class: "ace-input-file"}
|
50
|
-
# Relacionamento
|
51
|
-
# campo_formulario :grupos, label: "Grupos",
|
52
|
-
# label_method: :nome,
|
53
|
-
# as: :check_boxes,
|
54
|
-
# input_html: {class: "i-checks"}
|
55
|
-
# campo_busca :nome, model: 'Grupo', full_name: 'grupos_nome', label: "Nome"
|
56
|
-
# escopos
|
57
|
-
# escopos [[:maiores_que_1000, "Maiores"], [:menores_que_1000, "Menores"], [:ativos, "Ativos"], [:nao_ativos, "Desativos"]]
|
58
|
-
end
|