motor-admin 0.1.65 → 0.1.71
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -0
- data/app/controllers/motor/api_base_controller.rb +6 -0
- data/app/views/layouts/motor/application.html.erb +1 -1
- data/config/locales/en.yml +217 -0
- data/config/locales/es.yml +302 -0
- data/lib/motor/active_record_utils.rb +1 -0
- data/lib/motor/active_record_utils/action_text_attribute_patch.rb +19 -0
- data/lib/motor/active_record_utils/active_record_connection_column_patch.rb +1 -0
- data/lib/motor/active_record_utils/active_record_filter_patch.rb +11 -0
- data/lib/motor/active_record_utils/active_storage_links_extension.rb +0 -4
- data/lib/motor/build_schema.rb +1 -34
- data/lib/motor/build_schema/active_storage_attachment_schema.rb +117 -107
- data/lib/motor/build_schema/adjust_devise_model_schema.rb +1 -1
- data/lib/motor/build_schema/defaults.rb +49 -0
- data/lib/motor/build_schema/load_from_rails.rb +45 -14
- data/lib/motor/build_schema/merge_schema_configs.rb +2 -2
- data/lib/motor/build_schema/utils.rb +5 -5
- data/lib/motor/configs/build_ui_app_tag.rb +6 -1
- data/lib/motor/version.rb +1 -1
- data/ui/dist/main-ff43eb24fb5b62cc171e.css.gz +0 -0
- data/ui/dist/main-ff43eb24fb5b62cc171e.js.gz +0 -0
- data/ui/dist/manifest.json +5 -5
- metadata +8 -4
- data/ui/dist/main-f6cb10fb0e14bdd1703b.css.gz +0 -0
- data/ui/dist/main-f6cb10fb0e14bdd1703b.js.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9949e78f65ec1ec3e6800c1cc86093b88e13e935f5af74adcb6fc7425f2d3336
|
4
|
+
data.tar.gz: 92b8a11dad6cf4408cdb2d09a932e674a060d052b691c3faa634e2ff4637edad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dfe7b35a8f05b6bf0eb56e632f68774120438ac522c273ac2aae7720e3fc198069190a59edeef4083424ffda68d3ef3338f1b7d955d82052e75bf2ed46ba3aa5
|
7
|
+
data.tar.gz: 78e33a2de3d45dd419cf03ffba778a7051ddd59d8d976adfc2ab8e4b6e4e8a687a5e7a5a490c93b31690a240ea320e647b9b1a9e3bc547b22081eb369372752b
|
data/README.md
CHANGED
@@ -27,6 +27,7 @@ $ rails motor:install && rake db:migrate
|
|
27
27
|
|
28
28
|
* [Customizable CRUD](#customizable-crud)
|
29
29
|
* [Custom actions](#custom-actions)
|
30
|
+
* [Virtual attributes](#virtual-attributes)
|
30
31
|
* [Forms builder](#forms-builder)
|
31
32
|
* [SQL queries](#sql-queries)
|
32
33
|
* [Data visualization](#data-visualization)
|
@@ -34,6 +35,7 @@ $ rails motor:install && rake db:migrate
|
|
34
35
|
* [Email alerts](#email-alerts)
|
35
36
|
* [Authorization](#authorization)
|
36
37
|
* [Intelligence search](#intelligence-search)
|
38
|
+
* [I18n](#i18n)
|
37
39
|
* [Optimized for mobile](#optimized-for-mobile)
|
38
40
|
* [Configurations sync between environments](#configurations-sync)
|
39
41
|
|
@@ -53,6 +55,22 @@ Data displayed on the resource page can be completely customized via [SQL querie
|
|
53
55
|
|
54
56
|
Custom resource actions can be added via Active Record method call, API endpoint, or [custom forms](#forms-builder). Also, it's possible to override default create/update/delete actions.
|
55
57
|
|
58
|
+
### Virtual attributes
|
59
|
+
|
60
|
+
Any ActiveRecord model method or attribute can be exposed to the admin panel by adding a new column with the name that matches the method name from the resource model:
|
61
|
+
|
62
|
+
```ruby
|
63
|
+
class Customer < ApplicationRecord
|
64
|
+
has_many :orders
|
65
|
+
|
66
|
+
def lifetime_value
|
67
|
+
orders.sum(&:total_price)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
![Virtual attribute](https://user-images.githubusercontent.com/5418788/123373683-76321c80-d58e-11eb-914d-675444b7eb2a.png)
|
73
|
+
|
56
74
|
### Forms Builder
|
57
75
|
|
58
76
|
![Custom form](https://user-images.githubusercontent.com/5418788/119264008-1391dd80-bbea-11eb-9f14-cb405e77fb60.png)
|
@@ -96,6 +114,25 @@ Intelligence search can be opened via the top right corner button or using <kbd>
|
|
96
114
|
|
97
115
|
Motor Admin allows to set row-level and column-level permissions via [cancan](https://github.com/CanCanCommunity/cancancan) gem. Admin UI permissions should be defined in `app/models/motor/ability.rb` file in `Motor::Ability` class. See [Motor Admin guide](https://github.com/omohokcoj/motor-admin/blob/master/guides/defining_permissions.md) and [CanCan documentation](https://github.com/CanCanCommunity/cancancan/blob/develop/docs/Defining-Abilities.md) to learn how to define user permissions.
|
98
116
|
|
117
|
+
### I18n
|
118
|
+
|
119
|
+
Motor Admin can use Rails ActiveRecord i18n keys to render resource translations:
|
120
|
+
|
121
|
+
```yml
|
122
|
+
es:
|
123
|
+
activerecord:
|
124
|
+
models:
|
125
|
+
customer:
|
126
|
+
one: Cliente
|
127
|
+
other: Clientes
|
128
|
+
attributes:
|
129
|
+
customer:
|
130
|
+
name: Nombre
|
131
|
+
scopes:
|
132
|
+
customer:
|
133
|
+
enabled: Activado
|
134
|
+
```
|
135
|
+
|
99
136
|
### Optimized for Mobile
|
100
137
|
|
101
138
|
![motor-mobile](https://user-images.githubusercontent.com/5418788/119269566-03392d00-bc01-11eb-9e9d-1f6a58fe0749.png)
|
@@ -5,6 +5,12 @@ module Motor
|
|
5
5
|
include Motor::CurrentUserMethod
|
6
6
|
include Motor::CurrentAbility
|
7
7
|
|
8
|
+
if defined?(ActionText::Content)
|
9
|
+
before_action do
|
10
|
+
ActionText::Content.renderer = Motor::ApplicationController.renderer.new(request.env)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
8
14
|
unless Rails.env.test?
|
9
15
|
rescue_from StandardError do |e|
|
10
16
|
Rails.logger.error(e)
|
@@ -0,0 +1,217 @@
|
|
1
|
+
en:
|
2
|
+
motor:
|
3
|
+
action_has_been_applied: Action has been applied!
|
4
|
+
action_has_failed_with_code: Action failed with code
|
5
|
+
action_type: Action type
|
6
|
+
actions: Actions
|
7
|
+
add: Add
|
8
|
+
add_action: Add Action
|
9
|
+
add_alert: Add Alert
|
10
|
+
add_column: Add Column
|
11
|
+
add_dashboard: Add Dashboard
|
12
|
+
add_field: Add Field
|
13
|
+
add_filter: Add Filter
|
14
|
+
add_form: Add Form
|
15
|
+
add_group: Add Group
|
16
|
+
add_item: Add Item
|
17
|
+
add_link: Add Link
|
18
|
+
add_query: Add Query
|
19
|
+
add_scope: Add Scope
|
20
|
+
add_tab: Add Tab
|
21
|
+
alert_email_has_been_sent: Alert email has been sent!
|
22
|
+
alert_has_been_activated: Alert has been activated
|
23
|
+
alert_has_been_disabled: Alert has been disabled
|
24
|
+
alert_has_been_saved: Alert has been saved!
|
25
|
+
alert_name: Alert name
|
26
|
+
alerts: Alerts
|
27
|
+
all: All
|
28
|
+
all_resources: All Resources
|
29
|
+
and: And
|
30
|
+
api: API
|
31
|
+
api_path: API path
|
32
|
+
api_request: API request
|
33
|
+
apply: Apply
|
34
|
+
are_you_sure: Are you sure?
|
35
|
+
associations: Associations
|
36
|
+
bar_chart: Bar chart
|
37
|
+
base: Base
|
38
|
+
boolean: Boolean
|
39
|
+
cancel: Cancel
|
40
|
+
cents: Cents
|
41
|
+
checkbox: Checkbox
|
42
|
+
clear_all: Clear All
|
43
|
+
clear_selection: Clear selection
|
44
|
+
close: Close
|
45
|
+
close_editor: Close editor
|
46
|
+
close_settings: Close Settings
|
47
|
+
close_variables: Close Variables
|
48
|
+
columns: Columns
|
49
|
+
contains: Contains
|
50
|
+
create: Create
|
51
|
+
currency: Currency
|
52
|
+
dashboard: Dashboard
|
53
|
+
dashboard_has_been_saved: Dashboard has been saved!
|
54
|
+
dashboard_title: Dashboard title
|
55
|
+
dashboards: Dashboards
|
56
|
+
date: Date
|
57
|
+
date_and_time: Date and Time
|
58
|
+
decimal: Decimal
|
59
|
+
default: Default
|
60
|
+
default_value: Default value
|
61
|
+
describe_this_alert_optional: Describe this alert (optional)
|
62
|
+
describe_your_dashboard_optional: Describe your dashboard (optional)
|
63
|
+
describe_your_form_optional: Describe your form (optional)
|
64
|
+
describe_your_query_optional: Describe your query (optional)
|
65
|
+
description: Description
|
66
|
+
deselect_all: Deselect All
|
67
|
+
details: Details
|
68
|
+
disable: Disable
|
69
|
+
display_as: Display as
|
70
|
+
edit: Edit
|
71
|
+
edit_sql: Edit SQL
|
72
|
+
emails: Emails
|
73
|
+
ends_with: Ends with
|
74
|
+
equal_to: Equal to
|
75
|
+
every_day_at_hh_mm: every day at HH:mm PM...
|
76
|
+
excludes: excludes
|
77
|
+
field_is_not_a_number: '%{field} is not a number'
|
78
|
+
field_is_required: '%{field} is required'
|
79
|
+
field_list_cant_be_empty: "%{field} list can't be empty"
|
80
|
+
field_must_be_exactly_in_length: '%{field} must be exactly %{length} in length'
|
81
|
+
field_name: Field name
|
82
|
+
field_value_does_not_match_pattern: '%{field} value does not match %{pattern}'
|
83
|
+
file: File
|
84
|
+
filters: Filters
|
85
|
+
form: Form
|
86
|
+
form_has_been_saved: Form has been saved!
|
87
|
+
form_has_been_submitted_successfully: Form has been submitted successfully!
|
88
|
+
form_name: Form name
|
89
|
+
forms: Forms
|
90
|
+
funnel: Funnel
|
91
|
+
greater_or_equal: Greater or equal
|
92
|
+
greater_than: Greater than
|
93
|
+
greater_than_or_equal_to: Greater than or equal to
|
94
|
+
group_name: Group name
|
95
|
+
has_been_created: has been created
|
96
|
+
has_been_removed_succesfully: has been removed succesfully
|
97
|
+
has_been_updated: has been updated
|
98
|
+
hello_admin: Hello Admin 👋
|
99
|
+
hidden: Hidden
|
100
|
+
image: Image
|
101
|
+
includes: Includes
|
102
|
+
input_type: Input type
|
103
|
+
integer: Integer
|
104
|
+
interval: Interval
|
105
|
+
is: Is
|
106
|
+
is_not: Is not
|
107
|
+
items_has_been_removed: items has been removed
|
108
|
+
items_will_be_removed: '%{count} items will be removed'
|
109
|
+
json: JSON
|
110
|
+
label: Currency
|
111
|
+
less_or_equal: Less or equal
|
112
|
+
less_than: Less than
|
113
|
+
less_than_or_equal_to: Less than or equal to
|
114
|
+
line_chart: Line chart
|
115
|
+
link_name: Link name
|
116
|
+
links: Links
|
117
|
+
load_initial_data: Load initial data
|
118
|
+
loading: Loading...
|
119
|
+
looks_like_you_are_new_here: Looks like you are new here 🙃
|
120
|
+
markdown: Markdown
|
121
|
+
method: Method
|
122
|
+
method_call: Method call
|
123
|
+
multiple: Multiple
|
124
|
+
name: Name
|
125
|
+
new_alert: New alert
|
126
|
+
new_dashboard: New dashboard
|
127
|
+
new_form: New form
|
128
|
+
new_query: New query
|
129
|
+
no_data: No data
|
130
|
+
not_found: Not Found
|
131
|
+
number: Number
|
132
|
+
ok: OK
|
133
|
+
options_separated_with_new_line_or_comma: Options separated with new line or comma
|
134
|
+
or: Or
|
135
|
+
other_than: Other than
|
136
|
+
param_name: Param name
|
137
|
+
path: Path
|
138
|
+
percent: Percent
|
139
|
+
pie_chart: Pie chart
|
140
|
+
queries: Queries
|
141
|
+
query: Query
|
142
|
+
query_has_been_saved: Query has been saved!
|
143
|
+
query_name: Query name
|
144
|
+
query_not_selected: Query not selected
|
145
|
+
query_revisions: Query Revisions
|
146
|
+
read_only: Read-Only
|
147
|
+
read_write: Read-Write
|
148
|
+
reference: Reference
|
149
|
+
reference_resource: Reference resource
|
150
|
+
remove: Remove
|
151
|
+
reports: Reports
|
152
|
+
request_param: Request param
|
153
|
+
required: Required
|
154
|
+
resource_filters: '%{resource} Filters'
|
155
|
+
resource_settings: '%{resource} Settings'
|
156
|
+
resources: Resources
|
157
|
+
resubmit: Resubmit
|
158
|
+
revert: Revert
|
159
|
+
revision_has_been_applied: Revision has been applied
|
160
|
+
revisions: Revisions
|
161
|
+
row_chart: Row chart
|
162
|
+
save: Save
|
163
|
+
save_and_create_new: Save and Create New
|
164
|
+
save_as_new: Save as new
|
165
|
+
save_dashboard: Save dashboard
|
166
|
+
save_form: Save form
|
167
|
+
save_query: Save query
|
168
|
+
scopes: Scopes
|
169
|
+
search: Search
|
170
|
+
search_placeholder: Search...
|
171
|
+
search_query: Search Query
|
172
|
+
select: Select
|
173
|
+
select_alert_tags: Select alert tags
|
174
|
+
select_dashboard: Select dashboard
|
175
|
+
select_dashboard_tags: Select dashboard tags
|
176
|
+
select_form: Select form
|
177
|
+
select_form_tags: Select dashform tags
|
178
|
+
select_options: Select options
|
179
|
+
select_placeholder: Select...
|
180
|
+
select_query: Select query
|
181
|
+
select_query_tags: Select query tags
|
182
|
+
select_resource_placeholder: Select resource...
|
183
|
+
selected_item_has_been_removed: Selected item has been removed
|
184
|
+
selected_item_will_be_removed: Selected item will be removed
|
185
|
+
selected_item_will_be_removed_are_you_sure: Selected item will be removed. Are you sure?
|
186
|
+
send_empty: Send empty?
|
187
|
+
send_now: Send Now
|
188
|
+
send_to: Send to
|
189
|
+
set_tags: Set tags
|
190
|
+
settings: Settings
|
191
|
+
should_be_a_valid_json: Should be a valid JSON
|
192
|
+
should_be_error_constraint: 'Should be %{error} %{constraint}'
|
193
|
+
stacked_bars: Stacked bars
|
194
|
+
starts_with: Starts with
|
195
|
+
submit: Submit
|
196
|
+
tab_type: Tab type
|
197
|
+
table: Table
|
198
|
+
tabs: Tabs
|
199
|
+
tags: Tags
|
200
|
+
text: Text
|
201
|
+
textarea: Textarea
|
202
|
+
timezone: Timezone
|
203
|
+
title: Title
|
204
|
+
type: Type
|
205
|
+
unable_to_load_form_data: Unable to load form data
|
206
|
+
unable_to_remove_item: Unable to remove item
|
207
|
+
unable_to_remove_items: Unable to remove items
|
208
|
+
unable_to_send_email: Unable to send email
|
209
|
+
unable_to_submit_form: Unable to submit form
|
210
|
+
unit: Unit
|
211
|
+
value: Value
|
212
|
+
values_axis: Values axis
|
213
|
+
variables: Variables
|
214
|
+
visibility: Visibility
|
215
|
+
visualization: Visualization
|
216
|
+
write_only: Write-Only
|
217
|
+
richtext: Richtext
|
@@ -0,0 +1,302 @@
|
|
1
|
+
es:
|
2
|
+
motor:
|
3
|
+
action_has_been_applied: ¡Acción aplicada!
|
4
|
+
action_has_failed_with_code: La acción falló con código
|
5
|
+
action_type: Tipo de acción
|
6
|
+
actions: Acciones
|
7
|
+
add: Añadir
|
8
|
+
add_action: Añadir Acción
|
9
|
+
add_alert: Añadir Alerta
|
10
|
+
add_column: Añadir Columna
|
11
|
+
add_dashboard: Añadir Dashboard
|
12
|
+
add_field: Añadir Campo
|
13
|
+
add_filter: Añadir Filtro
|
14
|
+
add_form: Añadir Formulario
|
15
|
+
add_group: Añadir Grupo
|
16
|
+
add_item: Añadir Elemento
|
17
|
+
add_link: Añadir Link
|
18
|
+
add_query: Añadir Consulta
|
19
|
+
add_scope: Añadir Alcance
|
20
|
+
add_tab: Añadir Pestaña
|
21
|
+
alert_email_has_been_sent: ¡Email de alerta enviado!
|
22
|
+
alert_has_been_activated: Alerta activada
|
23
|
+
alert_has_been_disabled: Alerta desactivada
|
24
|
+
alert_has_been_saved: ¡Alerta guardada!
|
25
|
+
alert_name: Nombre de la alerta
|
26
|
+
all_resources: Todos los Recursos
|
27
|
+
and: Y
|
28
|
+
api_path: Dirección en API
|
29
|
+
apply: Aplicar
|
30
|
+
are_you_sure: ¿Estás seguro?
|
31
|
+
associations: Asociaciones
|
32
|
+
bar_chart: Gráfico de barras
|
33
|
+
base: Base
|
34
|
+
cancel: Cancelar
|
35
|
+
clear_all: Quitar todos
|
36
|
+
clear_selection: Quitar selección
|
37
|
+
close: Cerrar
|
38
|
+
close_editor: Cerrar editor
|
39
|
+
close_settings: Cerrar Configuración
|
40
|
+
close_variables: Cerrar Variables
|
41
|
+
columns: Columnas
|
42
|
+
create: Crear
|
43
|
+
currency: Moneda
|
44
|
+
dashboard_has_been_saved: ¡Dashboard guardado!
|
45
|
+
dashboard_title: Título del dashboard
|
46
|
+
decimal: Decimal
|
47
|
+
default_value: Valor por defecto
|
48
|
+
describe_this_alert_optional: Describe esta alerta (opcional)
|
49
|
+
describe_your_dashboard_optional: Describe tu dashboard (opcional)
|
50
|
+
describe_your_form_optional: Describe tu formulario (opcional)
|
51
|
+
describe_your_query_optional: Describe tu consulta (opcional)
|
52
|
+
description: Descripción
|
53
|
+
deselect_all: Deseleccionar todo
|
54
|
+
disable: Desactivar
|
55
|
+
display_as: Mostrar como
|
56
|
+
edit: Editar
|
57
|
+
edit_sql: Editar SQL
|
58
|
+
emails: Emails
|
59
|
+
every_day_at_hh_mm: todos los días a las HH:mm PM...
|
60
|
+
field_name: Nombre del campo
|
61
|
+
filters: Filtros
|
62
|
+
form: Formulario
|
63
|
+
form_has_been_saved: ¡Formulario guardado!
|
64
|
+
form_has_been_submitted_successfully: ¡Formulario enviado con éxito!
|
65
|
+
form_name: Nombre del formulario
|
66
|
+
forms: Formularios
|
67
|
+
funnel: Embudo
|
68
|
+
group_name: Nombre del grupo
|
69
|
+
has_been_created: creado
|
70
|
+
has_been_removed_succesfully: eliminado con éxito
|
71
|
+
has_been_updated: actualizado
|
72
|
+
hello_admin: Hola Admin 👋
|
73
|
+
input_type: Tipo de campo
|
74
|
+
interval: Intervalo
|
75
|
+
items_has_been_removed: elementos fueron eliminados
|
76
|
+
label: Moneda
|
77
|
+
line_chart: Gráfico de líneas
|
78
|
+
link_name: Nombre del link
|
79
|
+
links: Links
|
80
|
+
load_initial_data: Cargar datos iniciales
|
81
|
+
loading: Cargando...
|
82
|
+
looks_like_you_are_new_here: Parece que eres nuevo aquí 🙃
|
83
|
+
markdown: Markdown
|
84
|
+
method: Método
|
85
|
+
multiple: Múltiple
|
86
|
+
name: Nombre
|
87
|
+
new_alert: Nueva alerta
|
88
|
+
new_dashboard: Nuevo dashboard
|
89
|
+
new_form: Nuevo formulario
|
90
|
+
new_query: Nueva consulta
|
91
|
+
no_data: Sin datos
|
92
|
+
not_found: Sin resultados
|
93
|
+
ok: OK
|
94
|
+
options_separated_with_new_line_or_comma: Las opciones van separadas con una nueva línea o una coma
|
95
|
+
param_name: Nombre del parámetro
|
96
|
+
path: Dirección
|
97
|
+
percent: Porcentaje
|
98
|
+
pie_chart: Gráfico circular
|
99
|
+
query: Consulta
|
100
|
+
query_has_been_saved: ¡Consulta guardada!
|
101
|
+
query_name: Nombre de la consulta
|
102
|
+
query_not_selected: Consulta no seleccionada
|
103
|
+
query_revisions: Revisiones de la consulta
|
104
|
+
reference: Referencia
|
105
|
+
reference_resource: Recurso de referencia
|
106
|
+
remove: Eliminar
|
107
|
+
reports: Reportes
|
108
|
+
request_param: Parametro de request
|
109
|
+
resources: Recursos
|
110
|
+
resubmit: Reenviar
|
111
|
+
revert: Revertir
|
112
|
+
revision_has_been_applied: Revisión aplicada
|
113
|
+
revisions: Revisiones
|
114
|
+
row_chart: Gráfico de filas
|
115
|
+
save: Guardar
|
116
|
+
save_and_create_new: Guardar y crear otro
|
117
|
+
save_as_new: Guardar como nuevo
|
118
|
+
save_dashboard: Guardar dashboard
|
119
|
+
save_form: Guardar formulario
|
120
|
+
save_query: Guardar consulta
|
121
|
+
scopes: Alcances
|
122
|
+
search: Buscar
|
123
|
+
search_placeholder: Buscar...
|
124
|
+
select_alert_tags: Etiquetas de alerta
|
125
|
+
select_dashboard: Seleccionar dashboard
|
126
|
+
select_dashboard_tags: Etiquetas de dashboard
|
127
|
+
select_form: Seleccionar formulario
|
128
|
+
select_form_tags: Etiquetas de formulario
|
129
|
+
select_options: Seleccionar opciones
|
130
|
+
select_placeholder: Seleccionar...
|
131
|
+
select_query: Seleccionar consulta
|
132
|
+
select_query_tags: Etiquetas de consulta
|
133
|
+
select_resource_placeholder: Seleccionar recurso...
|
134
|
+
selected_item_has_been_removed: El elemento seleccionado fue eliminado
|
135
|
+
selected_item_will_be_removed_are_you_sure: El elemento seleccionado será eliminado. ¿Estás seguro?
|
136
|
+
send_empty: ¿Enviar sin contenido?
|
137
|
+
send_now: Enviar ahora
|
138
|
+
send_to: Enviar a
|
139
|
+
set_tags: Seleccionar etiquetas
|
140
|
+
settings: Configuración
|
141
|
+
stacked_bars: Barras apiladas
|
142
|
+
submit: Enviar
|
143
|
+
tab_type: Tipo de pestaña
|
144
|
+
table: Tabla
|
145
|
+
tabs: Pestañas
|
146
|
+
tags: Etiquetas
|
147
|
+
timezone: Zona horaria
|
148
|
+
title: Título
|
149
|
+
type: Tipo
|
150
|
+
unable_to_load_form_data: No se pudieron cargar los datos del formulario
|
151
|
+
unable_to_remove_item: No se pudo eliminar el elemento
|
152
|
+
unable_to_remove_items: No se pudieron eliminar los elementos
|
153
|
+
unable_to_send_email: No se pudo enviar el email
|
154
|
+
unable_to_submit_form: No se pudo enviar el formulario
|
155
|
+
value: Valor
|
156
|
+
values_axis: Eje de valores
|
157
|
+
variables: Variables
|
158
|
+
visibility: Visibilidad
|
159
|
+
visualization: Visualización
|
160
|
+
alerts: Alertas
|
161
|
+
all: Todo
|
162
|
+
api: API
|
163
|
+
api_request: Request a una API
|
164
|
+
boolean: Booleano
|
165
|
+
cents: Centavos
|
166
|
+
checkbox: Checkbox
|
167
|
+
contains: Contiene
|
168
|
+
dashboard: Dashboard
|
169
|
+
dashboards: Dashboards
|
170
|
+
date: Fecha
|
171
|
+
date_and_time: Fecha y hora
|
172
|
+
default: Por defecto
|
173
|
+
details: Detalles
|
174
|
+
ends_with: Termina con
|
175
|
+
equal_to: Igual a
|
176
|
+
excludes: no contiene
|
177
|
+
field_is_not_a_number: '%{field} no es un número'
|
178
|
+
field_is_required: '%{field} es obligatorio'
|
179
|
+
field_list_cant_be_empty: "La lista %{field} no puede estar vacía"
|
180
|
+
field_must_be_exactly_in_length: '%{field} debe tener un largo de %{length} caracteres'
|
181
|
+
field_value_does_not_match_pattern: 'El valor de %{field} no coincide con %{pattern}'
|
182
|
+
file: Archivo
|
183
|
+
greater_or_equal: Mayor o igual
|
184
|
+
greater_than: Mayor que
|
185
|
+
greater_than_or_equal_to: Mayor o igual a
|
186
|
+
hidden: Esconder
|
187
|
+
image: Imagen
|
188
|
+
includes: Incluye
|
189
|
+
integer: Entero
|
190
|
+
is: Es
|
191
|
+
is_not: No es
|
192
|
+
items_will_be_removed: 'Se eliminarán %{count} elementos'
|
193
|
+
json: JSON
|
194
|
+
less_or_equal: Menor o igual
|
195
|
+
less_than: Menor que
|
196
|
+
less_than_or_equal_to: Menor o igual a
|
197
|
+
method_call: Llamado a método
|
198
|
+
number: Número
|
199
|
+
or: O
|
200
|
+
other_than: Otro que no sea
|
201
|
+
queries: Consultas
|
202
|
+
read_only: Sólo lectura
|
203
|
+
read_write: Lectura y escritura
|
204
|
+
required: Obligatorio
|
205
|
+
resource_filters: 'Filtros de %{resource}'
|
206
|
+
resource_settings: 'Configuración de %{resource}'
|
207
|
+
search_query: Buscar consulta
|
208
|
+
select: Selección
|
209
|
+
selected_item_will_be_removed: El elemento seleccionado será eliminado
|
210
|
+
should_be_a_valid_json: Debe ser un JSON válido
|
211
|
+
should_be_error_constraint: 'Debe ser %{error} %{constraint}'
|
212
|
+
starts_with: Empieza con
|
213
|
+
text: Texto
|
214
|
+
textarea: Área de texto
|
215
|
+
unit: Unidad
|
216
|
+
write_only: Sólo escritura
|
217
|
+
richtext: Texto enriquecido
|
218
|
+
i:
|
219
|
+
locale: es
|
220
|
+
select:
|
221
|
+
placeholder: Seleccionar
|
222
|
+
noMatch: Sin coincidencias
|
223
|
+
loading: Cargando
|
224
|
+
table:
|
225
|
+
noDataText: Sin Datos
|
226
|
+
noFilteredDataText: Sin Datos para el filtro
|
227
|
+
confirmFilter: Aceptar
|
228
|
+
resetFilter: Quitar filtro
|
229
|
+
clearFilter: Todos
|
230
|
+
sumText: Suma
|
231
|
+
datepicker:
|
232
|
+
selectDate: Seleccionar fecha
|
233
|
+
selectTime: Seleccionar hora
|
234
|
+
startTime: Hora de inicio
|
235
|
+
endTime: Hora de fin
|
236
|
+
clear: Limpiar
|
237
|
+
ok: Aceptar
|
238
|
+
datePanelLabel: "[mmmm] [yyyy]"
|
239
|
+
month: Mes
|
240
|
+
month1: Enero
|
241
|
+
month2: Febrero
|
242
|
+
month3: Marzo
|
243
|
+
month4: Abril
|
244
|
+
month5: Mayo
|
245
|
+
month6: Junio
|
246
|
+
month7: Julio
|
247
|
+
month8: Augosto
|
248
|
+
month9: Septiembre
|
249
|
+
month10: Octubre
|
250
|
+
month11: Noviembre
|
251
|
+
month12: Diciembre
|
252
|
+
year: Año
|
253
|
+
weekStartDay: '1'
|
254
|
+
weeks:
|
255
|
+
sun: Dom
|
256
|
+
mon: Lun
|
257
|
+
tue: Mar
|
258
|
+
wed: Mié
|
259
|
+
thu: Jue
|
260
|
+
fri: Vie
|
261
|
+
sat: Sáb
|
262
|
+
months:
|
263
|
+
m1: Ene
|
264
|
+
m2: Feb
|
265
|
+
m3: Mar
|
266
|
+
m4: Abr
|
267
|
+
m5: May
|
268
|
+
m6: Jun
|
269
|
+
m7: Jul
|
270
|
+
m8: Ago
|
271
|
+
m9: Sep
|
272
|
+
m10: Oct
|
273
|
+
m11: Nov
|
274
|
+
m12: Dic
|
275
|
+
transfer:
|
276
|
+
titles:
|
277
|
+
source: Origen
|
278
|
+
target: Destino
|
279
|
+
filterPlaceholder: Buscar aquí
|
280
|
+
notFoundText: Sin resultados
|
281
|
+
modal:
|
282
|
+
okText: Aceptar
|
283
|
+
cancelText: Cancelar
|
284
|
+
poptip:
|
285
|
+
okText: Aceptar
|
286
|
+
cancelText: Cancelar
|
287
|
+
page:
|
288
|
+
prev: Página Anterior
|
289
|
+
next: Página Siguiente
|
290
|
+
total: Total
|
291
|
+
item: Elemento
|
292
|
+
items: Elementos
|
293
|
+
prev5: 5 Páginas Anteriores
|
294
|
+
next5: 5 Páginas Siguientes
|
295
|
+
page: "/page"
|
296
|
+
goto: Ir a
|
297
|
+
p: ''
|
298
|
+
rate:
|
299
|
+
star: Estrella
|
300
|
+
stars: Estrellas
|
301
|
+
tree:
|
302
|
+
emptyText: Sin Datos
|
@@ -22,3 +22,4 @@ require_relative './active_record_utils/active_storage_links_extension'
|
|
22
22
|
require_relative './active_record_utils/active_storage_blob_patch'
|
23
23
|
require_relative './active_record_utils/active_record_filter_patch'
|
24
24
|
require_relative './active_record_utils/active_record_connection_column_patch'
|
25
|
+
require_relative './active_record_utils/action_text_attribute_patch'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
if defined?(ActionText::Attribute)
|
4
|
+
ActionText::Attribute::ClassMethods.prepend(Module.new do
|
5
|
+
# rubocop:disable Naming/PredicateName
|
6
|
+
def has_rich_text(*args)
|
7
|
+
super
|
8
|
+
|
9
|
+
name = args.first
|
10
|
+
|
11
|
+
alias_method :"#{name}_body=", :"#{name}="
|
12
|
+
|
13
|
+
define_method(:"#{name}_body") do
|
14
|
+
send(name).body&.to_trix_html
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# rubocop:enable Naming/PredicateName
|
18
|
+
end)
|
19
|
+
end
|
@@ -5,3 +5,14 @@ ActiveRecord::Filter.module_eval do
|
|
5
5
|
@filters ||= HashWithIndifferentAccess.new
|
6
6
|
end
|
7
7
|
end
|
8
|
+
|
9
|
+
if Rails::VERSION::MAJOR == 6
|
10
|
+
ActiveRecord::Relation::Filter.module_eval do
|
11
|
+
def build_arel(aliases = nil)
|
12
|
+
arel = super
|
13
|
+
my_alias_tracker = ActiveRecord::Associations::AliasTracker.create(connection, table.name, [])
|
14
|
+
build_filters(arel, my_alias_tracker)
|
15
|
+
arel
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/motor/build_schema.rb
CHANGED
@@ -22,40 +22,6 @@ module Motor
|
|
22
22
|
|
23
23
|
DEFAULT_SCOPE_TYPE = 'default'
|
24
24
|
|
25
|
-
DEFAULT_ACTIONS = [
|
26
|
-
{
|
27
|
-
name: 'create',
|
28
|
-
display_name: 'Create',
|
29
|
-
action_type: 'default',
|
30
|
-
preferences: {},
|
31
|
-
visible: true
|
32
|
-
},
|
33
|
-
{
|
34
|
-
name: 'edit',
|
35
|
-
display_name: 'Edit',
|
36
|
-
action_type: 'default',
|
37
|
-
preferences: {},
|
38
|
-
visible: true
|
39
|
-
},
|
40
|
-
{
|
41
|
-
name: 'remove',
|
42
|
-
display_name: 'Remove',
|
43
|
-
action_type: 'default',
|
44
|
-
preferences: {},
|
45
|
-
visible: true
|
46
|
-
}
|
47
|
-
].freeze
|
48
|
-
|
49
|
-
DEFAULT_TABS = [
|
50
|
-
{
|
51
|
-
name: 'details',
|
52
|
-
display_name: 'Details',
|
53
|
-
tab_type: 'default',
|
54
|
-
preferences: {},
|
55
|
-
visible: true
|
56
|
-
}
|
57
|
-
].freeze
|
58
|
-
|
59
25
|
module_function
|
60
26
|
|
61
27
|
def call(cache_keys = {}, current_ability = nil)
|
@@ -78,3 +44,4 @@ require_relative './build_schema/reorder_schema'
|
|
78
44
|
require_relative './build_schema/merge_schema_configs'
|
79
45
|
require_relative './build_schema/apply_permissions'
|
80
46
|
require_relative './build_schema/utils'
|
47
|
+
require_relative './build_schema/defaults'
|
@@ -2,113 +2,123 @@
|
|
2
2
|
|
3
3
|
module Motor
|
4
4
|
module BuildSchema
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
display_column: 'filename',
|
13
|
-
icon: 'paperclip',
|
14
|
-
columns: [
|
15
|
-
{
|
16
|
-
name: 'id',
|
17
|
-
display_name: 'ID',
|
18
|
-
column_type: 'integer',
|
19
|
-
access_type: 'read_only',
|
20
|
-
default_value: nil,
|
21
|
-
validators: [],
|
22
|
-
format: {},
|
23
|
-
is_array: false,
|
24
|
-
reference: nil,
|
25
|
-
virtual: false
|
26
|
-
},
|
27
|
-
{
|
28
|
-
name: 'path',
|
29
|
-
display_name: 'Path',
|
30
|
-
column_type: 'string',
|
31
|
-
access_type: 'read_only',
|
32
|
-
default_value: nil,
|
33
|
-
validators: [],
|
34
|
-
format: {},
|
35
|
-
is_array: false,
|
36
|
-
reference: nil,
|
37
|
-
virtual: true
|
38
|
-
},
|
39
|
-
{
|
40
|
-
name: 'name',
|
41
|
-
display_name: 'Name',
|
42
|
-
column_type: 'string',
|
43
|
-
access_type: 'read_write',
|
44
|
-
default_value: nil,
|
45
|
-
validators: [],
|
46
|
-
format: {},
|
47
|
-
is_array: false,
|
48
|
-
reference: nil,
|
49
|
-
virtual: false
|
50
|
-
},
|
51
|
-
{
|
52
|
-
name: 'record_type',
|
53
|
-
display_name: 'Record type',
|
54
|
-
column_type: 'string',
|
55
|
-
access_type: 'read_write',
|
56
|
-
default_value: nil,
|
57
|
-
validators: [],
|
58
|
-
format: {},
|
59
|
-
is_array: false,
|
60
|
-
reference: nil,
|
61
|
-
virtual: false
|
62
|
-
},
|
63
|
-
{
|
64
|
-
name: 'record_id',
|
65
|
-
display_name: 'Record',
|
66
|
-
column_type: 'integer',
|
67
|
-
access_type: 'read_write',
|
68
|
-
default_value: nil,
|
69
|
-
validators: [],
|
70
|
-
format: {},
|
71
|
-
is_array: false,
|
72
|
-
reference: {
|
73
|
-
name: 'record',
|
74
|
-
display_name: 'Record',
|
75
|
-
model_name: nil,
|
76
|
-
reference_type: 'belongs_to',
|
77
|
-
foreign_key: 'record_id',
|
78
|
-
polymorphic: true
|
79
|
-
},
|
80
|
-
virtual: false
|
81
|
-
},
|
82
|
-
{
|
83
|
-
name: 'file',
|
84
|
-
display_name: 'File',
|
85
|
-
column_type: 'file',
|
86
|
-
access_type: 'write_only',
|
87
|
-
default_value: nil,
|
88
|
-
validators: [],
|
89
|
-
format: {},
|
90
|
-
is_array: false,
|
91
|
-
reference: nil,
|
92
|
-
virtual: false
|
93
|
-
},
|
5
|
+
module ActiveStorageAttachmentSchema
|
6
|
+
module_function
|
7
|
+
|
8
|
+
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
|
9
|
+
def call
|
10
|
+
model = ActiveStorage::Attachment
|
11
|
+
|
94
12
|
{
|
95
|
-
name:
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
13
|
+
name: model.name.underscore,
|
14
|
+
slug: Utils.slugify(model),
|
15
|
+
class_name: model.class.name,
|
16
|
+
table_name: model.table_name,
|
17
|
+
primary_key: model.primary_key,
|
18
|
+
display_name: model.model_name.human(count: 2, default: 'Attachments'),
|
19
|
+
display_column: 'filename',
|
20
|
+
icon: 'paperclip',
|
21
|
+
columns: [
|
22
|
+
{
|
23
|
+
name: 'id',
|
24
|
+
display_name: 'ID',
|
25
|
+
column_type: 'integer',
|
26
|
+
access_type: 'read_only',
|
27
|
+
default_value: nil,
|
28
|
+
validators: [],
|
29
|
+
format: {},
|
30
|
+
is_array: false,
|
31
|
+
reference: nil,
|
32
|
+
virtual: false
|
33
|
+
},
|
34
|
+
{
|
35
|
+
name: 'path',
|
36
|
+
display_name: model.human_attribute_name(:path),
|
37
|
+
column_type: 'string',
|
38
|
+
access_type: 'read_only',
|
39
|
+
default_value: nil,
|
40
|
+
validators: [],
|
41
|
+
format: {},
|
42
|
+
is_array: false,
|
43
|
+
reference: nil,
|
44
|
+
virtual: true
|
45
|
+
},
|
46
|
+
{
|
47
|
+
name: 'name',
|
48
|
+
display_name: model.human_attribute_name(:name),
|
49
|
+
column_type: 'string',
|
50
|
+
access_type: 'read_write',
|
51
|
+
default_value: nil,
|
52
|
+
validators: [],
|
53
|
+
format: {},
|
54
|
+
is_array: false,
|
55
|
+
reference: nil,
|
56
|
+
virtual: false
|
57
|
+
},
|
58
|
+
{
|
59
|
+
name: 'record_type',
|
60
|
+
display_name: model.human_attribute_name(:record_type),
|
61
|
+
column_type: 'string',
|
62
|
+
access_type: 'read_write',
|
63
|
+
default_value: nil,
|
64
|
+
validators: [],
|
65
|
+
format: {},
|
66
|
+
is_array: false,
|
67
|
+
reference: nil,
|
68
|
+
virtual: false
|
69
|
+
},
|
70
|
+
{
|
71
|
+
name: 'record_id',
|
72
|
+
display_name: model.human_attribute_name(:record),
|
73
|
+
column_type: 'integer',
|
74
|
+
access_type: 'read_write',
|
75
|
+
default_value: nil,
|
76
|
+
validators: [],
|
77
|
+
format: {},
|
78
|
+
is_array: false,
|
79
|
+
reference: {
|
80
|
+
name: 'record',
|
81
|
+
display_name: model.human_attribute_name(:record),
|
82
|
+
model_name: nil,
|
83
|
+
reference_type: 'belongs_to',
|
84
|
+
foreign_key: 'record_id',
|
85
|
+
polymorphic: true
|
86
|
+
},
|
87
|
+
virtual: false
|
88
|
+
},
|
89
|
+
{
|
90
|
+
name: 'file',
|
91
|
+
display_name: model.human_attribute_name(:file),
|
92
|
+
column_type: 'file',
|
93
|
+
access_type: 'write_only',
|
94
|
+
default_value: nil,
|
95
|
+
validators: [],
|
96
|
+
format: {},
|
97
|
+
is_array: false,
|
98
|
+
reference: nil,
|
99
|
+
virtual: false
|
100
|
+
},
|
101
|
+
{
|
102
|
+
name: 'created_at',
|
103
|
+
display_name: model.human_attribute_name(:created_at),
|
104
|
+
column_type: 'datetime',
|
105
|
+
access_type: 'read_only',
|
106
|
+
default_value: nil,
|
107
|
+
validators: [],
|
108
|
+
format: {},
|
109
|
+
is_array: false,
|
110
|
+
reference: nil,
|
111
|
+
virtual: false
|
112
|
+
}
|
113
|
+
],
|
114
|
+
associations: [],
|
115
|
+
scopes: [],
|
116
|
+
actions: Motor::BuildSchema::Defaults.actions.reject { |e| e[:name] == 'edit' },
|
117
|
+
tabs: Motor::BuildSchema::Defaults.tabs,
|
118
|
+
visible: true
|
119
|
+
}.with_indifferent_access
|
120
|
+
end
|
121
|
+
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
|
122
|
+
end
|
113
123
|
end
|
114
124
|
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Motor
|
4
|
+
module BuildSchema
|
5
|
+
module Defaults
|
6
|
+
module_function
|
7
|
+
|
8
|
+
# rubocop:disable Metrics/MethodLength
|
9
|
+
def actions
|
10
|
+
[
|
11
|
+
{
|
12
|
+
name: 'create',
|
13
|
+
display_name: I18n.t('motor.create'),
|
14
|
+
action_type: 'default',
|
15
|
+
preferences: {},
|
16
|
+
visible: true
|
17
|
+
},
|
18
|
+
{
|
19
|
+
name: 'edit',
|
20
|
+
display_name: I18n.t('motor.edit'),
|
21
|
+
action_type: 'default',
|
22
|
+
preferences: {},
|
23
|
+
visible: true
|
24
|
+
},
|
25
|
+
{
|
26
|
+
name: 'remove',
|
27
|
+
display_name: I18n.t('motor.remove'),
|
28
|
+
action_type: 'default',
|
29
|
+
preferences: {},
|
30
|
+
visible: true
|
31
|
+
}
|
32
|
+
].freeze
|
33
|
+
end
|
34
|
+
# rubocop:enable Metrics/MethodLength
|
35
|
+
|
36
|
+
def tabs
|
37
|
+
[
|
38
|
+
{
|
39
|
+
name: 'details',
|
40
|
+
display_name: I18n.t('motor.details'),
|
41
|
+
tab_type: 'default',
|
42
|
+
preferences: {},
|
43
|
+
visible: true
|
44
|
+
}
|
45
|
+
].freeze
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -6,6 +6,13 @@ module Motor
|
|
6
6
|
MUTEX = Mutex.new
|
7
7
|
UNIFIED_TYPES = ActiveRecordUtils::Types::UNIFIED_TYPES
|
8
8
|
|
9
|
+
I18N_SCOPES_KEY = 'activerecord.scopes'
|
10
|
+
|
11
|
+
ACTION_TEXT_REFLECTION_PREFIX = 'rich_text_'
|
12
|
+
ACTION_TEXT_COLUMN_SUFFIX = '_body'
|
13
|
+
ACTION_TEXT_SCOPE_PREFIX = 'with_rich_text_'
|
14
|
+
ACTIVE_STORAGE_SCOPE_PREFIX = 'with_attached_'
|
15
|
+
|
9
16
|
module_function
|
10
17
|
|
11
18
|
def call
|
@@ -38,6 +45,7 @@ module Motor
|
|
38
45
|
models -= [ActiveRecord::SchemaMigration] if defined?(ActiveRecord::SchemaMigration)
|
39
46
|
models -= [ActiveRecord::InternalMetadata] if defined?(ActiveRecord::InternalMetadata)
|
40
47
|
models -= [ActiveStorage::Blob] if defined?(ActiveStorage::Blob)
|
48
|
+
models -= [ActionText::RichText] if defined?(ActionText::RichText)
|
41
49
|
models -= [ActiveStorage::VariantRecord] if defined?(ActiveStorage::VariantRecord)
|
42
50
|
|
43
51
|
models
|
@@ -46,7 +54,7 @@ module Motor
|
|
46
54
|
def build_model_schema(model)
|
47
55
|
model_name = model.name
|
48
56
|
|
49
|
-
return Motor::BuildSchema::
|
57
|
+
return Motor::BuildSchema::ActiveStorageAttachmentSchema.call if model_name == 'ActiveStorage::Attachment'
|
50
58
|
|
51
59
|
{
|
52
60
|
name: model_name.underscore,
|
@@ -54,14 +62,14 @@ module Motor
|
|
54
62
|
table_name: model.table_name,
|
55
63
|
class_name: model.name,
|
56
64
|
primary_key: model.primary_key,
|
57
|
-
display_name: model_name.titleize.pluralize,
|
65
|
+
display_name: model.model_name.human(count: :many, default: model_name.titleize.pluralize),
|
58
66
|
display_column: FindDisplayColumn.call(model),
|
59
67
|
columns: fetch_columns(model),
|
60
68
|
associations: fetch_associations(model),
|
61
|
-
icon: Motor::FindIcon.call(
|
69
|
+
icon: Motor::FindIcon.call(model_name),
|
62
70
|
scopes: fetch_scopes(model),
|
63
|
-
actions:
|
64
|
-
tabs:
|
71
|
+
actions: BuildSchema::Defaults.actions,
|
72
|
+
tabs: BuildSchema::Defaults.tabs,
|
65
73
|
visible: true
|
66
74
|
}.with_indifferent_access
|
67
75
|
end
|
@@ -70,11 +78,14 @@ module Motor
|
|
70
78
|
model.defined_scopes.map do |scope_name|
|
71
79
|
scope_name = scope_name.to_s
|
72
80
|
|
73
|
-
next if scope_name.starts_with?(
|
81
|
+
next if scope_name.starts_with?(ACTIVE_STORAGE_SCOPE_PREFIX)
|
82
|
+
next if scope_name.starts_with?(ACTION_TEXT_SCOPE_PREFIX)
|
74
83
|
|
75
84
|
{
|
76
85
|
name: scope_name,
|
77
|
-
display_name: scope_name
|
86
|
+
display_name: I18n.t(scope_name,
|
87
|
+
scope: [I18N_SCOPES_KEY, model.name.underscore].join('.'),
|
88
|
+
default: scope_name.humanize),
|
78
89
|
scope_type: DEFAULT_SCOPE_TYPE,
|
79
90
|
visible: true,
|
80
91
|
preferences: {}
|
@@ -102,9 +113,9 @@ module Motor
|
|
102
113
|
|
103
114
|
{
|
104
115
|
name: column.name,
|
105
|
-
display_name: Utils.humanize_column_name(column.name),
|
116
|
+
display_name: Utils.humanize_column_name(model.human_attribute_name(column.name)),
|
106
117
|
column_type: is_enum ? 'string' : UNIFIED_TYPES[column.type.to_s] || column.type.to_s,
|
107
|
-
is_array: column.
|
118
|
+
is_array: column.array?,
|
108
119
|
access_type: COLUMN_NAME_ACCESS_TYPES.fetch(column.name, ColumnAccessTypes::READ_WRITE),
|
109
120
|
default_value: default_attrs[column.name],
|
110
121
|
validators: fetch_validators(model, column.name),
|
@@ -135,27 +146,47 @@ module Motor
|
|
135
146
|
end
|
136
147
|
|
137
148
|
def build_reflection_column(name, model, ref, default_attrs)
|
149
|
+
if !ref.polymorphic? && ref.klass.name == 'ActionText::RichText'
|
150
|
+
return build_action_text_column(name, model, ref)
|
151
|
+
end
|
152
|
+
|
138
153
|
column_name = ref.belongs_to? ? ref.foreign_key.to_s : name
|
139
154
|
is_attachment = !ref.polymorphic? && ref.klass.name == 'ActiveStorage::Attachment'
|
140
155
|
access_type = ref.belongs_to? || is_attachment ? ColumnAccessTypes::READ_WRITE : ColumnAccessTypes::READ_ONLY
|
141
156
|
|
142
157
|
{
|
143
158
|
name: column_name,
|
144
|
-
display_name:
|
159
|
+
display_name: model.human_attribute_name(name),
|
145
160
|
column_type: is_attachment ? 'file' : 'integer',
|
146
161
|
access_type: access_type,
|
147
162
|
default_value: default_attrs[column_name],
|
148
163
|
validators: fetch_validators(model, column_name, ref),
|
149
164
|
format: {},
|
150
|
-
reference: build_reference(name, ref),
|
165
|
+
reference: build_reference(model, name, ref),
|
151
166
|
virtual: false
|
152
167
|
}
|
153
168
|
end
|
154
169
|
|
155
|
-
def
|
170
|
+
def build_action_text_column(name, model, ref)
|
171
|
+
name = name.delete_prefix(ACTION_TEXT_REFLECTION_PREFIX)
|
172
|
+
|
173
|
+
{
|
174
|
+
name: name + ACTION_TEXT_COLUMN_SUFFIX,
|
175
|
+
display_name: model.human_attribute_name(name),
|
176
|
+
column_type: 'richtext',
|
177
|
+
access_type: BuildSchema::ColumnAccessTypes::READ_WRITE,
|
178
|
+
default_value: '',
|
179
|
+
validators: fetch_validators(model, name, ref),
|
180
|
+
format: {},
|
181
|
+
reference: nil,
|
182
|
+
virtual: true
|
183
|
+
}
|
184
|
+
end
|
185
|
+
|
186
|
+
def build_reference(model, name, reflection)
|
156
187
|
{
|
157
188
|
name: name,
|
158
|
-
display_name: name
|
189
|
+
display_name: model.human_attribute_name(name),
|
159
190
|
model_name: reflection.polymorphic? ? nil : reflection.klass.name.underscore,
|
160
191
|
reference_type: reflection.belongs_to? ? 'belongs_to' : 'has_one',
|
161
192
|
foreign_key: reflection.foreign_key,
|
@@ -175,7 +206,7 @@ module Motor
|
|
175
206
|
|
176
207
|
{
|
177
208
|
name: name,
|
178
|
-
display_name: name
|
209
|
+
display_name: model.human_attribute_name(name),
|
179
210
|
slug: name.underscore,
|
180
211
|
model_name: model_class.name.underscore,
|
181
212
|
foreign_key: ref.foreign_key,
|
@@ -29,7 +29,7 @@ module Motor
|
|
29
29
|
updated_model = model.merge(configs.slice(*RESOURCE_ATTRS))
|
30
30
|
|
31
31
|
merge_actions!(updated_model, configs)
|
32
|
-
|
32
|
+
merge_associations!(updated_model, configs)
|
33
33
|
merge_columns!(updated_model, configs)
|
34
34
|
merge_tabs!(updated_model, configs)
|
35
35
|
merge_scopes!(updated_model, configs)
|
@@ -40,7 +40,7 @@ module Motor
|
|
40
40
|
# @param model [HashWithIndifferentAccess]
|
41
41
|
# @param configs [HashWithIndifferentAccess]
|
42
42
|
# @return [HashWithIndifferentAccess]
|
43
|
-
def
|
43
|
+
def merge_associations!(model, configs)
|
44
44
|
model[:associations] = merge_by_name(
|
45
45
|
model[:associations],
|
46
46
|
configs[:associations],
|
@@ -4,12 +4,12 @@ module Motor
|
|
4
4
|
module BuildSchema
|
5
5
|
module Utils
|
6
6
|
ABBREVIATIONS = {
|
7
|
-
'
|
8
|
-
'
|
9
|
-
'
|
7
|
+
'Id' => 'ID',
|
8
|
+
'Url' => 'URL',
|
9
|
+
'Iso' => 'ISO',
|
10
10
|
'vip' => 'VIP',
|
11
|
-
'
|
12
|
-
'
|
11
|
+
'Ip' => 'IP',
|
12
|
+
'Zip' => 'ZIP'
|
13
13
|
}.freeze
|
14
14
|
|
15
15
|
module_function
|
@@ -15,7 +15,7 @@ module Motor
|
|
15
15
|
def call(current_user = nil, current_ability = nil)
|
16
16
|
cache_keys = LoadFromCache.load_cache_keys
|
17
17
|
|
18
|
-
CACHE_STORE.fetch("#{cache_keys.hash}#{current_user&.id}") do
|
18
|
+
CACHE_STORE.fetch("#{I18n.locale}#{cache_keys.hash}#{current_user&.id}") do
|
19
19
|
CACHE_STORE.clear
|
20
20
|
|
21
21
|
data = build_data(cache_keys, current_user, current_ability)
|
@@ -29,6 +29,7 @@ module Motor
|
|
29
29
|
current_user: current_user&.as_json(only: %i[id email]),
|
30
30
|
current_rules: current_ability.serialized_rules,
|
31
31
|
audits_count: Motor::Audit.count,
|
32
|
+
i18n: i18n_data,
|
32
33
|
base_path: Motor::Admin.routes.url_helpers.motor_path,
|
33
34
|
schema: Motor::BuildSchema.call(cache_keys, current_ability),
|
34
35
|
header_links: header_links_data_hash(cache_keys[:configs]),
|
@@ -42,6 +43,10 @@ module Motor
|
|
42
43
|
}
|
43
44
|
end
|
44
45
|
|
46
|
+
def i18n_data
|
47
|
+
I18n.t('motor', default: I18n.t('motor', locale: :en))
|
48
|
+
end
|
49
|
+
|
45
50
|
# @return [String]
|
46
51
|
def build_cache_key(cache_keys, key, current_user, current_ability)
|
47
52
|
"#{cache_keys[key].hash}#{current_user&.id}#{current_ability&.rules_hash}"
|
data/lib/motor/version.rb
CHANGED
Binary file
|
Binary file
|
data/ui/dist/manifest.json
CHANGED
@@ -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-
|
2072
|
-
"main-
|
2073
|
-
"main-
|
2074
|
-
"main.css": "main-
|
2075
|
-
"main.js": "main-
|
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",
|
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.
|
4
|
+
version: 0.1.71
|
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-
|
11
|
+
date: 2021-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord-filter
|
@@ -162,6 +162,8 @@ files:
|
|
162
162
|
- app/views/layouts/motor/application.html.erb
|
163
163
|
- app/views/motor/alerts_mailer/alert_email.html.erb
|
164
164
|
- app/views/motor/ui/show.html.erb
|
165
|
+
- config/locales/en.yml
|
166
|
+
- config/locales/es.yml
|
165
167
|
- config/routes.rb
|
166
168
|
- lib/generators/motor/install_generator.rb
|
167
169
|
- lib/generators/motor/migration.rb
|
@@ -169,6 +171,7 @@ files:
|
|
169
171
|
- lib/motor-admin.rb
|
170
172
|
- lib/motor.rb
|
171
173
|
- lib/motor/active_record_utils.rb
|
174
|
+
- lib/motor/active_record_utils/action_text_attribute_patch.rb
|
172
175
|
- lib/motor/active_record_utils/active_record_connection_column_patch.rb
|
173
176
|
- lib/motor/active_record_utils/active_record_filter_patch.rb
|
174
177
|
- lib/motor/active_record_utils/active_storage_blob_patch.rb
|
@@ -194,6 +197,7 @@ files:
|
|
194
197
|
- lib/motor/build_schema/active_storage_attachment_schema.rb
|
195
198
|
- lib/motor/build_schema/adjust_devise_model_schema.rb
|
196
199
|
- lib/motor/build_schema/apply_permissions.rb
|
200
|
+
- lib/motor/build_schema/defaults.rb
|
197
201
|
- lib/motor/build_schema/find_display_column.rb
|
198
202
|
- lib/motor/build_schema/find_icon.rb
|
199
203
|
- lib/motor/build_schema/load_from_rails.rb
|
@@ -1491,8 +1495,8 @@ files:
|
|
1491
1495
|
- ui/dist/icons/zoom-money.svg.gz
|
1492
1496
|
- ui/dist/icons/zoom-out.svg.gz
|
1493
1497
|
- ui/dist/icons/zoom-question.svg.gz
|
1494
|
-
- ui/dist/main-
|
1495
|
-
- ui/dist/main-
|
1498
|
+
- ui/dist/main-ff43eb24fb5b62cc171e.css.gz
|
1499
|
+
- ui/dist/main-ff43eb24fb5b62cc171e.js.gz
|
1496
1500
|
- ui/dist/manifest.json
|
1497
1501
|
homepage:
|
1498
1502
|
licenses:
|
Binary file
|
Binary file
|