motor-admin 0.2.9 → 0.2.13

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: f810c064605d59e011ec3b01567e592951b09717fe98482b5602489b471d0935
4
- data.tar.gz: 032b28c51dce430021d2dfda417e083d9fac2933041df82db95fd6fbf06d63bb
3
+ metadata.gz: 697f544810f933295dcac90682261144d4200b664ef0046dd88c4173a4753cbf
4
+ data.tar.gz: 18279efc9ab7d7ec5aa389eada2b5ad3ac646c613c08c1d08d380215affbbb29
5
5
  SHA512:
6
- metadata.gz: 6d9c6e98979b5e69bd91213b0f22ba8a5f9a892117cf0d6bcd65f6b2777fd6f75ee66e361e97efad275bc65c12bbcc994c064d4200ac75819de411e96340234b
7
- data.tar.gz: 79670f3add6f53d94545f1d9cf68a0c6d200ef3ad5f461f08e70aec5d83869c4a9baea826328309b5c63bf148c0be87579399259b5fc3de473fed0fb60af5b2b
6
+ metadata.gz: 5fe13200b02aa8d1b1492de03fe1371b2b60366c9ad8fe87b9c4307dc040a87acb5434a559515162544fb6fba1106153f5a1b0e012f795ef8d7e9085e65f030f
7
+ data.tar.gz: 75e21f9f22ad5ec5663aa8fd5e7080f56d123cb28865c8a564819cde9d77ef9f4231780f4dbfa01ba3a19ebac0dd2d2ace0929ac09df72d2a41256e130371d15
@@ -22,7 +22,11 @@ module Motor
22
22
  rescue_from CanCan::AccessDenied do |e|
23
23
  Rails.logger.error(e)
24
24
 
25
- render json: { errors: [e.message] }, status: :forbidden
25
+ if params[:action].in?(%w[create update destroy])
26
+ render json: { errors: [I18n.t('motor.not_authorized_to_perform_action')] }, status: :forbidden
27
+ else
28
+ render json: { errors: [e.message] }, status: :forbidden
29
+ end
26
30
  end
27
31
  end
28
32
  end
@@ -265,3 +265,4 @@ en:
265
265
  audio: Audio
266
266
  video: Video
267
267
  display_column: Display column
268
+ not_authorized_to_perform_action: You are not authorized to perform this action.
@@ -265,6 +265,7 @@ es:
265
265
  audio: Audio
266
266
  video: Video
267
267
  display_column: Columna de visualización
268
+ not_authorized_to_perform_action: No está autorizado a realizar esta acción.
268
269
  i:
269
270
  locale: es
270
271
  select:
@@ -261,6 +261,7 @@ pt:
261
261
  audio: Áudio
262
262
  video: Vídeo
263
263
  display_column: Coluna de exibição
264
+ not_authorized_to_perform_action: Não está autorizado a realizar esta acção.
264
265
  i:
265
266
  locale: pt
266
267
  select:
@@ -83,18 +83,52 @@ module Motor
83
83
  # @param result [ActiveRecord::Result]
84
84
  # @return [Hash]
85
85
  def build_columns_hash(result)
86
- result.columns.map do |column_name|
87
- column_type = result.column_types[column_name]
86
+ result.columns.map.with_index do |column_name, index|
87
+ column_type_class = result.column_types[column_name]
88
+
89
+ column_type =
90
+ if column_type_class
91
+ ActiveRecordUtils::Types.find_name_for_type(column_type_class)
92
+ else
93
+ not_nil_value = result.rows.reduce(nil) do |acc, row|
94
+ column = row[index]
95
+
96
+ break column unless column.nil?
97
+
98
+ acc
99
+ end
100
+
101
+ fetch_column_type_from_value(not_nil_value)
102
+ end
88
103
 
89
104
  {
90
105
  name: column_name,
91
106
  display_name: column_name.humanize,
92
- column_type: ActiveRecordUtils::Types.find_name_for_type(column_type),
107
+ column_type: column_type,
93
108
  is_array: column_type.class.to_s == 'ActiveRecord::ConnectionAdapters::PostgreSQL::OID::Array'
94
109
  }
95
110
  end
96
111
  end
97
112
 
113
+ # @param value [Object]
114
+ # @return [String]
115
+ def fetch_column_type_from_value(value)
116
+ case value
117
+ when Integer
118
+ 'integer'
119
+ when Float
120
+ 'float'
121
+ when Time
122
+ 'datetime'
123
+ when Date
124
+ 'date'
125
+ when TrueClass, FalseClass
126
+ 'boolean'
127
+ else
128
+ 'string'
129
+ end
130
+ end
131
+
98
132
  # @param query [Motor::Query]
99
133
  # @param limit [Integer]
100
134
  # @param variables_hash [Hash]
data/lib/motor/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Motor
4
- VERSION = '0.2.9'
4
+ VERSION = '0.2.13'
5
5
  end
@@ -2601,9 +2601,9 @@
2601
2601
  "icons/zoom-out.svg.gz": "icons/zoom-out.svg.gz",
2602
2602
  "icons/zoom-question.svg": "icons/zoom-question.svg",
2603
2603
  "icons/zoom-question.svg.gz": "icons/zoom-question.svg.gz",
2604
- "main-440589ed06b181856305.css.gz": "main-440589ed06b181856305.css.gz",
2605
- "main-440589ed06b181856305.js.LICENSE.txt": "main-440589ed06b181856305.js.LICENSE.txt",
2606
- "main-440589ed06b181856305.js.gz": "main-440589ed06b181856305.js.gz",
2607
- "main.css": "main-440589ed06b181856305.css",
2608
- "main.js": "main-440589ed06b181856305.js"
2604
+ "main-674256170310c4d08732.css.gz": "main-674256170310c4d08732.css.gz",
2605
+ "main-674256170310c4d08732.js.LICENSE.txt": "main-674256170310c4d08732.js.LICENSE.txt",
2606
+ "main-674256170310c4d08732.js.gz": "main-674256170310c4d08732.js.gz",
2607
+ "main.css": "main-674256170310c4d08732.css",
2608
+ "main.js": "main-674256170310c4d08732.js"
2609
2609
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motor-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.9
4
+ version: 0.2.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Matsyburka
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-15 00:00:00.000000000 Z
11
+ date: 2021-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -1524,8 +1524,8 @@ files:
1524
1524
  - ui/dist/icons/zoom-money.svg.gz
1525
1525
  - ui/dist/icons/zoom-out.svg.gz
1526
1526
  - ui/dist/icons/zoom-question.svg.gz
1527
- - ui/dist/main-440589ed06b181856305.css.gz
1528
- - ui/dist/main-440589ed06b181856305.js.gz
1527
+ - ui/dist/main-674256170310c4d08732.css.gz
1528
+ - ui/dist/main-674256170310c4d08732.js.gz
1529
1529
  - ui/dist/manifest.json
1530
1530
  homepage:
1531
1531
  licenses: