keystone_ui 0.25.0 → 0.26.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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: c9326e16fe4c64a14c5887cd37a4dee97f6a5683572c5170312f9696f0826b1f
|
|
4
|
+
data.tar.gz: 1f4b15310af0f3fd7ef1523137eb7f35b7697cddf64a3d0326259ae2d3b480c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8d0630ea4fc5547a6f1644fcb73b61630189baae97fe6b2525847b5a8858a28b7db0bcc5d841f4c03541d3f985e99a8eb07f0fe3330ffa6450c90e1d9680081
|
|
7
|
+
data.tar.gz: e26a899b093a8f678c60b43dfe6a8e3d92a2d52c0f38accd1b3421649d99ed36800ad9c3c2a201ba4857c069d5af1c66afb094ad05c182cacfa5cf590fb80546
|
|
@@ -5,16 +5,23 @@ module Keystone
|
|
|
5
5
|
class ActionMenuItemComponent < ViewComponent::Base
|
|
6
6
|
ITEM_CLASSES = "ks-menu-option block w-full text-left"
|
|
7
7
|
|
|
8
|
-
def initialize(label:, href:, method: :get)
|
|
8
|
+
def initialize(label:, href:, method: :get, confirm: nil)
|
|
9
9
|
@label = label
|
|
10
10
|
@href = href
|
|
11
11
|
@method = method.to_sym
|
|
12
|
+
@confirm = confirm
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def question
|
|
16
|
+
return @confirm if @confirm
|
|
17
|
+
|
|
18
|
+
"#{@label} this? This cannot be undone." if @method == :delete
|
|
12
19
|
end
|
|
13
20
|
|
|
14
21
|
def call
|
|
15
22
|
return link_to(@label, @href, class: ITEM_CLASSES) if @method == :get
|
|
16
23
|
|
|
17
|
-
button_to(@href, method: @method, class: ITEM_CLASSES) { @label }
|
|
24
|
+
button_to(@href, method: @method, class: ITEM_CLASSES, form: { data: { turbo_confirm: question }.compact }) { @label }
|
|
18
25
|
end
|
|
19
26
|
end
|
|
20
27
|
end
|
data/lib/keystone_ui/version.rb
CHANGED
|
@@ -120,12 +120,15 @@ outer element. See Conventions before using it.
|
|
|
120
120
|
- `ui_action_menu` — no keywords, takes a block. An ellipsis (⋯) button that
|
|
121
121
|
opens a dropdown of actions, shown at every screen size. Fill the block with
|
|
122
122
|
`ui_action_menu_item` calls.
|
|
123
|
-
- `ui_action_menu_item(label:, href:, method: :get)` — one entry
|
|
124
|
-
menu. With `method: :get` it is a link to `href`. Any other
|
|
125
|
-
`:post`, `:patch` or `:delete`, renders a button inside its
|
|
126
|
-
that sends that method to `href`, so never place such an item
|
|
127
|
-
`ui_form` block, since a form cannot contain another form.
|
|
128
|
-
|
|
123
|
+
- `ui_action_menu_item(label:, href:, method: :get, confirm: nil)` — one entry
|
|
124
|
+
in an action menu. With `method: :get` it is a link to `href`. Any other
|
|
125
|
+
method, such as `:post`, `:patch` or `:delete`, renders a button inside its
|
|
126
|
+
own small form that sends that method to `href`, so never place such an item
|
|
127
|
+
inside a `ui_form` block, since a form cannot contain another form.
|
|
128
|
+
`confirm:` is a question Turbo asks before the item sends. With no
|
|
129
|
+
`confirm:`, a `method: :delete` item asks "<label> this? This cannot be
|
|
130
|
+
undone.", and every other method sends without asking. A `method: :get` item
|
|
131
|
+
is a plain link and ignores `confirm:`.
|
|
129
132
|
- `ui_mobile_actions` — no keywords, takes a block. An ellipsis dropdown for
|
|
130
133
|
mobile actions; the block holds the menu items. Hidden above `lg:`. Use
|
|
131
134
|
`ui_action_menu` instead when the actions must also be reachable on desktop.
|
|
@@ -381,9 +384,10 @@ outer element. See Conventions before using it.
|
|
|
381
384
|
Put the actions on a record, such as Edit and Delete, in an action menu
|
|
382
385
|
rather than in a row of buttons: `menu:` on the `ui_section` that shows the
|
|
383
386
|
record, `table.actions` for a table row, or `ui_action_menu` anywhere else.
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
+
A delete item asks for confirmation on its own, so pass `confirm:` only
|
|
388
|
+
when the developer wants different wording. A `:post`, `:patch` or `:put`
|
|
389
|
+
item sends without asking, so ask the developer whether that action needs
|
|
390
|
+
a question, and pass it as `confirm:` if it does.
|
|
387
391
|
|
|
388
392
|
6. For a table, decide how columns are declared. Use `{ key: "Label" }` hashes
|
|
389
393
|
when every column is plain. Switch the whole set to `Keystone::Ui::Column`
|
|
@@ -78,8 +78,10 @@ holds the catalog.
|
|
|
78
78
|
of actions, shown at every screen size. The mobile action menu is the one
|
|
79
79
|
hidden from `lg:` up. Each action is a label, an address and an HTTP method.
|
|
80
80
|
A plain visit renders as a link. Any other method renders as a button that
|
|
81
|
-
sends that method, so an action that changes data is never a bare link.
|
|
82
|
-
|
|
81
|
+
sends that method, so an action that changes data is never a bare link. An
|
|
82
|
+
action can carry a question that Turbo asks before it runs. A delete asks
|
|
83
|
+
"<label> this? This cannot be undone." unless it is given its own question,
|
|
84
|
+
and other actions ask nothing unless given one. A data table puts each row's actions in one action menu at the end of the row,
|
|
83
85
|
and a section can carry an action menu in its header beside its title.
|
|
84
86
|
- **Options are symbols, and each component accepts its own set.** Appearance is
|
|
85
87
|
chosen by name — `variant:`, `size:`, `type:`, `padding:`, `spacing:`,
|
|
@@ -215,8 +215,9 @@ built on ViewComponent; hook it in before building any screen with those helpers
|
|
|
215
215
|
A page that passes no Back link goes back to the trail's last link. A page
|
|
216
216
|
that passes its own trail or Back link keeps it. With no supplier, or a
|
|
217
217
|
`nil` return, the page shows its Back link. Return `nil`, not an empty
|
|
218
|
-
array, for a page with no trail
|
|
219
|
-
|
|
218
|
+
array, for a page with no trail. An empty array replaces the page's Back
|
|
219
|
+
link with breadcrumbs holding only its title, and on a page that passes
|
|
220
|
+
no Back link it raises `KeystoneUi::MissingBackLink`.
|
|
220
221
|
- Every form and show page must end up with a Back link. A page that passes
|
|
221
222
|
no Back link and no trail, and gets no trail from the supplier, raises
|
|
222
223
|
`KeystoneUi::MissingBackLink` naming the page's title when it renders.
|