active_scaffold 4.2.0 → 4.2.1

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: 2b0a91aeeb1bc60a06fe9860ed1dd816c7b1c31af2f1ec5ba0edd40eca14aeab
4
- data.tar.gz: c65e359d10216b4a68740814292c4428adcb92fbc4982143f4bdcb245c40fd19
3
+ metadata.gz: 0ce255799e0bff6d3854d55afdf9278d3a283f68f6d0b1a639acf5bd229b359a
4
+ data.tar.gz: 62761ad0b3530526880f7d8ac464f1f61623f76a6cbdd55512ab6e6102b6f963
5
5
  SHA512:
6
- metadata.gz: b6a1157e40597529cc709046dc473313df2f4e57e188b6525ec705a2b2d63ee9e4bd3710dc001aa98ff3dd1c55b3168a8276cca3ff52e4e3464b89edea89dec5
7
- data.tar.gz: 357b94e6fb8e5de5d90d881ea2f797c33b388e8d01401fd5004c05f16f7e6c0148a67532600cb33d7fb3f44b1935c7d4ad8b76b2fbcd55f9b5edeb37bd6c211b
6
+ metadata.gz: ad75a5aef07ab0ed9a6997847249ebfd30b749ffe6502472a74066e86ff08fd196b85579bdec112108a71d149f7918af79cfeec64cdee23d095440594a33dba0
7
+ data.tar.gz: 6bcb9392ee5554b46ebb708d957b061c890b23fc613298c8296370276480b27bae10c4dc7fbb683aeed615aec9bbb1c83de7ac11ada6e1714fcf1d5b6958813b
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ = 4.2.1
2
+ - Fix replacing tinymce fields with update_columns
3
+ - Support refresh_link in radio form UI
4
+ - Rewrite refresh_link JS event handler to find the field without relying in the html structure
5
+
1
6
  = 4.2.0
2
7
  - Integrate LogicalQueryParser, supporting full logical search, or simplified searches with 'all keywords' and 'any keyword' operators.
3
8
  - Display unauthorized column in form as show action, so show_ui or show override is used if exists.
data/README.md CHANGED
@@ -13,11 +13,12 @@ ActiveScaffold provides a quick and powerful user interfaces for CRUD (create, r
13
13
  Branch Details
14
14
  --------------
15
15
  master supports rails >= 7.2.x and ruby >= 3.2.0
16
- 4-1-stable supports rails >= 7.0.x and <= 7.2.x, and ruby >= 3.1.0
16
+ 4-2-stable supports rails >= 7.2.x and ruby >= 3.2.0
17
17
 
18
18
  These versions are not supported anymore:
19
- 4-0-stable supports rails >= 6.1.x and <= 7.2.x, and ruby >= 2.5.0
20
- 3-7-stable supports rails >= 5.2.x and <= 7.1.x, and ruby >= 2.5.0
19
+ 4-1-stable supports rails >= 7.0.x and <= 7.2.x, and ruby >= 3.1.0
20
+ 4-0-stable supports rails >= 6.1.x and <= 7.2.x, and ruby >= 2.5.0
21
+ 3-7-stable supports rails >= 5.2.x and <= 7.1.x, and ruby >= 2.5.0
21
22
  3-6-stable supports rails >= 4.2.x and <= 6.1.x, and ruby >= 2.3.0
22
23
  3-5-stable supports rails >= 4.0.x and <= 5.1.x, and ruby >= 2.0.0
23
24
  3-4-stable supports rails >= 3.2.x and <= 4.2.x, and ruby >= 1.9.3
@@ -321,14 +321,15 @@
321
321
  });
322
322
  jQuery(document).on('click', 'a.refresh-link', function(event) {
323
323
  event.preventDefault();
324
- var element = jQuery(this);
325
- var form_element = element.prev();
326
- var value;
324
+ var element = jQuery(this), selector = element.data('field-selector'), value, form_element;
325
+ form_element = selector.startsWith('#') ? jQuery(selector) : element.closest('.form-element').find(selector);
326
+ if (form_element.is('.draggable-list')) form_element = form_element.closest('.draggable-lists-container');
327
327
  if (form_element.is(".field_with_errors")) form_element = form_element.children().last();
328
328
  if (form_element.is(".checkbox-list")) {
329
329
  value = form_element.find(':checked').map(function(item) { return jQuery(this).val(); }).toArray();
330
330
  form_element = form_element.parent().find("input:checkbox"); // parent is needed for draggable-list, checked list may be empty
331
- } else value = form_element.is("input:checkbox:not(:checked)") ? null : form_element.val();
331
+ } else if (form_element.is(':radio, :checkbox')) value = form_element.filter(':checked').val() || null;
332
+ else value = form_element.val();
332
333
  ActiveScaffold.update_column(form_element, element.attr('href'), element.data('update_send_form'), form_element.attr('id'), value);
333
334
  });
334
335
  jQuery(document).on('click', 'a.visibility-toggle', function(e) {
@@ -7,6 +7,26 @@
7
7
  action_link_close.apply(this);
8
8
  };
9
9
 
10
+ ActiveScaffold.remove_tinymce = function(element) {
11
+ if (typeof(element) == 'string') element = '#' + element;
12
+ element = jQuery(element);
13
+ element.find('textarea.mceEditor').each(function(index, elem) {
14
+ tinymce.remove('#' + elem.id);
15
+ });
16
+ };
17
+
18
+ var as_replace = ActiveScaffold.replace,
19
+ as_replace_html = ActiveScaffold.replace_html;
20
+
21
+ ActiveScaffold.replace = function(element) {
22
+ this.remove_tinymce(element);
23
+ return as_replace.apply(this, arguments);
24
+ };
25
+ ActiveScaffold.replace_html = function(element) {
26
+ this.remove_tinymce(element);
27
+ return as_replace_html.apply(this, arguments);
28
+ };
29
+
10
30
  function loadTinyMCE() {
11
31
  var global_settings = ActiveScaffold.config.tiny_mce_settings || {};
12
32
  var local_settings = jQuery(this).data('tinymce');
@@ -504,7 +504,7 @@ module ActiveScaffold
504
504
  end
505
505
 
506
506
  def active_scaffold_refresh_link(column, html_options, record, ui_options = {})
507
- link_options = {object: record}
507
+ link_options = {object: record, data: {field_selector: ui_options[:field_selector] || "##{html_options[:id]}"}}
508
508
  if html_options['data-update_url']
509
509
  link_options['data-update_send_form'] = html_options['data-update_send_form']
510
510
  link_options['data-update_send_form_selector'] = html_options['data-update_send_form_selector']
@@ -644,6 +644,54 @@ module ActiveScaffold
644
644
  content_tag(:label, radio_button(:record, column.name, value, radio_options) + text)
645
645
  end
646
646
 
647
+ def active_scaffold_input_radio_content(column, record, options, html_options, ui_options)
648
+ if ui_options[:add_new]
649
+ add_new_subform = ui_options[:add_new] == true || ui_options[:add_new][:mode].in?([nil, :subform])
650
+ if add_new_subform
651
+ html_options[:data] ||= {}
652
+ html_options[:data][:subform_id] = active_scaffold_subform_attributes(column, ui_options: ui_options)[:id]
653
+ end
654
+ radio_html_options = html_options.merge(class: "#{html_options[:class]} hide-new-subform")
655
+ else
656
+ radio_html_options = html_options
657
+ end
658
+
659
+ selected = record.send(column.association.name) if column.association
660
+ radios = options.map do |option|
661
+ active_scaffold_radio_option(option, selected&.id, column, radio_html_options, ui_options: ui_options)
662
+ end
663
+
664
+ if ui_options[:include_blank]
665
+ label = ui_options[:include_blank]
666
+ label = as_(ui_options[:include_blank]) if ui_options[:include_blank].is_a?(Symbol)
667
+ radio_id = "#{html_options[:id]}-"
668
+ radios.prepend content_tag(:label, radio_button(:record, column.name, '', html_options.merge(id: radio_id)) + label)
669
+ end
670
+ if ui_options[:add_new]
671
+ if add_new_subform
672
+ create_new = content_tag(:label) do
673
+ radio_button_tag(html_options[:name], '', selected&.new_record?, html_options.merge(
674
+ id: "#{html_options[:id]}-create_new", class: "#{html_options[:class]} show-new-subform"
675
+ ).except(:object)) <<
676
+ active_scaffold_add_new_text(ui_options[:add_new], :add_new_text, :create_new)
677
+ end
678
+ radios << create_new
679
+ skip_link = true
680
+ else
681
+ ui_options = ui_options.merge(add_new: ui_options[:add_new].merge(
682
+ url_options: {
683
+ parent_scope: html_options[:name].gsub(/^record|\[[^\]]*\]$/, '').presence,
684
+ radio_data: html_options.slice(*html_options.keys.grep(/^data-update_/))
685
+ }
686
+ ))
687
+ radios << content_tag(:span, '', class: 'new-radio-container', id: html_options[:id])
688
+ end
689
+ radios << active_scaffold_add_new(column, record, html_options, ui_options: ui_options, skip_link: skip_link)
690
+ end
691
+
692
+ safe_join radios
693
+ end
694
+
647
695
  def active_scaffold_input_radio(column, html_options, ui_options: column.options)
648
696
  record = html_options[:object]
649
697
  html_options.merge!(ui_options[:html_options] || {})
@@ -656,59 +704,19 @@ module ActiveScaffold
656
704
  send(enum_options_method, column, record, ui_options: ui_options)
657
705
  end
658
706
 
659
- selected = record.send(column.association.name) if column.association
660
- selected_id = selected&.id
661
707
  if options.present?
662
- if ui_options[:add_new]
663
- add_new_subform = ui_options[:add_new] == true || ui_options[:add_new][:mode].in?([nil, :subform])
664
- if add_new_subform
665
- html_options[:data] ||= {}
666
- html_options[:data][:subform_id] = active_scaffold_subform_attributes(column, ui_options: ui_options)[:id]
667
- end
668
- radio_html_options = html_options.merge(class: "#{html_options[:class]} hide-new-subform")
669
- else
670
- radio_html_options = html_options
671
- end
672
- radios = options.map do |option|
673
- active_scaffold_radio_option(option, selected_id, column, radio_html_options, ui_options: ui_options)
674
- end
675
- if ui_options[:include_blank]
676
- label = ui_options[:include_blank]
677
- label = as_(ui_options[:include_blank]) if ui_options[:include_blank].is_a?(Symbol)
678
- radio_id = "#{html_options[:id]}-"
679
- radios.prepend content_tag(:label, radio_button(:record, column.name, '', html_options.merge(id: radio_id)) + label)
680
- end
681
- if ui_options[:add_new]
682
- if add_new_subform
683
- create_new = content_tag(:label) do
684
- radio_button_tag(html_options[:name], '', selected&.new_record?, html_options.merge(
685
- id: "#{html_options[:id]}-create_new", class: "#{html_options[:class]} show-new-subform"
686
- ).except(:object)) <<
687
- active_scaffold_add_new_text(ui_options[:add_new], :add_new_text, :create_new)
688
- end
689
- radios << create_new
690
- skip_link = true
691
- else
692
- ui_options = ui_options.merge(add_new: ui_options[:add_new].merge(
693
- url_options: {
694
- parent_scope: html_options[:name].gsub(/^record|\[[^\]]*\]$/, '').presence,
695
- radio_data: html_options.slice(*html_options.keys.grep(/^data-update_/))
696
- }
697
- ))
698
- radios << content_tag(:span, '', class: 'new-radio-container', id: html_options[:id])
699
- end
700
- radios << active_scaffold_add_new(column, record, html_options, ui_options: ui_options, skip_link: skip_link)
701
- end
702
- safe_join radios
708
+ html = active_scaffold_input_radio_content(column, record, options, html_options, ui_options)
703
709
  else
704
- html = content_tag(:span, as_(:no_options), class: "#{html_options[:class]} no-options", id: html_options[:id])
705
- html << hidden_field_tag(html_options[:name], '', id: nil)
710
+ html = content_tag(:span, as_(:no_options), class: "#{html_options[:class]} no-options")
711
+ html << hidden_field_tag(html_options[:name], '', id: html_options[:id])
706
712
  if ui_options[:add_new]
707
713
  html = content_tag(:div, html, class: 'select-field') <<
708
714
  active_scaffold_add_new(column, record, html_options, ui_options: ui_options)
709
715
  end
710
716
  html
711
717
  end
718
+ html << active_scaffold_refresh_link(column, html_options, record, ui_options.merge(field_selector: "[name=\"#{html_options[:name]}\"]")) if ui_options[:refresh_link]
719
+ html
712
720
  end
713
721
 
714
722
  def active_scaffold_input_checkbox(column, options, ui_options: column.options)
@@ -4,7 +4,7 @@ module ActiveScaffold
4
4
  module Version
5
5
  MAJOR = 4
6
6
  MINOR = 2
7
- PATCH = 0
7
+ PATCH = 1
8
8
  FIX = nil
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, FIX].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0
4
+ version: 4.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Many, see README
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-02-03 00:00:00.000000000 Z
11
+ date: 2026-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dartsass-sprockets