anoubis 1.0.1 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/app/controllers/anoubis/application_controller.rb +4 -0
- data/app/controllers/anoubis/core/index/actions.rb +1 -1
- data/app/controllers/anoubis/core/index_controller.rb +3 -3
- data/app/controllers/anoubis/data/actions.rb +947 -0
- data/app/controllers/anoubis/data/callbacks.rb +66 -0
- data/app/controllers/anoubis/data/convert.rb +422 -0
- data/app/controllers/anoubis/data/defaults.rb +215 -0
- data/app/controllers/anoubis/data/get.rb +529 -0
- data/app/controllers/anoubis/data/load.rb +87 -0
- data/app/controllers/anoubis/data/set.rb +47 -0
- data/app/controllers/anoubis/data/setup.rb +102 -0
- data/app/controllers/anoubis/data_controller.rb +21 -0
- data/app/controllers/anoubis/etc/field.rb +7 -0
- data/app/controllers/anoubis/output/basic.rb +1 -1
- data/app/controllers/anoubis/sso/client/index_controller.rb +2 -2
- data/app/controllers/anoubis/sso/server/login_controller.rb +5 -5
- data/app/controllers/anoubis/sso/server/user_controller.rb +2 -2
- data/app/controllers/anoubis/tenant/index_controller.rb +3 -3
- data/app/models/anoubis/application_record.rb +141 -0
- data/app/services/anoubis/log_service.rb +97 -0
- data/app/services/anoubis/request_service.rb +134 -0
- data/config/locales/en.yml +20 -6
- data/config/locales/ru.yml +25 -13
- data/config/routes.rb +19 -19
- data/lib/anoubis/version.rb +1 -1
- metadata +32 -33
- data/app/controllers/anoubis/core/data/actions.rb +0 -962
- data/app/controllers/anoubis/core/data/callbacks.rb +0 -68
- data/app/controllers/anoubis/core/data/convert.rb +0 -407
- data/app/controllers/anoubis/core/data/defaults.rb +0 -217
- data/app/controllers/anoubis/core/data/get.rb +0 -531
- data/app/controllers/anoubis/core/data/load.rb +0 -89
- data/app/controllers/anoubis/core/data/set.rb +0 -49
- data/app/controllers/anoubis/core/data/setup.rb +0 -104
- data/app/controllers/anoubis/core/data_controller.rb +0 -28
- data/app/controllers/anoubis/sso/client/data/actions.rb +0 -5
- data/app/controllers/anoubis/sso/client/data/callbacks.rb +0 -5
- data/app/controllers/anoubis/sso/client/data/convert.rb +0 -5
- data/app/controllers/anoubis/sso/client/data/defaults.rb +0 -5
- data/app/controllers/anoubis/sso/client/data/get.rb +0 -5
- data/app/controllers/anoubis/sso/client/data/load.rb +0 -26
- data/app/controllers/anoubis/sso/client/data/set.rb +0 -5
- data/app/controllers/anoubis/sso/client/data/setup.rb +0 -5
- data/app/controllers/anoubis/sso/client/data_controller.rb +0 -21
- data/app/controllers/anoubis/tenant/data/actions.rb +0 -11
- data/app/controllers/anoubis/tenant/data/callbacks.rb +0 -11
- data/app/controllers/anoubis/tenant/data/convert.rb +0 -11
- data/app/controllers/anoubis/tenant/data/defaults.rb +0 -11
- data/app/controllers/anoubis/tenant/data/get.rb +0 -11
- data/app/controllers/anoubis/tenant/data/load.rb +0 -52
- data/app/controllers/anoubis/tenant/data/set.rb +0 -11
- data/app/controllers/anoubis/tenant/data/setup.rb +0 -11
- data/app/controllers/anoubis/tenant/data_controller.rb +0 -28
- data/app/controllers/anoubis/tenants_controller.rb +0 -7
- data/app/controllers/anoubis/users_controller.rb +0 -7
- data/app/mailers/anoubis/application_mailer.rb +0 -8
@@ -0,0 +1,215 @@
|
|
1
|
+
module Anoubis
|
2
|
+
module Data
|
3
|
+
##
|
4
|
+
# Module sets default parameters for {DataController}.
|
5
|
+
module Defaults
|
6
|
+
##
|
7
|
+
# Sets hash of defined tabs. Every tab consists of next attributes:
|
8
|
+
#
|
9
|
+
# *Attributes:*
|
10
|
+
# - *:title* (String) --- title of the tab
|
11
|
+
# - *:where* (Hash | Array) --- hash or array of where parameters for ActiveRecord request. If doesn't present
|
12
|
+
# then there are no additional where statements for current tab
|
13
|
+
#
|
14
|
+
# @return [Hash] returns hash of assigned tabs.
|
15
|
+
#
|
16
|
+
# @example Sets custom tabs
|
17
|
+
# def tabs
|
18
|
+
# {
|
19
|
+
# :all => {
|
20
|
+
# title: 'All IDs'
|
21
|
+
# },
|
22
|
+
# :id_1 => {
|
23
|
+
# title: 'Only ID 1',
|
24
|
+
# where: { id: 1 }
|
25
|
+
# },
|
26
|
+
# :other_id => {
|
27
|
+
# title: 'Other IDs',
|
28
|
+
# where: ['id > ?', 1]
|
29
|
+
# }
|
30
|
+
# }
|
31
|
+
# end
|
32
|
+
def tabs
|
33
|
+
{
|
34
|
+
:default => {
|
35
|
+
title: I18n.t('anoubis.default_tab'),
|
36
|
+
tips: I18n.t('anoubis.default_tab_hint')
|
37
|
+
}
|
38
|
+
}
|
39
|
+
end
|
40
|
+
|
41
|
+
##
|
42
|
+
# Sets frame buttons for every using tab.
|
43
|
+
# Key of the button is an action for frontend application. Every button consists of next attributes:
|
44
|
+
#
|
45
|
+
# *Attributes:*
|
46
|
+
# - *:type* (String) <i>(defaults to: 'default')</i> --- type of the button ('primary', 'danger', 'default')
|
47
|
+
# - *:mode* (String) <i>(defaults to: 'single')</i> --- button action object ('single', 'multiple')
|
48
|
+
#
|
49
|
+
# By default system defines two buttons: 'New' (for create new element in table) and 'Delete' (for
|
50
|
+
# delete multiple element)
|
51
|
+
#
|
52
|
+
# @param [Hash] args additional parameters are used for define frame buttons.
|
53
|
+
# @option args [String] :tab current tab is used for generation
|
54
|
+
#
|
55
|
+
# @return [Hash] returns hash of assigned buttons.
|
56
|
+
#
|
57
|
+
# @example Sets no buttons
|
58
|
+
# def frame_buttons(args = {})
|
59
|
+
# {
|
60
|
+
# }
|
61
|
+
# end
|
62
|
+
#
|
63
|
+
# @example Sets only 'New' button
|
64
|
+
# def frame_buttons(args = {})
|
65
|
+
# {
|
66
|
+
# new: { type: 'primary' }
|
67
|
+
# }
|
68
|
+
# end
|
69
|
+
def frame_buttons(args = {})
|
70
|
+
{
|
71
|
+
new: { type: 'primary' },
|
72
|
+
delete: { mode: 'multiple', type: 'danger' }
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# Returns model that is used for controller actions. By default it's not defined.
|
78
|
+
# This is primary model and it must be defined in customer conroller. Different models may be defined according
|
79
|
+
# by {Anoubis::Etc::Base#action self.etc.action} attribute.
|
80
|
+
# @return [Anoubis::ApplicationRecord, nil, any] returns model
|
81
|
+
def model
|
82
|
+
nil
|
83
|
+
end
|
84
|
+
|
85
|
+
##
|
86
|
+
# Returns defined select fields. If returns nil, then return default select fields
|
87
|
+
def select
|
88
|
+
nil
|
89
|
+
end
|
90
|
+
|
91
|
+
##
|
92
|
+
# Returns eager load parameters that are used for controller actions. By default it's set to \[\].
|
93
|
+
# This procedure could be redefined in cusomer controller. Different eager loads may be defined according
|
94
|
+
# by {Anoubis::Etc::Base#action self.etc.action} attribute.
|
95
|
+
def eager_load
|
96
|
+
[]
|
97
|
+
end
|
98
|
+
|
99
|
+
##
|
100
|
+
# Returns fields that is used for controller actions in defined {#model}. By default it's defined for id field.
|
101
|
+
# This is primary definition and it must be defined in customer conroller. Different fields may be defined according
|
102
|
+
# by {Anoubis::Etc::Base#action self.etc.action} attribute.
|
103
|
+
# @return [Hash] returns defined fields for current model
|
104
|
+
def fields
|
105
|
+
{
|
106
|
+
id: { type: 'number', precision: 0 }
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
110
|
+
##
|
111
|
+
# Get array of field's identifiers in desired order. By default it's current defined order of all fields.
|
112
|
+
def fields_order
|
113
|
+
result = []
|
114
|
+
self.etc.data.fields.each_key do |key|
|
115
|
+
result.push key.to_s
|
116
|
+
end
|
117
|
+
result
|
118
|
+
end
|
119
|
+
|
120
|
+
##
|
121
|
+
# Get array of field's identifiers in desired order for filter form. By default it's current defined order of all fields.
|
122
|
+
def filter_order
|
123
|
+
self.fields_order
|
124
|
+
end
|
125
|
+
|
126
|
+
##
|
127
|
+
# Returns parent model that is used for controller actions. By default it's defined as <i>nil</i>.
|
128
|
+
# This procedure could be redefined in customer controller. Different models may be defined according
|
129
|
+
# by {Anoubis::Etc::Base#action self.etc.action} attribute.
|
130
|
+
# @return [Anoubis::ApplicationRecord, nil] returns model
|
131
|
+
def parent_model
|
132
|
+
nil
|
133
|
+
end
|
134
|
+
|
135
|
+
##
|
136
|
+
# Returns eager load parameters for parent model that are used for controller actions. By default it's set to \[\].
|
137
|
+
# This procedure could be redefined in customer controller. Different eager loads may be defined according
|
138
|
+
# by {Anoubis::Etc::Base#action self.etc.action} attribute.
|
139
|
+
def parent_eager_load
|
140
|
+
[]
|
141
|
+
end
|
142
|
+
|
143
|
+
##
|
144
|
+
# Returns parent model id. By default it's set to 0.
|
145
|
+
# This procedure could be rewrote in customer controller.
|
146
|
+
def parent_id
|
147
|
+
return 0
|
148
|
+
end
|
149
|
+
|
150
|
+
##
|
151
|
+
# @!group Block of default controller table actions
|
152
|
+
|
153
|
+
##
|
154
|
+
# Sets default table actions for every row
|
155
|
+
# @return [Array] return string array of action identifiers
|
156
|
+
def table_actions
|
157
|
+
%w[edit delete]
|
158
|
+
end
|
159
|
+
|
160
|
+
##
|
161
|
+
# Returns possibility of 'edit' action for current row
|
162
|
+
# @param row [ActiveRecord] single model's data row
|
163
|
+
def table_action_edit(row)
|
164
|
+
row.can_edit({ controller: params[:controller], tab: self.etc.tab })
|
165
|
+
end
|
166
|
+
|
167
|
+
##
|
168
|
+
# Returns possibility of 'delete' action for current row
|
169
|
+
# @param row [ActiveRecord] single model's data row
|
170
|
+
def table_action_delete(row)
|
171
|
+
row.can_delete({ controller: params[:controller], tab: self.etc.tab })
|
172
|
+
end
|
173
|
+
|
174
|
+
##
|
175
|
+
# Returns default where condition
|
176
|
+
# @return [Hash, Array] default where condition
|
177
|
+
def where
|
178
|
+
[]
|
179
|
+
end
|
180
|
+
|
181
|
+
#@!endgroup
|
182
|
+
|
183
|
+
##
|
184
|
+
# Returns export format for current action. Procedure is rewrote for change default export format.
|
185
|
+
def export_format
|
186
|
+
'xls'
|
187
|
+
end
|
188
|
+
|
189
|
+
##
|
190
|
+
# Returns filter possibility for defined options. It's rewrote for custom controllers.
|
191
|
+
# @param [Hash] args additional parameters.
|
192
|
+
# @option args [String] :tab current tab is used for generation
|
193
|
+
# @return [Boolean] Possibility of filter table data. Default: true
|
194
|
+
def is_filter(args = {})
|
195
|
+
true
|
196
|
+
end
|
197
|
+
|
198
|
+
##
|
199
|
+
# Returns export possibility for defined options. It's rewrote for custom controllers.
|
200
|
+
# @param [Hash] args additional parameters.
|
201
|
+
# @option args [String] :tab current tab is used for generation
|
202
|
+
# @return [Boolean] Possibility of export table data. Default: true
|
203
|
+
def is_export(args = {})
|
204
|
+
true
|
205
|
+
end
|
206
|
+
|
207
|
+
##
|
208
|
+
# Returns field name for manual table order or nil if table can't be sorted manually.
|
209
|
+
# @return [String] Field name for manual table order
|
210
|
+
def is_sortable
|
211
|
+
nil
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|