katalyst-navigation 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +25 -0
- data/app/assets/config/katalyst-navigation.js +1 -0
- data/app/assets/javascripts/controllers/navigation/editor/item_controller.js +45 -0
- data/app/assets/javascripts/controllers/navigation/editor/list_controller.js +105 -0
- data/app/assets/javascripts/controllers/navigation/editor/menu_controller.js +110 -0
- data/app/assets/javascripts/controllers/navigation/editor/new_item_controller.js +12 -0
- data/app/assets/javascripts/controllers/navigation/editor/status_bar_controller.js +22 -0
- data/app/assets/javascripts/utils/navigation/editor/item.js +245 -0
- data/app/assets/javascripts/utils/navigation/editor/menu.js +54 -0
- data/app/assets/javascripts/utils/navigation/editor/rules-engine.js +140 -0
- data/app/assets/stylesheets/katalyst/navigation/editor/_icon.scss +17 -0
- data/app/assets/stylesheets/katalyst/navigation/editor/_index.scss +145 -0
- data/app/assets/stylesheets/katalyst/navigation/editor/_item-actions.scss +92 -0
- data/app/assets/stylesheets/katalyst/navigation/editor/_item-rules.scss +24 -0
- data/app/assets/stylesheets/katalyst/navigation/editor/_new-items.scss +22 -0
- data/app/assets/stylesheets/katalyst/navigation/editor/_status-bar.scss +87 -0
- data/app/controllers/katalyst/navigation/base_controller.rb +12 -0
- data/app/controllers/katalyst/navigation/items_controller.rb +57 -0
- data/app/controllers/katalyst/navigation/menus_controller.rb +82 -0
- data/app/helpers/katalyst/navigation/editor/base.rb +41 -0
- data/app/helpers/katalyst/navigation/editor/item.rb +69 -0
- data/app/helpers/katalyst/navigation/editor/list.rb +41 -0
- data/app/helpers/katalyst/navigation/editor/menu.rb +37 -0
- data/app/helpers/katalyst/navigation/editor/new_item.rb +53 -0
- data/app/helpers/katalyst/navigation/editor/status_bar.rb +57 -0
- data/app/helpers/katalyst/navigation/editor_helper.rb +46 -0
- data/app/helpers/katalyst/navigation/frontend/builder.rb +53 -0
- data/app/helpers/katalyst/navigation/frontend_helper.rb +42 -0
- data/app/models/concerns/katalyst/navigation/garbage_collection.rb +31 -0
- data/app/models/concerns/katalyst/navigation/has_tree.rb +63 -0
- data/app/models/katalyst/navigation/button.rb +15 -0
- data/app/models/katalyst/navigation/item.rb +21 -0
- data/app/models/katalyst/navigation/link.rb +10 -0
- data/app/models/katalyst/navigation/menu.rb +123 -0
- data/app/models/katalyst/navigation/node.rb +21 -0
- data/app/models/katalyst/navigation/types/nodes_type.rb +42 -0
- data/app/views/katalyst/navigation/items/_button.html.erb +28 -0
- data/app/views/katalyst/navigation/items/_link.html.erb +21 -0
- data/app/views/katalyst/navigation/items/edit.html.erb +4 -0
- data/app/views/katalyst/navigation/items/new.html.erb +4 -0
- data/app/views/katalyst/navigation/items/update.turbo_stream.erb +7 -0
- data/app/views/katalyst/navigation/menus/_item.html.erb +15 -0
- data/app/views/katalyst/navigation/menus/_list_item.html.erb +14 -0
- data/app/views/katalyst/navigation/menus/_new_item.html.erb +3 -0
- data/app/views/katalyst/navigation/menus/_new_items.html.erb +5 -0
- data/app/views/katalyst/navigation/menus/edit.html.erb +15 -0
- data/app/views/katalyst/navigation/menus/index.html.erb +17 -0
- data/app/views/katalyst/navigation/menus/new.html.erb +15 -0
- data/app/views/katalyst/navigation/menus/show.html.erb +15 -0
- data/config/importmap.rb +5 -0
- data/config/locales/en.yml +12 -0
- data/config/routes.rb +9 -0
- data/db/migrate/20220826034057_create_katalyst_navigation_menus.rb +25 -0
- data/db/migrate/20220826034507_create_katalyst_navigation_items.rb +17 -0
- data/lib/katalyst/navigation/engine.rb +36 -0
- data/lib/katalyst/navigation/version.rb +7 -0
- data/lib/katalyst/navigation.rb +9 -0
- data/lib/tasks/yarn.rake +18 -0
- data/spec/factories/katalyst/navigation/items.rb +14 -0
- data/spec/factories/katalyst/navigation/menus.rb +17 -0
- metadata +109 -0
@@ -0,0 +1,123 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Katalyst
|
4
|
+
module Navigation
|
5
|
+
# A menu is a list of items (links, buttons, etc) with order and depth creating a tree structure.
|
6
|
+
# Items should be copy-on-write, as menus store their structure as copy-on-write versions using item ids.
|
7
|
+
class Menu < ApplicationRecord
|
8
|
+
include GarbageCollection
|
9
|
+
|
10
|
+
before_destroy :unset_versions
|
11
|
+
|
12
|
+
belongs_to :draft_version,
|
13
|
+
autosave: true,
|
14
|
+
class_name: "Katalyst::Navigation::Menu::Version",
|
15
|
+
inverse_of: :parent,
|
16
|
+
optional: true
|
17
|
+
belongs_to :published_version,
|
18
|
+
class_name: "Katalyst::Navigation::Menu::Version",
|
19
|
+
inverse_of: :parent,
|
20
|
+
optional: true
|
21
|
+
|
22
|
+
has_many :versions,
|
23
|
+
class_name: "Katalyst::Navigation::Menu::Version",
|
24
|
+
dependent: :delete_all,
|
25
|
+
foreign_key: :parent_id,
|
26
|
+
inverse_of: :parent,
|
27
|
+
validate: true do
|
28
|
+
def active
|
29
|
+
menu = proxy_association.owner
|
30
|
+
where(id: [menu.published_version_id, menu.draft_version_id].uniq.compact)
|
31
|
+
end
|
32
|
+
|
33
|
+
def inactive
|
34
|
+
menu = proxy_association.owner
|
35
|
+
where.not(id: [menu.published_version_id, menu.draft_version_id].uniq.compact)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
has_many :items,
|
40
|
+
autosave: true,
|
41
|
+
class_name: "Katalyst::Navigation::Item",
|
42
|
+
dependent: :delete_all,
|
43
|
+
inverse_of: :menu,
|
44
|
+
validate: true
|
45
|
+
|
46
|
+
validates :title, :slug, presence: true
|
47
|
+
validates :slug, uniqueness: true
|
48
|
+
|
49
|
+
# A menu is in draft mode if it has an unpublished draft or it has no published version.
|
50
|
+
# @return the current state of the menu, either `published` or `draft`
|
51
|
+
def state
|
52
|
+
if published_version_id && published_version_id == draft_version_id
|
53
|
+
:published
|
54
|
+
else
|
55
|
+
:draft
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Promotes the draft version to become the published version
|
60
|
+
def publish!
|
61
|
+
update!(published_version: draft_version)
|
62
|
+
self
|
63
|
+
end
|
64
|
+
|
65
|
+
# Reverts the draft version to the current published version
|
66
|
+
def revert!
|
67
|
+
update!(draft_version: published_version)
|
68
|
+
self
|
69
|
+
end
|
70
|
+
|
71
|
+
# Updates the current draft version with new structure. Attributes should be structural information about the
|
72
|
+
# items, e.g. `{index => {id:, depth:}` or `[{id:, depth:}]`.
|
73
|
+
#
|
74
|
+
# This method conforms to the behaviour of `accepts_nested_attributes_for` so that it can be used with rails form
|
75
|
+
# helpers.
|
76
|
+
def items_attributes=(attributes)
|
77
|
+
next_version.nodes = attributes
|
78
|
+
end
|
79
|
+
|
80
|
+
delegate :nodes, :items, :tree, to: :published_version, prefix: :published, allow_nil: true
|
81
|
+
delegate :nodes, :items, :tree, to: :draft_version, prefix: :draft, allow_nil: true
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def unset_versions
|
86
|
+
update(draft_version: nil, published_version: nil)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Returns an unsaved copy of draft version for accumulating changes.
|
90
|
+
def next_version
|
91
|
+
if draft_version.nil?
|
92
|
+
build_draft_version
|
93
|
+
elsif draft_version.persisted?
|
94
|
+
self.draft_version = draft_version.dup
|
95
|
+
else
|
96
|
+
draft_version
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
class Version < ApplicationRecord
|
101
|
+
include HasTree
|
102
|
+
|
103
|
+
belongs_to :parent, class_name: "Katalyst::Navigation::Menu", inverse_of: :versions
|
104
|
+
|
105
|
+
attribute :nodes, Types::NodesType.new, default: -> { [] }
|
106
|
+
|
107
|
+
def items
|
108
|
+
# support building menus in memory
|
109
|
+
# requires that items are added in order and index and depth are set
|
110
|
+
return parent.items unless parent.persisted?
|
111
|
+
|
112
|
+
items = parent.items.where(id: nodes.map(&:id)).index_by(&:id)
|
113
|
+
nodes.map do |node|
|
114
|
+
item = items[node.id]
|
115
|
+
item.index = node.index
|
116
|
+
item.depth = node.depth
|
117
|
+
item
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Katalyst
|
4
|
+
module Navigation
|
5
|
+
# Data class for representing menu structure.
|
6
|
+
class Node
|
7
|
+
include ActiveModel::Model
|
8
|
+
include ActiveModel::Attributes
|
9
|
+
|
10
|
+
attribute :id, :integer
|
11
|
+
attribute :index, :integer
|
12
|
+
attribute :depth, :integer, default: 0
|
13
|
+
|
14
|
+
attr_accessor :item
|
15
|
+
|
16
|
+
def as_json
|
17
|
+
attributes.slice("id", "depth").as_json
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Katalyst
|
4
|
+
module Navigation
|
5
|
+
module Types
|
6
|
+
# Data serialization/deserialization for Katalyst::Navigation::Menu::Version structural data
|
7
|
+
class NodesType < ActiveRecord::Type::Json
|
8
|
+
def serialize(value)
|
9
|
+
super(value.as_json)
|
10
|
+
end
|
11
|
+
|
12
|
+
def deserialize(value)
|
13
|
+
case value
|
14
|
+
when nil
|
15
|
+
nil
|
16
|
+
when String
|
17
|
+
deserialize(super)
|
18
|
+
when Hash
|
19
|
+
deserialize_params(value)
|
20
|
+
when Array
|
21
|
+
deserialize_array(value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
# Deserialize a params-style array, e.g. "0" => { ... }
|
28
|
+
def deserialize_params(value)
|
29
|
+
value.map do |index, attributes|
|
30
|
+
Node.new(index: index, **attributes)
|
31
|
+
end.select(&:id).sort_by(&:index)
|
32
|
+
end
|
33
|
+
|
34
|
+
def deserialize_array(value)
|
35
|
+
value.map.with_index do |attributes, index|
|
36
|
+
Node.new(index: index, **attributes)
|
37
|
+
end.select(&:id).sort_by(&:index)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
<%= form_with model: item, scope: :item, url: path do |form| %>
|
2
|
+
<%= form.hidden_field :type %>
|
3
|
+
|
4
|
+
<div class="input">
|
5
|
+
<%= form.label :title %>
|
6
|
+
<%= form.text_field :title %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="input">
|
10
|
+
<%= form.label :url %>
|
11
|
+
<%= form.text_field :url %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div class="input">
|
15
|
+
<%= form.label :http_method %>
|
16
|
+
<%= form.select :http_method, Katalyst::Navigation::Button::HTTP_METHODS %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div class="input">
|
20
|
+
<%= form.check_box :visible %>
|
21
|
+
<%= form.label :visible %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="button-row">
|
25
|
+
<%= form.submit "Done" %>
|
26
|
+
<%= link_to "Discard", menu_path(item.menu), class: "button--text" %>
|
27
|
+
</div>
|
28
|
+
<% end %>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= form_with model: item, scope: :item, url: path do |form| %>
|
2
|
+
<%= form.hidden_field :type %>
|
3
|
+
|
4
|
+
<div class="field">
|
5
|
+
<%= form.label :title %>
|
6
|
+
<%= form.text_field :title %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="field">
|
10
|
+
<%= form.label :url %>
|
11
|
+
<%= form.text_field :url %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= form.label :visible %>
|
16
|
+
<%= form.check_box :visible %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<%= form.submit "Done" %>
|
20
|
+
<%= link_to "Discard", item.menu %>
|
21
|
+
<% end %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<%= turbo_stream.replace "navigation--editor--item-frame" do %>
|
2
|
+
<%= render "katalyst/navigation/menus/new_items", menu: item.menu %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<%= turbo_stream.replace dom_id(previous) do %>
|
6
|
+
<%= render "katalyst/navigation/menus/item", item: item %>
|
7
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%= navigation_editor_item item: item do |builder| %>
|
2
|
+
<div class="tree" data-invisible="<%= !item.visible? %>">
|
3
|
+
<%= builder.accordion_actions %>
|
4
|
+
|
5
|
+
<span role="img" value="<%= item.url.present? ? "link" : "title" %>" title="Hidden"></span>
|
6
|
+
<h4 class="title" title="<%= item.title %>"><%= item.title %></h4>
|
7
|
+
<span role="img" value="invisible" title="Hidden"></span>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<div class="url">
|
11
|
+
<%= link_to item.url || "", item.url || "" %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= builder.item_actions %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<li draggable="true"
|
2
|
+
data-navigation-item
|
3
|
+
data-navigation-item-id="<%= item.id %>"
|
4
|
+
data-navigation-index="<%= item.index %>"
|
5
|
+
data-navigation-depth="<%= item.depth %>"
|
6
|
+
data-deny-de-nest
|
7
|
+
data-deny-nest
|
8
|
+
data-deny-collapse
|
9
|
+
data-deny-expand
|
10
|
+
data-deny-remove
|
11
|
+
data-deny-drag
|
12
|
+
data-deny-edit>
|
13
|
+
<%= yield %>
|
14
|
+
</li>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% content_for :title, "Edit navigation" %>
|
2
|
+
|
3
|
+
<%= form_with model: menu do |form| %>
|
4
|
+
<div class="field">
|
5
|
+
<%= form.label :title %>
|
6
|
+
<%= form.text_field :title %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="field">
|
10
|
+
<%= form.label :slug %>
|
11
|
+
<%= form.text_field :slug %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= form.submit :save %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<% content_for :title, "Navigations" %>
|
2
|
+
|
3
|
+
<nav class="index-table-actions">
|
4
|
+
<div class="item-actions">
|
5
|
+
<%= link_to "Add", [:new, :menu], class: "button button--primary" %>
|
6
|
+
</div>
|
7
|
+
</nav>
|
8
|
+
|
9
|
+
<%= table_with collection: menus, sort: sort, class: "index-table" do |row, menu| %>
|
10
|
+
<%= row.cell :title do |cell| %>
|
11
|
+
<%= link_to cell.value, menu %>
|
12
|
+
<% end %>
|
13
|
+
<%= row.cell :slug %>
|
14
|
+
<%= row.cell :actions do |cell| %>
|
15
|
+
<%= button_to "Delete", menu, method: :delete, class: "button button--text" %>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% content_for :title, "New navigation" %>
|
2
|
+
|
3
|
+
<%= form_with model: menu do |form| %>
|
4
|
+
<div class="field">
|
5
|
+
<%= form.label :title %>
|
6
|
+
<%= form.text_field :title %>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div class="field">
|
10
|
+
<%= form.label :slug %>
|
11
|
+
<%= form.text_field :slug %>
|
12
|
+
</div>
|
13
|
+
|
14
|
+
<%= form.submit %>
|
15
|
+
<% end %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% content_for :title, menu.title %>
|
2
|
+
|
3
|
+
<%= navigation_editor_status_bar menu: menu %>
|
4
|
+
|
5
|
+
<%= navigation_editor_menu menu: menu do |form| %>
|
6
|
+
<div role="rowheader">
|
7
|
+
<h4>Title</h4>
|
8
|
+
<h4>Url</h4>
|
9
|
+
<h4>Actions</h4>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<%= navigation_editor_list menu: menu %>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%= render "katalyst/navigation/menus/new_items", menu: menu %>
|
data/config/importmap.rb
ADDED
data/config/routes.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateKatalystNavigationMenus < ActiveRecord::Migration[7.0]
|
4
|
+
def change
|
5
|
+
create_table :katalyst_navigation_menus do |t|
|
6
|
+
t.string :title
|
7
|
+
t.string :slug, index: true
|
8
|
+
|
9
|
+
t.references :published_version
|
10
|
+
t.references :draft_version
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
|
15
|
+
create_table :katalyst_navigation_menu_versions do |t|
|
16
|
+
t.references :parent, foreign_key: { to_table: :katalyst_navigation_menus }, null: false
|
17
|
+
t.json :nodes
|
18
|
+
|
19
|
+
t.timestamps
|
20
|
+
end
|
21
|
+
|
22
|
+
add_foreign_key :katalyst_navigation_menus, :katalyst_navigation_menu_versions, column: :published_version_id
|
23
|
+
add_foreign_key :katalyst_navigation_menus, :katalyst_navigation_menu_versions, column: :draft_version_id
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class CreateKatalystNavigationItems < ActiveRecord::Migration[7.0]
|
4
|
+
def change
|
5
|
+
create_table :katalyst_navigation_items do |t|
|
6
|
+
t.belongs_to :menu, foreign_key: { to_table: :katalyst_navigation_menus }, null: false
|
7
|
+
|
8
|
+
t.string :type
|
9
|
+
t.string :title
|
10
|
+
t.string :url
|
11
|
+
t.string :http_method
|
12
|
+
t.boolean :visible, default: true
|
13
|
+
|
14
|
+
t.timestamps
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails"
|
4
|
+
|
5
|
+
module Katalyst
|
6
|
+
module Navigation
|
7
|
+
class Engine < ::Rails::Engine
|
8
|
+
isolate_namespace Katalyst::Navigation
|
9
|
+
|
10
|
+
initializer "katalyst-navigation.asset" do
|
11
|
+
config.after_initialize do |app|
|
12
|
+
if app.config.respond_to?(:assets)
|
13
|
+
app.config.assets.precompile += %w(katalyst-navigation.js)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer "katalyst-navigation.importmap", before: "importmap" do |app|
|
19
|
+
if app.config.respond_to?(:importmap)
|
20
|
+
app.config.importmap.paths << root.join("config/importmap.rb")
|
21
|
+
app.config.importmap.cache_sweepers << root.join("app/assets/javascripts")
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
initializer "katalyst-navigation.factories", after: "factory_bot.set_factory_paths" do
|
26
|
+
FactoryBot.definition_file_paths << Engine.root.join("spec/factories") if defined?(FactoryBot)
|
27
|
+
end
|
28
|
+
|
29
|
+
config.generators do |g|
|
30
|
+
g.test_framework :rspec
|
31
|
+
g.fixture_replacement :factory_bot
|
32
|
+
g.factory_bot dir: "spec/factories"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/tasks/yarn.rake
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
namespace :yarn do
|
4
|
+
desc "Install npm packages with yarn"
|
5
|
+
task install: :environment do
|
6
|
+
sh "yarn install"
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Lint JS/SCSS files using yarn (prettier)"
|
10
|
+
task lint: :install do
|
11
|
+
sh "yarn lint"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Autoformat JS/SCSS files using yarn (prettier)"
|
15
|
+
task format: :install do
|
16
|
+
sh "yarn format"
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
FactoryBot.define do
|
4
|
+
factory :katalyst_navigation_link, aliases: [:navigation_link], class: "Katalyst::Navigation::Link" do
|
5
|
+
title { Faker::Beer.hop }
|
6
|
+
url { Faker::Internet.unique.url }
|
7
|
+
end
|
8
|
+
|
9
|
+
factory :katalyst_navigation_button, aliases: [:navigation_button], class: "Katalyst::Navigation::Button" do
|
10
|
+
title { Faker::Beer.hop }
|
11
|
+
url { Faker::Internet.unique.url }
|
12
|
+
http_method { Katalyst::Navigation::Button::HTTP_METHODS.keys.sample }
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
FactoryBot.define do
|
4
|
+
factory :katalyst_navigation_menu, aliases: [:navigation_menu], class: "Katalyst::Navigation::Menu" do
|
5
|
+
title { Faker::Beer.unique.name }
|
6
|
+
slug { title.parameterize }
|
7
|
+
|
8
|
+
after(:build) do |menu, _context|
|
9
|
+
menu.items.each { |item| item.menu = menu }
|
10
|
+
end
|
11
|
+
|
12
|
+
after(:create) do |menu, _context|
|
13
|
+
menu.items_attributes = menu.items.map.with_index { |item, index| { id: item.id, index: index, depth: 0 } }
|
14
|
+
menu.publish!
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: katalyst-navigation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Katalyst Interactive
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-09-05 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- developers@katalyst.com.au
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- CHANGELOG.md
|
21
|
+
- LICENSE.txt
|
22
|
+
- README.md
|
23
|
+
- app/assets/config/katalyst-navigation.js
|
24
|
+
- app/assets/javascripts/controllers/navigation/editor/item_controller.js
|
25
|
+
- app/assets/javascripts/controllers/navigation/editor/list_controller.js
|
26
|
+
- app/assets/javascripts/controllers/navigation/editor/menu_controller.js
|
27
|
+
- app/assets/javascripts/controllers/navigation/editor/new_item_controller.js
|
28
|
+
- app/assets/javascripts/controllers/navigation/editor/status_bar_controller.js
|
29
|
+
- app/assets/javascripts/utils/navigation/editor/item.js
|
30
|
+
- app/assets/javascripts/utils/navigation/editor/menu.js
|
31
|
+
- app/assets/javascripts/utils/navigation/editor/rules-engine.js
|
32
|
+
- app/assets/stylesheets/katalyst/navigation/editor/_icon.scss
|
33
|
+
- app/assets/stylesheets/katalyst/navigation/editor/_index.scss
|
34
|
+
- app/assets/stylesheets/katalyst/navigation/editor/_item-actions.scss
|
35
|
+
- app/assets/stylesheets/katalyst/navigation/editor/_item-rules.scss
|
36
|
+
- app/assets/stylesheets/katalyst/navigation/editor/_new-items.scss
|
37
|
+
- app/assets/stylesheets/katalyst/navigation/editor/_status-bar.scss
|
38
|
+
- app/controllers/katalyst/navigation/base_controller.rb
|
39
|
+
- app/controllers/katalyst/navigation/items_controller.rb
|
40
|
+
- app/controllers/katalyst/navigation/menus_controller.rb
|
41
|
+
- app/helpers/katalyst/navigation/editor/base.rb
|
42
|
+
- app/helpers/katalyst/navigation/editor/item.rb
|
43
|
+
- app/helpers/katalyst/navigation/editor/list.rb
|
44
|
+
- app/helpers/katalyst/navigation/editor/menu.rb
|
45
|
+
- app/helpers/katalyst/navigation/editor/new_item.rb
|
46
|
+
- app/helpers/katalyst/navigation/editor/status_bar.rb
|
47
|
+
- app/helpers/katalyst/navigation/editor_helper.rb
|
48
|
+
- app/helpers/katalyst/navigation/frontend/builder.rb
|
49
|
+
- app/helpers/katalyst/navigation/frontend_helper.rb
|
50
|
+
- app/models/concerns/katalyst/navigation/garbage_collection.rb
|
51
|
+
- app/models/concerns/katalyst/navigation/has_tree.rb
|
52
|
+
- app/models/katalyst/navigation/button.rb
|
53
|
+
- app/models/katalyst/navigation/item.rb
|
54
|
+
- app/models/katalyst/navigation/link.rb
|
55
|
+
- app/models/katalyst/navigation/menu.rb
|
56
|
+
- app/models/katalyst/navigation/node.rb
|
57
|
+
- app/models/katalyst/navigation/types/nodes_type.rb
|
58
|
+
- app/views/katalyst/navigation/items/_button.html.erb
|
59
|
+
- app/views/katalyst/navigation/items/_link.html.erb
|
60
|
+
- app/views/katalyst/navigation/items/edit.html.erb
|
61
|
+
- app/views/katalyst/navigation/items/new.html.erb
|
62
|
+
- app/views/katalyst/navigation/items/update.turbo_stream.erb
|
63
|
+
- app/views/katalyst/navigation/menus/_item.html.erb
|
64
|
+
- app/views/katalyst/navigation/menus/_list_item.html.erb
|
65
|
+
- app/views/katalyst/navigation/menus/_new_item.html.erb
|
66
|
+
- app/views/katalyst/navigation/menus/_new_items.html.erb
|
67
|
+
- app/views/katalyst/navigation/menus/edit.html.erb
|
68
|
+
- app/views/katalyst/navigation/menus/index.html.erb
|
69
|
+
- app/views/katalyst/navigation/menus/new.html.erb
|
70
|
+
- app/views/katalyst/navigation/menus/show.html.erb
|
71
|
+
- config/importmap.rb
|
72
|
+
- config/locales/en.yml
|
73
|
+
- config/routes.rb
|
74
|
+
- db/migrate/20220826034057_create_katalyst_navigation_menus.rb
|
75
|
+
- db/migrate/20220826034507_create_katalyst_navigation_items.rb
|
76
|
+
- lib/katalyst/navigation.rb
|
77
|
+
- lib/katalyst/navigation/engine.rb
|
78
|
+
- lib/katalyst/navigation/version.rb
|
79
|
+
- lib/tasks/yarn.rake
|
80
|
+
- spec/factories/katalyst/navigation/items.rb
|
81
|
+
- spec/factories/katalyst/navigation/menus.rb
|
82
|
+
homepage: https://github.com/katalyst/navigation
|
83
|
+
licenses:
|
84
|
+
- MIT
|
85
|
+
metadata:
|
86
|
+
homepage_uri: https://github.com/katalyst/navigation
|
87
|
+
source_code_uri: https://github.com/katalyst/navigation
|
88
|
+
changelog_uri: https://github.com/katalyst/navigation/blob/main/CHANGELOG.md
|
89
|
+
rubygems_mfa_required: 'true'
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: 2.7.0
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubygems_version: 3.3.7
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: Navigation generator and editor
|
109
|
+
test_files: []
|