pg_rails 7.6.4 → 7.6.6

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: 558b69c5a93797c069002f3477d6ccc34b63b98fa4f1a37ddedcc4ab6010ef3b
4
- data.tar.gz: a3cc4d53326372aaa5e7155b2d50cfdee3fc3d0814a81eee53ec3701814c3e23
3
+ metadata.gz: 365f1740542a5fbba1bce8e40441e42581235cd67e68a7890292f512a63535d7
4
+ data.tar.gz: dfc9376def176892e05dc733c8a0df12a97f4b3da8c2fd0a31b1f7f5fc9b77a5
5
5
  SHA512:
6
- metadata.gz: 259c3f0cc7c935f4a5b9569a2cd33cb1cc60e71a1c5cc85118fb3190415ebad4d78065c641bbe0bdaf479639df1be0ef93ded0ad589313f7dd23011ecfa618d8
7
- data.tar.gz: b0e0ad29958f836916d4469d43bd5f3c8797eb9e00a981694034c025158083f28a0ea32bce7057a957bd2d2898d75daf7905fc9e0facd2ec78677f0de06c3389
6
+ metadata.gz: 94fc43c2038e908511860200282138fc7fa4ca95d8536abbbaa1530e5a975ffcdc8e6d64243669511c7c8a9abe6dfea0922f27fc23eea91f71c455d92295851f
7
+ data.tar.gz: 9020921857f2ec5e1d7af48321a9655b2f34557c0496a55b92bebd557772e9873e921bb7f1a9b8133093759c2f388c9ccc395949b13c5ad06ee68d52ae1eee86
@@ -39,7 +39,7 @@ module PgAssociable
39
39
  def collection_pc(atributo, _options)
40
40
  klass = clase_asociacion(atributo)
41
41
  user = Current.user
42
- puede_crear = !template.using_modal? && Pundit::PolicyFinder.new(klass).policy.new(user, klass).new?
42
+ puede_crear = Pundit::PolicyFinder.new(klass).policy.new(user, klass).new_from_associable?
43
43
  collection = Pundit::PolicyFinder.new(klass).scope.new(user, klass).resolve
44
44
  collection = collection.kept if collection.respond_to?(:kept)
45
45
  [collection, puede_crear]
@@ -4,7 +4,8 @@ module PgAssociable
4
4
 
5
5
  def pg_respond_abrir_modal
6
6
  src = clase_modelo.new.decorate.new_object_url
7
- content = ModalContentComponent.new(src:).render_in(view_context)
7
+ turbo_frame_id = "modal_content_#{params[:id]}"
8
+ content = ModalContentComponent.new(src:, turbo_frame_id:).render_in(view_context)
8
9
  modal = AsociableModalComponent.new(modal_id: params[:id]).with_content(content)
9
10
  render turbo_stream: turbo_stream.append_all('body', modal)
10
11
  end
@@ -204,22 +204,47 @@ input[type=datetime-local], input[type=datetime] {
204
204
  // Inline edit
205
205
 
206
206
  .inline-edit {
207
- // text-decoration: underline;
208
- // text-decoration-style: dotted;
209
- // text-decoration-color: #262626;
210
207
  border-bottom: 1px dotted #333;
211
208
  padding-bottom: 1px;
212
209
 
210
+ &:not(:has(.trix-content)) .edit-link {
211
+ margin-right: 0.25em;
212
+ }
213
+
214
+ &:has(.trix-content) .edit-link {
215
+ margin-bottom: 0.55em;
216
+ display: inline-block;
217
+ border-bottom: 1px dotted #333;
218
+ }
219
+
213
220
  a:hover {
214
221
  i {
215
222
  color: black;
216
223
  }
217
224
  }
218
225
 
226
+ form {
227
+ display: flex;
228
+ align-items: start;
229
+ gap: 0.25rem;
230
+
231
+ &:has(trix-editor) {
232
+ display: block;
233
+
234
+ .actions {
235
+ margin-top: 0.25rem;
236
+ }
237
+ }
238
+ }
239
+
219
240
  input[type=text] {
220
241
  min-width: 22em;
221
242
  }
222
243
 
244
+ select {
245
+ max-width: 45em;
246
+ }
247
+
223
248
  // To display correctly in tables with fixed witdh columns
224
249
  .form-select {
225
250
  width: initial;
@@ -1,14 +1,14 @@
1
1
  = helpers.turbo_frame_tag(@frame_id, class: 'inline-edit')
2
- = helpers.pg_form_for(@model, render_errors: false, wrapper_mappings: @wrapper_mappings,
3
- html: { class: 'd-flex align-items-start gap-1' }) do |f|
2
+ = helpers.pg_form_for(@model, render_errors: false, wrapper_mappings: @wrapper_mappings) do |f|
4
3
  = hidden_field_tag :inline_attribute, @attribute
5
4
 
6
5
  = f.field @unsuffixed_attribute, label: false, html5: true
7
6
 
8
- = button_tag class: 'btn btn-sm btn-primary',
9
- data: { controller: 'tooltip', 'bs-title': 'Guardar' } do
10
- i.bi.bi-check-lg
11
- = link_to users_inline_show_path(model: @model.to_gid, attribute: @attribute),
12
- class: 'btn btn-sm btn-secondary',
13
- data: { controller: 'tooltip', 'bs-title': 'Cancelar' } do
14
- i.bi.bi-x-lg
7
+ .actions.d-flex.gap-1
8
+ = button_tag class: 'btn btn-sm btn-primary',
9
+ data: { controller: 'tooltip', 'bs-title': 'Guardar' } do
10
+ i.bi.bi-check-lg
11
+ = link_to users_inline_show_path(model: @model.to_gid, attribute: @attribute),
12
+ class: 'btn btn-sm btn-secondary',
13
+ data: { controller: 'tooltip', 'bs-title': 'Cancelar' } do
14
+ i.bi.bi-x-lg
@@ -1,8 +1,8 @@
1
1
  - if @model.class.inline_editable?(@unsuffixed_attribute) && helpers.policy(@model).edit?
2
2
  = helpers.turbo_frame_tag(@frame_id, class: 'inline-edit')
3
3
  = link_to users_inline_edit_path(model: @model.to_gid, attribute: @attribute),
4
- class: 'text-body-tertiary', style: 'font-size: 0.8em' do
4
+ class: 'text-body-tertiary edit-link', style: 'font-size: 0.8em' do
5
5
  i.bi.bi-pencil
6
- span.ms-1 = @model.decorate.send(@attribute)
6
+ span = @model.decorate.send(@attribute)
7
7
  - else
8
8
  = @model.decorate.send(@attribute)
@@ -1,5 +1,6 @@
1
1
  class ModalContentComponent < ViewComponent::Base
2
- def initialize(src: nil)
2
+ def initialize(src: nil, turbo_frame_id: :modal_content)
3
+ @turbo_frame_id = turbo_frame_id
3
4
  @src = src
4
5
  with_content(loading_html) if @src.present?
5
6
 
@@ -20,7 +21,7 @@ class ModalContentComponent < ViewComponent::Base
20
21
  <div class="flash position-relative w-100 d-flex justify-content-center">
21
22
  </div>
22
23
  </div>
23
- <%= helpers.turbo_frame_tag :modal_content,
24
+ <%= helpers.turbo_frame_tag @turbo_frame_id,
24
25
  **{ src: @src, refresh: :morph }.compact do %>
25
26
  <%= content %>
26
27
  <% end %>
@@ -31,6 +31,8 @@ class PgFormBuilder < SimpleForm::FormBuilder
31
31
 
32
32
  if find_on_all_associations(model.class, attribute_name).present?
33
33
  pg_associable(attribute_name, options)
34
+ elsif model.respond_to?("rich_text_#{attribute_name}")
35
+ rich_text_area attribute_name
34
36
  else
35
37
  input(attribute_name, options, &)
36
38
  end
@@ -28,6 +28,11 @@ class AccountPolicy < ApplicationPolicy
28
28
  # def acceso_total?
29
29
  # user.developer?
30
30
  # end
31
+
32
+ def new_from_associable?
33
+ false
34
+ end
35
+
31
36
  def base_access_to_record?
32
37
  ActsAsTenant.unscoped? ||
33
38
  record.user_accounts.pluck(:user_id).include?(user.id)
@@ -25,6 +25,10 @@ module PgEngine
25
25
  create?
26
26
  end
27
27
 
28
+ def new_from_associable?
29
+ new?
30
+ end
31
+
28
32
  def update?
29
33
  puede_editar? && !objeto_borrado?
30
34
  end
@@ -18,6 +18,10 @@ class UserPolicy < ApplicationPolicy
18
18
  # acceso_total? && !record.readonly?
19
19
  # end
20
20
 
21
+ def new_from_associable?
22
+ false
23
+ end
24
+
21
25
  def base_access_to_record?
22
26
  user.developer? || user == record
23
27
  end
@@ -14,9 +14,9 @@
14
14
  - if @filtros.present?
15
15
  = render SearchBarComponent.new(@q, @filtros)
16
16
 
17
- div
17
+ .table-responsive style="padding-bottom: 15em"
18
18
  - if @collection.any?
19
- .table-responsive
19
+ .xtable-responsive
20
20
  table.table.table-sm.listado.xpg-revert-width.xborder-end
21
21
  caption.ps-3 = page_entries_info @collection
22
22
  thead.table-light
@@ -24,7 +24,8 @@ describe 'Modal windows' do
24
24
  visitar
25
25
  click_on 'Cargar coso'
26
26
  select 'Completar', from: 'cosa_tipo'
27
- select categoria_de_cosa.to_s, from: 'cosa_categoria_de_cosa_id'
27
+ find("input[placeholder='el placeholder'").click
28
+ click_on categoria_de_cosa.to_s
28
29
  find('.modal input[type=submit]').click
29
30
  expect(page).to have_text 'Por favor, revisá los campos obligatorios'
30
31
  fill_in 'cosa_nombre', with: 'bla'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.6.4'
4
+ VERSION = '7.6.6'
5
5
  end
@@ -76,6 +76,11 @@ $values: 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100;
76
76
  text-overflow: ellipsis;
77
77
  white-space: nowrap;
78
78
  min-width: 30em * $value * 0.01;
79
+
80
+ // TODO: con css grid esto se debería poder hacer mejor
81
+ &:has(form) {
82
+ min-width: 28em;
83
+ }
79
84
  }
80
85
  }
81
86
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.6.4
4
+ version: 7.6.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso