plutonium 0.19.7 → 0.19.9

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: 3df0f828455b7b089d1b37ded391dce4f0a6a686ffece56ed924d58a06c1186c
4
- data.tar.gz: 4920459f99392f14f070d51d30261c1e7066d8edba8a4c8f9220b5f5ff74c08a
3
+ metadata.gz: 8abd5778444672b73c3d753ff3cabb345b3ce4df072be785fa4b26e7bf467f95
4
+ data.tar.gz: 2d98edacc5cacf6b30c8b5feaf77c3c5c6a4397e39650003ea0216bf15cc6757
5
5
  SHA512:
6
- metadata.gz: 5aac0589c1a66546d09e4e86730710f18f0466701a9baa7574df3e34c4c84e9403bbed71db3eb81034f903a2be7994ad96f541d5843671a4d6aed07b67ab7f63
7
- data.tar.gz: 92b2e0dc58a7a075149069227f7fa9cdc32a8ab0136ccaa61f00480d6793ea8b64304a26d27b51c18db2df8ea86e1c6a7d5ea0fbe0cf5d8a1476443fb7cab6ab
6
+ metadata.gz: 93f0c4e6f53206fc2ff1390b24812637b00e6dd930574304729847222d39d323228991084105f64635da44961132c4c3b241c2d81fb8ffe47c777c02957897f8
7
+ data.tar.gz: 1a0c4f493282a182fe264001b69c4dfd09788e81a2d38ee665edcf10365f369bc638f67d2a7386edcb8e4dff828d26f4b9e5bc686ac4e1174ce0a4bdfced0cb8
@@ -16,7 +16,8 @@ module Plutonium
16
16
  end
17
17
 
18
18
  helper Plutonium::Helpers
19
- helper_method :make_page_title, :resource_url_for, :resource_url_args_for, :root_path
19
+ helper_method :make_page_title, :resource_url_for,
20
+ :resource_url_args_for, :root_path, :app_name
20
21
 
21
22
  append_view_path File.expand_path("app/views", Plutonium.root)
22
23
  layout -> { turbo_frame_request? ? false : "resource" }
@@ -30,7 +31,11 @@ module Plutonium
30
31
  end
31
32
 
32
33
  def make_page_title(title)
33
- [title.presence, helpers.application_name].compact.join(" | ")
34
+ [title.presence, app_name].compact.join(" | ")
35
+ end
36
+
37
+ def app_name
38
+ helpers.application_name
34
39
  end
35
40
 
36
41
  #
@@ -26,6 +26,7 @@ module Plutonium
26
26
  class Base
27
27
  include DefineableProps
28
28
  include ConfigAttr
29
+ include InheritableConfigAttr
29
30
  include Actions
30
31
  include Sorting
31
32
  include Search
@@ -64,6 +65,14 @@ module Plutonium
64
65
  :new_page_title, :new_page_description,
65
66
  :edit_page_title, :edit_page_description
66
67
 
68
+ # breadcrumbs
69
+ inheritable_config_attr :breadcrumbs,
70
+ :index_page_breadcrumbs, :new_page_breadcrumbs,
71
+ :edit_page_breadcrumbs, :show_page_breadcrumbs,
72
+ :interactive_action_page_breadcrumbs
73
+ # global default
74
+ breadcrumbs true
75
+
67
76
  def initialize
68
77
  super
69
78
  end
@@ -0,0 +1,33 @@
1
+ module Plutonium
2
+ module Definition
3
+ module InheritableConfigAttr
4
+ extend ActiveSupport::Concern
5
+
6
+ class_methods do
7
+ def inheritable_config_attr(*names)
8
+ names.each do |name|
9
+ # Create the underlying class_attribute
10
+ attr_name = :"#{name}_config"
11
+ class_attribute attr_name, instance_reader: true, instance_accessor: false, default: nil
12
+
13
+ # Define class-level method that acts as both getter/setter
14
+ define_singleton_method(name) do |value = :__not_set__|
15
+ if value == :__not_set__
16
+ # Getter behavior
17
+ public_send(:"#{attr_name}")
18
+ else
19
+ # Setter behavior
20
+ public_send(:"#{attr_name}=", value)
21
+ end
22
+ end
23
+
24
+ # Instance-level method
25
+ define_method(name) do
26
+ self.class.send(name)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
@@ -20,6 +20,11 @@ module Plutonium
20
20
  def attachment_tag(**, &)
21
21
  create_component(Plutonium::UI::Display::Components::Attachment, :attachment, **, &)
22
22
  end
23
+
24
+ def phlexi_render_tag(**, &)
25
+ create_component(Plutonium::UI::Display::Components::PhlexiRender, :phlexi_render, **, &)
26
+ end
27
+ alias_method :phlexi_tag, :phlexi_render_tag
23
28
  end
24
29
 
25
30
  private
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "redcarpet"
4
+
5
+ module Plutonium
6
+ module UI
7
+ module Display
8
+ module Components
9
+ class PhlexiRender < Phlexi::Display::Components::Base
10
+ include Phlexi::Display::Components::Concerns::DisplaysValue
11
+ include Plutonium::UI::Component::Behaviour
12
+
13
+ def render_value(value)
14
+ phlexi_render(build_phlexi_component(value)) {
15
+ p(**attributes) {
16
+ value
17
+ }
18
+ }
19
+ end
20
+
21
+ protected
22
+
23
+ def build_attributes
24
+ super
25
+ @builder = attributes.delete(:with)
26
+ end
27
+
28
+ def build_phlexi_component(value)
29
+ raise "Required option, :with not passed" unless @builder
30
+
31
+ @builder.call(value, attributes)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -22,7 +22,8 @@ module Plutonium
22
22
  json: "text-sm text-gray-900 dark:text-white mb-1 whitespace-pre font-mono shadow-inner p-4",
23
23
  prefixed_icon: "w-8 h-8 mr-2",
24
24
  markdown: "format dark:format-invert format-primary",
25
- attachment_value_wrapper: "grid grid-cols-[repeat(auto-fill,minmax(0,180px))]"
25
+ attachment_value_wrapper: "grid grid-cols-[repeat(auto-fill,minmax(0,180px))]",
26
+ phlexi_render: :string
26
27
  })
27
28
  end
28
29
  end
@@ -25,7 +25,7 @@ module Plutonium
25
25
  end
26
26
 
27
27
  def submit_button(*, **)
28
- super(*, **) do
28
+ super do
29
29
  object.label
30
30
  end
31
31
  end
@@ -43,9 +43,17 @@ module Plutonium
43
43
  end
44
44
 
45
45
  def render_breadcrumbs
46
+ return unless render_breadcrumbs?
47
+
46
48
  Breadcrumbs()
47
49
  end
48
50
 
51
+ def render_breadcrumbs?
52
+ # Check specific page setting first, fall back to global setting
53
+ page_specific_setting = current_definition.send(:"#{page_type}_breadcrumbs")
54
+ page_specific_setting.nil? ? current_definition.breadcrumbs : page_specific_setting
55
+ end
56
+
49
57
  def render_page_header
50
58
  return unless page_title
51
59
 
@@ -106,6 +114,8 @@ module Plutonium
106
114
 
107
115
  def render_after_footer
108
116
  end
117
+
118
+ def page_type = raise NotImplementedError, "#{self.class}#page_type"
109
119
  end
110
120
  end
111
121
  end
@@ -17,6 +17,8 @@ module Plutonium
17
17
  def render_default_content
18
18
  render "resource_form"
19
19
  end
20
+
21
+ def page_type = :edit_page
20
22
  end
21
23
  end
22
24
  end
@@ -21,6 +21,8 @@ module Plutonium
21
21
  def render_default_content
22
22
  render "resource_table"
23
23
  end
24
+
25
+ def page_type = :index_page
24
26
  end
25
27
  end
26
28
  end
@@ -17,6 +17,8 @@ module Plutonium
17
17
  def render_default_content
18
18
  render "interactive_action_form"
19
19
  end
20
+
21
+ def page_type = :interactive_action_page
20
22
  end
21
23
  end
22
24
  end
@@ -17,6 +17,8 @@ module Plutonium
17
17
  def render_default_content
18
18
  render "resource_form"
19
19
  end
20
+
21
+ def page_type = :new_page
20
22
  end
21
23
  end
22
24
  end
@@ -21,6 +21,8 @@ module Plutonium
21
21
  def render_default_content
22
22
  render "resource_details"
23
23
  end
24
+
25
+ def page_type = :show_page
24
26
  end
25
27
  end
26
28
  end
@@ -1,5 +1,5 @@
1
1
  module Plutonium
2
- VERSION = "0.19.7"
2
+ VERSION = "0.19.9"
3
3
  NEXT_MAJOR_VERSION = VERSION.split(".").tap { |v|
4
4
  v[1] = v[1].to_i + 1
5
5
  v[2] = 0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plutonium
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.7
4
+ version: 0.19.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefan Froelich
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-01-25 00:00:00.000000000 Z
11
+ date: 2025-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk
@@ -726,6 +726,7 @@ files:
726
726
  - lib/plutonium/definition/base.rb
727
727
  - lib/plutonium/definition/config_attr.rb
728
728
  - lib/plutonium/definition/defineable_props.rb
729
+ - lib/plutonium/definition/inheritable_config_attr.rb
729
730
  - lib/plutonium/definition/nested_inputs.rb
730
731
  - lib/plutonium/definition/presentable.rb
731
732
  - lib/plutonium/definition/search.rb
@@ -808,6 +809,7 @@ files:
808
809
  - lib/plutonium/ui/display/components/association.rb
809
810
  - lib/plutonium/ui/display/components/attachment.rb
810
811
  - lib/plutonium/ui/display/components/markdown.rb
812
+ - lib/plutonium/ui/display/components/phlexi_render.rb
811
813
  - lib/plutonium/ui/display/options/inferred_types.rb
812
814
  - lib/plutonium/ui/display/resource.rb
813
815
  - lib/plutonium/ui/display/theme.rb