Commit 12eda134f45f1150dec690ecb86366d5c8f47ddc

Authored by Andrey Karpikov
1 parent 700a3fef

check variables

... ... @@ -21,9 +21,11 @@ module Kanjai
21 21 current_page = current_page.parent
22 22 end
23 23 end
24   - TemplateGenerator.method("#{type}_generator").call(session, domain, elements, subparts, @original_hash_value[0], current_page)
  24 + TemplateGenerator.method("#{type}_generator").call(session, domain, elements, subparts, @original_hash_value[0], true, current_page)
  25 + elsif type == 'menu'
  26 + TemplateGenerator.method("#{type}_generator").call(session, domain, elements, subparts, @original_hash_value[0], false )
25 27 else
26   - TemplateGenerator.method("#{type}_generator").call(session, domain, elements, subparts, @original_hash_value[0])
  28 + TemplateGenerator.method("#{type}_generator").call(session, domain, elements, subparts, @original_hash_value[0] )
27 29 end
28 30 end
29 31
... ... @@ -39,7 +41,7 @@ module Kanjai
39 41
40 42
41 43
42   - def self.menu_generator(session, domain, elements, subparts, hash_value, current_page = nil)
  44 + def self.menu_generator(session, domain, elements, subparts, hash_value, start_from_current_page, current_page = nil)
43 45 elements.each do |item|
44 46 case item[:name]
45 47 when 'text'
... ... @@ -61,7 +63,7 @@ module Kanjai
61 63 if normal_state
62 64 doc_normal_state = Nokogiri::HTML::DocumentFragment.parse ""
63 65 Nokogiri::HTML::Builder.with(doc_normal_state) do |repeat_part|
64   - self.menu_generator(session, domain, normal_state[:children], repeat_part, nil)
  66 + self.menu_generator(session, domain, normal_state[:children], repeat_part, nil, false)
65 67 end
66 68 normal_state_template = doc_normal_state.to_html
67 69 end
... ... @@ -69,7 +71,7 @@ module Kanjai
69 71 if active_state
70 72 doc_active_state = Nokogiri::HTML::DocumentFragment.parse ""
71 73 Nokogiri::HTML::Builder.with(doc_active_state) do |repeat_part|
72   - self.menu_generator(session, domain, active_state[:children], repeat_part, nil)
  74 + self.menu_generator(session, domain, active_state[:children], repeat_part, nil, false)
73 75 end
74 76 active_state_template = doc_active_state.to_html
75 77 end
... ... @@ -77,7 +79,7 @@ module Kanjai
77 79 if separator
78 80 doc_separator = Nokogiri::HTML::DocumentFragment.parse ""
79 81 Nokogiri::HTML::Builder.with(doc_separator) do |repeat_part|
80   - self.menu_generator(session, domain, separator[:children], repeat_part, nil)
  82 + self.menu_generator(session, domain, separator[:children], repeat_part, nil, false)
81 83 end
82 84 separator_template = doc_separator.to_html
83 85 end
... ... @@ -99,7 +101,11 @@ module Kanjai
99 101 end
100 102
101 103 unless current_page.nil?
102   - page_collection = page_collection.where(:parent_id => current_page.id)
  104 + if start_from_current_page
  105 + page_collection = page_collection.where(:id => current_page.id)
  106 + else
  107 + page_collection = page_collection.where(:parent_id => current_page.id)
  108 + end
103 109 end
104 110
105 111 begin
... ... @@ -120,7 +126,7 @@ module Kanjai
120 126 if page.children.length > 0 and next_level
121 127 subparts << item[:source]
122 128
123   - self.menu_generator(session, domain, next_level[:children], subparts, nil, page)
  129 + self.menu_generator(session, domain, next_level[:children], subparts, nil, false, page)
124 130 else
125 131
126 132 if session[:url] == page.lang_attributes(I18n.locale, :url)
... ... @@ -150,7 +156,7 @@ module Kanjai
150 156 p attributes
151 157 end
152 158 subparts.send(item[:name].to_s, attributes) do |next_subparts|
153   - self.menu_generator(session, domain, item[:children], next_subparts, nil, current_page)
  159 + self.menu_generator(session, domain, item[:children], next_subparts, nil, start_from_current_page, current_page)
154 160 end
155 161 end
156 162
... ... @@ -241,7 +247,7 @@ module Kanjai
241 247
242 248 row_index.each_with_index do |row_index, position|
243 249 value = scope.where(row_item: row_index).collect{|item| [item.marker, item.text_value] }.to_h
244   -
  250 + value = value.merge(hash_value)
245 251 if(position == 0)
246 252 value['###FIRST_ITEM_ACTIVE###'] = 'active show'
247 253 value['###FIRST_ITEM_TRUE###'] = 'true'
... ...
1 1 module Kanjai
2   - VERSION = "0.0.307"
  2 + VERSION = "0.0.308"
3 3 end
... ...