compony 0.11.4 → 0.11.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.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/Gemfile.lock +1 -1
  4. data/VERSION +1 -1
  5. data/compony.gemspec +3 -3
  6. data/doc/ComponentGenerator.html +1 -1
  7. data/doc/Components.html +1 -1
  8. data/doc/ComponentsGenerator.html +1 -1
  9. data/doc/Compony/Component.html +50 -48
  10. data/doc/Compony/ComponentMixins/Default/Labelling.html +1 -1
  11. data/doc/Compony/ComponentMixins/Default/Standalone/ResourcefulVerbDsl.html +1 -1
  12. data/doc/Compony/ComponentMixins/Default/Standalone/StandaloneDsl.html +1 -1
  13. data/doc/Compony/ComponentMixins/Default/Standalone/VerbDsl.html +1 -1
  14. data/doc/Compony/ComponentMixins/Default/Standalone.html +1 -1
  15. data/doc/Compony/ComponentMixins/Default.html +1 -1
  16. data/doc/Compony/ComponentMixins/Resourceful.html +1 -1
  17. data/doc/Compony/ComponentMixins.html +1 -1
  18. data/doc/Compony/Components/Buttons/CssButton.html +1 -1
  19. data/doc/Compony/Components/Buttons/Link.html +1 -1
  20. data/doc/Compony/Components/Buttons.html +1 -1
  21. data/doc/Compony/Components/Destroy.html +1 -1
  22. data/doc/Compony/Components/Edit.html +1 -1
  23. data/doc/Compony/Components/Form.html +1 -1
  24. data/doc/Compony/Components/Index.html +1 -1
  25. data/doc/Compony/Components/List.html +39 -33
  26. data/doc/Compony/Components/New.html +1 -1
  27. data/doc/Compony/Components/Show.html +1 -1
  28. data/doc/Compony/Components/WithForm.html +1 -1
  29. data/doc/Compony/Components.html +1 -1
  30. data/doc/Compony/ControllerMixin.html +1 -1
  31. data/doc/Compony/Engine.html +1 -1
  32. data/doc/Compony/Intent.html +1 -1
  33. data/doc/Compony/ManageIntentsDsl.html +1 -1
  34. data/doc/Compony/MethodAccessibleHash.html +1 -1
  35. data/doc/Compony/ModelFields/Anchormodel.html +1 -1
  36. data/doc/Compony/ModelFields/Association.html +1 -1
  37. data/doc/Compony/ModelFields/Attachment.html +1 -1
  38. data/doc/Compony/ModelFields/Base.html +1 -1
  39. data/doc/Compony/ModelFields/Boolean.html +1 -1
  40. data/doc/Compony/ModelFields/Color.html +1 -1
  41. data/doc/Compony/ModelFields/Currency.html +1 -1
  42. data/doc/Compony/ModelFields/Date.html +1 -1
  43. data/doc/Compony/ModelFields/Datetime.html +1 -1
  44. data/doc/Compony/ModelFields/Decimal.html +1 -1
  45. data/doc/Compony/ModelFields/Email.html +1 -1
  46. data/doc/Compony/ModelFields/Float.html +1 -1
  47. data/doc/Compony/ModelFields/Integer.html +1 -1
  48. data/doc/Compony/ModelFields/Percentage.html +1 -1
  49. data/doc/Compony/ModelFields/Phone.html +1 -1
  50. data/doc/Compony/ModelFields/RichText.html +1 -1
  51. data/doc/Compony/ModelFields/String.html +1 -1
  52. data/doc/Compony/ModelFields/Text.html +1 -1
  53. data/doc/Compony/ModelFields/Time.html +1 -1
  54. data/doc/Compony/ModelFields/Url.html +1 -1
  55. data/doc/Compony/ModelFields.html +1 -1
  56. data/doc/Compony/ModelMixin.html +1 -1
  57. data/doc/Compony/NaturalOrdering.html +1 -1
  58. data/doc/Compony/RequestContext.html +66 -1
  59. data/doc/Compony/Version.html +1 -1
  60. data/doc/Compony/ViewHelpers.html +1 -1
  61. data/doc/Compony/VirtualModel.html +1 -1
  62. data/doc/Compony.html +1 -1
  63. data/doc/ComponyController.html +1 -1
  64. data/doc/_index.html +1 -1
  65. data/doc/file.README.html +1 -1
  66. data/doc/index.html +1 -1
  67. data/doc/method_list.html +31 -23
  68. data/doc/top-level-namespace.html +1 -1
  69. data/lib/compony/component.rb +2 -1
  70. data/lib/compony/components/edit.rb +1 -1
  71. data/lib/compony/components/list.rb +9 -6
  72. data/lib/compony/components/new.rb +1 -1
  73. data/lib/compony/request_context.rb +6 -0
  74. metadata +2 -2
@@ -142,7 +142,7 @@
142
142
  </div>
143
143
 
144
144
  <div id="footer">
145
- Generated on Thu Jan 22 13:14:05 2026 by
145
+ Generated on Tue Apr 7 09:32:01 2026 by
146
146
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
147
147
  0.9.34 (ruby-3.3.5).
148
148
  </div>
data/doc/Compony.html CHANGED
@@ -1674,7 +1674,7 @@
1674
1674
  </div>
1675
1675
 
1676
1676
  <div id="footer">
1677
- Generated on Thu Jan 22 13:14:04 2026 by
1677
+ Generated on Tue Apr 7 09:32:00 2026 by
1678
1678
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
1679
1679
  0.9.34 (ruby-3.3.5).
1680
1680
  </div>
@@ -114,7 +114,7 @@
114
114
  </div>
115
115
 
116
116
  <div id="footer">
117
- Generated on Thu Jan 22 13:14:05 2026 by
117
+ Generated on Tue Apr 7 09:32:02 2026 by
118
118
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
119
119
  0.9.34 (ruby-3.3.5).
120
120
  </div>
data/doc/_index.html CHANGED
@@ -622,7 +622,7 @@
622
622
  </div>
623
623
 
624
624
  <div id="footer">
625
- Generated on Thu Jan 22 13:14:04 2026 by
625
+ Generated on Tue Apr 7 09:32:00 2026 by
626
626
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
627
627
  0.9.34 (ruby-3.3.5).
628
628
  </div>
data/doc/file.README.html CHANGED
@@ -199,7 +199,7 @@
199
199
  </div></div>
200
200
 
201
201
  <div id="footer">
202
- Generated on Thu Jan 22 13:14:04 2026 by
202
+ Generated on Tue Apr 7 09:32:00 2026 by
203
203
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
204
204
  0.9.34 (ruby-3.3.5).
205
205
  </div>
data/doc/index.html CHANGED
@@ -199,7 +199,7 @@
199
199
  </div></div>
200
200
 
201
201
  <div id="footer">
202
- Generated on Thu Jan 22 13:14:04 2026 by
202
+ Generated on Tue Apr 7 09:32:00 2026 by
203
203
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
204
204
  0.9.34 (ruby-3.3.5).
205
205
  </div>
data/doc/method_list.html CHANGED
@@ -1749,6 +1749,14 @@
1749
1749
 
1750
1750
 
1751
1751
  <li class="even ">
1752
+ <div class="item">
1753
+ <span class='object_link'><a href="Compony/RequestContext.html#standalone_name-instance_method" title="Compony::RequestContext#standalone_name (method)">#standalone_name</a></span>
1754
+ <small>Compony::RequestContext</small>
1755
+ </div>
1756
+ </li>
1757
+
1758
+
1759
+ <li class="odd ">
1752
1760
  <div class="item">
1753
1761
  <span class='object_link'><a href="Compony/ComponentMixins/Resourceful.html#store_data-instance_method" title="Compony::ComponentMixins::Resourceful#store_data (method)">#store_data</a></span>
1754
1762
  <small>Compony::ComponentMixins::Resourceful</small>
@@ -1756,7 +1764,7 @@
1756
1764
  </li>
1757
1765
 
1758
1766
 
1759
- <li class="odd ">
1767
+ <li class="even ">
1760
1768
  <div class="item">
1761
1769
  <span class='object_link'><a href="Compony/ComponentMixins/Default/Standalone/ResourcefulVerbDsl.html#store_data-instance_method" title="Compony::ComponentMixins::Default::Standalone::ResourcefulVerbDsl#store_data (method)">#store_data</a></span>
1762
1770
  <small>Compony::ComponentMixins::Default::Standalone::ResourcefulVerbDsl</small>
@@ -1764,7 +1772,7 @@
1764
1772
  </li>
1765
1773
 
1766
1774
 
1767
- <li class="even ">
1775
+ <li class="odd ">
1768
1776
  <div class="item">
1769
1777
  <span class='object_link'><a href="Compony/Component.html#sub_comp-instance_method" title="Compony::Component#sub_comp (method)">#sub_comp</a></span>
1770
1778
  <small>Compony::Component</small>
@@ -1772,7 +1780,7 @@
1772
1780
  </li>
1773
1781
 
1774
1782
 
1775
- <li class="odd ">
1783
+ <li class="even ">
1776
1784
  <div class="item">
1777
1785
  <span class='object_link'><a href="Compony/Components/WithForm.html#submit_path-instance_method" title="Compony::Components::WithForm#submit_path (method)">#submit_path</a></span>
1778
1786
  <small>Compony::Components::WithForm</small>
@@ -1780,7 +1788,7 @@
1780
1788
  </li>
1781
1789
 
1782
1790
 
1783
- <li class="even ">
1791
+ <li class="odd ">
1784
1792
  <div class="item">
1785
1793
  <span class='object_link'><a href="Compony/Components/WithForm.html#submit_verb-instance_method" title="Compony::Components::WithForm#submit_verb (method)">#submit_verb</a></span>
1786
1794
  <small>Compony::Components::WithForm</small>
@@ -1788,7 +1796,7 @@
1788
1796
  </li>
1789
1797
 
1790
1798
 
1791
- <li class="odd ">
1799
+ <li class="even ">
1792
1800
  <div class="item">
1793
1801
  <span class='object_link'><a href="Compony/ComponentMixins/Default/Standalone/VerbDsl.html#to_conf-instance_method" title="Compony::ComponentMixins::Default::Standalone::VerbDsl#to_conf (method)">#to_conf</a></span>
1794
1802
  <small>Compony::ComponentMixins::Default::Standalone::VerbDsl</small>
@@ -1796,7 +1804,7 @@
1796
1804
  </li>
1797
1805
 
1798
1806
 
1799
- <li class="even ">
1807
+ <li class="odd ">
1800
1808
  <div class="item">
1801
1809
  <span class='object_link'><a href="Compony/ComponentMixins/Default/Standalone/StandaloneDsl.html#to_conf-instance_method" title="Compony::ComponentMixins::Default::Standalone::StandaloneDsl#to_conf (method)">#to_conf</a></span>
1802
1810
  <small>Compony::ComponentMixins::Default::Standalone::StandaloneDsl</small>
@@ -1804,7 +1812,7 @@
1804
1812
  </li>
1805
1813
 
1806
1814
 
1807
- <li class="odd ">
1815
+ <li class="even ">
1808
1816
  <div class="item">
1809
1817
  <span class='object_link'><a href="Compony/ComponentMixins/Default/Standalone/ResourcefulVerbDsl.html#to_conf-instance_method" title="Compony::ComponentMixins::Default::Standalone::ResourcefulVerbDsl#to_conf (method)">#to_conf</a></span>
1810
1818
  <small>Compony::ComponentMixins::Default::Standalone::ResourcefulVerbDsl</small>
@@ -1812,7 +1820,7 @@
1812
1820
  </li>
1813
1821
 
1814
1822
 
1815
- <li class="even ">
1823
+ <li class="odd ">
1816
1824
  <div class="item">
1817
1825
  <span class='object_link'><a href="Compony/ModelFields/Base.html#transform_and_join-instance_method" title="Compony::ModelFields::Base#transform_and_join (method)">#transform_and_join</a></span>
1818
1826
  <small>Compony::ModelFields::Base</small>
@@ -1820,7 +1828,7 @@
1820
1828
  </li>
1821
1829
 
1822
1830
 
1823
- <li class="odd ">
1831
+ <li class="even ">
1824
1832
  <div class="item">
1825
1833
  <span class='object_link'><a href="Compony/ModelFields/Url.html#value_for-instance_method" title="Compony::ModelFields::Url#value_for (method)">#value_for</a></span>
1826
1834
  <small>Compony::ModelFields::Url</small>
@@ -1828,7 +1836,7 @@
1828
1836
  </li>
1829
1837
 
1830
1838
 
1831
- <li class="even ">
1839
+ <li class="odd ">
1832
1840
  <div class="item">
1833
1841
  <span class='object_link'><a href="Compony/ModelFields/Base.html#value_for-instance_method" title="Compony::ModelFields::Base#value_for (method)">#value_for</a></span>
1834
1842
  <small>Compony::ModelFields::Base</small>
@@ -1836,7 +1844,7 @@
1836
1844
  </li>
1837
1845
 
1838
1846
 
1839
- <li class="odd ">
1847
+ <li class="even ">
1840
1848
  <div class="item">
1841
1849
  <span class='object_link'><a href="Compony/ModelFields/Date.html#value_for-instance_method" title="Compony::ModelFields::Date#value_for (method)">#value_for</a></span>
1842
1850
  <small>Compony::ModelFields::Date</small>
@@ -1844,7 +1852,7 @@
1844
1852
  </li>
1845
1853
 
1846
1854
 
1847
- <li class="even ">
1855
+ <li class="odd ">
1848
1856
  <div class="item">
1849
1857
  <span class='object_link'><a href="Compony/ModelFields/Color.html#value_for-instance_method" title="Compony::ModelFields::Color#value_for (method)">#value_for</a></span>
1850
1858
  <small>Compony::ModelFields::Color</small>
@@ -1852,7 +1860,7 @@
1852
1860
  </li>
1853
1861
 
1854
1862
 
1855
- <li class="odd ">
1863
+ <li class="even ">
1856
1864
  <div class="item">
1857
1865
  <span class='object_link'><a href="Compony/ModelFields/Email.html#value_for-instance_method" title="Compony::ModelFields::Email#value_for (method)">#value_for</a></span>
1858
1866
  <small>Compony::ModelFields::Email</small>
@@ -1860,7 +1868,7 @@
1860
1868
  </li>
1861
1869
 
1862
1870
 
1863
- <li class="even ">
1871
+ <li class="odd ">
1864
1872
  <div class="item">
1865
1873
  <span class='object_link'><a href="Compony/ModelFields/Phone.html#value_for-instance_method" title="Compony::ModelFields::Phone#value_for (method)">#value_for</a></span>
1866
1874
  <small>Compony::ModelFields::Phone</small>
@@ -1868,7 +1876,7 @@
1868
1876
  </li>
1869
1877
 
1870
1878
 
1871
- <li class="odd ">
1879
+ <li class="even ">
1872
1880
  <div class="item">
1873
1881
  <span class='object_link'><a href="Compony/ModelFields/Boolean.html#value_for-instance_method" title="Compony::ModelFields::Boolean#value_for (method)">#value_for</a></span>
1874
1882
  <small>Compony::ModelFields::Boolean</small>
@@ -1876,7 +1884,7 @@
1876
1884
  </li>
1877
1885
 
1878
1886
 
1879
- <li class="even ">
1887
+ <li class="odd ">
1880
1888
  <div class="item">
1881
1889
  <span class='object_link'><a href="Compony/ModelFields/Currency.html#value_for-instance_method" title="Compony::ModelFields::Currency#value_for (method)">#value_for</a></span>
1882
1890
  <small>Compony::ModelFields::Currency</small>
@@ -1884,7 +1892,7 @@
1884
1892
  </li>
1885
1893
 
1886
1894
 
1887
- <li class="odd ">
1895
+ <li class="even ">
1888
1896
  <div class="item">
1889
1897
  <span class='object_link'><a href="Compony/ModelFields/Datetime.html#value_for-instance_method" title="Compony::ModelFields::Datetime#value_for (method)">#value_for</a></span>
1890
1898
  <small>Compony::ModelFields::Datetime</small>
@@ -1892,7 +1900,7 @@
1892
1900
  </li>
1893
1901
 
1894
1902
 
1895
- <li class="even ">
1903
+ <li class="odd ">
1896
1904
  <div class="item">
1897
1905
  <span class='object_link'><a href="Compony/ModelFields/Attachment.html#value_for-instance_method" title="Compony::ModelFields::Attachment#value_for (method)">#value_for</a></span>
1898
1906
  <small>Compony::ModelFields::Attachment</small>
@@ -1900,7 +1908,7 @@
1900
1908
  </li>
1901
1909
 
1902
1910
 
1903
- <li class="odd ">
1911
+ <li class="even ">
1904
1912
  <div class="item">
1905
1913
  <span class='object_link'><a href="Compony/ModelFields/Percentage.html#value_for-instance_method" title="Compony::ModelFields::Percentage#value_for (method)">#value_for</a></span>
1906
1914
  <small>Compony::ModelFields::Percentage</small>
@@ -1908,7 +1916,7 @@
1908
1916
  </li>
1909
1917
 
1910
1918
 
1911
- <li class="even ">
1919
+ <li class="odd ">
1912
1920
  <div class="item">
1913
1921
  <span class='object_link'><a href="Compony/ModelFields/Anchormodel.html#value_for-instance_method" title="Compony::ModelFields::Anchormodel#value_for (method)">#value_for</a></span>
1914
1922
  <small>Compony::ModelFields::Anchormodel</small>
@@ -1916,7 +1924,7 @@
1916
1924
  </li>
1917
1925
 
1918
1926
 
1919
- <li class="odd ">
1927
+ <li class="even ">
1920
1928
  <div class="item">
1921
1929
  <span class='object_link'><a href="Compony/ModelFields/Association.html#value_for-instance_method" title="Compony::ModelFields::Association#value_for (method)">#value_for</a></span>
1922
1930
  <small>Compony::ModelFields::Association</small>
@@ -1924,7 +1932,7 @@
1924
1932
  </li>
1925
1933
 
1926
1934
 
1927
- <li class="even ">
1935
+ <li class="odd ">
1928
1936
  <div class="item">
1929
1937
  <span class='object_link'><a href="Compony/ComponentMixins/Default/Standalone/StandaloneDsl.html#verb-instance_method" title="Compony::ComponentMixins::Default::Standalone::StandaloneDsl#verb (method)">#verb</a></span>
1930
1938
  <small>Compony::ComponentMixins::Default::Standalone::StandaloneDsl</small>
@@ -1932,7 +1940,7 @@
1932
1940
  </li>
1933
1941
 
1934
1942
 
1935
- <li class="odd ">
1943
+ <li class="even ">
1936
1944
  <div class="item">
1937
1945
  <span class='object_link'><a href="Compony/Components/Form.html#with_simpleform-instance_method" title="Compony::Components::Form#with_simpleform (method)">#with_simpleform</a></span>
1938
1946
  <small>Compony::Components::Form</small>
@@ -102,7 +102,7 @@
102
102
  </div>
103
103
 
104
104
  <div id="footer">
105
- Generated on Thu Jan 22 13:14:04 2026 by
105
+ Generated on Tue Apr 7 09:32:00 2026 by
106
106
  <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
107
  0.9.34 (ruby-3.3.5).
108
108
  </div>
@@ -60,7 +60,8 @@ module Compony
60
60
  end
61
61
 
62
62
  def inspect
63
- "#<#{self.class.name}:#{hash}>"
63
+ standalone_paths = standalone_configs.values.to_h { |c| [c[:path], c.verbs.keys] }
64
+ return "#<#{self.class.name} id_path: #{id_path.inspect}, standalone_paths: #{standalone_paths.inspect}, data: #{@data.inspect}>"
64
65
  end
65
66
 
66
67
  # Returns the current root comp.
@@ -86,7 +86,7 @@ module Compony
86
86
 
87
87
  on_update_failed do
88
88
  Rails.logger.warn(@data&.errors&.full_messages)
89
- render_standalone(controller, status: :unprocessable_entity)
89
+ render_standalone(controller, status: :unprocessable_content)
90
90
  end
91
91
  end
92
92
 
@@ -236,22 +236,25 @@ module Compony
236
236
  if filtering_enabled? || sorting_enabled?
237
237
  @q = @data.ransack(controller.params[param_name(:q)], auth_object: controller.current_ability, search_key: param_name(:q))
238
238
  @q.sorts = @default_sorting if @q.sorts.empty?
239
- filtered_data = @q.result.accessible_by(controller.current_ability)
239
+ @filtered_data = @q.result.accessible_by(controller.current_ability)
240
240
  else
241
- filtered_data = @data
241
+ @filtered_data = @data
242
242
  end
243
243
  # Pagination
244
244
  if pagination_enabled?
245
245
  @page = controller.params[param_name('page')].presence&.to_i || 1
246
246
  @pagination_offset = (@page - 1) * @results_per_page
247
- @total_pages = (filtered_data.count.to_f / @results_per_page).ceil
248
- if @pagination_offset < 0 || @pagination_offset >= filtered_data.count # out of bounds check
247
+ @total_pages = (@filtered_data.count.to_f / @results_per_page).ceil
248
+ if @pagination_offset < 0 || @pagination_offset >= @filtered_data.count # out of bounds check
249
249
  @page = 1
250
250
  @pagination_offset = 0
251
251
  end
252
- @processed_data = filtered_data.offset(@pagination_offset).limit(@results_per_page)
252
+ @processed_data = @filtered_data.offset(@pagination_offset).limit(@results_per_page)
253
253
  else
254
- @processed_data = filtered_data
254
+ @processed_data = @filtered_data
255
+ @page = 1
256
+ @total_pages = 1
257
+ @pagination_offset = 0
255
258
  end
256
259
  # Apply skips to configs
257
260
  # Exclude columns that are skipped or the user is not allowed to display
@@ -74,7 +74,7 @@ module Compony
74
74
 
75
75
  on_create_failed_respond do
76
76
  Rails.logger.warn(@data&.errors&.full_messages)
77
- render_standalone(controller, status: :unprocessable_entity)
77
+ render_standalone(controller, status: :unprocessable_content)
78
78
  end
79
79
  end
80
80
 
@@ -89,5 +89,11 @@ module Compony
89
89
  sub_comp(*, **).render(controller)
90
90
  end
91
91
  end
92
+
93
+ # View helper that returns the current request's standalone name as configured when calling `standalone` in the component's `setup`.
94
+ # Attention: returns nil if the standalone name is nil OR component is rendered non-standalone.
95
+ def standalone_name
96
+ component.standalone_configs.find { |_, config| config[:rails_action_name] == action_name }&.first
97
+ end
92
98
  end
93
99
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: compony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.4
4
+ version: 0.11.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Kalbermatter
@@ -369,7 +369,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
369
369
  - !ruby/object:Gem::Version
370
370
  version: '0'
371
371
  requirements: []
372
- rubygems_version: 4.0.4
372
+ rubygems_version: 4.0.7
373
373
  specification_version: 4
374
374
  summary: Compony is a Gem that allows you to write your Rails application in component-style
375
375
  fashion. It combines a controller action and route along \ with its view into a