satis 2.4.1 → 2.4.2
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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2c8b8f688d732d57a4df263b47f48f1b072f709c1d9ae5b224cc1e7197e5fc08
|
|
4
|
+
data.tar.gz: 42d9edfb45401ad6cb797ffa95195acceff18b3a1aa8b8931c95d29afacba49f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4bbf1820f21de79035eb8c5285de9ac084f7609a1b33ba57dc8261592d65d122e79d73d808d772aa40b55d1dddc60962b218e7803bb2798c51b506d057186b38
|
|
7
|
+
data.tar.gz: ac095ab29b95766986c70e2f15322a4f1e16cfc8014ee365b56fc58e628ced330392eddb6b5f67479b3637d8e0004153b58329bbe2c9a7ea7dc3d13038ee86ee
|
|
@@ -21,6 +21,15 @@ module Satis
|
|
|
21
21
|
super()
|
|
22
22
|
end
|
|
23
23
|
|
|
24
|
+
def render_in(view_context, &)
|
|
25
|
+
self.original_view_context ||= view_context
|
|
26
|
+
self.original_virtual_path ||= Satis.current_original_virtual_path.presence || view_context.instance_variable_get(:@virtual_path)
|
|
27
|
+
|
|
28
|
+
Satis.with_original_virtual_path(original_virtual_path) do
|
|
29
|
+
super
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
24
33
|
def component_name
|
|
25
34
|
self.class.name.sub(/::Component$/, "").sub(/^Satis::/, "").underscore
|
|
26
35
|
end
|
|
@@ -1,10 +1,5 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
# FIXME:
|
|
4
|
-
# translation scope seems wrong:
|
|
5
|
-
# old/okay) title="translation missing: en.users.edit.card.profile.tab.about"
|
|
6
|
-
# new/broken) title="translation missing: en.users.edit.tabs.main.tab.about"
|
|
7
|
-
|
|
8
3
|
module Satis
|
|
9
4
|
module Tabs
|
|
10
5
|
class Component < Satis::ApplicationComponent
|
|
@@ -8,6 +8,8 @@ module Satis
|
|
|
8
8
|
extend ActiveSupport::Concern
|
|
9
9
|
|
|
10
10
|
included do
|
|
11
|
+
attr_accessor :original_virtual_path
|
|
12
|
+
|
|
11
13
|
#
|
|
12
14
|
# This provides us with a translation helper which scopes into the original view
|
|
13
15
|
# and thereby conveniently scopes the translations.
|
|
@@ -41,9 +43,25 @@ module Satis
|
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
def original_i18n_scope
|
|
46
|
+
virtual_path = original_virtual_path.presence || original_view_context_virtual_path
|
|
47
|
+
|
|
48
|
+
return virtual_path.gsub(%r{/_?}, ".").split(".") if virtual_path.present? && !satis_component_virtual_path?(virtual_path)
|
|
49
|
+
|
|
44
50
|
[original_view_context.controller_path.tr("/", "."), original_view_context.action_name]
|
|
45
51
|
end
|
|
46
52
|
|
|
53
|
+
def satis_component_virtual_path?(virtual_path)
|
|
54
|
+
virtual_path.start_with?("satis/")
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def original_view_context_virtual_path
|
|
58
|
+
if original_view_context.respond_to?(:virtual_path)
|
|
59
|
+
original_view_context.virtual_path
|
|
60
|
+
elsif original_view_context.instance_variable_defined?(:@virtual_path)
|
|
61
|
+
original_view_context.instance_variable_get(:@virtual_path)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
47
65
|
def i18n_scope
|
|
48
66
|
self.class.name.split('::').second.underscore.to_sym
|
|
49
67
|
end
|
data/lib/satis/version.rb
CHANGED
data/lib/satis.rb
CHANGED
|
@@ -27,6 +27,21 @@ module Satis
|
|
|
27
27
|
Satis::Helpers::Container.add_helper(name, component)
|
|
28
28
|
end
|
|
29
29
|
|
|
30
|
+
def current_original_virtual_path
|
|
31
|
+
original_virtual_path_stack.last
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def with_original_virtual_path(virtual_path)
|
|
35
|
+
original_virtual_path_stack.push(virtual_path)
|
|
36
|
+
yield
|
|
37
|
+
ensure
|
|
38
|
+
original_virtual_path_stack.pop
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def original_virtual_path_stack
|
|
42
|
+
Thread.current[:satis_original_virtual_path_stack] ||= []
|
|
43
|
+
end
|
|
44
|
+
|
|
30
45
|
def add_component_helper(component_name, name, component)
|
|
31
46
|
klass = "Satis::#{component_name.to_s.classify}::Component".safe_constantize
|
|
32
47
|
return if klass.blank?
|