motor-admin 0.1.71 → 0.1.76

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: 9949e78f65ec1ec3e6800c1cc86093b88e13e935f5af74adcb6fc7425f2d3336
4
- data.tar.gz: 92b8a11dad6cf4408cdb2d09a932e674a060d052b691c3faa634e2ff4637edad
3
+ metadata.gz: 06d50bf7bf7c919d161f50f8d8a258287696959c8b7f30957c1e690c18785f90
4
+ data.tar.gz: 2b9e032003062d26889f0b22541f0687e6389fa715e16b248726b65d499cbee8
5
5
  SHA512:
6
- metadata.gz: dfe7b35a8f05b6bf0eb56e632f68774120438ac522c273ac2aae7720e3fc198069190a59edeef4083424ffda68d3ef3338f1b7d955d82052e75bf2ed46ba3aa5
7
- data.tar.gz: 78e33a2de3d45dd419cf03ffba778a7051ddd59d8d976adfc2ab8e4b6e4e8a687a5e7a5a490c93b31690a240ea320e647b9b1a9e3bc547b22081eb369372752b
6
+ metadata.gz: ec3bac77b7826886d5412645e235a87fdefce3994fcc78c153c950adf44b1e4a04f14cd255d100ccaa91e686c9f088823d717c080551353fbe3cd500f7477433
7
+ data.tar.gz: e372e79f0fe48661200d8e4f2d4e812d25e4b68d44460324f7751e9053ffe0917e3a20096ba330d92cdfb27cbf64f27e2e40a5f007bb6e3441a786cc4e9ba169
@@ -18,6 +18,8 @@ en:
18
18
  add_query: Add Query
19
19
  add_scope: Add Scope
20
20
  add_tab: Add Tab
21
+ adjust_form: Adjust form
22
+ adjust_fields: Adjust fields
21
23
  alert_email_has_been_sent: Alert email has been sent!
22
24
  alert_has_been_activated: Alert has been activated
23
25
  alert_has_been_disabled: Alert has been disabled
@@ -36,6 +38,7 @@ en:
36
38
  bar_chart: Bar chart
37
39
  base: Base
38
40
  boolean: Boolean
41
+ build_custom_form: Build custom form
39
42
  cancel: Cancel
40
43
  cents: Cents
41
44
  checkbox: Checkbox
@@ -134,6 +137,7 @@ en:
134
137
  or: Or
135
138
  other_than: Other than
136
139
  param_name: Param name
140
+ password: Password
137
141
  path: Path
138
142
  percent: Percent
139
143
  pie_chart: Pie chart
@@ -158,6 +162,7 @@ en:
158
162
  revert: Revert
159
163
  revision_has_been_applied: Revision has been applied
160
164
  revisions: Revisions
165
+ richtext: Richtext
161
166
  row_chart: Row chart
162
167
  save: Save
163
168
  save_and_create_new: Save and Create New
@@ -214,4 +219,12 @@ en:
214
219
  visibility: Visibility
215
220
  visualization: Visualization
216
221
  write_only: Write-Only
217
- richtext: Richtext
222
+ long_text: Long text
223
+ percentage: Percentage
224
+ change: Change
225
+ chart: Chart
226
+ tag: Tag
227
+ link: Link
228
+ color: Color
229
+ link_text: Link text
230
+ copied_to_the_clipboard: Copied to the clipboard
@@ -215,6 +215,19 @@ es:
215
215
  unit: Unidad
216
216
  write_only: Sólo escritura
217
217
  richtext: Texto enriquecido
218
+ adjust_form: Ajustar formulario
219
+ adjust_fields: Ajustar campos
220
+ build_custom_form: Crear formulario personalizado
221
+ password: Contraseña
222
+ long_text: Texto largo
223
+ percentage: Porcentaje
224
+ change: Cambia
225
+ chart: Gráfico
226
+ tag: Etiqueta
227
+ link: Enlace
228
+ color: Color
229
+ link_text: Texto del enlace
230
+ copied_to_the_clipboard: Copiado al portapapeles
218
231
  i:
219
232
  locale: es
220
233
  select:
@@ -11,6 +11,29 @@ module Motor
11
11
  ].freeze
12
12
  end
13
13
 
14
+ module ColumnTypes
15
+ ALL = [
16
+ STRING = 'string',
17
+ INTEGER = 'integer',
18
+ DECIMAL = 'float',
19
+ DATETIME = 'datetime',
20
+ DATE = 'date',
21
+ BOOLEAN = 'boolean',
22
+ TEXTAREA = 'textarea',
23
+ RICHTEXT = 'richtext',
24
+ CURRENCY = 'currency',
25
+ PERCENTAGE = 'percentage',
26
+ CHANGE = 'change',
27
+ CHART = 'chart',
28
+ TAG = 'tag',
29
+ LINK = 'link',
30
+ COLOR = 'color',
31
+ IMAGE = 'image',
32
+ FILE = 'file',
33
+ JSON = 'json'
34
+ ].freeze
35
+ end
36
+
14
37
  SEARCHABLE_COLUMN_TYPES = %i[citext text string bitstring].freeze
15
38
 
16
39
  COLUMN_NAME_ACCESS_TYPES = {
@@ -13,6 +13,11 @@ module Motor
13
13
  ACTION_TEXT_SCOPE_PREFIX = 'with_rich_text_'
14
14
  ACTIVE_STORAGE_SCOPE_PREFIX = 'with_attached_'
15
15
 
16
+ DEFAULT_CURRENCY_FORMAT_HASH = {
17
+ currency: 'USD',
18
+ currency_base: 'units'
19
+ }.freeze
20
+
16
21
  module_function
17
22
 
18
23
  def call
@@ -109,22 +114,40 @@ module Motor
109
114
  end
110
115
 
111
116
  def build_table_column(column, model, default_attrs)
112
- is_enum = model.defined_enums[column.name]
113
-
114
117
  {
115
118
  name: column.name,
116
119
  display_name: Utils.humanize_column_name(model.human_attribute_name(column.name)),
117
- column_type: is_enum ? 'string' : UNIFIED_TYPES[column.type.to_s] || column.type.to_s,
120
+ column_type: fetch_column_type(column, model),
118
121
  is_array: column.array?,
119
122
  access_type: COLUMN_NAME_ACCESS_TYPES.fetch(column.name, ColumnAccessTypes::READ_WRITE),
120
123
  default_value: default_attrs[column.name],
121
124
  validators: fetch_validators(model, column.name),
122
125
  reference: nil,
123
- format: {},
126
+ format: fetch_format_hash(column, model),
124
127
  virtual: false
125
128
  }
126
129
  end
127
130
 
131
+ def fetch_format_hash(column, model)
132
+ return DEFAULT_CURRENCY_FORMAT_HASH if column.name == 'price'
133
+
134
+ inclusion_validator, = model.validators_on(column.name).grep(ActiveModel::Validations::InclusionValidator)
135
+ return { select_options: inclusion_validator.send(:delimiter) } if inclusion_validator
136
+
137
+ {}
138
+ end
139
+
140
+ def fetch_column_type(column, model)
141
+ return ColumnTypes::CURRENCY if column.name == 'price'
142
+ return ColumnTypes::COLOR if %w[hex color].include?(column.name)
143
+ return ColumnTypes::TAG if model.defined_enums[column.name]
144
+ return ColumnTypes::TAG if model.validators_on(column.name).any?(ActiveModel::Validations::InclusionValidator)
145
+ return ColumnTypes::RICHTEXT if column.name.ends_with?('_html')
146
+ return ColumnTypes::COLOR if column.name.match?(/_(color|hex)\z/)
147
+
148
+ UNIFIED_TYPES[column.type.to_s] || column.type.to_s
149
+ end
150
+
128
151
  def fetch_reference_columns(model)
129
152
  default_attrs = model.new.attributes
130
153
 
@@ -157,7 +180,7 @@ module Motor
157
180
  {
158
181
  name: column_name,
159
182
  display_name: model.human_attribute_name(name),
160
- column_type: is_attachment ? 'file' : 'integer',
183
+ column_type: is_attachment ? ColumnTypes::FILE : ColumnTypes::INTEGER,
161
184
  access_type: access_type,
162
185
  default_value: default_attrs[column_name],
163
186
  validators: fetch_validators(model, column_name, ref),
@@ -173,8 +196,8 @@ module Motor
173
196
  {
174
197
  name: name + ACTION_TEXT_COLUMN_SUFFIX,
175
198
  display_name: model.human_attribute_name(name),
176
- column_type: 'richtext',
177
- access_type: BuildSchema::ColumnAccessTypes::READ_WRITE,
199
+ column_type: ColumnTypes::RICHTEXT,
200
+ access_type: ColumnAccessTypes::READ_WRITE,
178
201
  default_value: '',
179
202
  validators: fetch_validators(model, name, ref),
180
203
  format: {},
@@ -1,6 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- module CancanUtils
3
+ module Motor
4
+ module CancanUtils
5
+ end
4
6
  end
5
7
 
6
8
  require_relative './cancan_utils/ability_patch'
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.1.71'
4
+ VERSION = '0.1.76'
5
5
  end
@@ -2068,11 +2068,11 @@
2068
2068
  "mail-opened.svg": "icons/mail-opened.svg",
2069
2069
  "mail.svg": "icons/mail.svg",
2070
2070
  "mailbox.svg": "icons/mailbox.svg",
2071
- "main-ff43eb24fb5b62cc171e.css.gz": "main-ff43eb24fb5b62cc171e.css.gz",
2072
- "main-ff43eb24fb5b62cc171e.js.LICENSE.txt": "main-ff43eb24fb5b62cc171e.js.LICENSE.txt",
2073
- "main-ff43eb24fb5b62cc171e.js.gz": "main-ff43eb24fb5b62cc171e.js.gz",
2074
- "main.css": "main-ff43eb24fb5b62cc171e.css",
2075
- "main.js": "main-ff43eb24fb5b62cc171e.js",
2071
+ "main-0402aeca6e4cb904f4c9.css.gz": "main-0402aeca6e4cb904f4c9.css.gz",
2072
+ "main-0402aeca6e4cb904f4c9.js.LICENSE.txt": "main-0402aeca6e4cb904f4c9.js.LICENSE.txt",
2073
+ "main-0402aeca6e4cb904f4c9.js.gz": "main-0402aeca6e4cb904f4c9.js.gz",
2074
+ "main.css": "main-0402aeca6e4cb904f4c9.css",
2075
+ "main.js": "main-0402aeca6e4cb904f4c9.js",
2076
2076
  "man.svg": "icons/man.svg",
2077
2077
  "manual-gearbox.svg": "icons/manual-gearbox.svg",
2078
2078
  "map-2.svg": "icons/map-2.svg",
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.1.71
4
+ version: 0.1.76
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-06-26 00:00:00.000000000 Z
11
+ date: 2021-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord-filter
@@ -1495,8 +1495,8 @@ files:
1495
1495
  - ui/dist/icons/zoom-money.svg.gz
1496
1496
  - ui/dist/icons/zoom-out.svg.gz
1497
1497
  - ui/dist/icons/zoom-question.svg.gz
1498
- - ui/dist/main-ff43eb24fb5b62cc171e.css.gz
1499
- - ui/dist/main-ff43eb24fb5b62cc171e.js.gz
1498
+ - ui/dist/main-0402aeca6e4cb904f4c9.css.gz
1499
+ - ui/dist/main-0402aeca6e4cb904f4c9.js.gz
1500
1500
  - ui/dist/manifest.json
1501
1501
  homepage:
1502
1502
  licenses: