plutonium 0.20.4 → 0.21.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 +4 -4
- data/app/assets/plutonium.css +2 -2
- data/app/assets/plutonium.js +19 -144
- data/app/assets/plutonium.js.map +4 -4
- data/app/assets/plutonium.min.js +41 -41
- data/app/assets/plutonium.min.js.map +4 -4
- data/app/views/rodauth/_login_form.html.erb +5 -5
- data/app/views/rodauth/verify_account.html.erb +4 -3
- data/lib/generators/pu/pkg/portal/templates/app/views/package/dashboard/index.html.erb +81 -21
- data/lib/plutonium/interaction/README.md +114 -2
- data/lib/plutonium/interaction/base.rb +3 -0
- data/lib/plutonium/interaction/nested_attributes.rb +93 -0
- data/lib/plutonium/resource/controllers/crud_actions.rb +28 -14
- data/lib/plutonium/resource/controllers/interactive_actions.rb +38 -18
- data/lib/plutonium/resource/record/associated_with.rb +2 -2
- data/lib/plutonium/ui/form/base.rb +6 -0
- data/lib/plutonium/ui/form/resource.rb +22 -7
- data/lib/plutonium/ui/form/theme.rb +1 -1
- data/lib/plutonium/version.rb +1 -1
- data/package.json +1 -1
- data/src/js/controllers/form_controller.js +17 -1
- metadata +3 -2
@@ -8,6 +8,8 @@ module Plutonium
|
|
8
8
|
|
9
9
|
attr_reader :resource_fields, :resource_definition
|
10
10
|
|
11
|
+
alias_method :record, :object
|
12
|
+
|
11
13
|
def initialize(*, resource_fields:, resource_definition:, **, &)
|
12
14
|
super(*, **, &)
|
13
15
|
@resource_fields = resource_fields
|
@@ -59,12 +61,23 @@ module Plutonium
|
|
59
61
|
input_definition = definition.defined_inputs[name] || {}
|
60
62
|
input_options = input_definition[:options] || {}
|
61
63
|
|
64
|
+
condition = input_options[:condition] || field_options[:condition]
|
65
|
+
return if condition && !instance_exec(&condition)
|
66
|
+
|
62
67
|
tag = input_options[:as] || field_options[:as]
|
63
|
-
tag_attributes =
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
tag_attributes =
|
69
|
+
input_options.except(:wrapper, :as, :pre_submit, :condition)
|
70
|
+
if input_options[:pre_submit]
|
71
|
+
tag_attributes[
|
72
|
+
"data-action"
|
73
|
+
] = "change->form#preSubmit"
|
74
|
+
end
|
75
|
+
tag_block =
|
76
|
+
input_definition[:block] ||
|
77
|
+
->(f) do
|
78
|
+
tag ||= f.inferred_field_component
|
79
|
+
f.send(:"#{tag}_tag", **tag_attributes)
|
80
|
+
end
|
68
81
|
|
69
82
|
wrapper_options = input_options[:wrapper] || {}
|
70
83
|
if !wrapper_options[:class] || !wrapper_options[:class].include?("col-span")
|
@@ -73,8 +86,10 @@ module Plutonium
|
|
73
86
|
wrapper_options[:class] = tokens("col-span-full", wrapper_options[:class])
|
74
87
|
end
|
75
88
|
|
76
|
-
field_options = field_options.except(:as)
|
77
|
-
render form.field(name, **field_options).wrapped(
|
89
|
+
field_options = field_options.except(:as, :condition)
|
90
|
+
render form.field(name, **field_options).wrapped(
|
91
|
+
**wrapper_options
|
92
|
+
) do |f|
|
78
93
|
render instance_exec(f, &tag_block)
|
79
94
|
end
|
80
95
|
end
|
@@ -37,7 +37,7 @@ module Plutonium
|
|
37
37
|
# file
|
38
38
|
# file: "w-full border rounded-md shadow-sm font-medium text-sm dark:bg-gray-700 focus:outline-none",
|
39
39
|
# hint themes
|
40
|
-
hint: "mt-2 text-sm text-gray-500 dark:text-gray-200",
|
40
|
+
hint: "mt-2 text-sm text-gray-500 dark:text-gray-200 whitespace-pre",
|
41
41
|
# error themes
|
42
42
|
error: "mt-2 text-sm text-red-600 dark:text-red-500",
|
43
43
|
# button themes
|
data/lib/plutonium/version.rb
CHANGED
data/package.json
CHANGED
@@ -1,11 +1,27 @@
|
|
1
1
|
import { Controller } from "@hotwired/stimulus"
|
2
|
-
import debounce from "lodash.debounce";
|
3
2
|
|
4
3
|
// Connects to data-controller="form"
|
5
4
|
export default class extends Controller {
|
6
5
|
connect() {
|
7
6
|
}
|
7
|
+
|
8
|
+
preSubmit() {
|
9
|
+
// Create a hidden input field
|
10
|
+
const hiddenField = document.createElement('input');
|
11
|
+
hiddenField.type = 'hidden';
|
12
|
+
hiddenField.name = 'pre_submit';
|
13
|
+
hiddenField.value = 'true';
|
14
|
+
|
15
|
+
// Append it to the form
|
16
|
+
this.element.appendChild(hiddenField);
|
8
17
|
|
18
|
+
// Skip validation by setting novalidate attribute
|
19
|
+
this.element.setAttribute('novalidate', '');
|
20
|
+
|
21
|
+
// Submit the form
|
22
|
+
this.submit();
|
23
|
+
}
|
24
|
+
|
9
25
|
submit() {
|
10
26
|
this.element.requestSubmit()
|
11
27
|
}
|
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.
|
4
|
+
version: 0.21.1
|
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-
|
11
|
+
date: 2025-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|
@@ -750,6 +750,7 @@ files:
|
|
750
750
|
- lib/plutonium/interaction/README.md
|
751
751
|
- lib/plutonium/interaction/base.rb
|
752
752
|
- lib/plutonium/interaction/concerns/workflow_dsl.rb
|
753
|
+
- lib/plutonium/interaction/nested_attributes.rb
|
753
754
|
- lib/plutonium/interaction/outcome.rb
|
754
755
|
- lib/plutonium/interaction/response/base.rb
|
755
756
|
- lib/plutonium/interaction/response/failure.rb
|