anoubis 1.0.8 → 1.0.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5464dccc282a05f485f875d7961916178f580dfb96957bde888ab61ec73f7276
4
- data.tar.gz: 8cc6edd51976891558a02532f13b2d8613763f0f50075b2dcaa642f18707f268
3
+ metadata.gz: ca54a9f12fd045c1744271d6cf951da94061e002af8d32a1eb50e2616daeac75
4
+ data.tar.gz: e5dbe2556e68d9e2a6509dfca422237f94626b060006e40e319e649619b8be90
5
5
  SHA512:
6
- metadata.gz: 7ff86708955579d2f88fa8f6492b7c9dc59f6d33e15e290578f046547bd921eb92dea83f0a16f3e97a6144e6c5f0775dc27bc478f1deb33441c140da4f5903a7
7
- data.tar.gz: 32e3ce400a9838b7785a0fea0ba6f60e884c25dc4ece6d8e15a5ae940c05c4e6cb79931a0fc6f68dc47597655da1aa6d431eeff067218ff4db1488800a7afb77
6
+ metadata.gz: 91436b864c0a61a4d66d510b5e1845c73e07857c40f3f93b06fc1c406fc7b5d3dc3e9c247cb26285f6746ac04da526bb9adb1a7bddfdf337492220756dbe1caa
7
+ data.tar.gz: 209eeb301e6bd66bf17617c7fb395ec4cb3d31cf48d838ee06adfdf67c23205e1e73d72a3d2c131bf775bcc2955fe7128de0f5a9e3c726eb7d427f5ce466ea85
@@ -14,6 +14,10 @@ class Anoubis::ApplicationController < ActionController::API
14
14
  # @return [Anoubis::Output] standard output.
15
15
  attr_accessor :output
16
16
 
17
+ # @!attribute [rw] exports
18
+ # @return [Anubis::Export] Export data class
19
+ attr_accessor :exports
20
+
17
21
  ##
18
22
  # Returns default locale initialized in application configuration file. Variable is taken from {https://guides.rubyonrails.org/i18n.html Rails.configuration.i18n.default_locale} parameter
19
23
  # @return [String] default locale
@@ -54,6 +58,7 @@ class Anoubis::ApplicationController < ActionController::API
54
58
  self.locale = params[:locale] if params.has_key? :locale
55
59
  self.locale = default_locale unless self.locale
56
60
  self.locale = default_locale if self.locale == ''
61
+ self.exports = nil
57
62
  begin
58
63
  I18n.locale = locale
59
64
  rescue
@@ -104,7 +104,7 @@ module Anoubis
104
104
  self.after_get_table_data
105
105
  self.before_output
106
106
 
107
- render json: around_output(self.output.to_h)
107
+ render json: around_output(output.to_h)
108
108
  end
109
109
 
110
110
  ##
@@ -193,7 +193,7 @@ module Anoubis
193
193
  setup_frame
194
194
  before_output
195
195
 
196
- render json: self.output.to_h
196
+ render json: around_output(output.to_h)
197
197
  end
198
198
 
199
199
  ##
@@ -301,12 +301,11 @@ module Anoubis
301
301
  end
302
302
  if self.output.result == 0
303
303
  self.output.title = I18n.t(format('%s.show.form.title', params[:controller].sub('/', '.')), title: self.output.values[:sys_title],
304
- default: I18n.t('anubis.form.titles.show', title: self.output.values[:sys_title]))
304
+ default: I18n.t('anoubis.form.titles.show', title: self.output.values[:sys_title]))
305
305
  end
306
306
  self.before_output
307
- respond_to do |format|
308
- format.json { render json: self.output.to_h }
309
- end
307
+
308
+ render json: around_output(output.to_h)
310
309
  end
311
310
 
312
311
  ##
@@ -405,14 +404,11 @@ module Anoubis
405
404
  self.output.result = -1
406
405
  end
407
406
  if self.output.result == 0
408
- self.output.title = I18n.t(format('%s.%s.form.title', params[:controller].sub('/', '.'), action), default: I18n.t('anubis.form.titles.new'))
407
+ self.output.title = I18n.t(format('%s.%s.form.title', params[:controller].sub('/', '.'), action), default: I18n.t('anoubis.form.titles.new'))
409
408
  end
410
409
  self.before_output
411
410
 
412
-
413
- respond_to do |format|
414
- format.json { render json: self.output.to_h }
415
- end
411
+ render json: around_output(output.to_h)
416
412
  end
417
413
 
418
414
  ##
@@ -533,9 +529,8 @@ module Anoubis
533
529
  self.output.result = -2
534
530
  end
535
531
  self.before_output
536
- respond_to do |format|
537
- format.json { render json: self.output.to_h }
538
- end
532
+
533
+ render json: around_output(output.to_h)
539
534
  end
540
535
 
541
536
  ##
@@ -647,12 +642,11 @@ module Anoubis
647
642
  end
648
643
  if self.output.result == 0
649
644
  self.output.title = I18n.t(format('%s.edit.form.title', params[:controller].sub('/', '.')), title: self.output.values[:sys_title],
650
- default: I18n.t('anubis.form.titles.edit', title: self.output.values[:sys_title]))
645
+ default: I18n.t('anoubis.form.titles.edit', title: self.output.values[:sys_title]))
651
646
  end
652
647
  self.before_output
653
- respond_to do |format|
654
- format.json { render json: self.output.to_h }
655
- end
648
+
649
+ render json: around_output(output.to_h)
656
650
  end
657
651
 
658
652
  ##
@@ -766,9 +760,8 @@ module Anoubis
766
760
  self.output.result = -1
767
761
  end
768
762
  self.before_output
769
- respond_to do |format|
770
- format.json { render json: self.output.to_h }
771
- end
763
+
764
+ render json: around_output(output.to_h)
772
765
  end
773
766
 
774
767
  ##
@@ -849,9 +842,8 @@ module Anoubis
849
842
  self.output.result = -1
850
843
  end
851
844
  self.before_output
852
- respond_to do |format|
853
- format.json { render json: self.output.to_h }
854
- end
845
+
846
+ render json: around_output(output.to_h)
855
847
  end
856
848
 
857
849
  ##
@@ -877,9 +869,8 @@ module Anoubis
877
869
  end
878
870
  end
879
871
  self.before_output
880
- respond_to do |format|
881
- format.json { render json: self.output.to_h }
882
- end
872
+
873
+ render json: around_output(output.to_h)
883
874
  end
884
875
 
885
876
  ##
@@ -143,12 +143,8 @@ module Anoubis
143
143
  #puts value.class
144
144
  if (value.class == Date) || (value.class == ActiveSupport::TimeWithZone)
145
145
  begin
146
- new_value = case field.format
147
- when 'month' then I18n.t('anubis.months.main')[value.month-1]+' '+value.year.to_s
148
- when 'date' then value.day.to_s+' '+ I18n.t('anubis.months.second')[value.month-1]+' '+value.year.to_s
149
- when 'datetime' then value.day.to_s+' '+ I18n.t('anubis.months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)
150
- else value.day.to_s+' '+ I18n.t('anubis.months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)+':'+('%02d' % value.sec)
151
- end
146
+ new_value = convert_datetime_to_string value, field.format
147
+
152
148
  if %w[month date].include? field.format
153
149
  raw_value = value.year.to_s + '-' + ('%02d' % value.month) + '-' + ('%02d' % value.day)
154
150
  else
@@ -170,7 +166,28 @@ module Anoubis
170
166
  return { key => new_value, format('%s_raw', key).to_sym => value }
171
167
  end
172
168
 
169
+ ##
170
+ # Convert value from database to view format for 'hash' type
171
+ # @param key [Symbol] field's identifier in {Anoubis::Etc::Data#fields self.etc.data.fields} structure
172
+ # @param value [String] value from database
173
+ # @return [Hash] returns text representation of database value
174
+ def convert_db_to_view_value_hash(key, value)
175
+ return { key => '' } if !value
176
+ return { key => value }
177
+ end
173
178
 
179
+ ##
180
+ # Converts DateTime representation to string value
181
+ # @param value [DateTime] date and time
182
+ # @param format [String] convert representation ('month' - return only month and year, 'date' - returns only date, 'datetime' - returns date and time)
183
+ # @return Returns date and time representation string
184
+ def convert_datetime_to_string(value, format)
185
+ return I18n.t('anoubis.months.main')[value.month-1]+' '+value.year.to_s if format == 'month'
186
+ return value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s if format == 'date'
187
+ return value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min) if format == 'datetime'
188
+
189
+ value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)+':'+('%02d' % value.sec)
190
+ end
174
191
 
175
192
 
176
193
 
@@ -219,10 +236,10 @@ module Anoubis
219
236
  def convert_db_to_table_value_datetime1(key, field, value)
220
237
  begin
221
238
  value = case field[:format]
222
- when 'month' then I18n.t('months.main')[value.month-1]+' '+value.year.to_s
223
- when 'date' then value.day.to_s+' '+ I18n.t('months.second')[value.month-1]+' '+value.year.to_s
224
- when 'datetime' then value.day.to_s+' '+ I18n.t('months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)
225
- else value.day.to_s+' '+ I18n.t('months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)+':'+('%02d' % value.sec)
239
+ when 'month' then I18n.t('anoubis.months.main')[value.month-1]+' '+value.year.to_s
240
+ when 'date' then value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s
241
+ when 'datetime' then value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)
242
+ else value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)+':'+('%02d' % value.sec)
226
243
  end
227
244
  rescue
228
245
  value = I18n.t('incorrect_field_format')
@@ -249,10 +266,10 @@ module Anoubis
249
266
  def convert_db_to_table_value_datetime(key, field, value)
250
267
  begin
251
268
  value = case field[:format]
252
- when 'month' then I18n.t('months.main')[value.month-1]+' '+value.year.to_s
253
- when 'date' then value.day.to_s+' '+ I18n.t('months.second')[value.month-1]+' '+value.year.to_s
254
- when 'datetime' then value.day.to_s+' '+ I18n.t('months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)
255
- else value.day.to_s+' '+ I18n.t('months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)+':'+('%02d' % value.sec)
269
+ when 'month' then I18n.t('anoubis.months.main')[value.month-1]+' '+value.year.to_s
270
+ when 'date' then value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s
271
+ when 'datetime' then value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)
272
+ else value.day.to_s+' '+ I18n.t('anoubis.months.second')[value.month-1]+' '+value.year.to_s+', '+value.hour.to_s+':'+('%02d' % value.min)+':'+('%02d' % value.sec)
256
273
  end
257
274
  rescue
258
275
  value = I18n.t('incorrect_field_format')
@@ -10,6 +10,7 @@ require_dependency "anoubis/data/callbacks"
10
10
  ##
11
11
  # Main data controller class
12
12
  class Anoubis::DataController < Anoubis::ApplicationController
13
+ include ActionController::MimeResponds
13
14
  include Anoubis::Data::Actions
14
15
  include Anoubis::Data::Load
15
16
  include Anoubis::Data::Get
@@ -152,6 +152,13 @@ module Anoubis
152
152
 
153
153
  end
154
154
 
155
+ ##
156
+ # Initialize additional parameters for {Anoubis::Etc::Field#type 'hash' field type} for controller actions.
157
+ # @param options [Hash] field's initial options
158
+ def initialize_hash (options)
159
+
160
+ end
161
+
155
162
  ##
156
163
  # Initialize additional parameters for {Anoubis::Etc::Field#type 'number' field type} for controller actions.
157
164
  # @param options [Hash] field's initial options
@@ -2,9 +2,29 @@
2
2
  class Anoubis::ApplicationRecord < ActiveRecord::Base
3
3
  self.abstract_class = true
4
4
 
5
+ after_initialize :initialize_anubis_application_record
6
+
5
7
  ## Redis database variable
6
8
  attr_accessor :redis
7
9
 
10
+ # @!attribute [rw] need_refresh
11
+ # @return [Boolean] defines when table representation data should be updated even after simple update
12
+ attr_accessor :need_refresh
13
+
14
+ ##
15
+ # Fires after ApplicationRecord initialized for define default values
16
+ def initialize_anubis_application_record
17
+ self.need_refresh = false
18
+
19
+ after_initialize_anubis_application_record
20
+ end
21
+
22
+ ##
23
+ # Fires after initialize default variables
24
+ def after_initialize_anubis_application_record
25
+
26
+ end
27
+
8
28
  ##
9
29
  # Returns {https://github.com/redis/redis-rb Redis database} class
10
30
  # @return [Class] {https://github.com/redis/redis-rb Redis} class reference
@@ -130,4 +150,37 @@ class Anoubis::ApplicationRecord < ActiveRecord::Base
130
150
  def sys_title
131
151
  id.to_s
132
152
  end
153
+
154
+ ##
155
+ # Returns the ability to create new data. By default all items may be deleted. For another result
156
+ # procedure should be overridden.
157
+ # @param args [Hash] transferred parameters
158
+ # @option args [String] :controller Called controller identifier
159
+ # @option args [String] :tab Called controller tab element
160
+ # @return [Boolean] true if new data may be created.
161
+ def can_new(args = {})
162
+ true
163
+ end
164
+
165
+ ##
166
+ # Returns the ability to edit the data. By default all items may be edited. For another result
167
+ # procedure should be overridden.
168
+ # @param args [Hash] transferred parameters
169
+ # @option args [String] :controller Called controller identifier
170
+ # @option args [String] :tab Called controller tab element
171
+ # @return [Boolean] true if data may be edited
172
+ def can_edit(args = {})
173
+ true
174
+ end
175
+
176
+ ##
177
+ # Returns the ability to delete a data. By default all items may be deleted. For another result
178
+ # procedure should be overridden.
179
+ # @param args [Hash] transferred parameters
180
+ # @option args [String] :controller Called controller identifier
181
+ # @option args [String] :tab Called controller tab element
182
+ # @return [Boolean] true if data may be deleted
183
+ def can_delete(args = {})
184
+ true
185
+ end
133
186
  end
@@ -52,6 +52,51 @@ ru:
52
52
  title: "Дашборд"
53
53
  page_title: "Дашборд"
54
54
  short_title: "Дашборд"
55
+ form:
56
+ titles:
57
+ edit: "Редактирование элемента: %{title}"
58
+ show: "Просмотр элемента: %{title}"
59
+ new: "Добавление нового элемента"
60
+ months:
61
+ main:
62
+ - "Январь"
63
+ - "Февраль"
64
+ - "Март"
65
+ - "Апрель"
66
+ - "Май"
67
+ - "Июнь"
68
+ - "Июль"
69
+ - "Август"
70
+ - "Сентябрь"
71
+ - "Октябрь"
72
+ - "Ноябрь"
73
+ - "Декабрь"
74
+ second:
75
+ - "Января"
76
+ - "Февраля"
77
+ - "Марта"
78
+ - "Апреля"
79
+ - "Мая"
80
+ - "Июня"
81
+ - "Июля"
82
+ - "Августа"
83
+ - "Сентября"
84
+ - "Октября"
85
+ - "Ноября"
86
+ - "Декабря"
87
+ short:
88
+ - "янв"
89
+ - "фев"
90
+ - "мар"
91
+ - "апр"
92
+ - "май"
93
+ - "июн"
94
+ - "июл"
95
+ - "авг"
96
+ - "сен"
97
+ - "окт"
98
+ - "ноя"
99
+ - "дек"
55
100
 
56
101
 
57
102
 
@@ -69,46 +114,6 @@ ru:
69
114
  error_changing_data: Ошибка изменения данных
70
115
 
71
116
 
72
- months:
73
- main:
74
- - Январь
75
- - Февраль
76
- - Март
77
- - Апрель
78
- - Май
79
- - Июнь
80
- - Июль
81
- - Август
82
- - Сентябрь
83
- - Октябрь
84
- - Ноябрь
85
- - Декабрь
86
- second:
87
- - Января
88
- - Февраля
89
- - Марта
90
- - Апреля
91
- - Мая
92
- - Июня
93
- - Июля
94
- - Августа
95
- - Сентября
96
- - Октября
97
- - Ноября
98
- - Декабря
99
- short:
100
- - янв
101
- - фев
102
- - мар
103
- - апр
104
- - май
105
- - июн
106
- - июл
107
- - авг
108
- - сен
109
- - окт
110
- - ноя
111
- - дек
112
117
  install2:
113
118
  groups:
114
119
  admin: Администраторы
@@ -123,11 +128,6 @@ ru:
123
128
  buttons:
124
129
  edit: "Редактировать: %{title}"
125
130
  delete: "Удалить: %{title}"
126
- form:
127
- titles:
128
- edit: "Редактирование элемента: %{title}"
129
- show: "Просмотр элемента: %{title}"
130
- new: "Добавление нового элемента"
131
131
 
132
132
  tenants:
133
133
  errors:
@@ -1,5 +1,5 @@
1
1
  module Anoubis
2
2
  ##
3
3
  # Anoubis current version
4
- VERSION = '1.0.8'
4
+ VERSION = '1.0.12'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anoubis
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrey Ryabov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-04-23 00:00:00.000000000 Z
11
+ date: 2022-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -321,7 +321,7 @@ metadata:
321
321
  homepage_uri: https://github.com/RA-Company/
322
322
  source_code_uri: https://github.com/RA-Company/anoubis
323
323
  changelog_uri: https://github.com/RA-Company/anoubis/blob/main/CHANGELOG.md
324
- documentation_uri: https://www.rubydoc.info/gems/anoubis/1.0.8
324
+ documentation_uri: https://www.rubydoc.info/gems/anoubis/1.0.12
325
325
  post_install_message:
326
326
  rdoc_options: []
327
327
  require_paths: