katalyst-navigation 1.0.2 → 1.0.3

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: 0b1e30c9f62f9c95fbd95824c1fca798f29e8d8240040cf92bfe3e6d802f0f4b
4
- data.tar.gz: 7b86b9670845b41baa6214bd1ac19e5b6cf9aed0e391f31f270b183b5891e32a
3
+ metadata.gz: 94de0bbf95ab99d4893ec9decb52fa6c1a7231f1d58d17b1263e63124baaf10a
4
+ data.tar.gz: 3ec009c2845a80e4371aca788ac2b06de9a602cc468afecbbb5666d5a50fcb07
5
5
  SHA512:
6
- metadata.gz: 247b24aec0411a6e45c316a68d1020f57bb3672cb2c7f649f3deab98c6c0c3820b3ca49fd4074b779d693ee4bc39ecaad112586b2a75fc32cddb574be8568245
7
- data.tar.gz: 8dbe6529fea49f7f497ee5d1310cc5f4f618f86f41bfcd9b83395a91bf4c5764e9fe7ddab32bd0da04826689c5f5b6556ee3bfda79da6ee48397db9e733aa70f
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 {
@@ -16,8 +16,4 @@
16
16
  display: none !important;
17
17
  pointer-events: none;
18
18
  }
19
-
20
- [data-invalid-depth] {
21
- box-shadow: inset 0 0 0 3px var(--row-depth-invalid-color);
22
- }
23
19
  }
@@ -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
@@ -62,7 +62,7 @@ module Katalyst
62
62
 
63
63
  menu.destroy!
64
64
 
65
- redirect_to action: :index
65
+ redirect_to action: :index, status: :see_other
66
66
  end
67
67
 
68
68
  private
@@ -11,5 +11,10 @@
11
11
  <%= form.text_field :slug %>
12
12
  </div>
13
13
 
14
- <%= form.submit :save %>
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 %>
@@ -11,7 +11,4 @@
11
11
  <%= link_to cell.value, menu %>
12
12
  <% end %>
13
13
  <%= row.cell :slug %>
14
- <%= row.cell :actions do |cell| %>
15
- <%= button_to "Delete", menu, method: :delete, class: "button button--text" %>
16
- <% end %>
17
14
  <% end %>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Katalyst
4
4
  module Navigation
5
- VERSION = "1.0.2"
5
+ VERSION = "1.0.3"
6
6
  end
7
7
  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.2
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-06 00:00:00.000000000 Z
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