Commit ca026e51ae5acdc4891ef9e14ec6582db92b78bc

Authored by Andrey Karpikov
1 parent ea0fcee8

check repear first item active class

... ... @@ -78,7 +78,6 @@ module Kanjai
78 78 field_options: @field_options,
79 79 conditions: conditions
80 80 }
81   - p '3'
82 81 end
83 82 end
84 83
... ... @@ -91,7 +90,7 @@ module Kanjai
91 90 result = []
92 91 @html_source.scan(/{"static":[\w\W\{]+?}}/).each do |str|
93 92 element_hash = JSON.parse(str)
94   - result << {:name => element_hash["static"]["title"], :itemName => element_hash["static"]["itemName"] , :type => element_hash["static"]["type"], :source => str}
  93 + result << {:name => identifier(element_hash["static"]), :itemName => element_hash["static"]["itemName"] , :type => element_hash["static"]["type"], :source => str}
95 94 end
96 95 result
97 96 end
... ... @@ -155,16 +154,16 @@ module Kanjai
155 154
156 155 source.to_s.scan(/{"element":[\w\W\{]+?}}/).each do |str|
157 156 element_hash = JSON.parse(str)
158   - @field_options << {:name => element_hash["element"]["title"], :itemName => element_hash["element"]["itemName"] , main: element_hash["element"]["main"].to_i, :attributes => {'type' => element_hash["element"]["type"], 'repeat' => repeat, 'repeatItemId' => repeatItemId}, :source => nil, :children => {}}
159   - source.gsub!(str, element_hash["element"]["title"])
  157 + @field_options << {:name => identifier(element_hash["element"]), :itemName => element_hash["element"]["itemName"] , main: element_hash["element"]["main"].to_i, :attributes => {'type' => element_hash["element"]["type"], 'repeat' => repeat, 'repeatItemId' => repeatItemId}, :source => nil, :children => {}}
  158 + source.gsub!(str, identifier(element_hash["element"]))
160 159 end
161 160
162 161 attr.each do |key, value|
163 162 value.to_s.scan(/{"element":[\w\W\{]+?}}/).each do |str|
164 163
165 164 element_hash = JSON.parse(str)
166   - @field_options << {:name => element_hash["element"]["title"], :itemName => element_hash["element"]["itemName"] , main: element_hash["element"]["main"].to_i, :attributes => {'type' => element_hash["element"]["type"], 'repeat' => repeat, 'repeatItemId' => repeatItemId}, :source => nil, :children => {}}
167   - value.gsub!(str, element_hash["element"]["title"])
  165 + @field_options << {:name => identifier(element_hash["element"]), :itemName => element_hash["element"]["itemName"] , main: element_hash["element"]["main"].to_i, :attributes => {'type' => element_hash["element"]["type"], 'repeat' => repeat, 'repeatItemId' => repeatItemId}, :source => nil, :children => {}}
  166 + value.gsub!(str, identifier(element_hash["element"]))
168 167 end
169 168 end
170 169
... ... @@ -175,5 +174,9 @@ module Kanjai
175 174 mas
176 175 end
177 176
  177 + def identifier(el)
  178 + el['id'].present? ? el['id'] : el['title']
  179 + end
  180 +
178 181 end
179 182 end
\ No newline at end of file
... ...
1 1 module Kanjai
2   - VERSION = "0.0.289"
  2 + VERSION = "0.0.290"
3 3 end
... ...