katalyst-navigation 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5c41babca4e58e13c18e53437a8992f93a1f2e82566542ed43dd8f62a2a0a83f
4
- data.tar.gz: 4d3ea6600b660cf877ac8c53aa81be4367169ea27ffca16d86374ca0a61a0b41
3
+ metadata.gz: e67d176cb768b324a1be109e98dc001bd9ce8419abba00d4856cd0d3c84dc6c9
4
+ data.tar.gz: 35555b9bac352c1e21786dcdddc638ccc3929e314003c7859dc3be56ad13c03e
5
5
  SHA512:
6
- metadata.gz: dfff1369051123cbd3411fe4d873a8a1bee97166c09f05c117f6df9a11b0a0b618d8255349aed78213b76ee5b8c078807d904fd51899e803e2222f56d9beb086
7
- data.tar.gz: 07e367633bd15cc6f84aa242d5f785e82822f9354482ed071a90e4ed975aa4ed40eeac22bea5d30ab949031d7aa6702cfd18c7fae6f3f9beb08d2c202dbd6d1d
6
+ metadata.gz: 4ba4e987c87e8dfe56def8ef4d2f9214c7376cd285385008079b82b84f2ed44e354248d1d8aceaa50f2ac0cad81311935b038c5cedaff9001ab38199bea61b8a
7
+ data.tar.gz: 0ac8744ff0e111c921974d82951f4c7b09f57df32d1c93d8c5cff0474de53b5254d53bbc2129d90ca81597ae08c8166e843f0609e58bd5c6311606da0fa1f4f7
@@ -41,9 +41,7 @@ export default class MenuController extends Controller {
41
41
  nest(event) {
42
42
  const item = getEventItem(event);
43
43
 
44
- item.traverse((child) => {
45
- child.depth += 1;
46
- });
44
+ item.nest();
47
45
 
48
46
  this.#update();
49
47
  event.preventDefault();
@@ -52,9 +50,7 @@ export default class MenuController extends Controller {
52
50
  deNest(event) {
53
51
  const item = getEventItem(event);
54
52
 
55
- item.traverse((child) => {
56
- child.depth -= 1;
57
- });
53
+ item.deNest();
58
54
 
59
55
  this.#update();
60
56
  event.preventDefault();
@@ -128,6 +128,39 @@ export default class Item {
128
128
  expanded.forEach((item) => item.traverse(callback));
129
129
  }
130
130
 
131
+ /**
132
+ * Increase the depth of this item and its descendants.
133
+ * If this causes it to become a child of a collapsed item, then collapse this item.
134
+ */
135
+ nest() {
136
+ this.traverse((child) => {
137
+ child.depth += 1;
138
+ });
139
+
140
+ if (this.previousItem.hasCollapsedDescendants()) {
141
+ this.previousItem.collapseChild(this);
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Move the given item into this element's hidden children list.
147
+ * Assumes the list already exists.
148
+ *
149
+ * @param item {Item}
150
+ */
151
+ collapseChild(item) {
152
+ this.#childrenListElement.appendChild(item.node);
153
+ }
154
+
155
+ /**
156
+ * Decrease the depth of this item (and its descendants).
157
+ */
158
+ deNest() {
159
+ this.traverse((child) => {
160
+ child.depth -= 1;
161
+ });
162
+ }
163
+
131
164
  /**
132
165
  * Collapses visible (logical) children into this element's hidden children
133
166
  * list, creating it if it doesn't already exist.
@@ -162,10 +195,12 @@ export default class Item {
162
195
  * @param deny {boolean}
163
196
  */
164
197
  toggleRule(rule, deny = false) {
165
- if (this.node.dataset.hasOwnProperty(rule) && !deny)
198
+ if (this.node.dataset.hasOwnProperty(rule) && !deny) {
166
199
  delete this.node.dataset[rule];
167
- if (!this.node.dataset.hasOwnProperty(rule) && deny)
200
+ }
201
+ if (!this.node.dataset.hasOwnProperty(rule) && deny) {
168
202
  this.node.dataset[rule] = "";
203
+ }
169
204
 
170
205
  if (rule === "denyDrag") {
171
206
  if (!this.node.hasAttribute("draggable") && !deny) {
@@ -118,7 +118,7 @@ $status-dirty-color: #aaa !default;
118
118
  }
119
119
 
120
120
  // Ensures vertical alignment of header with rows
121
- [data-controller="navigation--editor-menu"] {
121
+ [data-controller="navigation--editor--menu"] {
122
122
  [role="rowheader"] {
123
123
  min-height: var(--row-height);
124
124
  background: var(--table-header-color);
@@ -14,13 +14,6 @@ module Katalyst
14
14
  end
15
15
  end
16
16
 
17
- def build_all(*items)
18
- render partial: "katalyst/navigation/menus/link_item",
19
- layout: "katalyst/navigation/menus/navigation_menu_link",
20
- collection: items,
21
- as: :item
22
- end
23
-
24
17
  def accordion_actions
25
18
  tag.div role: "toolbar", data: { tree_accordion_controls: "" } do
26
19
  concat tag.span(role: "button", value: "collapse",
@@ -2,7 +2,7 @@
2
2
  <div class="tree" data-invisible="<%= !item.visible? %>">
3
3
  <%= builder.accordion_actions %>
4
4
 
5
- <span role="img" value="<%= item.url.present? ? "link" : "title" %>" title="Hidden"></span>
5
+ <span role="img" value="<%= item.url.present? ? "link" : "title" %>" title="Type"></span>
6
6
  <h4 class="title" title="<%= item.title %>"><%= item.title %></h4>
7
7
  <span role="img" value="invisible" title="Hidden"></span>
8
8
  </div>
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Katalyst
4
4
  module Navigation
5
- VERSION = "1.1.1"
5
+ VERSION = "1.1.2"
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.1.1
4
+ version: 1.1.2
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-12 00:00:00.000000000 Z
11
+ date: 2022-09-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: