Commit 12eda134f45f1150dec690ecb86366d5c8f47ddc

Authored by Andrey Karpikov
1 parent 700a3fef

check variables

@@ -21,9 +21,11 @@ module Kanjai @@ -21,9 +21,11 @@ module Kanjai
21 current_page = current_page.parent 21 current_page = current_page.parent
22 end 22 end
23 end 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 else 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 end 29 end
28 end 30 end
29 31
@@ -39,7 +41,7 @@ module Kanjai @@ -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 elements.each do |item| 45 elements.each do |item|
44 case item[:name] 46 case item[:name]
45 when 'text' 47 when 'text'
@@ -61,7 +63,7 @@ module Kanjai @@ -61,7 +63,7 @@ module Kanjai
61 if normal_state 63 if normal_state
62 doc_normal_state = Nokogiri::HTML::DocumentFragment.parse "" 64 doc_normal_state = Nokogiri::HTML::DocumentFragment.parse ""
63 Nokogiri::HTML::Builder.with(doc_normal_state) do |repeat_part| 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 end 67 end
66 normal_state_template = doc_normal_state.to_html 68 normal_state_template = doc_normal_state.to_html
67 end 69 end
@@ -69,7 +71,7 @@ module Kanjai @@ -69,7 +71,7 @@ module Kanjai
69 if active_state 71 if active_state
70 doc_active_state = Nokogiri::HTML::DocumentFragment.parse "" 72 doc_active_state = Nokogiri::HTML::DocumentFragment.parse ""
71 Nokogiri::HTML::Builder.with(doc_active_state) do |repeat_part| 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 end 75 end
74 active_state_template = doc_active_state.to_html 76 active_state_template = doc_active_state.to_html
75 end 77 end
@@ -77,7 +79,7 @@ module Kanjai @@ -77,7 +79,7 @@ module Kanjai
77 if separator 79 if separator
78 doc_separator = Nokogiri::HTML::DocumentFragment.parse "" 80 doc_separator = Nokogiri::HTML::DocumentFragment.parse ""
79 Nokogiri::HTML::Builder.with(doc_separator) do |repeat_part| 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 end 83 end
82 separator_template = doc_separator.to_html 84 separator_template = doc_separator.to_html
83 end 85 end
@@ -99,7 +101,11 @@ module Kanjai @@ -99,7 +101,11 @@ module Kanjai
99 end 101 end
100 102
101 unless current_page.nil? 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 end 109 end
104 110
105 begin 111 begin
@@ -120,7 +126,7 @@ module Kanjai @@ -120,7 +126,7 @@ module Kanjai
120 if page.children.length > 0 and next_level 126 if page.children.length > 0 and next_level
121 subparts << item[:source] 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 else 130 else
125 131
126 if session[:url] == page.lang_attributes(I18n.locale, :url) 132 if session[:url] == page.lang_attributes(I18n.locale, :url)
@@ -150,7 +156,7 @@ module Kanjai @@ -150,7 +156,7 @@ module Kanjai
150 p attributes 156 p attributes
151 end 157 end
152 subparts.send(item[:name].to_s, attributes) do |next_subparts| 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 end 160 end
155 end 161 end
156 162
@@ -241,7 +247,7 @@ module Kanjai @@ -241,7 +247,7 @@ module Kanjai
241 247
242 row_index.each_with_index do |row_index, position| 248 row_index.each_with_index do |row_index, position|
243 value = scope.where(row_item: row_index).collect{|item| [item.marker, item.text_value] }.to_h 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 if(position == 0) 251 if(position == 0)
246 value['###FIRST_ITEM_ACTIVE###'] = 'active show' 252 value['###FIRST_ITEM_ACTIVE###'] = 'active show'
247 value['###FIRST_ITEM_TRUE###'] = 'true' 253 value['###FIRST_ITEM_TRUE###'] = 'true'
1 module Kanjai 1 module Kanjai
2 - VERSION = "0.0.307" 2 + VERSION = "0.0.308"
3 end 3 end