pg_rails 7.6.3 → 7.6.5

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: 7c827faeb7ffa9b904395708a6f9c6184a930ee22663bcec472b600046497baa
4
- data.tar.gz: bb256bb482b6697302d7e3b2131f5cd9e3ddeaa17447f739b943091a6b90c431
3
+ metadata.gz: d093a397aa4021d053313ee524475eb24295290e56974623fdf03b0ab14691ee
4
+ data.tar.gz: b0ae6c35558a26ff88d59e4949341a2d1046bd0ff81ff83279961b70d20813dd
5
5
  SHA512:
6
- metadata.gz: c06b67c6b8bdeb5462db606077e29b1d1a68bc58ee65a6df7c9e21a13615f723d68189a497b769faf401160875741caf946010f6b162659aa5d9c8dffec6f35d
7
- data.tar.gz: 471922d32d56e46a8e7d20ecd0fe2793d22849a66d813c8fc103a51a8e1d44d4d8229f1b04457d0b3f16f9a9c6ab6ea052dac95dcd43605b9120ddaf8eeb8a88
6
+ metadata.gz: 2c1d7f92c914bf3ca632cfcb04cdcb9a52870e69a057085df1b68bc7e402a4831f7ce1b008f9aa3a6e50bd3436ce192225f795f52841b939bb0733024c4c98fa
7
+ data.tar.gz: 87b8d08575eca14e090029038176c1dcf352047a340f41b3f908bfaf21b06614e952d5543a595e02503f25bb47d0dd45cb5ba86d74c089f0d4c35cde4b23db96
@@ -204,9 +204,18 @@ 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;
207
+ border-bottom: 1px dotted #333;
208
+ padding-bottom: 1px;
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
+ }
210
219
 
211
220
  a:hover {
212
221
  i {
@@ -214,7 +223,45 @@ input[type=datetime-local], input[type=datetime] {
214
223
  }
215
224
  }
216
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
+
217
240
  input[type=text] {
218
241
  min-width: 22em;
219
242
  }
243
+
244
+ select {
245
+ max-width: 45em;
246
+ }
247
+
248
+ // To display correctly in tables with fixed witdh columns
249
+ .form-select {
250
+ width: initial;
251
+ }
252
+ }
253
+
254
+ // WIP, inline rich text en listados
255
+ .listado {
256
+ .inline-edit {
257
+ display: flex!important;
258
+ align-items: center;
259
+ gap: 0.25em;
260
+
261
+ &:has(.trix-content) .edit-link {
262
+ margin-bottom: 0;
263
+ display: inline;
264
+ border-bottom: none;
265
+ }
266
+ }
220
267
  }
@@ -0,0 +1,27 @@
1
+ class InlineComponent < ViewComponent::Base
2
+ def initialize(model, attribute)
3
+ @model = model
4
+ @attribute = attribute
5
+ @unsuffixed_attribute = unsuffixed(attribute)
6
+ @frame_id = dom_id(model, "#{attribute}_inline_edit")
7
+
8
+ super
9
+ end
10
+
11
+ def before_render
12
+ return unless controller.in_modal?
13
+
14
+ controller.instance_variable_set(:@using_modal, true)
15
+ end
16
+
17
+ SUFIJOS = %i[f text].freeze
18
+ def unsuffixed(attribute)
19
+ ret = attribute.to_s.dup
20
+
21
+ SUFIJOS.each do |sufijo|
22
+ ret.gsub!(/_#{sufijo}$/, '')
23
+ end
24
+
25
+ ret
26
+ end
27
+ end
@@ -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
- = f.field @attribute, label: false, html5: true
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,11 +1,7 @@
1
- class InlineEditComponent < ViewComponent::Base
2
- def initialize(model, attribute)
3
- @model = model
4
- @attribute = attribute
5
- @frame_id = dom_id(model, "#{attribute}_inline_edit")
6
-
1
+ class InlineEditComponent < InlineComponent
2
+ def initialize(*)
7
3
  @wrapper_mappings = {
8
- string: :inline_form_control,
4
+ string: :inline_form_grow,
9
5
  pg_associable: :inline_form_control,
10
6
  date: :inline_form_control,
11
7
  datetime: :inline_form_control,
@@ -14,10 +10,4 @@ class InlineEditComponent < ViewComponent::Base
14
10
 
15
11
  super
16
12
  end
17
-
18
- def before_render
19
- return unless controller.in_modal?
20
-
21
- controller.instance_variable_set(:@using_modal, true)
22
- end
23
13
  end
@@ -1,8 +1,8 @@
1
- - if @model.class.inline_editable?(@attribute) && helpers.policy(@model).edit?
1
+ - if @model.class.inline_editable?(@unsuffixed_attribute) && helpers.policy(@model).edit?
2
2
  = helpers.turbo_frame_tag(@frame_id, class: 'inline-edit')
3
- span = @model.decorate.send(@attribute)
4
3
  = link_to users_inline_edit_path(model: @model.to_gid, attribute: @attribute),
5
- class: 'text-body-tertiary ms-1', style: 'font-size: 0.8em' do
4
+ class: 'text-body-tertiary edit-link', style: 'font-size: 0.8em' do
6
5
  i.bi.bi-pencil
6
+ span = @model.decorate.send(@attribute)
7
7
  - else
8
8
  = @model.decorate.send(@attribute)
@@ -1,15 +1,2 @@
1
- class InlineShowComponent < ViewComponent::Base
2
- def initialize(model, attribute)
3
- @model = model
4
- @attribute = attribute
5
- @frame_id = dom_id(model, "#{attribute}_inline_edit")
6
-
7
- super
8
- end
9
-
10
- def before_render
11
- return unless controller.in_modal?
12
-
13
- controller.instance_variable_set(:@using_modal, true)
14
- end
1
+ class InlineShowComponent < InlineComponent
15
2
  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
@@ -270,6 +270,21 @@ SimpleForm.setup do |config|
270
270
  # inline forms
271
271
  #
272
272
  # inline default_wrapper
273
+ config.wrappers :inline_form_grow, class: 'flex-grow-1' do |b|
274
+ b.use :html5
275
+ b.use :placeholder
276
+ b.optional :maxlength
277
+ b.optional :minlength
278
+ b.optional :pattern
279
+ b.optional :min_max
280
+ b.optional :readonly
281
+ b.use :label, class: 'visually-hidden'
282
+
283
+ b.use :input, class: 'form-control form-control-sm', error_class: 'is-invalid'
284
+ b.use :error, wrap_with: { class: 'invalid-feedback' }
285
+ b.optional :hint, wrap_with: { class: 'form-text' }
286
+ end
287
+
273
288
  config.wrappers :inline_form_control, class: '' do |b|
274
289
  b.use :html5
275
290
  b.use :placeholder
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PgRails
4
- VERSION = '7.6.3'
4
+ VERSION = '7.6.5'
5
5
  end
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.3
4
+ version: 7.6.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Martín Rosso
@@ -674,6 +674,7 @@ files:
674
674
  - pg_engine/app/components/date_selector_component.html.slim
675
675
  - pg_engine/app/components/date_selector_component.rb
676
676
  - pg_engine/app/components/flash_container_component.rb
677
+ - pg_engine/app/components/inline_edit/inline_component.rb
677
678
  - pg_engine/app/components/inline_edit/inline_edit_component.html.slim
678
679
  - pg_engine/app/components/inline_edit/inline_edit_component.rb
679
680
  - pg_engine/app/components/inline_edit/inline_show_component.html.slim