katalyst-navigation 1.3.2 → 1.3.3

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: 7355ef157efbf9879accdafa63efa35f02815aa29be531d9e4f73289c130e433
4
- data.tar.gz: 32cb8173a0f397d3b36491b35687b4a4848d5e7deed554742e5310d2a33b7a35
3
+ metadata.gz: 0430e1c7846b906e84d20fd7c0302b9a602a0a4427a925b12590983ec07a15c2
4
+ data.tar.gz: 85387acf67b2842d791daf9f7272b067cca28991913e36541eb7c6ef6b9aedf3
5
5
  SHA512:
6
- metadata.gz: 52ec419f941ed4f1fb101206552c4bfde580a9c9afe8a50b63ca68ea2e569f6356a2feba27230bd9f7a6fec29f7c571703e7faee22007609aab393a0b21c7ba0
7
- data.tar.gz: 0dbf4578c6b223b5fc6ab8f506cf4e45a392811ad181272352a64bdae83242367f927c7fa673349247f791b69387d08072c8f55b5609fa19d637880f2bf81c71
6
+ metadata.gz: '034680c7620436686cf44504c3b22fd93a23301678c86a61fd2741719bdc8b16a561bb09d44b61256c33c41ee09a9418df071b1274615a38ab5a337f54049310'
7
+ data.tar.gz: db8060ce2d4bc572340af555630db50a3dc117f64c5f74b8faa85d9b674a2ec16c6f9ecede44eb16722059358ccdd6ef9d5a2d5fde1a5dede83ce5c21ade9d8d
@@ -46,11 +46,11 @@ module Katalyst
46
46
  end
47
47
 
48
48
  def render_link(link)
49
- link_to(link.title, link.url)
49
+ link_to(link.title, link.url, link.item_options)
50
50
  end
51
51
 
52
52
  def render_button(link)
53
- link_to(link.title, link.url, method: link.http_method)
53
+ link_to(link.title, link.url, link.item_options)
54
54
  end
55
55
 
56
56
  private
@@ -14,6 +14,17 @@ module Katalyst
14
14
  def self.permitted_params
15
15
  super + %i[http_method]
16
16
  end
17
+
18
+ def options_for_target
19
+ options = super
20
+
21
+ if target == "_blank" || target == "_top" || target == "self"
22
+ options.deep_merge!({ data: { method: http_method } })
23
+ else
24
+ options.deep_merge!({ data: { turbo_method: http_method } })
25
+ end
26
+ options
27
+ end
17
28
  end
18
29
  end
19
30
  end
@@ -10,12 +10,16 @@ module Katalyst
10
10
 
11
11
  attr_accessor :parent, :children, :index, :depth
12
12
 
13
+ TARGETS = %i[self _top _blank kpop].index_by(&:itself).freeze
14
+
15
+ enum method: TARGETS, _prefix: :target
16
+
13
17
  def self.permitted_params
14
18
  %i[
15
19
  title
16
20
  url
17
21
  visible
18
- new_tab
22
+ target
19
23
  type
20
24
  ]
21
25
  end
@@ -24,6 +28,22 @@ module Katalyst
24
28
  is_a? Layout
25
29
  end
26
30
 
31
+ # Entrypoint for combining additional options based on attribute rules
32
+ def item_options
33
+ options_for_target
34
+ end
35
+
36
+ def options_for_target
37
+ return {} if target == "self"
38
+
39
+ options = { target: target }
40
+
41
+ unless target == "_blank" || target == "_top"
42
+ options = { data: { turbo: true, turbo_frame: target } }
43
+ end
44
+ options
45
+ end
46
+
27
47
  private
28
48
 
29
49
  def initialize_tree
@@ -9,6 +9,7 @@ class CreateKatalystNavigationItems < ActiveRecord::Migration[7.0]
9
9
  t.string :title
10
10
  t.string :url
11
11
  t.string :http_method
12
+ t.string :target
12
13
  t.boolean :visible, default: true
13
14
 
14
15
  t.timestamps
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Katalyst
4
4
  module Navigation
5
- VERSION = "1.3.2"
5
+ VERSION = "1.3.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.3.2
4
+ version: 1.3.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-11-08 00:00:00.000000000 Z
11
+ date: 2022-11-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: