katalyst-navigation 1.0.2 → 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/rules-engine.js +16 -12
- data/app/assets/stylesheets/katalyst/navigation/editor/_index.scss +0 -3
- data/app/assets/stylesheets/katalyst/navigation/editor/_item-rules.scss +0 -4
- 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/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 -2
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
|
*
|
@@ -10,7 +10,6 @@ $grey: #ececec !default;
|
|
10
10
|
$grey-dark: #999 !default;
|
11
11
|
$table-hover-background: #fff0eb !default;
|
12
12
|
$primary-color: #ff521f !default;
|
13
|
-
$error-color: #990000 !default;
|
14
13
|
|
15
14
|
$row-inset: 2rem !default;
|
16
15
|
$row-height: 3rem !default;
|
@@ -20,7 +19,6 @@ $row-background-color: $grey-light !default;
|
|
20
19
|
$row-hover-color: $table-hover-background !default;
|
21
20
|
$icon-active-color: $primary-color !default;
|
22
21
|
$icon-passive-color: $grey-dark !default;
|
23
|
-
$row-depth-invalid-color: $error-color !default;
|
24
22
|
|
25
23
|
$status-published-background-color: #ebf9eb !default;
|
26
24
|
$status-published-border-color: #4dd45c !default;
|
@@ -42,7 +40,6 @@ $status-dirty-color: #aaa !default;
|
|
42
40
|
--row-hover-color: #{$row-hover-color};
|
43
41
|
--icon-active-color: #{$icon-active-color};
|
44
42
|
--icon-passive-color: #{$icon-passive-color};
|
45
|
-
--row-depth-invalid-color: #{$row-depth-invalid-color};
|
46
43
|
|
47
44
|
ol,
|
48
45
|
li {
|
@@ -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:
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- app/assets/stylesheets/katalyst/navigation/editor/_item-rules.scss
|
35
35
|
- app/assets/stylesheets/katalyst/navigation/editor/_new-items.scss
|
36
36
|
- app/assets/stylesheets/katalyst/navigation/editor/_status-bar.scss
|
37
|
+
- app/controllers/concerns/katalyst/navigation/has_navigation.rb
|
37
38
|
- app/controllers/katalyst/navigation/base_controller.rb
|
38
39
|
- app/controllers/katalyst/navigation/items_controller.rb
|
39
40
|
- app/controllers/katalyst/navigation/menus_controller.rb
|