templus_models 1.5.15 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c9e7f45b44a2a79d03a0e61eb6fd5ecf7c762169
4
- data.tar.gz: dc30934e74dde8a2d842ea33cd364330c5f1b2f6
3
+ metadata.gz: b887141343645d9ac164c5fec736112a4f68a3fe
4
+ data.tar.gz: 91c089d619d572a2998de38c8781a3bd8ebbe16f
5
5
  SHA512:
6
- metadata.gz: b3b0d3421f6f72e7f7bf5e56d3bce508a4d51e27d24d27576a240e1c05b544c5e99344059a794ff2928142fbf9e8fb30de7969e010214f75f6c0da9aec64beb7
7
- data.tar.gz: 4f3685bb1172cd51d0b08e2720f265356f81070f3aa97dc251b76abe9321fd73aca80175c71e919d93c4eb2ee7a207ad53df54a46fb506c61d1d5879166374bf
6
+ metadata.gz: dd0503928ce0f12f1a16ad7a66d01267576a1ac69e0aabacd5ac97fbf82d0c27fd5fbf61355ab09bb365b01dcefe199f926aabcefe035557bcfbf921b568d8af
7
+ data.tar.gz: a58b677b0f78b05ae83b6b87fd5a955d9897011910963d2243967d7fa682fe5118f917b99f1ec735a6df401f9f76f7a26159e0dd1bb494289138453cdf3d9dc3
@@ -0,0 +1,12 @@
1
+ // *.js.erb
2
+ var link_to = function(url, params) {
3
+ if(!!params){
4
+ var _params = [];
5
+ for(i in params) {
6
+ _params.push(i + '=' + params[i]);
7
+ }
8
+ return "<%= ENV['RAILS_RELATIVE_URL_ROOT']%>" + url + "?" + _params.join('&');
9
+ }else{
10
+ return "<%= ENV['RAILS_RELATIVE_URL_ROOT']%>" + url;
11
+ }
12
+ };
@@ -8,8 +8,7 @@ function new_record(id,name,model_name){
8
8
 
9
9
  var model_target = "#modal_new_record." + model_name;
10
10
 
11
-
12
- var url = "/crud/" + class_name + "/new.js?render=modal&attribute="+ model_name;
11
+ var url = link_to("/crud/" + class_name + "/new.js", {"render": "modal", "attribute": model_name});
13
12
  var jqxhr = $.ajax(url)
14
13
  .done(function(result) {
15
14
  $(model_target).attr('data-source',id);
@@ -1,6 +1,6 @@
1
1
  class CrudController < ApplicationController
2
2
  before_filter :setup, except: :autocomplete
3
-
3
+
4
4
  private
5
5
  def setup
6
6
  if params[:associacao]
@@ -8,18 +8,20 @@ class CrudController < ApplicationController
8
8
  @model = Module.const_get(params[:model].camelize).find(params[:id]).send(params[:associacao])
9
9
  c_helper = Module.const_get(params[:model].camelize).reflect_on_association(params[:associacao]).class_name
10
10
  @crud_helper = Module.const_get("#{c_helper}Crud") unless params[:render] == "modal" and params[:action] == "new"
11
+ @url = crud_associacao_models_path(model: params[:model], id: params[:id], associacao: params[:associacao], page: params[:page], q: params[:q])
12
+ @url_str = "/crud/#{params[:model]}/#{params[:id]}/#{params[:associacao]}/"
11
13
  @model_permission = c_helper.constantize
12
- @url = "/crud/#{params[:model]}/#{params[:id]}/#{params[:associacao]}"
13
14
  @id = params[:associacao_id] if params[:associacao_id]
14
15
  else
15
16
  @model = Module.const_get(params[:model].camelize)
16
17
  @model_permission = @model
17
18
  @crud_helper = Module.const_get("#{params[:model]}_crud".camelize) unless params[:render] == "modal" and params[:action] == "new"
18
- @url = "/crud/#{params[:model]}"
19
+ @url = crud_models_path(model: params[:model], page: params[:page], q: params[:q])
20
+ @url_str = "/crud/#{params[:model]}/"
19
21
  @id = params[:id] if params[:id]
20
22
  end
21
23
  end
22
-
24
+
23
25
  public
24
26
  def index
25
27
  authorize! :read, @model_permission if respond_to?(:current_usuario)
@@ -43,7 +45,7 @@ class CrudController < ApplicationController
43
45
  @titulo = @model.name.pluralize
44
46
  render partial: 'records' if request.respond_to?(:wiselinks_partial?) && request.wiselinks_partial?
45
47
  end
46
-
48
+
47
49
  def new
48
50
  if params[:render] == "modal"
49
51
  if @model.reflect_on_association(params[:attribute].to_s).present?
@@ -51,14 +53,14 @@ class CrudController < ApplicationController
51
53
  else
52
54
  @model = params[:attribute].to_s.camelcase.constantize
53
55
  end
56
+ @url = crud_models_path(model: @model.name.underscore)
54
57
  @model_permission = @model
55
- @url = "/crud/#{@model.name.underscore}"
56
58
  @crud_helper = Module.const_get("#{@model}Crud".camelize)
57
59
  end
58
60
  authorize! :new, @model_permission if respond_to?(:current_usuario)
59
61
  @record = @model.new
60
62
  end
61
-
63
+
62
64
  def edit
63
65
  @record = @model.find(@id)
64
66
  authorize! :edit, @record if respond_to?(:current_usuario)
@@ -85,7 +87,7 @@ class CrudController < ApplicationController
85
87
  render partial: "/#{@model.name.underscore.pluralize}/#{params[:acao]}" if request.respond_to?(:wiselinks_partial?) && request.wiselinks_partial?
86
88
  end
87
89
  end
88
-
90
+
89
91
  def create
90
92
  @saved = false
91
93
  if @id
@@ -97,11 +99,11 @@ class CrudController < ApplicationController
97
99
  authorize! :create, @model_permission if respond_to?(:current_usuario)
98
100
  @saved = @record.save
99
101
  end
100
-
102
+
101
103
  respond_to do |format|
102
104
  if @saved
103
105
  flash[:success] = params[:id].present? ? "Cadastro alterado com sucesso." : "Cadastro efetuado com sucesso."
104
- format.html { redirect_to "#{@url}?page=#{params[:page]}" }
106
+ format.html { redirect_to @url }
105
107
  unless params[:render] == 'modal'
106
108
  format.js { render action: :index}
107
109
  else
@@ -114,7 +116,7 @@ class CrudController < ApplicationController
114
116
  end
115
117
  end
116
118
  end
117
-
119
+
118
120
  def destroy
119
121
  @record = @model.find(@id)
120
122
  authorize! :destroy, @record if respond_to?(:current_usuario)
@@ -132,7 +134,7 @@ class CrudController < ApplicationController
132
134
  end
133
135
  end
134
136
  end
135
-
137
+
136
138
  def query
137
139
  authorize! :read, @model_permission if respond_to?(:current_usuario)
138
140
  @resource = @model
@@ -150,7 +152,7 @@ class CrudController < ApplicationController
150
152
  render :index, controller: request[:controller]
151
153
  end
152
154
  end
153
-
155
+
154
156
  def autocomplete
155
157
  @model = Module.const_get(params[:model].camelize)
156
158
  authorize! :read, @model if respond_to?(:current_usuario)
@@ -168,10 +170,10 @@ class CrudController < ApplicationController
168
170
  end
169
171
 
170
172
  private
171
- def params_permitt
173
+ def params_permitt
172
174
  params.require(@model.name.underscore.to_sym).permit(fields_model)
173
175
  end
174
-
176
+
175
177
  def fields_model
176
178
  fields = []
177
179
  @crud_helper.form_fields.each do |field|
@@ -201,7 +203,7 @@ class CrudController < ApplicationController
201
203
  end
202
204
  fields
203
205
  end
204
-
206
+
205
207
  def permitt_group(fields, key, groups,mod)
206
208
  chave = "#{key}_attributes"
207
209
  group = {chave => [:id, :_destroy]}
@@ -219,8 +221,8 @@ class CrudController < ApplicationController
219
221
  elsif (modelo.columns_hash[field[:attribute].to_s] || (modelo.respond_to?(:params_permitt) && modelo.params_permitt.include?(field[:attribute].to_sym)))
220
222
  group[chave] << field[:attribute]
221
223
  end
222
- end
224
+ end
223
225
  end
224
226
  group
225
227
  end
226
- end
228
+ end
@@ -1,5 +1,5 @@
1
1
  module CrudHelper
2
-
2
+
3
3
  def is_active_controller(controller_name)
4
4
  params[:controller] == controller_name ? "active" : nil
5
5
  end
@@ -7,7 +7,7 @@ module CrudHelper
7
7
  def is_active_action(action_name)
8
8
  params[:action] == action_name ? "active" : nil
9
9
  end
10
-
10
+
11
11
  def is_raro_crud(classe)
12
12
  #if(Rails.env == "production")
13
13
  # @@cruds = Dir[Rails.root.join("app","raro_crud","*.rb")].map{|f| f.split(/\//).last.gsub(/_crud\.rb/,'')} unless @@cruds
@@ -16,7 +16,7 @@ module CrudHelper
16
16
  #end
17
17
  return @@cruds.include?(classe.underscore.to_s)
18
18
  end
19
-
19
+
20
20
  def lista_menus_crud(raro_models)
21
21
  menus = []
22
22
  raro_models.each do |modelo|
@@ -24,7 +24,7 @@ module CrudHelper
24
24
  end
25
25
  menus
26
26
  end
27
-
27
+
28
28
  def menu_helper_crud(modelo, url, nome, classe, icon='')
29
29
  if can?(:read, classe)
30
30
  buffer = ""
@@ -58,8 +58,8 @@ module CrudHelper
58
58
  def is_action_query?
59
59
  params[:action] == "query"
60
60
  end
61
-
62
-
61
+
62
+
63
63
  def render_link(link,url)
64
64
  if link[:partial].present?
65
65
  render link[:partial]
@@ -72,7 +72,7 @@ module CrudHelper
72
72
 
73
73
  def gen_icon(i)
74
74
  if i
75
- "<i class='#{i}'></i>"
75
+ "<i class='#{i}'></i>"
76
76
  else
77
77
  ""
78
78
  end
@@ -94,7 +94,7 @@ module CrudHelper
94
94
  end
95
95
  models.uniq.flatten
96
96
  end
97
-
97
+
98
98
  def raro_permissions
99
99
  permissions = []
100
100
  Dir["#{Rails.root.to_s}/app/controllers/*"].each do |f|
@@ -113,7 +113,7 @@ module CrudHelper
113
113
  field[:sf][:wrapper] = :with_button
114
114
  render_field(field,f,modelo,record)
115
115
  end
116
-
116
+
117
117
  def render_field(field,f,modelo,record)
118
118
  field[:sf][:wrapper] ||= :default
119
119
  if field[:sf].present? && field[:sf][:if].present?
@@ -125,22 +125,22 @@ module CrudHelper
125
125
  end
126
126
  if !field[:sf][:edit].nil? || !field[:sf][:create].nil?
127
127
  if !field[:sf][:edit].nil? && !field[:sf][:edit] && !record.new_record?
128
- elsif !field[:sf][:create].nil? && !field[:sf][:create] && record.new_record?
129
- else
128
+ elsif !field[:sf][:create].nil? && !field[:sf][:create] && record.new_record?
129
+ else
130
130
  unless modelo.reflect_on_association(field[:attribute])
131
131
  if modelo.new.send(field[:attribute]).class.to_s =~ /Uploader/ and f.object.send(field[:attribute]).present?
132
132
  f.input field[:attribute], field[:sf].merge(hint: "Arquivo Atual: #{f.object.send(field[:attribute]).file.filename}")
133
133
  else
134
134
  f.input field[:attribute], field[:sf]
135
135
  end
136
- else
136
+ else
137
137
  f.association field[:attribute], field[:sf]
138
- end
139
- end
138
+ end
139
+ end
140
140
  else
141
141
  if field[:sf][:value] and field[:sf][:value].class == Proc
142
- field[:sf][:input_html] ||= {}
143
- field[:sf][:input_html][:value] = f.instance_eval &field[:sf][:value]
142
+ field[:sf][:input_html] ||= {}
143
+ field[:sf][:input_html][:value] = f.instance_eval &field[:sf][:value]
144
144
  end
145
145
  if field[:sf][:collection_if] and field[:sf][:collection_if].class == Proc
146
146
  field[:sf][:collection] = f.instance_eval &field[:sf][:collection_if]
@@ -151,24 +151,24 @@ module CrudHelper
151
151
  else
152
152
  f.input field[:attribute], field[:sf]
153
153
  end
154
- else
154
+ else
155
155
  f.association field[:attribute], field[:sf]
156
- end
156
+ end
157
157
  end
158
158
  end
159
-
159
+
160
160
  def imagem?(file)
161
161
  file.present? && file.content_type.start_with?('image')
162
162
  end
163
163
 
164
164
  def video?(file)
165
165
  file.present? && file.content_type.start_with?('video')
166
- end
167
-
166
+ end
167
+
168
168
  def documento?(file)
169
169
  !(video?(file) || imagem?(file))
170
170
  end
171
-
171
+
172
172
  def render_field_file(field)
173
173
  if imagem?(field) && field.url(:thumb)
174
174
  image_tag(field.url(:thumb))
@@ -178,31 +178,31 @@ module CrudHelper
178
178
  link_to field, field.url, target: "_blank"
179
179
  end
180
180
  end
181
-
181
+
182
182
  def render_crud(&block)
183
183
  render "/crud/shared", block: block
184
184
  end
185
-
185
+
186
186
  def render_default_actions_crud
187
187
  render "default_actions_crud"
188
188
  end
189
-
189
+
190
190
  #Permissions
191
- def shold_view?(crud_helper,record)
191
+ def should_view?(crud_helper,record)
192
192
  return false unless can?(:read, record)
193
193
  return true if crud_helper.condition_view_action.nil?
194
194
  crud_helper.condition_view_action.call(record)
195
195
  end
196
196
 
197
- def shold_edit?(crud_helper,record)
197
+ def should_edit?(crud_helper,record)
198
198
  return false unless can?(:update, record)
199
199
  return true if crud_helper.condition_edit_action.nil?
200
200
  crud_helper.condition_edit_action.call(record)
201
201
  end
202
202
 
203
- def shold_destroy?(crud_helper,record)
203
+ def should_destroy?(crud_helper,record)
204
204
  return false unless can?(:destroy, record)
205
205
  return true if crud_helper.condition_destroy_action.nil?
206
206
  crud_helper.condition_destroy_action.call(record)
207
207
  end
208
- end
208
+ end
@@ -72,7 +72,7 @@ class RaroCrud
72
72
  end
73
73
 
74
74
  def self.root_path
75
- "/crud/#{self.to_s.gsub('Crud', '').underscore}"
75
+ self.to_s.gsub('Crud', '').underscore
76
76
  end
77
77
 
78
78
  def self.index_path str
@@ -238,7 +238,7 @@ class RaroCrud
238
238
  if opts.present? && opts[:autocomplete].present?
239
239
  opts[:as] = :autocomplete
240
240
  label_method = opts[:autocomplete][:label_method] || opts[:autocomplete][:campo]
241
- opts[:url] = "/crud/#{opts[:autocomplete][:classe]}/autocomplete?campo=#{opts[:autocomplete][:campo]}&tipo=start&label=#{label_method}"
241
+ opts[:url] = autocomplete_crud_path(model: opts[:autocomplete][:classe], campo: opts[:autocomplete][:campo], tipo: "start", label: label_method)
242
242
  name = "#{opts[:autocomplete][:campo]}_#{opts[:autocomplete][:classe]}"
243
243
  opts[:input_html] = {name: name, id: name}
244
244
  opts[:id_element] = "##{self.modelo}_#{nome}_id"
@@ -3,7 +3,7 @@
3
3
  <% if @crud_associacao.present? %>
4
4
  <li class=""><%= link_to @crud_associacao.title, @crud_associacao.root_path %></li>
5
5
  <% end %>
6
- <li class=""><%= link_to @crud_helper.title, @crud_helper.root_path %></li>
6
+ <li class=""><%= link_to @crud_helper.title, crud_models_path(model: @crud_helper.root_path) %></li>
7
7
  <% end %>
8
8
 
9
9
 
@@ -1,2 +1,2 @@
1
1
  <%= submit_tag("Salvar", class: "btn btn-primary") %>
2
- <%= link_to "Voltar", @url, class: 'btn btn-default', data: {push: 'partial', target: "#form"} %>
2
+ <%= link_to "Voltar", @url, class: 'btn btn-default', data: {push: 'partial', target: "#form"} %>
@@ -11,10 +11,22 @@
11
11
  </div>
12
12
  </div>
13
13
  <%unless params[:render] == 'modal'%>
14
- <% url = "#{@url}/#{@record.new_record? ? 'create' : @record.id.to_s+'/create'}?page=#{params[:page]}" %>
14
+ <% if @record.new_record? %>
15
+ <% if @crud_associacao.present? %>
16
+ <% url = create_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], page: params[:page], q: params[:q]) %>
17
+ <% else %>
18
+ <% url = create_crud_path(model: @model.name.underscore, page: params[:page], q: params[:q]) %>
19
+ <% end %>
20
+ <% else %>
21
+ <% if @crud_associacao.present? %>
22
+ <% url = update_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: @record.id, page: params[:page], q: params[:q]) %>
23
+ <% else %>
24
+ <% url = update_crud_path(model: @model.name.underscore, id: @record.id, page: params[:page], q: params[:q]) %>
25
+ <% end %>
26
+ <% end %>
15
27
  <% remote_form = false%>
16
28
  <%else%>
17
- <% url = "#{@url}/#{@record.new_record? ? 'create?render=modal' : @record.id.to_s+'/create?render=modal'}" %>
29
+ <% url = "#{@url_str}/#{@record.new_record? ? 'create?render=modal' : @record.id.to_s+'/create?render=modal'}" %>
18
30
  <% remote_form = true%>
19
31
  <%end%>
20
32
  <%= simple_nested_form_for @record, remote: remote_form, html: {class: "form-horizontal"}, url: url do |f| %>
@@ -40,7 +52,7 @@
40
52
  <div class="col-sm-4 col-sm-offset-2">
41
53
  <%= f.submit "Salvar", class: 'btn btn-primary' %>
42
54
  <%unless params[:render] == 'modal'%>
43
- <%= link_to "Voltar", "#{@url}?page=#{params[:page]}", class: 'btn btn-default', data: {push: 'partial', target: "#form"} %>
55
+ <%= link_to "Voltar", @url, class: 'btn btn-default', data: {push: 'partial', target: "#form"} %>
44
56
  <% end %>
45
57
  </div>
46
58
  </div>
@@ -29,12 +29,12 @@
29
29
  <% end %>
30
30
  </td>
31
31
  <% elsif record.send(att[:attribute]).respond_to?(:url) and record.send(att[:attribute]).url(:thumb) %>
32
- <td><%= image_tag(record.send(att[:attribute]).url(:thumb)) %></td>
32
+ <td><%= image_tag(record.send(att[:attribute]).url(:thumb)) %></td>
33
33
  <% else %>
34
34
  <% if record.send(att[:attribute]).to_s == "false" or record.send(att[:attribute]).to_s == "true" %>
35
- <td><%= record.send(att[:attribute]) ? "Sim" : "Não" %></td>
35
+ <td><%= record.send(att[:attribute]) ? "Sim" : "Não" %></td>
36
36
  <% else %>
37
- <td><%= record.send(att[:attribute]).to_s %></td>
37
+ <td><%= record.send(att[:attribute]).to_s %></td>
38
38
  <% end %>
39
39
  <% end %>
40
40
  <% else %>
@@ -44,8 +44,7 @@
44
44
  <td>
45
45
  <%@crud_helper.actions.each do |a|%>
46
46
  <% if ((a[2].present? && a[2].call(record)) || !a[2].present?) %>
47
- <a href="/crud/<%=@model.name.underscore%>/<%=record.id%>/acao/<%=a[0]%>"
48
- class="btn btn-primary btn-xs" data-push="partial" data-target="#form"><%=a[1]%></a>
47
+ <%= link_to a[1], action_crud_path(model: @model.name.underscore, id: record.id, acao: a[0], page: params[:page], q: params[:q]), class: "btn btn-primary btn-xs", data: {push: "partial", target: "#form"}%>
49
48
  <% end %>
50
49
  <% end %>
51
50
  <%@crud_helper.actions_links.each do |name, options|%>
@@ -64,24 +63,31 @@
64
63
  </a>
65
64
  <% end %>
66
65
  <% elsif options[:associacao].present? %>
67
- <a href="/crud/<%= @model.name.underscore %>/<%= record.id %>/<%= options[:associacao].to_s %>" class="btn btn-success btn-xs">
68
- <%=name%>
69
- </a>
66
+ <%= link_to name, crud_associacao_models_path(model: @model.name.underscore, id: record.id, associacao: options[:associacao].to_s), class: "btn btn-success btn-xs", data: {push: "partial", target: "#form"} %>
70
67
  <% elsif options[:partial].present? %>
71
68
  <%= render options[:partial], record: record %>
72
69
  <% end %>
73
70
  <% end %>
74
- <%if @crud_helper.view_action && shold_view?(@crud_helper, record)%>
75
- <a href="<%= @url %>/<%=record.id%>?page=<%=params[:page]%>"
76
- class="btn btn-primary btn-xs" data-push="partial" data-target="#form">Visualizar</a>
71
+ <%if @crud_helper.view_action && should_view?(@crud_helper, record)%>
72
+ <% if @crud_associacao.present? %>
73
+ <%= link_to "Visualizar", crud_associacao_model_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs', data: {push: 'partial', target: '#form'} %>
74
+ <% else %>
75
+ <%= link_to "Visualizar", crud_model_path(model: @model.name.underscore, id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs', data: {push: 'partial', target: '#form'} %>
76
+ <% end %>
77
77
  <% end %>
78
- <%if @crud_helper.edit_action && shold_edit?(@crud_helper, record) %>
79
- <a href="<%= @url %>/<%=record.id%>/edit?page=<%=params[:page]%>"
80
- class="btn btn-primary btn-xs" data-push="partial" data-target="#form">Editar</a>
78
+ <%if @crud_helper.edit_action && should_edit?(@crud_helper, record) %>
79
+ <% if @crud_associacao.present? %>
80
+ <%= link_to "Editar", edit_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs', data: {push: 'partial', target: '#form'} %>
81
+ <% else %>
82
+ <%= link_to "Editar", edit_crud_path(model: @model.name.underscore, id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs', data: {push: 'partial', target: '#form'} %>
83
+ <% end %>
81
84
  <% end %>
82
- <%if @crud_helper.destroy_action && shold_destroy?(@crud_helper, record)%>
83
- <a href="<%= @url %>/<%=record.id%>/destroy"
84
- class="btn btn-danger btn-xs" data-method="delete" data-confirm="Você têm certeza?">Excluir</a>
85
+ <%if @crud_helper.destroy_action && should_destroy?(@crud_helper, record)%>
86
+ <% if @crud_associacao.present? %>
87
+ <%= link_to "Excluir", destroy_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-danger btn-xs', data: {method: 'delete', confirm: 'Você tem certeza?'} %>
88
+ <% else %>
89
+ <%= link_to "Excluir", destroy_crud_path(model: @model.name.underscore, id: record.id, page: params[:page], q: params[:q]), class: 'btn btn-danger btn-xs', data: {method: 'delete', confirm: 'Você tem certeza?'} %>
90
+ <% end %>
85
91
  <% end %>
86
- </td>
92
+ </td>
87
93
  <% end %>
@@ -1,8 +1,8 @@
1
1
  <% if @crud_helper.layout[1].present? and @crud_helper.layout[1].call() and @crud_helper.layout[0] == "escopo_lateral" %>
2
2
  <% if @crud_helper.scopes.present? %>
3
3
  <div class="col-lg-3" style="padding-right:0;">
4
- <div class="ibox float-e-margins" style="padding-top:40px">
5
- <div class="ibox-content">
4
+ <div class="ibox float-e-margins" style="padding-top:40px">
5
+ <div class="ibox-content">
6
6
  <div class="file-manager">
7
7
  <%= render '/crud/scopes' %>
8
8
  </div>
@@ -11,7 +11,7 @@
11
11
  </div>
12
12
  <% end %>
13
13
  <% end %>
14
- <div class="col-lg-<%= @crud_helper.layout[1].present? and @crud_helper.layout[1].call() and @crud_helper.layout[0] == "escopo_lateral" and @crud_helper.scopes.present? ? 9 : 12 %>" style="padding-left:0;">
14
+ <div class="col-lg-<%= @crud_helper.layout[1].present? && @crud_helper.layout[1].call() && @crud_helper.layout[0] == 'escopo_lateral' && @crud_helper.scopes.present? ? 9 : 12 %>" style="padding-left:0;">
15
15
  <%= render_crud do %>
16
16
  <div>
17
17
  <%= render "/crud/links" %>
@@ -48,4 +48,4 @@
48
48
  <%= paginate @records, target: '#form', theme: 'templus'%>
49
49
  </div>
50
50
  <% end %>
51
- </div>
51
+ </div>
@@ -1,7 +1,7 @@
1
1
  <% if @crud_helper.scopes.present? %>
2
2
  <% if @crud_helper.scopes.class == Array %>
3
3
  <% @crud_helper.scopes.each do |escopo| %>
4
- <%= link_to "#{@url}?scope=#{escopo[0]}", id: "#{escopo[0]}", data: {push: true, crumb: 'wielka'} do%>
4
+ <%= link_to crud_models_path(model: @model.name.underscore, scope: escopo[0]), id: "#{escopo[0]}", data: {push: true, crumb: 'wielka'} do%>
5
5
  <div style="float: left; margin-left: 10px; min-width: 100px; position:relative;">
6
6
  <div class="widget style1 gray-bg" style="padding:15px 0px!important;">
7
7
  <div class="row vertical-align text-center" style="margin:0!important;">
@@ -23,4 +23,4 @@
23
23
  <% else %>
24
24
  <%= render @crud_helper.scopes %>
25
25
  <% end %>
26
- <% end %>
26
+ <% end %>
@@ -8,7 +8,12 @@
8
8
  <small class="font-bold"></small>
9
9
  </div>
10
10
  <div class="modal-body">
11
- <%=raro_search_form(@model, 'records','records',"#{@url}/query") do%>
11
+ <% if @crud_associacao.present? %>
12
+ <% url = query_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao]) %>
13
+ <% else %>
14
+ <% url = query_crud_path(model: @model.name.underscore) %>
15
+ <% end %>
16
+ <%=raro_search_form(@model, 'records','records', url) do%>
12
17
  <%raro_group "#{@crud_helper.title}"%>
13
18
  <%@crud_helper.search_fields.each do |att| %>
14
19
  <% if att[:sf].present? && !att[:sf][:visible_if].nil?%>
@@ -22,4 +27,4 @@
22
27
  </div>
23
28
  </div>
24
29
  </div>
25
- </div>
30
+ </div>
@@ -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,@url) if self.instance_eval &link[:can]%>
29
+ <%=render_link(link,@url_str) if self.instance_eval &link[:can]%>
30
30
  <% else %>
31
- <%=render_link(link,@url)%>
31
+ <%=render_link(link,@url_str)%>
32
32
  <% end %>
33
33
  <%end%>
34
34
  <% if @crud_helper.search_fields.present? %>
@@ -37,6 +37,21 @@
37
37
  </button>
38
38
  <% end %>
39
39
  </div>
40
+ <% elsif is_action_show? %>
41
+ <% if (@crud_helper.present? && @crud_helper.destroy_action) && should_destroy?(@crud_helper, @record) %>
42
+ <% if @crud_associacao.present? %>
43
+ <%= link_to "Excluir", destroy_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-danger btn-xs pull-right m-l-xs', data: {method: 'delete', confirm: 'Você tem certeza?'} %>
44
+ <% else %>
45
+ <%= link_to "Excluir", destroy_crud_path(model: @model.name.underscore, id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-danger btn-xs pull-right m-l-xs', data: {method: 'delete', confirm: 'Você tem certeza?'} %>
46
+ <% end %>
47
+ <% end %>
48
+ <% if (@crud_helper.present? && @crud_helper.edit_action) && should_edit?(@crud_helper, @record) %>
49
+ <% if @crud_associacao.present? %>
50
+ <%= link_to "Editar", edit_crud_associacao_path(model: params[:model], id: params[:id], associacao: params[:associacao], associacao_id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs pull-right m-l-xs', data: {push: 'partial', target: '#form'} %>
51
+ <% else %>
52
+ <%= link_to "Editar", edit_crud_path(model: @model.name.underscore, id: @record.id, page: params[:page], q: params[:q]), class: 'btn btn-primary btn-xs pull-right m-l-xs', data: {push: 'partial', target: '#form'} %>
53
+ <% end %>
54
+ <% end %>
40
55
  <% end %>
41
56
  </div>
42
57
  <div class="ibox-content">
@@ -48,4 +63,4 @@
48
63
  </div>
49
64
  <% else %>
50
65
  <% block.call %>
51
- <% end %>
66
+ <% end %>
@@ -73,5 +73,5 @@
73
73
  </div>
74
74
  </div>
75
75
  <hr>
76
- <%= link_to "Voltar", "#{@url}" ,class: 'btn btn-default', data: {push: 'partial', target: "#form"} %>
77
- <% end %>
76
+ <%= link_to "Voltar", @url ,class: 'btn btn-default', data: {push: 'partial', target: "#form"} %>
77
+ <% end %>
@@ -1,6 +1,12 @@
1
1
  <% content_for :corpo do %>
2
2
  <div id="form" >
3
- <%= render '/crud/records' %>
3
+ <% if @crud_helper.layout[1].present? and @crud_helper.layout[1].call() and @crud_helper.layout[0] == "escopo_lateral" %>
4
+ <div class="row">
5
+ <%= render '/crud/records' %>
6
+ </div>
7
+ <% else %>
8
+ <%= render '/crud/records' %>
9
+ <% end %>
4
10
  </div>
5
11
  <% end %>
6
12
 
@@ -1,6 +1,21 @@
1
1
  <%= paginator.render do -%>
2
2
  <div class="row">
3
- <div class="col-xs-12">
3
+ <div class="col-xs-4">
4
+ <div class="pagination pull-left">
5
+ <% if @options[:current_page].number < 2 %>
6
+ <% inicio = 1 %>
7
+ <% else %>
8
+ <% inicio = ((@options[:current_page].number - 1) * @options[:per_page]) + 1 %>
9
+ <% end %>
10
+ <% if @options[:current_page].last? %>
11
+ <% fim = @options[:total_count] %>
12
+ <% else %>
13
+ <% fim = @options[:current_page].number * @options[:per_page] %>
14
+ <% end %>
15
+ Exibindo <%= inicio %> - <%= fim %> de um total de <%= @options[:total_count] %>
16
+ </div>
17
+ </div>
18
+ <div class="col-xs-8">
4
19
  <div class="dataTables_paginate paging_simple_numbers">
5
20
  <ul class="pagination">
6
21
  <%= first_page_tag unless current_page.first? %>
@@ -8,7 +8,9 @@
8
8
  </h2>
9
9
  <ol class="breadcrumb">
10
10
  <li>
11
- <a href="/">Home</a>
11
+ <%= link_to root_path do %>
12
+ Home
13
+ <% end %>
12
14
  </li>
13
15
  <% if content_for? :breadcumb %>
14
16
  <%= yield :breadcumb %>
data/config/routes.rb CHANGED
@@ -1,25 +1,25 @@
1
1
  Rails.application.routes.draw do
2
2
  # Routes for RaroCrud
3
- get '/crud/:model' => "crud#index"
4
- get '/crud/:model/:id/edit' => "crud#edit"
5
- delete '/crud/:model/:id/destroy' => "crud#destroy"
6
- get '/crud/:model/new' => "crud#new"
7
- get '/crud/:model/query' => "crud#query"
8
- get '/crud/:model/autocomplete' => "crud#autocomplete"
9
- post '/crud/:model/create' => "crud#create"
10
- patch '/crud/:model/:id/create' => "crud#create"
11
- get '/crud/:model/:id/acao/:acao' => "crud#action"
12
- get '/crud/:model/:id' => "crud#show"
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
+ patch '/crud/:model/:id/create' => "crud#create", as: :update_crud
11
+ get '/crud/:model/:id/acao/:acao' => "crud#action", as: :action_crud
12
+ get '/crud/:model/:id' => "crud#show", as: :crud_model
13
13
 
14
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"
15
+ get '/crud/:model/:id/:associacao' => "crud#index", as: :crud_associacao_models
16
+ get '/crud/:model/:id/:associacao/:associacao_id/edit' => "crud#edit", as: :edit_crud_associacao
17
+ delete '/crud/:model/:id/:associacao/:associacao_id/destroy' => "crud#destroy", as: :destroy_crud_associacao
18
+ get '/crud/:model/:id/:associacao/new' => "crud#new", as: :new_crud_associacao
19
+ get '/crud/:model/:id/:associacao/query' => "crud#query", as: :query_crud_associacao
20
+ get '/crud/:model/:id/:associacao/autocomplete' => "crud#autocomplete", as: :autocomplete_crud_associacao
21
+ post '/crud/:model/:id/:associacao/create' => "crud#create", as: :create_crud_associacao
22
+ patch '/crud/:model/:id/:associacao/:associacao_id/create' => "crud#create", as: :update_crud_associacao
23
+ get '/crud/:model/:id/:associacao/:associacao_id/acao/:acao' => "crud#action", as: :action_crud_associacao
24
+ get '/crud/:model/:id/:associacao/:associacao_id' => "crud#show", as: :crud_associacao_model
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module TemplusModels
2
- VERSION = "1.5.15"
2
+ VERSION = "1.6.0"
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: 1.5.15
4
+ version: 1.6.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: 2016-04-18 00:00:00.000000000 Z
12
+ date: 2016-05-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -133,6 +133,7 @@ extra_rdoc_files: []
133
133
  files:
134
134
  - MIT-LICENSE
135
135
  - Rakefile
136
+ - app/assets/javascripts/link_to.js.erb
136
137
  - app/assets/javascripts/raro_crud.js
137
138
  - app/assets/javascripts/templus_models.js.coffee
138
139
  - app/controllers/crud_controller.rb