katalyst-navigation 1.0.0 → 1.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/utils/navigation/editor/menu.js +1 -1
- data/app/assets/javascripts/utils/navigation/editor/rules-engine.js +16 -12
- data/app/assets/stylesheets/katalyst/navigation/editor/_index.scss +1 -1
- data/app/assets/stylesheets/katalyst/navigation/editor/_item-actions.scss +1 -0
- data/app/assets/stylesheets/katalyst/navigation/editor/_item-rules.scss +0 -5
- data/app/assets/stylesheets/katalyst/navigation/editor/_new-items.scss +19 -2
- data/app/controllers/concerns/katalyst/navigation/has_navigation.rb +28 -0
- data/app/controllers/katalyst/navigation/menus_controller.rb +1 -1
- data/app/views/katalyst/navigation/menus/_item.html.erb +1 -1
- data/app/views/katalyst/navigation/menus/edit.html.erb +6 -1
- data/app/views/katalyst/navigation/menus/index.html.erb +0 -3
- data/lib/katalyst/navigation/version.rb +1 -1
- metadata +3 -6
- data/CHANGELOG.md +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94de0bbf95ab99d4893ec9decb52fa6c1a7231f1d58d17b1263e63124baaf10a
|
4
|
+
data.tar.gz: 3ec009c2845a80e4371aca788ac2b06de9a602cc468afecbbb5666d5a50fcb07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 043ce598613d8f99b98d777be94b0805d1504989eab5dba1e651a8d7fa2a2d8d4f89135530e300e65d37fea900237cba0e2a30caa7e95e81ab17000639bba5bb
|
7
|
+
data.tar.gz: c0795c1f30ed8ecea198e90d90097bcb6728bcbe2e7116ecd106e0c21c6e97e9c68a4ff981586bfa9436a22a7e63adf8c33da00f593541b17e77d316675fe4bb
|
@@ -7,7 +7,6 @@ export default class RulesEngine {
|
|
7
7
|
"denyRemove",
|
8
8
|
"denyDrag",
|
9
9
|
"denyEdit",
|
10
|
-
"invalidDepth",
|
11
10
|
];
|
12
11
|
|
13
12
|
/**
|
@@ -19,8 +18,12 @@ export default class RulesEngine {
|
|
19
18
|
update(item) {
|
20
19
|
this.rules = {};
|
21
20
|
|
21
|
+
// structural rules enforce a valid tree structure
|
22
22
|
this.firstItemDepthZero(item);
|
23
23
|
this.depthMustBeSet(item);
|
24
|
+
this.itemCannotHaveInvalidDepth(item);
|
25
|
+
|
26
|
+
// behavioural rules define what the user is allowed to do
|
24
27
|
this.parentsCannotDeNest(item);
|
25
28
|
this.rootsCannotDeNest(item);
|
26
29
|
this.nestingNeedsParent(item);
|
@@ -28,7 +31,6 @@ export default class RulesEngine {
|
|
28
31
|
this.needHiddenItemsToExpand(item);
|
29
32
|
this.parentsCannotBeDeleted(item);
|
30
33
|
this.parentsCannotBeDragged(item);
|
31
|
-
this.itemCannotHaveInvalidDepth(item);
|
32
34
|
|
33
35
|
RulesEngine.rules.forEach((rule) => {
|
34
36
|
item.toggleRule(rule, !!this.rules[rule]);
|
@@ -55,6 +57,18 @@ export default class RulesEngine {
|
|
55
57
|
}
|
56
58
|
}
|
57
59
|
|
60
|
+
/**
|
61
|
+
* Depth must increase stepwise.
|
62
|
+
*
|
63
|
+
* @param {Item} item
|
64
|
+
*/
|
65
|
+
itemCannotHaveInvalidDepth(item) {
|
66
|
+
const previous = item.previousItem;
|
67
|
+
if (previous && previous.depth < item.depth - 1) {
|
68
|
+
item.depth = previous.depth + 1;
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
58
72
|
/**
|
59
73
|
* De-nesting an item would create a gap of 2 between itself and its children
|
60
74
|
*
|
@@ -119,16 +133,6 @@ export default class RulesEngine {
|
|
119
133
|
if (item.hasExpandedDescendants()) this.#deny("denyDrag");
|
120
134
|
}
|
121
135
|
|
122
|
-
/**
|
123
|
-
* Depth must increase stepwise.
|
124
|
-
*
|
125
|
-
* @param {Item} item
|
126
|
-
*/
|
127
|
-
itemCannotHaveInvalidDepth(item) {
|
128
|
-
const previous = item.previousItem;
|
129
|
-
if (previous && previous.depth < item.depth - 1) this.#deny("invalidDepth");
|
130
|
-
}
|
131
|
-
|
132
136
|
/**
|
133
137
|
* Record a deny.
|
134
138
|
*
|
@@ -3,7 +3,7 @@
|
|
3
3
|
.navigation--editor--new-items {
|
4
4
|
display: grid;
|
5
5
|
grid-template-columns: repeat(3, 1fr);
|
6
|
-
gap: 0.
|
6
|
+
gap: 0.5rem;
|
7
7
|
|
8
8
|
[role="listitem"] {
|
9
9
|
display: flex;
|
@@ -12,11 +12,28 @@
|
|
12
12
|
align-items: center;
|
13
13
|
transform: translate3d(0, 0, 0);
|
14
14
|
cursor: grab;
|
15
|
+
background: white;
|
16
|
+
box-shadow: rgb(0 0 0 / 25%) 0 1px 1px, rgb(0 0 0 / 31%) 0 0 2px;
|
17
|
+
min-height: 5rem;
|
18
|
+
padding: 1.5rem;
|
19
|
+
|
20
|
+
&:hover {
|
21
|
+
box-shadow: rgb(0 0 0 / 25%) 0 1px 2px, rgb(0 0 0 / 31%) 0 0 5px;
|
22
|
+
}
|
15
23
|
|
16
24
|
&::before {
|
17
25
|
@extend %icon;
|
26
|
+
width: 2.5rem;
|
27
|
+
height: 2.5rem;
|
18
28
|
position: unset;
|
19
|
-
|
29
|
+
}
|
30
|
+
|
31
|
+
&[data-item-type="link"]:before {
|
32
|
+
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0_67_1273)'%3E%3Cpath d='M16 22H32V26H16V22ZM40.2 24H44C44 18.48 39.52 14 34 14H26V17.8H34C37.42 17.8 40.2 20.58 40.2 24ZM7.8 24C7.8 20.58 10.58 17.8 14 17.8H22V14H14C8.48 14 4 18.48 4 24C4 29.52 8.48 34 14 34H22V30.2H14C10.58 30.2 7.8 27.42 7.8 24ZM38 24H34V30H28V34H34V40H38V34H44V30H38V24Z' /%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0_67_1273'%3E%3Crect width='48' height='48' /%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E");
|
33
|
+
}
|
34
|
+
|
35
|
+
&[data-item-type="button"]:before {
|
36
|
+
background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cg clip-path='url(%23clip0_67_1276)'%3E%3Cpath d='M44 18V30C44 32.2 42.2 34 40 34H38V30H40V18H8V30H20V34H8C5.8 34 4 32.2 4 30V18C4 15.8 5.8 14 8 14H40C42.2 14 44 15.8 44 18ZM29 38L31.18 33.18L36 31L31.18 28.82L29 24L26.82 28.82L22 31L26.82 33.18L29 38ZM34 28L35.24 25.24L38 24L35.24 22.76L34 20L32.76 22.76L30 24L32.76 25.24L34 28ZM29 38L31.18 33.18L36 31L31.18 28.82L29 24L26.82 28.82L22 31L26.82 33.18L29 38ZM34 28L35.24 25.24L38 24L35.24 22.76L34 20L32.76 22.76L30 24L32.76 25.24L34 28Z' /%3E%3C/g%3E%3Cdefs%3E%3CclipPath id='clip0_67_1276'%3E%3Crect width='48' height='48' /%3E%3C/clipPath%3E%3C/defs%3E%3C/svg%3E");
|
20
37
|
}
|
21
38
|
}
|
22
39
|
}
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Katalyst
|
4
|
+
module Navigation
|
5
|
+
module HasNavigation
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
module NavigationHelper
|
9
|
+
def navigation_menu_for(slug)
|
10
|
+
@navigation_menus[slug.to_s]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
included do
|
15
|
+
helper Katalyst::Navigation::FrontendHelper
|
16
|
+
helper NavigationHelper
|
17
|
+
|
18
|
+
before_action :set_navigation_menus
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def set_navigation_menus
|
24
|
+
@navigation_menus = Katalyst::Navigation::Menu.includes(:published_version).index_by(&:slug)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -11,5 +11,10 @@
|
|
11
11
|
<%= form.text_field :slug %>
|
12
12
|
</div>
|
13
13
|
|
14
|
-
|
14
|
+
<div class="button-row">
|
15
|
+
<%= form.submit :save %>
|
16
|
+
<%= link_to "Delete", url_for(action: :show),
|
17
|
+
class: "button button-secondary",
|
18
|
+
data: { turbo_method: :delete, turbo_confirm: "Are you sure?" } %>
|
19
|
+
</div>
|
15
20
|
<% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: katalyst-navigation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katalyst Interactive
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
11
|
+
date: 2022-09-07 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -17,7 +17,6 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
-
- CHANGELOG.md
|
21
20
|
- LICENSE.txt
|
22
21
|
- README.md
|
23
22
|
- app/assets/config/katalyst-navigation.js
|
@@ -35,6 +34,7 @@ files:
|
|
35
34
|
- app/assets/stylesheets/katalyst/navigation/editor/_item-rules.scss
|
36
35
|
- app/assets/stylesheets/katalyst/navigation/editor/_new-items.scss
|
37
36
|
- app/assets/stylesheets/katalyst/navigation/editor/_status-bar.scss
|
37
|
+
- app/controllers/concerns/katalyst/navigation/has_navigation.rb
|
38
38
|
- app/controllers/katalyst/navigation/base_controller.rb
|
39
39
|
- app/controllers/katalyst/navigation/items_controller.rb
|
40
40
|
- app/controllers/katalyst/navigation/menus_controller.rb
|
@@ -83,9 +83,6 @@ homepage: https://github.com/katalyst/navigation
|
|
83
83
|
licenses:
|
84
84
|
- MIT
|
85
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
86
|
rubygems_mfa_required: 'true'
|
90
87
|
post_install_message:
|
91
88
|
rdoc_options: []
|