plutonium 0.8.0 → 0.9.0
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/README.md +6 -0
- data/app/assets/js/controllers/application.js +1 -0
- data/app/assets/js/controllers/index.js +9 -0
- data/app/assets/js/controllers/resource_dismiss_controller.js +37 -0
- data/app/assets/js/controllers/resource_drop_down_controller.js +29 -0
- data/app/assets/js/turbo/index.js +1 -1
- data/app/views/application/_flash.html.erb +1 -1
- data/app/views/application/_flash_alerts.html.erb +51 -7
- data/app/views/application/_flash_toasts.html.erb +53 -23
- data/app/views/application/_resource_header.html.erb +563 -561
- data/app/views/components/form/form_builder.rb +2 -2
- data/app/views/components/form/form_component.html.erb +5 -6
- data/app/views/components/interactive_action_form/interactive_action_form_component.html.erb +1 -1
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.html.erb +66 -0
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_component.rb +23 -0
- data/app/views/components/nested_resource_form_fields/nested_resource_form_fields_controller.js +64 -0
- data/app/views/components/sidebar/sidebar_component.html.erb +61 -63
- data/app/views/components/table_search_input/table_search_input_component.html.erb +1 -1
- data/app/views/layouts/resource.html copy.erb +0 -2
- data/app/views/layouts/resource.html.erb +1 -3
- data/app/views/layouts/rodauth.html.erb +0 -1
- data/app/views/resource/_interactive_resource_action_form.html.erb +1 -1
- data/exe/pug +6 -0
- data/lib/generators/pu/gen/component/component_generator.rb +1 -1
- data/lib/generators/pu/gen/pug/pug_generator.rb +1 -1
- data/lib/generators/pu/lib/plutonium_generators/cli.rb +42 -0
- data/lib/generators/pu/lib/plutonium_generators/generator.rb +1 -5
- data/lib/generators/pu/lib/plutonium_generators/model_generator.rb +1 -1
- data/lib/generators/pu/lib/plutonium_generators.rb +8 -0
- data/lib/plutonium/core/actions/collection.rb +1 -1
- data/lib/plutonium/core/controllers/authorizable.rb +4 -4
- data/lib/plutonium/core/fields/inputs/base.rb +1 -1
- data/lib/plutonium/core/fields/inputs/nested_input.rb +57 -0
- data/lib/plutonium/core/fields/inputs/noop_input.rb +1 -1
- data/lib/plutonium/core/fields/inputs/phone_input.rb +1 -1
- data/lib/plutonium/core/fields/inputs/polymorphic_belongs_to_association_input.rb +1 -1
- data/lib/plutonium/core/fields/inputs/simple_form_association_input.rb +1 -1
- data/lib/plutonium/core/fields/inputs/simple_form_input.rb +1 -1
- data/lib/plutonium/core/fields/renderers/factory.rb +1 -0
- data/lib/plutonium/core/fields/renderers/map_renderer.rb +19 -0
- data/lib/plutonium/resource/policy.rb +6 -0
- data/lib/plutonium/resource/presenter.rb +35 -0
- data/lib/plutonium/resource/record.rb +40 -7
- data/lib/plutonium/version.rb +1 -1
- data/package-lock.json +7 -0
- data/package.json +5 -4
- data/templates/base.rb +8 -0
- metadata +14 -4
- data/app/assets/js/controllers/dropdown_controller.js +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 158056c876d10803c634088f4133a012e7b378f533925ce9fec161734bcc4a39
|
4
|
+
data.tar.gz: a6d0b5e28877477adf1e20a60deca2071861cb2625a263123f0b3536af6062d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c0f9c9a2b24367f18e3f65f009265b1bb991e4080b5652a065186555be298b776710eec9ff4b7bc219b370ca22876cbceb20f175a8ea7d44521610f983e0e52
|
7
|
+
data.tar.gz: 9978c7b3479f59ee8dc5716a61805fcab1632434ce5600acf267ad6f8c829e594529fa2e8a79f89cda43987b2caf7076cea3ce35116ee47775c66c3574eef788
|
data/README.md
CHANGED
@@ -79,3 +79,9 @@ gem "plutonium_generators", github: "radioactive-labs/plutonium-generators", gro
|
|
79
79
|
# --skip-test --skip-system-test --javascript=esbuild --css=bootstrap --database=postgresql
|
80
80
|
|
81
81
|
-->
|
82
|
+
|
83
|
+
```bash
|
84
|
+
rails new pluton8_starter --name="Pluton8 Starter" --database=sqlite3 --skip-action-mailbox --skip-action-text --skip-active-storage --asset-pipeline=propshaft --skip-jbuilder --javascript=importmap --css=tailwind
|
85
|
+
|
86
|
+
bin/rails app:template LOCATION=~/template.rb
|
87
|
+
```
|
@@ -2,6 +2,9 @@ import { application } from "./application"
|
|
2
2
|
|
3
3
|
// Register controllers here
|
4
4
|
|
5
|
+
import NestedResourceFormFieldsController from "../../../../app/views/components/nested_resource_form_fields/nested_resource_form_fields_controller.js"
|
6
|
+
application.register("nested-resource-form-fields", NestedResourceFormFieldsController)
|
7
|
+
|
5
8
|
import TabBarController from "../../../../app/views/components/tab_bar/tab_bar_controller.js"
|
6
9
|
application.register("tab-bar", TabBarController)
|
7
10
|
|
@@ -19,3 +22,9 @@ application.register("table", TableController)
|
|
19
22
|
|
20
23
|
import FormController from "../../../../app/views/components/form/form_controller.js"
|
21
24
|
application.register("form", FormController)
|
25
|
+
|
26
|
+
import ResourceDropDownController from "./resource_drop_down_controller.js"
|
27
|
+
application.register("resource-drop-down", ResourceDropDownController)
|
28
|
+
|
29
|
+
import ResourceDismissController from "./resource_dismiss_controller.js"
|
30
|
+
application.register("resource-dismiss", ResourceDismissController)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import { Dismiss } from 'flowbite';
|
3
|
+
|
4
|
+
|
5
|
+
// Connects to data-controller="resource-dismiss"
|
6
|
+
export default class extends Controller {
|
7
|
+
static targets = ["trigger", "target"]
|
8
|
+
|
9
|
+
static values = {
|
10
|
+
after: Number,
|
11
|
+
}
|
12
|
+
|
13
|
+
connect() {
|
14
|
+
// https://flowbite.com/docs/components/alerts/#javascript-behaviour
|
15
|
+
this.dismiss = new Dismiss(this.targetTarget, this.triggerTarget);
|
16
|
+
|
17
|
+
console.log(this.hasAfterValue)
|
18
|
+
console.log(this.afterValue)
|
19
|
+
if (this.hasAfterValue && this.afterValue > 0) {
|
20
|
+
this.autoDismissTimeout = setTimeout(() => {
|
21
|
+
this.hide()
|
22
|
+
this.autoDismissTimeout = null
|
23
|
+
}, this.afterValue);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
disconnect() {
|
28
|
+
if (this.autoDismissTimeout) clearTimeout(this.autoDismissTimeout)
|
29
|
+
|
30
|
+
this.dismiss = null
|
31
|
+
this.autoDismissTimeout = null
|
32
|
+
}
|
33
|
+
|
34
|
+
hide() {
|
35
|
+
this.dismiss.hide()
|
36
|
+
}
|
37
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { Controller } from "@hotwired/stimulus"
|
2
|
+
import { Dropdown } from 'flowbite';
|
3
|
+
|
4
|
+
|
5
|
+
// Connects to data-controller="resource-drop-down"
|
6
|
+
export default class extends Controller {
|
7
|
+
static targets = ["trigger", "menu"]
|
8
|
+
|
9
|
+
connect() {
|
10
|
+
// https://flowbite.com/docs/components/dropdowns/#javascript-behaviour
|
11
|
+
this.dropdown = new Dropdown(this.menuTarget, this.triggerTarget);
|
12
|
+
}
|
13
|
+
|
14
|
+
disconnect() {
|
15
|
+
this.dropdown = null
|
16
|
+
}
|
17
|
+
|
18
|
+
toggle() {
|
19
|
+
this.dropdown.toggle()
|
20
|
+
}
|
21
|
+
|
22
|
+
show() {
|
23
|
+
this.dropdown.show()
|
24
|
+
}
|
25
|
+
|
26
|
+
hide() {
|
27
|
+
this.dropdown.show()
|
28
|
+
}
|
29
|
+
}
|
@@ -1 +1 @@
|
|
1
|
-
<%= render "
|
1
|
+
<%= render "flash_alerts" %>
|
@@ -1,9 +1,53 @@
|
|
1
1
|
<% flash.each do |type, msg| %>
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
2
|
+
<%
|
3
|
+
color = case type.to_sym
|
4
|
+
when :success
|
5
|
+
# bg-green-50 text-green-800 text-green-500 text-green-400 ring-green-400
|
6
|
+
"green"
|
7
|
+
when :warning
|
8
|
+
# bg-yellow-50 text-yellow-800 text-yellow-500 text-yellow-400 ring-yellow-400
|
9
|
+
"yellow"
|
10
|
+
when :alert, :danger, :error
|
11
|
+
# bg-red-50 text-red-800 text-red-500 text-red-400 ring-red-400
|
12
|
+
"red"
|
13
|
+
else
|
14
|
+
# bg-blue-50 text-blue-800 text-blue-500 text-blue-400 ring-blue-400
|
15
|
+
"blue"
|
16
|
+
end
|
17
|
+
%>
|
18
|
+
|
19
|
+
<div data-controller="resource-dismiss"
|
20
|
+
data-resource-dismiss-target="target"
|
21
|
+
data-resource-dismiss-after-value="6000"
|
22
|
+
class="flex items-center p-4 mb-4 text-<%= color %>-800 rounded-lg bg-<%= color %>-50 dark:bg-gray-800 dark:text-<%= color %>-400"
|
23
|
+
role="alert">
|
24
|
+
<% case type.to_sym %>
|
25
|
+
<% when :success %>
|
26
|
+
<svg class="flex-shrink-0 w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
27
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/>
|
28
|
+
</svg>
|
29
|
+
<% when :warning %>
|
30
|
+
<svg class="flex-shrink-0 w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
31
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z"/>
|
32
|
+
</svg>
|
33
|
+
<% when :alert, :danger, :error %>
|
34
|
+
<svg class="flex-shrink-0 w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
35
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 11.793a1 1 0 1 1-1.414 1.414L10 11.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L8.586 10 6.293 7.707a1 1 0 0 1 1.414-1.414L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414L11.414 10l2.293 2.293Z"/>
|
36
|
+
</svg>
|
37
|
+
<% else %>
|
38
|
+
<svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 20">
|
39
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.147 15.085a7.159 7.159 0 0 1-6.189 3.307A6.713 6.713 0 0 1 3.1 15.444c-2.679-4.513.287-8.737.888-9.548A4.373 4.373 0 0 0 5 1.608c1.287.953 6.445 3.218 5.537 10.5 1.5-1.122 2.706-3.01 2.853-6.14 1.433 1.049 3.993 5.395 1.757 9.117Z"/>
|
40
|
+
</svg>
|
9
41
|
<% end %>
|
42
|
+
<div class="ms-3 text-sm font-normal"><%= msg %></div>
|
43
|
+
<button type="button"
|
44
|
+
class="ms-auto -mx-1.5 -my-1.5 bg-<%= color %>-50 text-<%= color %>-500 rounded-lg focus:ring-2 focus:ring-<%= color %>-400 p-1.5 hover:bg-<%= color %>-200 inline-flex items-center justify-center h-8 w-8 dark:bg-gray-800 dark:text-<%= color %>-400 dark:hover:bg-gray-700"
|
45
|
+
data-resource-dismiss-target="trigger"
|
46
|
+
aria-label="Close">
|
47
|
+
<span class="sr-only">Close</span>
|
48
|
+
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
49
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
50
|
+
</svg>
|
51
|
+
</button>
|
52
|
+
</div>
|
53
|
+
<% end %>
|
@@ -1,26 +1,56 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
1
|
+
<% flash.each do |type, msg| %>
|
2
|
+
<%
|
3
|
+
color = case type.to_sym
|
4
|
+
when :success
|
5
|
+
# text-green-500 bg-green-100 bg-green-800 text-green-200 bg-green-50 text-green-400 ring-green-400
|
6
|
+
"green"
|
7
|
+
when :warning
|
8
|
+
# text-yellow-500 bg-yellow-100 bg-yellow-800 text-yellow-200 bg-yellow-50 text-yellow-400 ring-yellow-400
|
9
|
+
"yellow"
|
10
|
+
when :alert, :danger, :error
|
11
|
+
# text-red-500 bg-red-100 bg-red-800 text-red-200 bg-red-50 text-red-400 ring-red-400
|
12
|
+
"red"
|
13
|
+
else
|
14
|
+
# text-blue-500 bg-blue-100 bg-blue-800 text-blue-200 bg-blue-50 text-blue-400 ring-blue-400
|
15
|
+
"blue"
|
16
|
+
end
|
17
|
+
%>
|
18
|
+
|
19
|
+
<div data-controller="resource-dismiss"
|
20
|
+
data-resource-dismiss-target="target"
|
21
|
+
data-resource-dismiss-after-value="6000"
|
22
|
+
class="fixed z-50 top-16 right-5 flex items-center w-full max-w-md p-4 text-gray-500 bg-<%= color %>-50 rounded-lg shadow dark:text-<%= color %>-400 dark:bg-gray-800"
|
23
|
+
role="alert">
|
24
|
+
|
25
|
+
<div class="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-<%= color %>-500 bg-<%= color %>-100 rounded-lg dark:bg-<%= color %>-800 dark:text-<%= color %>-200">
|
26
|
+
<% case type.to_sym %>
|
27
|
+
<% when :success %>
|
28
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
29
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z"/>
|
30
|
+
</svg>
|
31
|
+
<% when :warning %>
|
32
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
33
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM10 15a1 1 0 1 1 0-2 1 1 0 0 1 0 2Zm1-4a1 1 0 0 1-2 0V6a1 1 0 0 1 2 0v5Z"/>
|
34
|
+
</svg>
|
35
|
+
<% when :alert, :danger, :error %>
|
36
|
+
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
37
|
+
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 11.793a1 1 0 1 1-1.414 1.414L10 11.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L8.586 10 6.293 7.707a1 1 0 0 1 1.414-1.414L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414L11.414 10l2.293 2.293Z"/>
|
38
|
+
</svg>
|
39
|
+
<% else %>
|
40
|
+
<svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 20">
|
41
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.147 15.085a7.159 7.159 0 0 1-6.189 3.307A6.713 6.713 0 0 1 3.1 15.444c-2.679-4.513.287-8.737.888-9.548A4.373 4.373 0 0 0 5 1.608c1.287.953 6.445 3.218 5.537 10.5 1.5-1.122 2.706-3.01 2.853-6.14 1.433 1.049 3.993 5.395 1.757 9.117Z"/>
|
42
|
+
</svg>
|
24
43
|
<% end %>
|
25
44
|
</div>
|
45
|
+
<div class="ms-3 text-sm font-normal"><%= msg %></div>
|
46
|
+
<button type="button"
|
47
|
+
class="ms-auto -mx-1.5 -my-1.5 bg-<%= color %>-50 text-<%= color %>-400 rounded-lg focus:ring-2 focus:ring-<%= color %>-400 p-1.5 hover:bg-<%= color %>-200 inline-flex items-center justify-center h-8 w-8 dark:text-<%= color %>-400 dark:bg-gray-800 dark:hover:bg-gray-700"
|
48
|
+
data-resource-dismiss-target="trigger"
|
49
|
+
aria-label="Close">
|
50
|
+
<span class="sr-only">Close</span>
|
51
|
+
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 14 14">
|
52
|
+
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6"/>
|
53
|
+
</svg>
|
54
|
+
</button>
|
26
55
|
</div>
|
56
|
+
<% end %>
|