katalyst-navigation 1.8.4 → 2.0.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.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -2
  3. data/app/assets/builds/katalyst/navigation.esm.js +207 -109
  4. data/app/assets/builds/katalyst/navigation.js +207 -109
  5. data/app/assets/builds/katalyst/navigation.min.js +1 -1
  6. data/app/assets/builds/katalyst/navigation.min.js.map +1 -1
  7. data/app/assets/images/katalyst/navigation/icons/button.svg +1 -0
  8. data/app/assets/images/katalyst/navigation/icons/collapse.svg +3 -0
  9. data/app/assets/images/katalyst/navigation/icons/edit.svg +1 -0
  10. data/app/assets/images/katalyst/navigation/icons/expand.svg +3 -0
  11. data/app/assets/images/katalyst/navigation/icons/heading.svg +1 -0
  12. data/app/assets/images/katalyst/navigation/icons/hidden.svg +1 -0
  13. data/app/assets/images/katalyst/navigation/icons/indent.svg +3 -0
  14. data/app/assets/images/katalyst/navigation/icons/link.svg +1 -0
  15. data/app/assets/images/katalyst/navigation/icons/outdent.svg +4 -0
  16. data/app/assets/images/katalyst/navigation/icons/remove.svg +1 -0
  17. data/app/assets/stylesheets/katalyst/_navigation.scss +3 -0
  18. data/app/assets/stylesheets/katalyst/navigation/editor.css +175 -0
  19. data/app/assets/stylesheets/katalyst/navigation/icons.css +54 -0
  20. data/app/assets/stylesheets/katalyst/navigation/{editor/_status-bar.scss → status-bar.css} +30 -34
  21. data/app/assets/stylesheets/katalyst/navigation.css +3 -0
  22. data/app/components/katalyst/navigation/editor/base_component.rb +0 -6
  23. data/app/components/katalyst/navigation/editor/item_component.html.erb +26 -16
  24. data/app/components/katalyst/navigation/editor/item_component.rb +2 -3
  25. data/app/components/katalyst/navigation/editor/item_editor_component.rb +16 -19
  26. data/app/components/katalyst/navigation/editor/new_item_component.html.erb +15 -14
  27. data/app/components/katalyst/navigation/editor/new_item_component.rb +7 -10
  28. data/app/components/katalyst/navigation/editor/new_items_component.html.erb +41 -2
  29. data/app/components/katalyst/navigation/editor/new_items_component.rb +0 -2
  30. data/app/components/katalyst/navigation/editor/row_component.html.erb +2 -1
  31. data/app/components/katalyst/navigation/editor/status_bar_component.rb +9 -11
  32. data/app/components/katalyst/navigation/editor/table_component.html.erb +0 -6
  33. data/app/components/katalyst/navigation/editor/table_component.rb +12 -14
  34. data/app/components/katalyst/navigation/editor_component.html.erb +7 -0
  35. data/app/components/katalyst/navigation/editor_component.rb +13 -16
  36. data/app/controllers/katalyst/navigation/items_controller.rb +1 -1
  37. data/app/controllers/katalyst/navigation/menus_controller.rb +1 -1
  38. data/app/javascript/navigation/application.js +8 -3
  39. data/app/javascript/navigation/editor/item.js +1 -1
  40. data/app/javascript/navigation/editor/item_editor_controller.js +54 -0
  41. data/app/javascript/navigation/editor/list_controller.js +11 -103
  42. data/app/javascript/navigation/editor/new_items_controller.js +145 -0
  43. data/app/views/katalyst/navigation/items/_button.html.erb +24 -28
  44. data/app/views/katalyst/navigation/items/_form.html.erb +6 -0
  45. data/app/views/katalyst/navigation/items/_form_errors.html.erb +1 -1
  46. data/app/views/katalyst/navigation/items/_heading.html.erb +12 -14
  47. data/app/views/katalyst/navigation/items/_link.html.erb +24 -26
  48. data/app/views/katalyst/navigation/items/edit.html.erb +40 -2
  49. data/app/views/katalyst/navigation/items/edit.turbo_stream.erb +2 -0
  50. data/app/views/katalyst/navigation/items/update.turbo_stream.erb +0 -1
  51. data/app/views/katalyst/navigation/menus/show.html.erb +0 -1
  52. data/lib/katalyst/navigation/engine.rb +0 -1
  53. metadata +21 -28
  54. data/app/assets/stylesheets/katalyst/navigation/editor/_icon.scss +0 -17
  55. data/app/assets/stylesheets/katalyst/navigation/editor/_index.scss +0 -145
  56. data/app/assets/stylesheets/katalyst/navigation/editor/_item-actions.scss +0 -93
  57. data/app/assets/stylesheets/katalyst/navigation/editor/_item-rules.scss +0 -19
  58. data/app/assets/stylesheets/katalyst/navigation/editor/_new-items.scss +0 -67
  59. data/app/javascript/navigation/editor/new_item_controller.js +0 -12
@@ -1,24 +1,34 @@
1
1
  <%= tag.div(**html_attributes) do %>
2
- <div class="tree" data-invisible="<%= !item.visible? %>">
3
- <div role="toolbar" data-tree-accordion-controls>
4
- <span role="button" value="collapse" data-action="click-><%= MENU_CONTROLLER %>#collapse" title="Collapse tree"></span>
5
- <span role="button" value="expand" data-action="click-><%= MENU_CONTROLLER %>#expand" title="Expand tree"></span>
6
- </div>
2
+ <div class="tree">
3
+ <icon class="icon" data-icon="<%= item.model_name.param_key %>" aria-hidden="true">&nbsp;</icon>
7
4
 
8
- <span role="img" value="<%= item.model_name.param_key %>" title="Type"></span>
9
- <h4 class="heading" title="<%= item.title %>"><%= item.title %></h4>
10
- <span role="img" value="invisible" title="Hidden"></span>
11
- </div>
5
+ <%= link_to_if(item.url.presence, item.title, item.url, target: "_blank", rel: "noopener") %>
12
6
 
13
- <div class="url">
14
- <%= link_to item.url || "", item.url || "", data: { turbo: false } %>
7
+ <% unless item.visible? %>
8
+ <icon class="icon" data-icon="hidden" title="Hidden" role="img">&nbsp;</icon>
9
+ <% end %>
15
10
  </div>
16
11
 
17
- <div role="toolbar" data-tree-controls>
18
- <span role="button" value="de-nest" data-action="click-><%= MENU_CONTROLLER %>#deNest" title="Outdent"></span>
19
- <span role="button" value="nest" data-action="click-><%= MENU_CONTROLLER %>#nest" title="Indent"></span>
20
- <%= kpop_link_to("", edit_item_link, role: "button", title: "Edit", value: "edit") %>
21
- <span role="button" value="remove" data-action="click-><%= MENU_CONTROLLER %>#remove" title="Remove"></span>
12
+ <div role="toolbar" class="actions-group">
13
+ <button class="button" data-button-padding="tight" data-text-button data-action="navigation--editor--menu#collapse" title="Collapse tree">
14
+ <icon class="icon" data-icon="collapse" role="img">&nbsp;</icon>
15
+ </button>
16
+ <button class="button" data-button-padding="tight" data-text-button data-action="navigation--editor--menu#expand" title="Expand tree">
17
+ <icon class="icon" data-icon="expand" role="img">&nbsp;</icon>
18
+ </button>
19
+ <button class="button" data-button-padding="tight" data-text-button data-action="navigation--editor--menu#deNest" title="Outdent">
20
+ <icon class="icon" data-icon="outdent" role="img">&nbsp;</icon>
21
+ </button>
22
+ <button class="button" data-button-padding="tight" data-text-button data-action="navigation--editor--menu#nest" title="Indent">
23
+ <icon class="icon" data-icon="indent" role="img">&nbsp;</icon>
24
+ </button>
25
+ <%= link_to(edit_item_link, class: "button", title: "Edit", value: "edit",
26
+ data: { text_button: "", button_padding: "tight", turbo_frame: "navigation--editor--item-editor" }) do %>
27
+ <icon class="icon" data-icon="edit" role="img">&nbsp;</icon>
28
+ <% end %>
29
+ <button class="button" data-button-padding="tight" data-text-button data-action="navigation--editor--menu#remove" title="Remove">
30
+ <icon class="icon" data-icon="remove" role="img">&nbsp;</icon>
31
+ </button>
22
32
  </div>
23
33
 
24
34
  <input autocomplete="off" type="hidden" name="<%= attributes_scope %>[id]" value="<%= item.id %>">
@@ -4,8 +4,6 @@ module Katalyst
4
4
  module Navigation
5
5
  module Editor
6
6
  class ItemComponent < BaseComponent
7
- include KpopHelper
8
-
9
7
  def edit_item_link
10
8
  if item.persisted?
11
9
  helpers.katalyst_navigation.edit_menu_item_path(menu, item)
@@ -20,7 +18,8 @@ module Katalyst
20
18
  {
21
19
  id: dom_id(item),
22
20
  data: {
23
- controller: ITEM_CONTROLLER,
21
+ controller: "navigation--editor--item",
22
+ invisible: ("" unless item.visible?),
24
23
  },
25
24
  }
26
25
  end
@@ -3,24 +3,28 @@
3
3
  module Katalyst
4
4
  module Navigation
5
5
  module Editor
6
- class ItemEditorComponent < BaseComponent
7
- include ::Turbo::FramesHelper
6
+ class ItemEditorComponent < ViewComponent::Base
7
+ attr_reader :menu, :item
8
8
 
9
- module Helpers
10
- def prefix_partial_path_with_controller_namespace
11
- false
12
- end
9
+ alias_method :model, :item
10
+
11
+ def initialize(menu:, item:)
12
+ super()
13
+
14
+ @menu = menu
15
+ @item = item
13
16
  end
14
17
 
15
18
  def call
16
- tag.div(**html_attributes) do
17
- helpers.extend(Helpers)
18
- helpers.render(item.model_name.param_key, item:, path:)
19
- end
19
+ render("form", model:, scope:, url:, id:)
20
20
  end
21
21
 
22
22
  def id
23
- "item-editor-#{item.id}"
23
+ dom_id(item, :form)
24
+ end
25
+
26
+ def scope
27
+ :item
24
28
  end
25
29
 
26
30
  def title
@@ -31,20 +35,13 @@ module Katalyst
31
35
  end
32
36
  end
33
37
 
34
- def path
38
+ def url
35
39
  if item.persisted?
36
40
  view_context.katalyst_navigation.menu_item_path(menu, item)
37
41
  else
38
42
  view_context.katalyst_navigation.menu_items_path(menu)
39
43
  end
40
44
  end
41
-
42
- def default_html_attributes
43
- {
44
- id:,
45
- class: "navigation--item-editor",
46
- }
47
- end
48
45
  end
49
46
  end
50
47
  end
@@ -1,14 +1,15 @@
1
- <%= tag.div(**html_attributes) do %>
2
- <label><%= label %></label>
3
- <%#
4
- # Template is stored inside the new item dom, and copied into drag
5
- # events when the user initiates drag so that it can be copied into the
6
- # editor list on drop.
7
- #
8
- %>
9
- <template data-<%= NEW_ITEM_CONTROLLER %>-target="template">
10
- <%= render row_component do %>
11
- <%= render item_component %>
12
- <% end %>
13
- </template>
14
- <% end %>
1
+ <li>
2
+ <%= tag.button(**html_attributes) do %>
3
+ <icon class="icon" data-icon="<%= icon_name %>" role="img">&nbsp;</icon>
4
+ <%= label %>
5
+ <%#
6
+ # Template is stored inside the new item dom, and copied into the dom when
7
+ # the user selects the item.
8
+ %>
9
+ <template>
10
+ <%= render row_component do %>
11
+ <%= render item_component %>
12
+ <% end %>
13
+ </template>
14
+ <% end %>
15
+ </li>
@@ -4,10 +4,6 @@ module Katalyst
4
4
  module Navigation
5
5
  module Editor
6
6
  class NewItemComponent < BaseComponent
7
- ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
8
- dragstart->#{NEW_ITEM_CONTROLLER}#dragstart
9
- ACTIONS
10
-
11
7
  with_collection_parameter :item
12
8
 
13
9
  def initialize(item:, menu: item.menu)
@@ -30,16 +26,17 @@ module Katalyst
30
26
  item.model_name.param_key
31
27
  end
32
28
 
29
+ alias icon_name item_type
30
+
33
31
  private
34
32
 
35
33
  def default_html_attributes
36
34
  {
37
- draggable: "true",
38
- role: "listitem",
39
- data: {
40
- item_type:,
41
- controller: NEW_ITEM_CONTROLLER,
42
- action: ACTIONS,
35
+ class: "button",
36
+ role: "listitem",
37
+ data: {
38
+ ghost_button: "",
39
+ action: "navigation--editor--new-items#add",
43
40
  },
44
41
  }
45
42
  end
@@ -1,3 +1,42 @@
1
- <div class="navigation--editor--new-items" role="listbox">
2
- <%= render Katalyst::Navigation::Editor::NewItemComponent.with_collection(items) %>
1
+ <div class="navigation--editor--new-items"
2
+ data-controller="navigation--editor--new-items"
3
+ data-action="turbo:before-morph-element->navigation--editor--new-items#morph">
4
+ <button aria-controls="navigation--editor--new-items-dialog"
5
+ class="button"
6
+ data-action="click->navigation--editor--new-items#open"
7
+ data-button-padding="tight"
8
+ data-text-button>
9
+ <icon aria-hidden="true" class="icon" data-icon="add">&nbsp;</icon>
10
+ Add item
11
+ </button>
12
+ <div class="navigation--editor--inline-add" data-navigation--editor--new-items-target="inline" hidden>
13
+ <button aria-controls="navigation--editor--new-items-dialog"
14
+ class="button"
15
+ data-action="navigation--editor--new-items#open"
16
+ data-button-padding="tight">
17
+ <icon aria-hidden="true" class="icon" data-icon="add">&nbsp;</icon>
18
+ <span class="visually-hidden">Add item here</span>
19
+ </button>
20
+ </div>
21
+ <dialog id="navigation--editor--new-items-dialog" class="modal" data-action="click->navigation--editor--new-items#close">
22
+ <article class="flow" data-action="click->navigation--editor--new-items#noop:stop">
23
+ <header class="repel" data-nowrap>
24
+ <h2>Add item</h2>
25
+ <button class="button"
26
+ data-action="click->navigation--editor--new-items#close"
27
+ data-button-padding="tight"
28
+ data-text-button>
29
+ <icon aria-hidden="true" class="icon" data-icon="close">&nbsp;</icon>
30
+ <span class="visually-hidden">Close</span>
31
+ </button>
32
+ </header>
33
+ <main>
34
+ <%= tag.div(role: "list", data: { action: "click->navigation--editor--new-items#noop:stop" }) do %>
35
+ <ul role="list" class="items-list">
36
+ <%= render Katalyst::Navigation::Editor::NewItemComponent.with_collection(items) %>
37
+ </ul>
38
+ <% end %>
39
+ </main>
40
+ </article>
41
+ </dialog>
3
42
  </div>
@@ -4,8 +4,6 @@ module Katalyst
4
4
  module Navigation
5
5
  module Editor
6
6
  class NewItemsComponent < BaseComponent
7
- include ::Turbo::FramesHelper
8
-
9
7
  renders_many :items, Editor::NewItemComponent
10
8
 
11
9
  def items
@@ -1,4 +1,5 @@
1
- <li draggable="true"
1
+ <li class="navigation--editor--item"
2
+ draggable="true"
2
3
  data-navigation-item
3
4
  data-navigation-item-id="<%= item.id %>"
4
5
  data-navigation-index="<%= item.index %>"
@@ -4,11 +4,6 @@ module Katalyst
4
4
  module Navigation
5
5
  module Editor
6
6
  class StatusBarComponent < BaseComponent
7
- ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
8
- navigation:change@document->#{STATUS_BAR_CONTROLLER}#change
9
- turbo:morph-element->#{STATUS_BAR_CONTROLLER}#morph
10
- ACTIONS
11
-
12
7
  attr_reader :container
13
8
 
14
9
  def call
@@ -28,10 +23,10 @@ module Katalyst
28
23
 
29
24
  def actions
30
25
  tag.menu do
31
- concat action(:discard, class: "button button--text")
32
- concat action(:revert, class: "button button--text") if menu.state == :draft
33
- concat action(:save, class: "button button--secondary")
34
- concat action(:publish, class: "button button--primary")
26
+ concat action(:discard, class: "button", data: { text_button: "" })
27
+ concat action(:revert, class: "button", data: { text_button: "" }) if menu.state == :draft
28
+ concat action(:save, class: "button", data: { ghost_button: "" })
29
+ concat action(:publish, class: "button")
35
30
  end
36
31
  end
37
32
 
@@ -50,8 +45,11 @@ module Katalyst
50
45
  def default_html_attributes
51
46
  {
52
47
  data: {
53
- controller: STATUS_BAR_CONTROLLER,
54
- action: ACTIONS,
48
+ controller: "navigation--editor--status-bar",
49
+ action: %w[
50
+ navigation:change@document->navigation--editor--status-bar#change
51
+ turbo:morph-element->navigation--editor--status-bar#morph
52
+ ],
55
53
  state: menu.state,
56
54
  },
57
55
  }
@@ -1,9 +1,3 @@
1
- <div role="rowheader">
2
- <h4>Title</h4>
3
- <h4>URL</h4>
4
- <h4>Actions</h4>
5
- </div>
6
-
7
1
  <%= tag.ol(id: menu_form_id, **html_attributes) do %>
8
2
  <% items.each do |item| %>
9
3
  <%= item %>
@@ -4,16 +4,6 @@ module Katalyst
4
4
  module Navigation
5
5
  module Editor
6
6
  class TableComponent < BaseComponent
7
- ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
8
- dragstart->#{LIST_CONTROLLER}#dragstart
9
- dragover->#{LIST_CONTROLLER}#dragover
10
- dragenter->#{LIST_CONTROLLER}#dragenter
11
- dragleave->#{LIST_CONTROLLER}#dragleave
12
- drop->#{LIST_CONTROLLER}#drop
13
- dragend->#{LIST_CONTROLLER}#dragend
14
- keyup.esc@document->#{LIST_CONTROLLER}#dragend
15
- ACTIONS
16
-
17
7
  renders_many :items, ->(item) do
18
8
  row = RowComponent.new(item:, menu:)
19
9
  row.with_content(render(ItemComponent.new(item:, menu:)))
@@ -24,11 +14,19 @@ module Katalyst
24
14
 
25
15
  def default_html_attributes
26
16
  {
27
- data: {
28
- controller: LIST_CONTROLLER,
29
- action: ACTIONS,
30
- "#{MENU_CONTROLLER}_target": "menu",
17
+ class: "katalyst--navigation--editor",
18
+ data: {
19
+ controller: "navigation--editor--list",
20
+ action: %w[
21
+ dragstart->navigation--editor--list#dragstart
22
+ dragover->navigation--editor--list#dragover
23
+ drop->navigation--editor--list#drop
24
+ dragend->navigation--editor--list#dragend
25
+ keyup.esc@document->navigation--editor--list#dragend
26
+ ],
27
+ "navigation--editor--menu-target": "menu",
31
28
  },
29
+ role: "list",
32
30
  }
33
31
  end
34
32
  end
@@ -6,4 +6,11 @@
6
6
  <%= render Katalyst::Navigation::Editor::TableComponent.new(menu:) do |list| %>
7
7
  <%= menu.draft_items.each { |item| list.with_item(item) } %>
8
8
  <% end %>
9
+
10
+ <%= render Katalyst::Navigation::Editor::NewItemsComponent.new(menu:) %>
9
11
  <% end %>
12
+
13
+ <%= turbo_frame_tag(
14
+ "navigation--editor--item-editor",
15
+ data: { controller: "navigation--editor--item-editor" },
16
+ ) %>
@@ -3,22 +3,12 @@
3
3
  module Katalyst
4
4
  module Navigation
5
5
  class EditorComponent < Editor::BaseComponent
6
- ACTIONS = <<~ACTIONS.gsub(/\s+/, " ").freeze
7
- submit->#{MENU_CONTROLLER}#reindex
8
- navigation:drop->#{MENU_CONTROLLER}#drop
9
- navigation:reindex->#{MENU_CONTROLLER}#reindex
10
- navigation:reset->#{MENU_CONTROLLER}#reset
11
- turbo:render@document->#{MENU_CONTROLLER}#connect
12
- ACTIONS
6
+ include ::Turbo::FramesHelper
13
7
 
14
8
  def status_bar
15
9
  @status_bar ||= Editor::StatusBarComponent.new(menu:)
16
10
  end
17
11
 
18
- def new_items
19
- @new_items ||= Editor::NewItemsComponent.new(menu:)
20
- end
21
-
22
12
  def item_editor(item:)
23
13
  Editor::ItemEditorComponent.new(menu:, item:)
24
14
  end
@@ -35,11 +25,18 @@ module Katalyst
35
25
 
36
26
  def default_html_attributes
37
27
  {
38
- id: menu_form_id,
39
- data: {
40
- controller: MENU_CONTROLLER,
41
- action: ACTIONS,
42
- "#{MENU_CONTROLLER}-max-depth-value": menu.depth,
28
+ id: menu_form_id,
29
+ class: "navigation--editor",
30
+ data: {
31
+ controller: "navigation--editor--menu",
32
+ action: %w[
33
+ submit->navigation--editor--menu#reindex
34
+ navigation:drop->navigation--editor--menu#drop
35
+ navigation:reindex->navigation--editor--menu#reindex
36
+ navigation:reset->navigation--editor--menu#reset
37
+ turbo:render@document->navigation--editor--menu#connect
38
+ ],
39
+ "navigation--editor--menu-max-depth-value": menu.depth,
43
40
  },
44
41
  }
45
42
  end
@@ -59,7 +59,7 @@ module Katalyst
59
59
  end
60
60
 
61
61
  def item_params
62
- params.require(:item).permit(item_params_type.permitted_params)
62
+ params.expect(item: item_params_type.permitted_params)
63
63
  end
64
64
 
65
65
  def set_menu
@@ -83,7 +83,7 @@ module Katalyst
83
83
  def menu_params
84
84
  return {} if params[:menu].blank?
85
85
 
86
- params.require(:menu).permit(:title, :slug, :depth, items_attributes: %i[id index depth])
86
+ params.expect(menu: [:title, :slug, :depth, { items_attributes: [%i[id index depth]] }])
87
87
  end
88
88
  end
89
89
  end
@@ -1,7 +1,8 @@
1
1
  import MenuController from "./editor/menu_controller";
2
2
  import ItemController from "./editor/item_controller";
3
+ import ItemEditorController from "./editor/item_editor_controller";
3
4
  import ListController from "./editor/list_controller";
4
- import NewItemController from "./editor/new_item_controller";
5
+ import NewItemsController from "./editor/new_items_controller";
5
6
  import StatusBarController from "./editor/status_bar_controller";
6
7
 
7
8
  const Definitions = [
@@ -13,13 +14,17 @@ const Definitions = [
13
14
  identifier: "navigation--editor--item",
14
15
  controllerConstructor: ItemController,
15
16
  },
17
+ {
18
+ identifier: "navigation--editor--item-editor",
19
+ controllerConstructor: ItemEditorController,
20
+ },
16
21
  {
17
22
  identifier: "navigation--editor--list",
18
23
  controllerConstructor: ListController,
19
24
  },
20
25
  {
21
- identifier: "navigation--editor--new-item",
22
- controllerConstructor: NewItemController,
26
+ identifier: "navigation--editor--new-items",
27
+ controllerConstructor: NewItemsController,
23
28
  },
24
29
  {
25
30
  identifier: "navigation--editor--status-bar",
@@ -262,7 +262,7 @@ export default class Item {
262
262
  */
263
263
  function createChildrenList(node) {
264
264
  const childrenList = document.createElement("ol");
265
- childrenList.setAttribute("class", "hidden");
265
+ childrenList.toggleAttribute("hidden", true);
266
266
 
267
267
  childrenList.dataset[`navigationChildren`] = "";
268
268
 
@@ -0,0 +1,54 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+ import Item from "./item";
3
+
4
+ export default class ItemEditorController extends Controller {
5
+ static targets = ["dialog"];
6
+
7
+ connect() {
8
+ this.element.addEventListener("turbo:submit-end", this.onSubmit);
9
+ }
10
+
11
+ disconnect() {
12
+ this.element.removeEventListener("turbo:submit-end", this.onSubmit);
13
+ }
14
+
15
+ dismiss() {
16
+ if (!this.dialogTarget) return;
17
+ if (!this.dialogTarget.open) this.dialogTarget.close();
18
+
19
+ if (!("itemPersisted" in this.dialogTarget.dataset)) {
20
+ this.#removeTargetItem();
21
+ }
22
+
23
+ this.element.removeAttribute("src");
24
+ this.dialogTarget.remove();
25
+ }
26
+
27
+ dialogTargetConnected(dialog) {
28
+ dialog.showModal();
29
+ }
30
+
31
+ onSubmit = (event) => {
32
+ if (event.detail.success) {
33
+ this.dialogTarget.close();
34
+ this.element.removeAttribute("src");
35
+ this.dialogTarget.remove();
36
+ }
37
+ };
38
+
39
+ noop() {}
40
+
41
+ #removeTargetItem() {
42
+ const el = document.getElementById(this.dialogTarget.dataset.itemId);
43
+ const item = new Item(el.closest("[data-navigation-item]"));
44
+ const list = item.node.parentElement;
45
+
46
+ item.node.remove();
47
+
48
+ this.dispatch("reindex", {
49
+ target: list,
50
+ bubbles: true,
51
+ prefix: "navigation",
52
+ });
53
+ }
54
+ }