pg_rails 7.0.6 → 7.0.8.pre.alpha

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.
Files changed (88) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +13 -0
  3. data/pg_associable/app/assets/{css → stylesheets}/pg_associable.scss +1 -1
  4. data/pg_associable/app/helpers/pg_associable/form_builder_methods.rb +2 -19
  5. data/pg_associable/app/helpers/pg_associable/helpers.rb +2 -1
  6. data/pg_associable/app/inputs/pg_associable_input.rb +53 -0
  7. data/pg_associable/app/javascript/asociable_controller.tsx +171 -0
  8. data/pg_associable/app/{assets/js → javascript}/modal_controller.js +6 -3
  9. data/pg_associable/app/views/pg_associable/_resultados.html.slim +3 -1
  10. data/pg_associable/app/views/pg_associable/_resultados_inline.html.slim +5 -2
  11. data/pg_associable/index.js +2 -4
  12. data/pg_associable/lib/pg_associable/engine.rb +0 -8
  13. data/pg_associable/spec/pg_associable/helpers_spec.rb +4 -3
  14. data/pg_engine/app/admin/accounts.rb +25 -0
  15. data/pg_engine/{lib/templates/activeadmin → app/admin}/audits.rb +3 -3
  16. data/pg_engine/app/admin/dashboard.rb +34 -0
  17. data/pg_engine/app/admin/user_accounts.rb +26 -0
  18. data/pg_engine/{lib/templates/activeadmin → app/admin}/users.rb +1 -2
  19. data/pg_engine/app/assets/javascripts/active_admin.js +1 -0
  20. data/pg_engine/app/assets/stylesheets/active_admin.scss +17 -0
  21. data/pg_engine/app/controllers/admin/accounts_controller.rb +33 -0
  22. data/pg_engine/app/controllers/admin/user_accounts_controller.rb +33 -0
  23. data/pg_engine/app/controllers/admin/users_controller.rb +47 -0
  24. data/pg_engine/app/controllers/pg_engine/resource_helper.rb +1 -0
  25. data/pg_engine/app/decorators/account_decorator.rb +16 -0
  26. data/pg_engine/app/decorators/user_account_decorator.rb +19 -0
  27. data/pg_engine/app/decorators/user_decorator.rb +20 -0
  28. data/pg_engine/app/helpers/pg_engine/flash_helper.rb +1 -1
  29. data/pg_engine/app/models/account.rb +39 -0
  30. data/pg_engine/app/models/user.rb +61 -0
  31. data/pg_engine/app/models/user_account.rb +46 -0
  32. data/pg_engine/app/policies/account_policy.rb +31 -0
  33. data/pg_engine/app/policies/pg_engine/application_policy.rb +1 -1
  34. data/pg_engine/app/policies/user_account_policy.rb +31 -0
  35. data/pg_engine/app/policies/user_policy.rb +31 -0
  36. data/pg_engine/app/views/admin/accounts/_account.html.slim +1 -0
  37. data/pg_engine/app/views/admin/accounts/_form.html.slim +12 -0
  38. data/pg_engine/app/views/admin/accounts/edit.html.slim +5 -0
  39. data/pg_engine/app/views/admin/accounts/new.html.slim +5 -0
  40. data/pg_engine/app/views/admin/accounts/show.html.slim +27 -0
  41. data/pg_engine/app/views/admin/user_accounts/_form.html.slim +12 -0
  42. data/pg_engine/app/views/admin/user_accounts/_user_account.html.slim +1 -0
  43. data/pg_engine/app/views/admin/user_accounts/edit.html.slim +5 -0
  44. data/pg_engine/app/views/admin/user_accounts/new.html.slim +5 -0
  45. data/pg_engine/app/views/admin/user_accounts/show.html.slim +24 -0
  46. data/pg_engine/app/views/admin/users/_form.html.slim +12 -0
  47. data/pg_engine/app/views/admin/users/_user.html.slim +1 -0
  48. data/pg_engine/app/views/admin/users/edit.html.slim +5 -0
  49. data/pg_engine/app/views/admin/users/new.html.slim +5 -0
  50. data/pg_engine/app/views/admin/users/show.html.slim +27 -0
  51. data/pg_engine/config/initializers/active_admin.rb +352 -0
  52. data/pg_engine/config/initializers/devise.rb +313 -0
  53. data/pg_engine/config/locales/devise.en.yml +65 -0
  54. data/pg_engine/config/routes.rb +11 -0
  55. data/pg_engine/db/migrate/20240205194218_devise_create_users.rb +47 -0
  56. data/pg_engine/db/migrate/20240208234111_unaccent.rb +5 -0
  57. data/pg_engine/db/migrate/20240208234901_install_audited.rb +32 -0
  58. data/pg_engine/db/migrate/20240210025702_create_active_admin_comments.rb +16 -0
  59. data/pg_engine/db/migrate/20240211152951_create_accounts.rb +24 -0
  60. data/pg_engine/db/migrate/20240211153049_create_user_accounts.rb +20 -0
  61. data/pg_engine/db/seeds.rb +8 -0
  62. data/pg_engine/lib/pg_engine/engine.rb +16 -2
  63. data/pg_engine/lib/tasks/auto_anotar_modelos.rake +1 -1
  64. data/pg_engine/spec/controllers/admin/accounts_controller_spec.rb +206 -0
  65. data/pg_engine/spec/controllers/admin/user_accounts_controller_spec.rb +189 -0
  66. data/pg_engine/spec/controllers/admin/users_controller_spec.rb +180 -0
  67. data/pg_engine/spec/factories/accounts.rb +11 -0
  68. data/pg_engine/spec/factories/user_accounts.rb +21 -0
  69. data/pg_engine/spec/factories/users.rb +59 -0
  70. data/pg_engine/spec/models/account_spec.rb +13 -0
  71. data/pg_engine/spec/models/user_account_spec.rb +13 -0
  72. data/pg_engine/spec/models/user_spec.rb +13 -0
  73. data/pg_layout/app/views/layouts/pg_layout/layout.html.slim +1 -0
  74. data/pg_layout/app/views/pg_layout/_flash.html.slim +1 -1
  75. data/pg_layout/lib/pg_layout/engine.rb +0 -1
  76. data/pg_rails/lib/version.rb +1 -1
  77. data/pg_rails/scss/pg_rails.scss +1 -1
  78. data/pg_scaffold/lib/generators/pg_pundit/templates/policy.rb +1 -1
  79. data/pg_scaffold/lib/generators/pg_rspec/scaffold/templates/controller_spec.rb +4 -4
  80. data/pg_scaffold/lib/generators/pg_slim/templates/_form.html.slim +1 -1
  81. data/pg_scaffold/spec/generators_spec.rb +1 -1
  82. metadata +62 -14
  83. data/pg_associable/app/assets/js/asociable_controller.js +0 -58
  84. data/pg_associable/app/assets/js/asociable_inline_controller.js +0 -142
  85. data/pg_associable/app/inputs/pg_associable/pg_associable_inline_input.rb +0 -39
  86. data/pg_associable/app/inputs/pg_associable/pg_associable_input.rb +0 -41
  87. data/pg_associable/lib/pg_associable/simple_form_initializer.rb +0 -34
  88. data/pg_associable/lib/tasks/pg_associable_tasks.rake +0 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7c4644fc0bcd9abce95b7cd8ac88f7779b7d8e6096590863d11fd1bbad1f1b7b
4
- data.tar.gz: df1ffd480c688adc40f24613b9d00eb57fe45940067191a942bd18e9d53e1209
3
+ metadata.gz: a6d74fa06142003ba7e436907908f3f7ca491e8ab6367796424de5af92d19217
4
+ data.tar.gz: a8a7545e0881a3fb79d3d2185314619341286488d7b1eeacb265c0adacb1b371
5
5
  SHA512:
6
- metadata.gz: c9afa947ca3962f7e81973a798664900bccdc15ab6dd500c5b8573f5177212585cf35e78194c1219b6137f6dd3198d4e23ffd982702fdc2cac3cbf8ae1f2c8df
7
- data.tar.gz: 4f26bb070447c9c07829628a2d99a7a8a0ec9a7ac8298ab2f4118444316cffa775ff3254577488d2c139d637468c995bc97c5b9d4adf561f17529cfe398d89c5
6
+ metadata.gz: 3f27603a1c050b0c5aada27652696a5b5cff62041d51b31ad99e4b09494a5b5f6b3f2376ce56bf725ae7bc7a3effcbb10d2851e5c9df7530902dec5a2d885f09
7
+ data.tar.gz: ce9641619c78d375984b774fd007c7054e8ac6fe605d0f2c95c0f71bddfe498b081f64589c8a566a4da48d82f60b332d20f1359c937aa8cb34c137fa7a497014
data/README.md CHANGED
@@ -73,3 +73,16 @@ Acceder a la app en <http://localhost:3000/>.
73
73
  4. `bundle exec rails g pg_scaffold Admin/CategoriaDeCosa nombre:string{required} "tipo:integer{enum,required}" fecha:date tiempo:datetime --model-name=CategoriaDeCosa --discard --activeadmin`
74
74
  5. `bundle exec rails g pg_scaffold Admin/Cosa nombre:string{required} "tipo:integer{enum,required}" categoria_de_cosa:references{required} --model-name=Cosa --discard --activeadmin`
75
75
  6. Setup asociacion creable en cosas/_form
76
+
77
+
78
+
79
+ be rake app:pg_engine_engine:install:migrations
80
+
81
+ be rails pg_engine_engine:install:migrations
82
+
83
+
84
+ "build": "esbuild pg_rails/js/index.js --bundle --sourcemap --format=esm --outdir=pg_rails/builds --public-path=/assets",
85
+ "build:css:compile": "sass ./pg_rails/scss/pg_rails.scss:./pg_rails/builds/application.css --no-source-map --load-path=node_modules",
86
+ "build:css:prefix": "postcss ./pg_rails/builds/application.css --use=autoprefixer --output=./pg_rails/builds/application.css",
87
+ "build:css": "yarn build:css:compile && yarn build:css:prefix",
88
+
@@ -7,7 +7,7 @@
7
7
  display: none;
8
8
  }
9
9
  .pg-form {
10
- .pg_associable_inline, .pg_associable {
10
+ .pg_associable {
11
11
  .limpiar {
12
12
  display: none;
13
13
  position: absolute;
@@ -6,26 +6,9 @@ module PgAssociable
6
6
  end
7
7
 
8
8
  def pg_associable(atributo, options = {})
9
- url_modal = namespaced_path(clase_asociacion(atributo), prefix: :abrir_modal)
10
- options[:as] = 'pg_associable/pg_associable'
11
- options[:wrapper] = :pg_associable
12
- options[:url_modal] = url_modal
9
+ options[:as] = 'pg_associable'
10
+ options[:wrapper_html] = { data: { controller: 'asociable', 'asociable-modal-outlet': '.modal' } }
13
11
  association atributo, options
14
12
  end
15
-
16
- def pg_associable_inline(atributo, options = {})
17
- url_search = namespaced_path(clase_asociacion(atributo), prefix: :buscar)
18
- options[:as] = 'pg_associable/pg_associable_inline'
19
- options[:wrapper] = :pg_associable_inline
20
- options[:url_search] = url_search
21
- association atributo, options
22
- end
23
-
24
- def clase_asociacion(atributo)
25
- asociacion = object.class.reflect_on_all_associations.find { |a| a.name == atributo.to_sym }
26
- nombre_clase = asociacion.options[:class_name]
27
- nombre_clase = asociacion.name.to_s.camelize if nombre_clase.nil?
28
- Object.const_get(nombre_clase)
29
- end
30
13
  end
31
14
  end
@@ -10,9 +10,10 @@ module PgAssociable
10
10
 
11
11
  def pg_respond_buscar
12
12
  partial = params[:partial] || 'pg_associable/resultados'
13
+ resultados = params[:resultados] || 'resultados'
13
14
  @collection = policy_scope(@clase_modelo).kept.query(params[:query]).limit(6)
14
15
  render turbo_stream:
15
- turbo_stream.update("resultados-#{params[:id]}",
16
+ turbo_stream.update("#{resultados}-#{params[:id]}",
16
17
  partial:, locals: { collection: @collection })
17
18
  end
18
19
  end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ class PgAssociableInput < SimpleForm::Inputs::StringInput
4
+ include ActionView::Helpers::FormTagHelper
5
+ include Rails.application.routes.url_helpers
6
+ include PgEngine::RouteHelper
7
+
8
+ def hidden_input(_wrapper_options = {})
9
+ @builder.hidden_field(attribute_name)
10
+ end
11
+
12
+ def controller
13
+ # Para que no rompa polymorphic_url en NamespaceDeductor
14
+ end
15
+
16
+ def input(wrapper_options = nil)
17
+ atributo = attribute_name.to_s.gsub('_id', '')
18
+ url_modal = namespaced_path(clase_asociacion(atributo), prefix: :abrir_modal)
19
+ url_search = namespaced_path(clase_asociacion(atributo), prefix: :buscar)
20
+
21
+ input_html_options[:data] = { url_search:, url_modal: }
22
+ input_html_options[:type] = 'text'
23
+
24
+ merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
25
+
26
+ build_input(merged_input_options)
27
+ end
28
+
29
+ def clase_asociacion(atributo)
30
+ asociacion = object.class.reflect_on_all_associations.find { |a| a.name == atributo.to_sym }
31
+ nombre_clase = asociacion.options[:class_name]
32
+ nombre_clase = asociacion.name.to_s.camelize if nombre_clase.nil?
33
+ Object.const_get(nombre_clase)
34
+ end
35
+
36
+ def build_input(input_options)
37
+ content_tag('div', class: 'position-relative') do
38
+ hidden_input + text_field_tag(nil, object.send(reflection.name).to_s,
39
+ input_options) + limpiar + pencil
40
+ end
41
+ end
42
+
43
+ def limpiar(_wrapper_options = nil)
44
+ content_tag('a', href: 'javascript:void(0)', class: 'limpiar', title: 'Limpiar', tabindex: '0',
45
+ data: { action: 'asociable#selectItem' }) do
46
+ '<i class="bi bi-x-lg"></i>'.html_safe
47
+ end
48
+ end
49
+
50
+ def pencil(_wrapper_options = nil)
51
+ '<i tabindex="-1" class="bi bi-pencil pencil"></i>'.html_safe
52
+ end
53
+ end
@@ -0,0 +1,171 @@
1
+ import { Controller } from '@hotwired/stimulus'
2
+ import * as React from 'react'
3
+ import { renderToStaticMarkup } from 'react-dom/server'
4
+
5
+ export default class extends Controller {
6
+ static outlets = ['modal']
7
+
8
+ lastValue = null
9
+ result = null
10
+ elemId = null
11
+ input = null
12
+
13
+ connect () {
14
+ console.log('connect asociable')
15
+
16
+ // ID único para identificar el campo y el modal
17
+ this.elemId = Math.trunc(Math.random() * 1000000000)
18
+
19
+ this.input = this.element.querySelector('input[type=text]')
20
+
21
+ this.element.setAttribute('data-asociable-modal-outlet', `.modal-${this.elemId}`)
22
+ this.element.classList.add(`asociable-${this.elemId}`)
23
+
24
+ this.result = document.createElement('div')
25
+ this.result.setAttribute('id', `resultados-inline-${this.elemId}`)
26
+ this.result.classList.add('resultados-wrapper')
27
+ this.input.parentNode.appendChild(this.result)
28
+
29
+ const input = this.element.querySelector('input[type=text]')
30
+ if (input.value) {
31
+ this.element.classList.add('filled')
32
+ }
33
+ this.element.querySelector('.pencil').onclick = () => {
34
+ input.focus()
35
+ }
36
+
37
+ const debounce = function (callback, wait) {
38
+ let timerId
39
+ return (...args) => {
40
+ clearTimeout(timerId)
41
+ timerId = setTimeout(() => {
42
+ callback(...args)
43
+ }, wait)
44
+ }
45
+ }
46
+ const doSearchBounce = debounce((force) => {
47
+ this.doSearch(force)
48
+ }, 200)
49
+
50
+ this.input.addEventListener('blur', () => {
51
+ this.input.placeholder = ''
52
+ })
53
+ this.input.onfocus = () => {
54
+ this.input.select()
55
+ if (this.input.value.length === 0) {
56
+ this.escribiAlgo()
57
+ }
58
+ }
59
+ this.input.onkeyup = (e) => {
60
+ if (this.input.value.length === 0) {
61
+ this.escribiAlgo()
62
+ }
63
+ if (e.keyCode === 13) {
64
+ doSearchBounce(true)
65
+ } else {
66
+ doSearchBounce()
67
+ }
68
+ }
69
+ this.input.onkeydown = (e) => {
70
+ if (e.keyCode === 13) {
71
+ e.preventDefault()
72
+ return false
73
+ }
74
+ }
75
+ }
76
+
77
+ crearItem () {
78
+ // Si ya hay un modal abierto lo abro y retorno
79
+ if (this.modalOutlets.length > 0) {
80
+ this.modalOutlet.openModal()
81
+ return
82
+ }
83
+
84
+ const elem = (
85
+ <form method="get" action={this.input.dataset.url_modal} data-turbo-stream="true">
86
+ <input type="hidden" name="id" value={this.elemId} />
87
+ </form>
88
+ )
89
+ const form = document.createElement('div')
90
+ form.innerHTML = renderToStaticMarkup(elem)
91
+ document.body.prepend(form)
92
+ form.childNodes[0].requestSubmit()
93
+ form.remove()
94
+ }
95
+
96
+ escribiAlgo () {
97
+ this.input.placeholder = 'Escribí algo para buscar'
98
+ }
99
+
100
+ buscando () {
101
+ this.result.innerHTML = renderToStaticMarkup(
102
+ <div className="resultados" tabIndex={-1}>
103
+ <div className="fst-italic text-secondary">Buscando...</div>
104
+ </div>
105
+ )
106
+ }
107
+
108
+ selectItem (e) {
109
+ if (e.target.dataset.object) {
110
+ this.completarCampo(JSON.parse(e.target.dataset.object))
111
+ } else {
112
+ this.completarCampo(null)
113
+ }
114
+ this.result.innerHTML = ''
115
+ }
116
+
117
+ doSearch (force = false) {
118
+ if (!force && this.input.value.length < 3) {
119
+ return
120
+ }
121
+ if (!force && this.input.value === this.lastValue) {
122
+ return
123
+ }
124
+ this.lastValue = this.input.value
125
+
126
+ const timerId = setTimeout(() => {
127
+ this.buscando()
128
+ }, 200)
129
+ document.addEventListener('turbo:before-stream-render', function () {
130
+ clearTimeout(timerId)
131
+ })
132
+ const elem = (
133
+ <form method="post" action={this.input.dataset.url_search} data-turbo-stream="true">
134
+ <input type="hidden" name="id" value={this.elemId} />
135
+ <input type="hidden" name="partial" value="pg_associable/resultados_inline" />
136
+ <input type="hidden" name="resultados" value="resultados-inline" />
137
+ <input type="hidden" name="query" value={this.input.value} />
138
+ </form>
139
+ )
140
+ const form = document.createElement('div')
141
+ form.innerHTML = renderToStaticMarkup(elem)
142
+ document.body.prepend(form)
143
+ form.childNodes[0].requestSubmit()
144
+ form.remove()
145
+ }
146
+
147
+ completarCampo (object) {
148
+ const textField = this.element.querySelector('input[type=text]')
149
+ const hiddenField = this.element.querySelector('input[type=hidden]')
150
+ if (object) {
151
+ hiddenField.value = object.id
152
+ textField.value = object.to_s
153
+ this.element.classList.add('filled')
154
+ this.element.dataset.object = object
155
+ const event = new CustomEvent('pg_associable:changed', { detail: object })
156
+ this.element.dispatchEvent(event)
157
+ } else {
158
+ textField.value = null
159
+ hiddenField.value = null
160
+ this.element.classList.remove('filled')
161
+ this.element.dataset.object = null
162
+ const event = new CustomEvent('pg_associable:changed')
163
+ this.element.dispatchEvent(event)
164
+ }
165
+ this.result.innerHTML = ''
166
+ }
167
+
168
+ disconnect () {
169
+ console.log('disconnect asociable')
170
+ }
171
+ }
@@ -78,15 +78,18 @@ export default class extends Controller {
78
78
 
79
79
  selectItem (e) {
80
80
  const asociable = this.asociableOutlet
81
- // TODO: text en data
82
- asociable.completarCampo(e.target.dataset.id, e.target.text)
81
+ if (e.target.dataset.object) {
82
+ asociable.completarCampo(JSON.parse(e.target.dataset.object))
83
+ } else {
84
+ asociable.completarCampo(null)
85
+ }
83
86
  this.remove()
84
87
  }
85
88
 
86
89
  responseTargetConnected (e) {
87
90
  const newObject = JSON.parse(e.dataset.response)
88
91
  const asociable = this.asociableOutlet
89
- asociable.completarCampo(newObject.id, newObject.to_s)
92
+ asociable.completarCampo(newObject)
90
93
  this.remove()
91
94
  }
92
95
 
@@ -3,7 +3,9 @@
3
3
  .list-group.list-group-flush
4
4
  - collection.each do |object|
5
5
  = link_to object.to_s, 'javascript:void(0)',
6
- class: 'list-group-item', data: { action: 'modal#selectItem', id: object.id }
6
+ class: 'list-group-item',
7
+ data: { action: 'modal#selectItem', id: object.id, \
8
+ object: object.decorate.to_json }
7
9
  - else
8
10
  ul.list-group.list-group-flush
9
11
  li.list-group-item No hay resultados para "#{params[:query]}"
@@ -1,12 +1,15 @@
1
1
  .resultados tabindex="-1"
2
2
  - if collection.any?
3
3
  .list-group.list-group-flush
4
+ = link_to 'Crear', 'javascript:void(0)',
5
+ class: 'list-group-item', data: { action: 'asociable#crearItem' }
4
6
  = link_to 'Ninguno', 'javascript:void(0)',
5
- class: 'list-group-item', data: { action: 'asociable_inline#selectItem' }
7
+ class: 'list-group-item', data: { action: 'asociable#selectItem' }
6
8
  - collection.each do |object|
7
9
  = link_to object.to_s, 'javascript:void(0)',
8
10
  class: 'list-group-item',
9
- data: { action: 'asociable_inline#selectItem', id: object.id }
11
+ data: { action: 'asociable#selectItem',
12
+ id: object.id, object: object.decorate.to_json }
10
13
  - else
11
14
  ul.list-group.list-group-flush
12
15
  li.list-group-item No hay resultados para "#{params[:query]}"
@@ -1,7 +1,5 @@
1
- import AsociableInlineController from './app/assets/js/asociable_inline_controller'
2
- import AsociableController from './app/assets/js/asociable_controller'
3
- import ModalController from './app/assets/js/modal_controller'
1
+ import AsociableController from './app/javascript/asociable_controller'
2
+ import ModalController from './app/javascript/modal_controller'
4
3
 
5
- window.Stimulus.register('asociable_inline', AsociableInlineController)
6
4
  window.Stimulus.register('asociable', AsociableController)
7
5
  window.Stimulus.register('modal', ModalController)
@@ -1,12 +1,4 @@
1
- require "#{__dir__}/../../app/helpers/pg_associable/helpers"
2
- require "#{__dir__}/../../app/helpers/pg_associable/form_builder_methods"
3
-
4
1
  module PgAssociable
5
2
  class Engine < ::Rails::Engine
6
- isolate_namespace PgAssociable
7
- # initializer 'configurar_simple_form', after: 'factory_bot.set_fixture_replacement' do
8
- initializer 'configurar_pg_scaffold' do
9
- require 'pg_associable/simple_form_initializer'
10
- end
11
3
  end
12
4
  end
@@ -2,10 +2,11 @@ require 'rails_helper'
2
2
 
3
3
  describe PgAssociable::Helpers do
4
4
  describe '#pg_respond_buscar' do
5
- let(:user) { create :user }
5
+ let(:user) { create :user, :developer }
6
6
  let(:ctrl) do
7
- clazz = Class.new(PgEngine::BaseController)
8
- clazz.new
7
+ # clazz = Class.new(Admin::CosasController)
8
+ # clazz.new
9
+ Admin::CosasController.new
9
10
  end
10
11
  let!(:cosa) { create :cosa }
11
12
 
@@ -0,0 +1,25 @@
1
+ ActiveAdmin.register Account do
2
+ permit_params :plan, :nombre, :hashid
3
+
4
+ index do
5
+ selectable_column
6
+ id_column
7
+ column :plan
8
+ column :nombre
9
+ column :hashid
10
+ actions
11
+ end
12
+
13
+ filter :plan
14
+ filter :nombre
15
+ filter :hashid
16
+
17
+ form do |f|
18
+ f.inputs do
19
+ f.input :plan
20
+ f.input :nombre
21
+ f.input :hashid
22
+ end
23
+ f.actions
24
+ end
25
+ end
@@ -1,7 +1,7 @@
1
1
  ActiveAdmin.register Audited::Audit do
2
- permit_params [:auditable_id, :auditable_type, :associated_id, :associated_type, :user_id,
3
- :user_type, :username, :action, :audited_changes, :version, :comment,
4
- :remote_address, :request_uuid, :created_at]
2
+ permit_params %i[auditable_id auditable_type associated_id associated_type user_id
3
+ user_type username action audited_changes version comment
4
+ remote_address request_uuid created_at]
5
5
 
6
6
  # :id
7
7
  # :discarded_at, :fecha, :nombre, :tiempo, :tipo, :created_at, :updated_at, :actualizado_por_id, :creado_por_id
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ ActiveAdmin.register_page 'Dashboard' do
4
+ menu priority: 1, label: proc { I18n.t('active_admin.dashboard') }
5
+
6
+ content title: proc { I18n.t('active_admin.dashboard') } do
7
+ div class: 'blank_slate_container', id: 'dashboard_default_message' do
8
+ span class: 'blank_slate' do
9
+ span I18n.t('active_admin.dashboard_welcome.welcome')
10
+ small I18n.t('active_admin.dashboard_welcome.call_to_action')
11
+ end
12
+ end
13
+
14
+ # Here is an example of a simple dashboard with columns and panels.
15
+ #
16
+ # columns do
17
+ # column do
18
+ # panel "Recent Posts" do
19
+ # ul do
20
+ # Post.recent(5).map do |post|
21
+ # li link_to(post.title, admin_post_path(post))
22
+ # end
23
+ # end
24
+ # end
25
+ # end
26
+
27
+ # column do
28
+ # panel "Info" do
29
+ # para "Welcome to ActiveAdmin."
30
+ # end
31
+ # end
32
+ # end
33
+ end
34
+ end
@@ -0,0 +1,26 @@
1
+ ActiveAdmin.register UserAccount do
2
+ decorate_with UserAccountDecorator
3
+ permit_params :user_id, :account_id, profiles: []
4
+
5
+ index do
6
+ selectable_column
7
+ id_column
8
+ column :user
9
+ column :account
10
+ column :profiles
11
+ actions
12
+ end
13
+
14
+ filter :user
15
+ filter :account
16
+ filter :profiles
17
+
18
+ form do |f|
19
+ f.inputs do
20
+ f.input :user
21
+ f.input :account
22
+ f.input :profiles, as: :select
23
+ end
24
+ f.actions
25
+ end
26
+ end
@@ -1,6 +1,6 @@
1
1
  ActiveAdmin.register User do
2
2
  decorate_with UserDecorator
3
- permit_params :email, :password, :password_confirmation, :confirmed_at, profiles: []
3
+ permit_params :email, :password, :password_confirmation, :confirmed_at
4
4
 
5
5
  index do
6
6
  selectable_column
@@ -19,7 +19,6 @@ ActiveAdmin.register User do
19
19
  else
20
20
  f.input :email
21
21
  f.input :password unless f.object.persisted?
22
- f.input :profiles, as: :select
23
22
  end
24
23
  end
25
24
  f.actions
@@ -0,0 +1 @@
1
+ //= require active_admin/base
@@ -0,0 +1,17 @@
1
+ // Sass variable overrides must be declared before loading up Active Admin's styles.
2
+ //
3
+ // To view the variables that Active Admin provides, take a look at
4
+ // `app/assets/stylesheets/active_admin/mixins/_variables.scss` in the
5
+ // Active Admin source.
6
+ //
7
+ // For example, to change the sidebar width:
8
+ // $sidebar-width: 242px;
9
+
10
+ // Active Admin's got SASS!
11
+ @import "active_admin/mixins";
12
+ @import "active_admin/base";
13
+
14
+ // Overriding any non-variable Sass must be done after the fact.
15
+ // For example, to change the default status-tag color:
16
+ //
17
+ // .status_tag { background: #6090DB; }
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ module Admin
6
+ class AccountsController < AdminController
7
+ before_action { @clase_modelo = Account }
8
+
9
+ before_action(only: :index) { authorize Account }
10
+
11
+ before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
12
+
13
+ add_breadcrumb Account.nombre_plural, :admin_accounts_path
14
+
15
+ private
16
+
17
+ def atributos_permitidos
18
+ %i[plan nombre hashid]
19
+ end
20
+
21
+ def atributos_para_buscar
22
+ %i[plan nombre hashid]
23
+ end
24
+
25
+ def atributos_para_listar
26
+ %i[plan nombre hashid]
27
+ end
28
+
29
+ def atributos_para_mostrar
30
+ %i[plan nombre hashid]
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ module Admin
6
+ class UserAccountsController < AdminController
7
+ before_action { @clase_modelo = UserAccount }
8
+
9
+ before_action(only: :index) { authorize UserAccount }
10
+
11
+ before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
12
+
13
+ add_breadcrumb UserAccount.nombre_plural, :admin_user_accounts_path
14
+
15
+ private
16
+
17
+ def atributos_permitidos
18
+ %i[user_id account_id profiles]
19
+ end
20
+
21
+ def atributos_para_buscar
22
+ %i[user account profiles]
23
+ end
24
+
25
+ def atributos_para_listar
26
+ %i[user account profiles]
27
+ end
28
+
29
+ def atributos_para_mostrar
30
+ %i[user account profiles]
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ # generado con pg_rails
4
+
5
+ module Admin
6
+ class UsersController < AdminController
7
+ before_action { @clase_modelo = User }
8
+
9
+ before_action(only: :index) { authorize User }
10
+
11
+ before_action only: %i[update] do
12
+ params[:user].delete(:password) if params[:user][:password].blank?
13
+ end
14
+
15
+ before_action :set_instancia_modelo, only: %i[new create show edit update destroy]
16
+
17
+ add_breadcrumb User.nombre_plural, :admin_users_path
18
+
19
+ def create
20
+ @user.skip_confirmation!
21
+ pg_respond_create
22
+ end
23
+
24
+ def update
25
+ @user.skip_reconfirmation!
26
+ pg_respond_update
27
+ end
28
+
29
+ private
30
+
31
+ def atributos_permitidos
32
+ %i[email password developer]
33
+ end
34
+
35
+ def atributos_para_buscar
36
+ %i[email developer]
37
+ end
38
+
39
+ def atributos_para_listar
40
+ %i[email developer]
41
+ end
42
+
43
+ def atributos_para_mostrar
44
+ %i[email developer]
45
+ end
46
+ end
47
+ end
@@ -225,6 +225,7 @@ module PgEngine
225
225
  authorize instancia_modelo
226
226
 
227
227
  # TODO: problema en create y update cuando falla la validacion
228
+ # Reproducir el error antes de arreglarlo
228
229
  self.instancia_modelo = instancia_modelo.decorate if action_name.in? %w[show edit new]
229
230
  end
230
231