anoubis 1.0.8 → 1.0.10

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
  SHA256:
3
- metadata.gz: 5464dccc282a05f485f875d7961916178f580dfb96957bde888ab61ec73f7276
4
- data.tar.gz: 8cc6edd51976891558a02532f13b2d8613763f0f50075b2dcaa642f18707f268
3
+ metadata.gz: cc8ceeedc090ec925b88f60a4590f8cbdd834818d47ce9f5478c7f7a425ed381
4
+ data.tar.gz: 3ffc744a25fbf9cef5506538898902eb55ec8283505292c66fb14740b7fb6d5e
5
5
  SHA512:
6
- metadata.gz: 7ff86708955579d2f88fa8f6492b7c9dc59f6d33e15e290578f046547bd921eb92dea83f0a16f3e97a6144e6c5f0775dc27bc478f1deb33441c140da4f5903a7
7
- data.tar.gz: 32e3ce400a9838b7785a0fea0ba6f60e884c25dc4ece6d8e15a5ae940c05c4e6cb79931a0fc6f68dc47597655da1aa6d431eeff067218ff4db1488800a7afb77
6
+ metadata.gz: 28801bcc259fe678bbffb89d96a36c5d31fb47b9aa4ea1fe82f59e1434142b93032587806a0882c4948b743272b0c2c5306fbf2952ecf5b9fef0c799e3446e97
7
+ data.tar.gz: d2bfc2c2e958e790f8f5b8aa4bd8bea22b9e9931d65a598668900afffddd7b97363e596f07d168d663f65d9cee2046b2008f2e659783f5854f162758903cb070
@@ -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('anubis.months.main')[value.month-1]+' '+value.year.to_s if format == 'month'
186
+ return value.day.to_s+' '+ I18n.t('anubis.months.second')[value.month-1]+' '+value.year.to_s if format == 'date'
187
+ return value.day.to_s+' '+ I18n.t('anubis.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('anubis.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
 
@@ -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,11 @@ ru:
52
52
  title: "Дашборд"
53
53
  page_title: "Дашборд"
54
54
  short_title: "Дашборд"
55
+ form:
56
+ titles:
57
+ edit: "Редактирование элемента: %{title}"
58
+ show: "Просмотр элемента: %{title}"
59
+ new: "Добавление нового элемента"
55
60
 
56
61
 
57
62
 
@@ -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.10'
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.10
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-05-03 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.10
325
325
  post_install_message:
326
326
  rdoc_options: []
327
327
  require_paths: