lipsiadmin 5.1.6 → 5.1.7
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.
- data/lib/access_control/authentication.rb +20 -20
- data/lib/access_control/base.rb +40 -40
- data/lib/controller/ext.rb +27 -27
- data/lib/controller/lipsiadmin_controller.rb +3 -3
- data/lib/controller/pdf_builder.rb +33 -31
- data/lib/controller/rescue.rb +12 -12
- data/lib/controller/responds_to_parent.rb +5 -5
- data/lib/data_base/attachment.rb +60 -60
- data/lib/data_base/attachment/attach.rb +18 -18
- data/lib/data_base/attachment/geometry.rb +7 -7
- data/lib/data_base/attachment/iostream.rb +1 -1
- data/lib/data_base/attachment/processor.rb +2 -2
- data/lib/data_base/attachment/storage.rb +11 -11
- data/lib/data_base/attachment/thumbnail.rb +2 -2
- data/lib/data_base/attachment_table.rb +27 -27
- data/lib/data_base/translate_attributes.rb +9 -9
- data/lib/data_base/utility_scopes.rb +7 -7
- data/lib/data_base/without_table.rb +10 -10
- data/lib/generator.rb +4 -4
- data/lib/loops.rb +77 -77
- data/lib/loops/base.rb +2 -2
- data/lib/loops/daemonize.rb +5 -5
- data/lib/loops/process_manager.rb +3 -3
- data/lib/loops/worker.rb +1 -1
- data/lib/loops/worker_pool.rb +1 -1
- data/lib/mailer/exception_notifier.rb +5 -5
- data/lib/mailer/pdf_builder.rb +20 -18
- data/lib/utils/literal.rb +6 -6
- data/lib/utils/pdf_builder.rb +10 -10
- data/lib/version.rb +1 -1
- data/lib/view/helpers/backend_helper.rb +123 -123
- data/lib/view/helpers/ext/button.rb +7 -7
- data/lib/view/helpers/ext/column_model.rb +18 -18
- data/lib/view/helpers/ext/component.rb +50 -50
- data/lib/view/helpers/ext/configuration.rb +5 -5
- data/lib/view/helpers/ext/grid.rb +46 -46
- data/lib/view/helpers/ext/store.rb +14 -14
- data/lib/view/helpers/ext/tool_bar.rb +6 -6
- data/lib/view/helpers/ext_helper.rb +21 -21
- data/lib/view/helpers/frontend_helper.rb +5 -5
- data/lib/view/helpers/pdf_helper.rb +7 -7
- data/lib/view/helpers/view_helper.rb +28 -28
- data/lipsiadmin_generators/attachment/attachment_generator.rb +7 -7
- data/lipsiadmin_generators/attachment/templates/controller.rb +13 -13
- data/lipsiadmin_generators/attachment/templates/migration.rb +1 -1
- data/lipsiadmin_generators/backend/backend_generator.rb +9 -9
- data/lipsiadmin_generators/backend/templates/controllers/backend/accounts_controller.rb +10 -10
- data/lipsiadmin_generators/backend/templates/controllers/backend/sessions_controller.rb +2 -2
- data/lipsiadmin_generators/backend/templates/controllers/javascripts_controller.rb +2 -2
- data/lipsiadmin_generators/backend/templates/migrations/create_accounts.rb +5 -5
- data/lipsiadmin_generators/backend/templates/models/account.rb +16 -16
- data/lipsiadmin_generators/backend/templates/models/account_access.rb +11 -11
- data/lipsiadmin_generators/backend/templates/models/notifier.rb +2 -2
- data/lipsiadmin_generators/backend_page/backend_page_generator.rb +22 -22
- data/lipsiadmin_generators/backend_page/templates/controller.rb +9 -9
- data/lipsiadmin_generators/backend_page/templates/functional_test.rb +10 -10
- data/lipsiadmin_generators/frontend/frontend_generator.rb +5 -5
- data/lipsiadmin_generators/frontend/templates/controllers/frontend/sessions_controller.rb +3 -3
- data/lipsiadmin_generators/loops/loops_generator.rb +2 -2
- data/lipsiadmin_generators/pdf/pdf_generator.rb +7 -7
- data/lipsiadmin_generators/state_session/state_session_generator.rb +9 -9
- data/lipsiadmin_generators/state_session/templates/controller.rb +2 -2
- data/lipsiadmin_generators/state_session/templates/migration.rb +2 -2
- data/resources/rdoc/horo.rb +3 -3
- metadata +4 -4
@@ -3,32 +3,32 @@ module Lipsiadmin
|
|
3
3
|
# This provide a simple login for backend and frontend.
|
4
4
|
# Use backend_login_required in backend and
|
5
5
|
# frontend_login_requirded in frontend.
|
6
|
-
#
|
6
|
+
#
|
7
7
|
# Examples:
|
8
|
-
#
|
8
|
+
#
|
9
9
|
# class FrontendController < ApplicationController
|
10
10
|
# before_filter :frontend_login_required, :except => [:login]
|
11
11
|
# end
|
12
|
-
#
|
12
|
+
#
|
13
13
|
module Authentication
|
14
14
|
protected
|
15
|
-
|
15
|
+
|
16
16
|
# Returns true if <tt>current_account</tt> is logged and active.
|
17
17
|
def logged_in?
|
18
18
|
current_account != :false && current_account.active?
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
# Returns the current_account, it's an instance of <tt>Account</tt> model
|
22
22
|
def current_account
|
23
23
|
@current_account ||= (login_from_session || :false)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
# Ovverride the current_account, you must provide an instance of Account Model
|
27
|
-
#
|
27
|
+
#
|
28
28
|
# Examples:
|
29
|
-
#
|
29
|
+
#
|
30
30
|
# current_account = Account.last
|
31
|
-
#
|
31
|
+
#
|
32
32
|
def current_account=(new_account)
|
33
33
|
session[:account] = (new_account.nil? || new_account.is_a?(Symbol)) ? nil : new_account.id
|
34
34
|
@current_account = new_account
|
@@ -36,42 +36,42 @@ module Lipsiadmin
|
|
36
36
|
|
37
37
|
# Returns true if the <tt>current_account</tt> is allowed to see the requested
|
38
38
|
# controller/action.
|
39
|
-
#
|
39
|
+
#
|
40
40
|
# For configure this role please refer to: <tt>Lipsiadmin::AccessControl::Base</tt>
|
41
41
|
def allowed?
|
42
42
|
maps = AccountAccess.maps_for(current_account)
|
43
|
-
|
43
|
+
|
44
44
|
allowed = maps.collect(&:allowed).flatten.uniq
|
45
45
|
denied = maps.collect(&:denied).flatten.uniq
|
46
|
-
|
46
|
+
|
47
47
|
allow = allowed.find do |a|
|
48
48
|
a[:controller] == params[:controller] &&
|
49
49
|
(a[:action].blank? || a[:action] == params[:action])
|
50
50
|
end
|
51
|
-
|
51
|
+
|
52
52
|
deny = denied.find do |a|
|
53
53
|
a[:controller] == params[:controller] &&
|
54
54
|
(a[:action].blank? || a[:action] == params[:action])
|
55
55
|
end
|
56
|
-
|
56
|
+
|
57
57
|
return allow && !deny
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
# Returns a helper to pass in a <tt>before_filter</tt> for check if
|
61
61
|
# an account are: <tt>logged_in?</tt> and <tt>allowed?</tt>
|
62
|
-
#
|
62
|
+
#
|
63
63
|
# By default this method is used in BackendController so is not necessary
|
64
64
|
def backend_login_required
|
65
65
|
logged_in? && allowed? || access_denied(:backend)
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
# Returns a helper to pass in a <tt>before_filter</tt> for check if
|
69
69
|
# an account are: <tt>logged_in?</tt> and <tt>allowed?</tt>
|
70
70
|
#
|
71
71
|
# Examples:
|
72
|
-
#
|
72
|
+
#
|
73
73
|
# before_filter :frontend_login_required, :except => [:some]
|
74
|
-
#
|
74
|
+
#
|
75
75
|
def frontend_login_required
|
76
76
|
logged_in? && allowed? || access_denied(:frontend)
|
77
77
|
end
|
@@ -87,7 +87,7 @@ module Lipsiadmin
|
|
87
87
|
def store_location#:nodoc:
|
88
88
|
session[:return_to] = request.request_uri
|
89
89
|
end
|
90
|
-
|
90
|
+
|
91
91
|
# Redirect the account to the page that requested an authentication or
|
92
92
|
# if the account is not allowed/logged return it to a default page
|
93
93
|
def redirect_back_or_default(default)
|
data/lib/access_control/base.rb
CHANGED
@@ -9,15 +9,15 @@ module Lipsiadmin
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
# This Class map and get roles/projects for accounts
|
14
|
-
#
|
14
|
+
#
|
15
15
|
# Examples:
|
16
|
-
#
|
16
|
+
#
|
17
17
|
# roles_for :administrator do |role, current_account|
|
18
18
|
# role.allow_all_actions "/backend/base"
|
19
19
|
# role.deny_action_of "/backend/accounts/details"
|
20
|
-
#
|
20
|
+
#
|
21
21
|
# role.project_module :administration do |project|
|
22
22
|
# project.menu :general_settings, "/backend/settings" do |submenu|
|
23
23
|
# submenu.add :accounts, "/backend/accounts" do |submenu|
|
@@ -25,29 +25,29 @@ module Lipsiadmin
|
|
25
25
|
# end
|
26
26
|
# end
|
27
27
|
# end
|
28
|
-
#
|
28
|
+
#
|
29
29
|
# role.project_module :categories do |project|
|
30
30
|
# current_account.categories.each do |cat|
|
31
31
|
# project.menu cat.name, "/backend/categories/#{cat.id}.js"
|
32
32
|
# end
|
33
33
|
# end
|
34
34
|
# end
|
35
|
-
#
|
35
|
+
#
|
36
36
|
# If a user logged with role administrator or that have a project_module administrator can:
|
37
|
-
#
|
37
|
+
#
|
38
38
|
# - Access in all actions of "/backend/base" controller
|
39
39
|
# - Denied access to ONLY action <tt>"/backend/accounts/details"</tt>
|
40
40
|
# - Access to a project module called Administration
|
41
41
|
# - Access to all actions of the controller "/backend/settings"
|
42
42
|
# - Access to all actions of the controller "/backend/categories"
|
43
43
|
# - Access to all actions EXCEPT <tt>details</tt> of controller "/backend/accounts"
|
44
|
-
#
|
44
|
+
#
|
45
45
|
class Base
|
46
46
|
@@cache = {}
|
47
47
|
cattr_accessor :cache
|
48
|
-
|
48
|
+
|
49
49
|
class << self
|
50
|
-
|
50
|
+
|
51
51
|
# We map project modules for a given role or roles
|
52
52
|
def roles_for(*roles, &block)
|
53
53
|
roles.each { |role| raise AccessControlError, "Role #{role} must be a symbol!" unless role.is_a?(Symbol) }
|
@@ -56,7 +56,7 @@ module Lipsiadmin
|
|
56
56
|
@roles.concat(roles)
|
57
57
|
@mappers << Proc.new { |account| Mapper.new(account, *roles, &block) }
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
# Returns all roles
|
61
61
|
def roles
|
62
62
|
@roles.nil? ? [] : @roles.collect(&:to_s)
|
@@ -70,11 +70,11 @@ module Lipsiadmin
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
73
|
+
|
74
74
|
class Mapper
|
75
75
|
include Helper
|
76
76
|
attr_reader :project_modules, :roles
|
77
|
-
|
77
|
+
|
78
78
|
def initialize(account, *roles, &block)#:nodoc:
|
79
79
|
@project_modules = []
|
80
80
|
@allowed = []
|
@@ -84,59 +84,59 @@ module Lipsiadmin
|
|
84
84
|
# Mantain backward compatibility
|
85
85
|
yield(self, Account.find(@account_id)) rescue yield(self)
|
86
86
|
end
|
87
|
-
|
87
|
+
|
88
88
|
# Create a new project module
|
89
89
|
def project_module(name, controller=nil, &block)
|
90
90
|
@project_modules << ProjectModule.new(name, controller, &block)
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
# Globally allow an action of a controller for the current role
|
94
94
|
def allow_action(path)
|
95
95
|
@allowed << recognize_path(path)
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
# Globally deny an action of a controllerfor the current role
|
99
99
|
def deny_action(path)
|
100
100
|
@denied << recognize_path(path)
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
# Globally allow all actions from a controller for the current role
|
104
104
|
def allow_all_actions(path)
|
105
105
|
@allowed << { :controller => recognize_path(path)[:controller] }
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
# Globally denty all actions from a controller for the current role
|
109
109
|
def deny_all_actions(path)
|
110
110
|
@denied << { :controller => recognize_path(path)[:controller] }
|
111
111
|
end
|
112
|
-
|
112
|
+
|
113
113
|
# Return true if current_account role is included in given roles
|
114
114
|
def allowed?
|
115
115
|
@roles.any? { |r| r.to_s.downcase == Account.find(@account_id).role.downcase }
|
116
116
|
end
|
117
|
-
|
117
|
+
|
118
118
|
# Return allowed actions/controllers
|
119
119
|
def allowed
|
120
120
|
# I know is a double check but is better 2 times that no one.
|
121
121
|
if allowed?
|
122
122
|
@project_modules.each { |pm| @allowed.concat pm.allowed }
|
123
123
|
@allowed.uniq
|
124
|
-
else
|
124
|
+
else
|
125
125
|
[]
|
126
126
|
end
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
# Return denied actions/controllers
|
130
130
|
def denied
|
131
131
|
@denied.uniq
|
132
132
|
end
|
133
133
|
end
|
134
|
-
|
134
|
+
|
135
135
|
class ProjectModule
|
136
136
|
include Helper
|
137
137
|
include ActionController::UrlWriter
|
138
138
|
attr_reader :name, :menus, :url
|
139
|
-
|
139
|
+
|
140
140
|
def initialize(name, path=nil, options={}, &block)#:nodoc:
|
141
141
|
@name = name
|
142
142
|
@options = options
|
@@ -148,28 +148,28 @@ module Lipsiadmin
|
|
148
148
|
end
|
149
149
|
yield self
|
150
150
|
end
|
151
|
-
|
151
|
+
|
152
152
|
# Build a new menu and automaitcally add the action on the allowed actions.
|
153
153
|
def menu(name, path=nil, options={}, &block)
|
154
154
|
@menus << Menu.new(name, path, options, &block)
|
155
155
|
end
|
156
|
-
|
156
|
+
|
157
157
|
# Return allowed controllers
|
158
158
|
def allowed
|
159
159
|
@menus.each { |m| @allowed.concat(m.allowed) }
|
160
160
|
@allowed.uniq
|
161
161
|
end
|
162
|
-
|
162
|
+
|
163
163
|
# Return the original name or try to translate or humanize the symbol
|
164
164
|
def human_name
|
165
165
|
@name.is_a?(Symbol) ? I18n.t("backend.menus.#{@name}", :default => @name.to_s.humanize) : @name
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
# Return a unique id for the given project module
|
169
169
|
def uid
|
170
170
|
@name.to_s.downcase.gsub(/[^a-z0-9]+/, '').gsub(/-+$/, '').gsub(/^-+$/, '')
|
171
171
|
end
|
172
|
-
|
172
|
+
|
173
173
|
# Return ExtJs Config for this project module
|
174
174
|
def config
|
175
175
|
options = @options.merge(:text => human_name)
|
@@ -178,48 +178,48 @@ module Lipsiadmin
|
|
178
178
|
options
|
179
179
|
end
|
180
180
|
end
|
181
|
-
|
181
|
+
|
182
182
|
class Menu
|
183
183
|
include Helper
|
184
184
|
include ActionController::UrlWriter
|
185
185
|
attr_reader :name, :options, :items
|
186
|
-
|
186
|
+
|
187
187
|
def initialize(name, path=nil, options={}, &block)#:nodoc:
|
188
188
|
@name = name
|
189
189
|
@url = path
|
190
190
|
@options = options
|
191
191
|
@allowed = []
|
192
|
-
@items = []
|
192
|
+
@items = []
|
193
193
|
@allowed << { :controller => recognize_path(path)[:controller] } if @url
|
194
194
|
yield self if block_given?
|
195
195
|
end
|
196
|
-
|
196
|
+
|
197
197
|
# Return the url of this menu
|
198
198
|
def url
|
199
199
|
@url.is_a?(Hash) ? url_for(@url.merge(:only_path => true)) : @url
|
200
200
|
end
|
201
|
-
|
201
|
+
|
202
202
|
# Add a new submenu to the menu
|
203
203
|
def add(name, path=nil, options={}, &block)
|
204
204
|
@items << Menu.new(name, path, options, &block)
|
205
205
|
end
|
206
|
-
|
206
|
+
|
207
207
|
# Return allowed controllers
|
208
208
|
def allowed
|
209
209
|
@items.each { |i| @allowed.concat i.allowed }
|
210
210
|
@allowed.uniq
|
211
211
|
end
|
212
|
-
|
212
|
+
|
213
213
|
# Return the original name or try to translate or humanize the symbol
|
214
214
|
def human_name
|
215
215
|
@name.is_a?(Symbol) ? I18n.t("backend.menus.#{@name}", :default => @name.to_s.humanize) : @name
|
216
216
|
end
|
217
|
-
|
217
|
+
|
218
218
|
# Return a unique id for the given project module
|
219
219
|
def uid
|
220
220
|
@name.to_s.downcase.gsub(/[^a-z0-9]+/, '').gsub(/-+$/, '').gsub(/^-+$/, '')
|
221
221
|
end
|
222
|
-
|
222
|
+
|
223
223
|
# Return ExtJs Config for this menu
|
224
224
|
def config
|
225
225
|
if @url.blank? && @items.empty?
|
@@ -232,8 +232,8 @@ module Lipsiadmin
|
|
232
232
|
options
|
233
233
|
end
|
234
234
|
end
|
235
|
-
|
235
|
+
|
236
236
|
class AccessControlError < StandardError#:nodoc:
|
237
237
|
end
|
238
238
|
end
|
239
|
-
end
|
239
|
+
end
|
data/lib/controller/ext.rb
CHANGED
@@ -2,13 +2,13 @@ module Lipsiadmin
|
|
2
2
|
module Controller
|
3
3
|
module Ext
|
4
4
|
# Return column config, and store config/data for ExtJS ColumnModel and Store
|
5
|
-
#
|
5
|
+
#
|
6
6
|
# Examples:
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# # app/controllers/backend/debtors_controller.rb
|
9
9
|
# def index
|
10
10
|
# @column_store = column_store_for Debtor do |cm|
|
11
|
-
# cm.add :id
|
11
|
+
# cm.add :id
|
12
12
|
# cm.add "full_name_or_company.upcase", "Full Name", :sortable => true, :dataIndex => :company
|
13
13
|
# cm.add :surname # Header will be autogenerated
|
14
14
|
# cm.add :email, "Email", :sortable => true
|
@@ -16,12 +16,12 @@ module Lipsiadmin
|
|
16
16
|
# cm.add :created_at, "Creato il", :sortable => true, :renderer => :date, :align => :right
|
17
17
|
# cm.add :updated_at, "Aggiornato il", :sortable => true, :renderer => :datetime, :align => :right
|
18
18
|
# end
|
19
|
-
#
|
19
|
+
#
|
20
20
|
# respond_to do |format|
|
21
|
-
# format.js
|
21
|
+
# format.js
|
22
22
|
# format.json do
|
23
23
|
# render :json => @column_store.store_data(params)
|
24
|
-
#
|
24
|
+
#
|
25
25
|
# # or you can manually do:
|
26
26
|
# # debtors = Debtor.search(params)
|
27
27
|
# # debtors_count = debtors.size
|
@@ -30,7 +30,7 @@ module Lipsiadmin
|
|
30
30
|
# end
|
31
31
|
# end
|
32
32
|
# end
|
33
|
-
#
|
33
|
+
#
|
34
34
|
# # app/views/backend/index.rjs
|
35
35
|
# page.grid do |grid|
|
36
36
|
# grid.id "debtors-grid" # If you don't set this columns are not saved in cookies
|
@@ -48,11 +48,11 @@ module Lipsiadmin
|
|
48
48
|
# end
|
49
49
|
# grid.bbar :store => grid.get_store, :pageSize => params[:limit] # Remember to add after defining store!
|
50
50
|
# end
|
51
|
-
#
|
51
|
+
#
|
52
52
|
def column_store_for(model, &block)
|
53
53
|
ColumnStore.new(model, &block)
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
class ColumnStore#:nodoc:
|
57
57
|
attr_reader :data
|
58
58
|
|
@@ -66,26 +66,26 @@ module Lipsiadmin
|
|
66
66
|
def add(*args)
|
67
67
|
options = { :method => args[0] }
|
68
68
|
options[:header] = args[1].is_a?(String) || args[1].is_a?(Symbol) ? args[1].to_s : nil
|
69
|
-
|
69
|
+
|
70
70
|
args.each { |a| options.merge!(a) if a.is_a?(Hash) }
|
71
|
-
|
71
|
+
|
72
72
|
# Add some defaults
|
73
73
|
options[:header] ||= options[:method].to_s
|
74
74
|
options[:sortable] = options[:sortable].nil? ? true : options[:sortable]
|
75
|
-
|
75
|
+
|
76
76
|
# Try to translate header
|
77
77
|
options[:header] = @model.human_attribute_name(options[:header].to_s)
|
78
|
-
|
78
|
+
|
79
79
|
# Reformat DataIndex
|
80
80
|
if options[:dataIndex].is_a?(Array)
|
81
|
-
options[:dataIndex] = options[:dataIndex].collect do |f|
|
82
|
-
f.is_a?(Symbol) ? "#{@model.table_name}.#{f}" : f
|
81
|
+
options[:dataIndex] = options[:dataIndex].collect do |f|
|
82
|
+
f.is_a?(Symbol) ? "#{@model.table_name}.#{f}" : f
|
83
83
|
end.join(",")
|
84
84
|
end
|
85
|
-
|
85
|
+
|
86
86
|
# Adding a name for our column
|
87
87
|
options[:name] ||= "#{@model.table_name.singularize}[#{options[:method]}]"
|
88
|
-
|
88
|
+
|
89
89
|
# Reformat query
|
90
90
|
if options[:method].is_a?(Symbol)
|
91
91
|
options[:dataIndex] ||= "#{@model.table_name}.#{options[:method]}"
|
@@ -100,14 +100,14 @@ module Lipsiadmin
|
|
100
100
|
options[:dataIndex] ||= columns[0..columns.length-2].collect(&:pluralize).join(".") + "." + columns.at(columns.size-1)
|
101
101
|
end
|
102
102
|
end
|
103
|
-
|
103
|
+
|
104
104
|
# Reformat dataIndex
|
105
105
|
options[:mapping] ||= options[:dataIndex].to_s.downcase.gsub(/[^a-z0-9]+/, '_').
|
106
106
|
gsub(/-+$/, '_').
|
107
107
|
gsub(/^-+$/, '_')
|
108
108
|
# Now is necessary for our columns an ID
|
109
109
|
options[:id] = options[:mapping]
|
110
|
-
|
110
|
+
|
111
111
|
@data << options
|
112
112
|
end
|
113
113
|
|
@@ -122,18 +122,18 @@ module Lipsiadmin
|
|
122
122
|
fields
|
123
123
|
end
|
124
124
|
end
|
125
|
-
|
125
|
+
|
126
126
|
# Return an array config for build an Ext.data.GroupingStore()
|
127
127
|
def store_fields
|
128
128
|
@data.inject([]) do |fields, data|
|
129
129
|
hash = { :name => data[:dataIndex], :mapping => data[:mapping] }
|
130
|
-
hash.merge!(:type => data[:renderer]) if data[:renderer] &&
|
130
|
+
hash.merge!(:type => data[:renderer]) if data[:renderer] &&
|
131
131
|
(data[:renderer] == :date || data[:renderer] == :datetime || data[:renderer] == :time_to_date)
|
132
132
|
fields << hash
|
133
133
|
fields
|
134
134
|
end
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
# Return data for a custom collection for the ExtJS Ext.data.GroupingStore() json
|
138
138
|
def store_data_from(collection)
|
139
139
|
collection.inject([]) do |store, c|
|
@@ -144,15 +144,15 @@ module Lipsiadmin
|
|
144
144
|
store
|
145
145
|
end
|
146
146
|
end
|
147
|
-
|
147
|
+
|
148
148
|
# Return a searched and paginated data collection for the ExtJS Ext.data.GroupingStore() json
|
149
149
|
# You can pass options like:
|
150
|
-
#
|
150
|
+
#
|
151
151
|
# Examples
|
152
|
-
#
|
152
|
+
#
|
153
153
|
# store_data(params, :conditions => "found = 1")
|
154
154
|
# store_data(params, :include => :posts)
|
155
|
-
#
|
155
|
+
#
|
156
156
|
def store_data(params, options={})
|
157
157
|
# Some can tell me that this method made two identical queries one for count one for paginate.
|
158
158
|
# We don't use the select count because in some circumstances require much time than select *.
|
@@ -167,4 +167,4 @@ module Lipsiadmin
|
|
167
167
|
end
|
168
168
|
end
|
169
169
|
end
|
170
|
-
end
|
170
|
+
end
|