5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/pult/panel/app/injector.rb', line 5
def self.inject! hash, panel, app
hash.instance_eval " def _app\n \"\#{app}\"\n end\n\n def _panel\n ->{ ObjectSpace._id2ref(\#{panel.object_id}) }.call\n end\n STR\n\n hash.instance_eval do\n def app?\n true\n end\n\n def _to_flat param=self, prefix=nil\n hash = param.each_pair.reduce({}) do |a, (k, v)|\n v.is_a?(Hash) && ! SYS_KEYS.include?(k) ?\n a.merge(_to_flat(v, \"\#{prefix}\#{k}.\"))\n : a.merge(\"\#{prefix}\#{k}\" => v)\n end\n\n Pult::Panel::App.to_app! hash, _panel, _app\n end\n\n def _config\n _panel[_app].config\n end\n\n def _actions\n keys - SYS_KEYS\n end\n\n def _translated_actions\n _actions.map{ |action| _action_title(action) }\n end\n\n #\n # TODO order param like :ui => :az, :orig => :config, etc..\n #\n def _ui_actions order: :az_ui\n resproc = proc { |action| [action, _action_title(action)] }\n tacts = _translated_actions\n\n case order\n when :config\n _actions.map(&resproc)\n when :config_ui\n _actions.map(&resproc).sort_by{|arr| tacts.index(arr[1]) }\n when :az\n _actions.sort.map(&resproc)\n when :az_ui\n _actions.map(&resproc).sort_by{|arr| arr[1] }\n end\n end\n\n def _action_title action\n _action_translate(action) || action\n end\n\n def _action_translate action\n self&.config&.ui&.ru&.action&.send(:[], action)\n end\n end\nend\n"
|