Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
dhuo14 committed Nov 21, 2014
1 parent 574f5d3 commit f5365a0
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions lib/base_function.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,34 @@ def transform_node_value(node,result,for_form=false)
if node.attributes.has_key?("data")
arr = eval(node.attributes["data"].to_str)
if arr[0].is_a?(Array)
tmp = arr.find{|d|d[0] == tranform_boolean(result)}
tmp = arr.find{|d|d[0] == tranform_boolean(result,true)}
result = tmp[1] unless tmp.blank?
end
end
else
result = tranform_boolean(result)
result = tranform_boolean(result,for_form)
end
return result
end

def tranform_boolean(s)
if s == true
return 1
elsif s == false
return 0
# 对布尔型进行转换,在form里要显示1或0,在show时要显示是或否
def tranform_boolean(s,show_cn=true)
if show_cn
if s == true
return 1
elsif s == false
return 0
else
return s
end
else
return s
if s == true
return "是"
elsif s == false
return "否"
else
return s
end
end
end

Expand Down

0 comments on commit f5365a0

Please sign in to comment.