@ -17,7 +17,7 @@ module Mobile
case field
case field
when :lasted_comment
when :lasted_comment
time_from_now f . created_on
time_from_now f . created_on
when : reply _count
when : comment _count
# f.children.count
# f.children.count
all_comments = [ ]
all_comments = [ ]
get_all_children ( all_comments , f ) . count
get_all_children ( all_comments , f ) . count
@ -27,6 +27,8 @@ module Mobile
'JournalsForMessage'
'JournalsForMessage'
when :act_id
when :act_id
f . id
f . id
when :content
f . notes
end
end
end
end
end
end
@ -42,10 +44,10 @@ module Mobile
end
end
jours_expose :created_on
jours_expose :created_on
jours_expose :lasted_comment
jours_expose :lasted_comment
jours_expose : notes
jours_expose : content
jours_expose :m_reply_id
jours_expose :m_reply_id
jours_expose :m_parent_id
jours_expose :m_parent_id
jours_expose : reply _count
jours_expose : comment _count
jours_expose :praise_count
jours_expose :praise_count
expose :course , using : Mobile :: Entities :: Course do | f , opt |
expose :course , using : Mobile :: Entities :: Course do | f , opt |
if f . is_a? ( :: JournalsForMessage ) && f [ :jour_type ] == " Course "
if f . is_a? ( :: JournalsForMessage ) && f [ :jour_type ] == " Course "
@ -55,9 +57,20 @@ module Mobile
expose :reply_user , using : Mobile :: Entities :: User do | f , opt |
expose :reply_user , using : Mobile :: Entities :: User do | f , opt |
f . at_user
f . at_user
end
end
expose : child_reply , using : Mobile :: Entities :: Jours do | f , opt |
expose : all_children , using : Mobile :: Entities :: Jours do | f , opt |
if f . is_a? ( :: JournalsForMessage )
if f . is_a? ( :: JournalsForMessage )
f . children . reverse
# f.children.reverse
if ! opt [ :children ] && opt [ :comment_type ] . nil?
if f . parent . nil? && opt [ :type ] == 0
opt [ :children ] = true
all_comments = [ ]
tStart = opt [ :page ] * 5
tEnd = ( opt [ :page ] + 1 ) * 5 - 1
all_comments = get_all_children ( all_comments , f ) [ tStart .. tEnd ]
all_comments
end
end
end
end
end
end
expose :has_praise , if : lambda { | instance , options | options [ :user ] } do | instance , options |
expose :has_praise , if : lambda { | instance , options | options [ :user ] } do | instance , options |
@ -67,6 +80,78 @@ module Mobile
has_praise = obj . empty? ? false : true
has_praise = obj . empty? ? false : true
has_praise
has_praise
end
end
expose :parents_count , if : lambda { | instance , options | options [ :user ] } do | instance , options |
parents_reply = [ ]
if options [ :comment_type ] . nil?
parents_reply = get_reply_parents_no_root ( parents_reply , instance )
elsif options [ :comment_type ] == " homework "
parents_reply = get_reply_parents ( parents_reply , instance )
end
parents_reply . count
end
expose :parents_reply_bottom , using : Mobile :: Entities :: Jours do | f , opt |
if f . is_a? ( :: JournalsForMessage )
#取二级回复的底楼层
parents_reply = [ ]
if opt [ :comment_type ] . nil?
parents_reply = get_reply_parents_no_root ( parents_reply , f )
elsif opt [ :comment_type ] == " homework "
parents_reply = get_reply_parents ( parents_reply , f )
end
if parents_reply . count > 0 && parents_reply . count != 2 && ! opt [ :bottom ]
if opt [ :type ] == 1
# opt[:bottom] = true
# parents_reply[opt[:page]..opt[:page]]
else
opt [ :bottom ] = true
parents_reply [ 0 .. 0 ]
end
else
[ ]
end
end
end
expose :parents_reply_top , using : Mobile :: Entities :: Jours do | f , opt |
if f . is_a? ( :: JournalsForMessage )
#取二级回复的顶楼层
parents_reply = [ ]
if opt [ :comment_type ] . nil?
parents_reply = get_reply_parents_no_root ( parents_reply , f )
elsif opt [ :comment_type ] == " homework "
parents_reply = get_reply_parents ( parents_reply , f )
end
if parents_reply . count > = 2 && ! opt [ :top ]
if opt [ :type ] == 1
opt [ :bottom ] = true
tStart = ( opt [ :page ] - 1 ) * 5 + 2
tEnd = ( opt [ :page ] ) * 5 + 2 - 1
if tEnd > = parents_reply . count - 1
tEnd = parents_reply . count - 2
end
if tStart < = parents_reply . count - 2
parents_reply = parents_reply . reverse [ tStart .. tEnd ]
parents_reply . reverse
else
[ ]
end
else
opt [ :top ] = true
parents_reply = parents_reply . reverse [ 0 .. 1 ]
parents_reply . reverse
end
else
[ ]
end
end
end
end
end
end
end
end
end