issue回复

This commit is contained in:
cxt 2016-04-01 23:22:39 +08:00
parent cc2fe6108a
commit 790b452a9b
8 changed files with 44 additions and 15 deletions

View File

@ -24,6 +24,7 @@ module Mobile
if (feedback.errors.empty?) if (feedback.errors.empty?)
homework_common.update_attributes(:updated_at => Time.now) homework_common.update_attributes(:updated_at => Time.now)
data = homework_common.journals_for_messages.last data = homework_common.journals_for_messages.last
present :data, data, with: Mobile::Entities::Jours
result = 2 result = 2
else else
result = 3 result = 3
@ -81,7 +82,9 @@ module Mobile
is_jour.notes = params[:content] is_jour.notes = params[:content]
is_jour.journalized = issue is_jour.journalized = issue
#is_jour.journalized_type = "Issue" #is_jour.journalized_type = "Issue"
if issue.journals << is_jour if is_jour.save
data = is_jour
present :data, data, with: Mobile::Entities::Journal
result = 2 result = 2
else else
result = 3 result = 3
@ -110,7 +113,6 @@ module Mobile
else else
result = 4 result = 4
end end
present :data, data, with: Mobile::Entities::Jours
present :result, result present :result, result
present :status, 0 present :status, 0
end end

View File

@ -27,7 +27,7 @@ module Mobile
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
ac.nil? || ac.act.nil? ? 0 : ac.act.children.count ac.nil? || ac.act.nil? ? 0 : ac.act.children.count
elsif ac.act_type == "Issue" elsif ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes != null").count ac.nil? || ac.act.nil? ? 0 : ac.act.journals.where("notes is not null and notes != ''").count
end end
when :subject when :subject
if ac.act_type == "HomeworkCommon" if ac.act_type == "HomeworkCommon"

View File

@ -23,9 +23,11 @@ module Mobile
when :issue_status when :issue_status
IssueStatus.find(issue.status_id).name IssueStatus.find(issue.status_id).name
when :journals_count when :journals_count
issue.journals.where("notes != null").count issue.journals.where("notes is not null and notes != ''").count
when :project_name when :project_name
issue.project.name issue.project.name
when :issue_praise_count
get_activity_praise_num(issue)
end end
end end
end end
@ -41,9 +43,10 @@ module Mobile
issue_expose :issue_status issue_expose :issue_status
issue_expose :journals_count issue_expose :journals_count
issue_expose :project_name issue_expose :project_name
issue_expose :issue_praise_count
expose :issue_journals, using: Mobile::Entities::Journal do |f, opt| expose :issue_journals, using: Mobile::Entities::Journal do |f, opt|
if f.is_a?(::Issue) if f.is_a?(::Issue)
f.journals.where("notes != null") f.journals.where("notes is not null and notes != ''")
end end
end end
end end

View File

@ -1,6 +1,7 @@
module Mobile module Mobile
module Entities module Entities
class Journal <Grape::Entity class Journal <Grape::Entity
include Redmine::I18n
=begin =begin
include Redmine::I18n include Redmine::I18n
include ApplicationHelper include ApplicationHelper
@ -16,7 +17,7 @@ module Entities
elsif journal.is_a?(::Journal) elsif journal.is_a?(::Journal)
if journal.respond_to?(f) if journal.respond_to?(f)
if f == :created_on if f == :created_on
format_time(journal.send(f)) time_from_now(journal.send(f))
else else
journal.send(f) journal.send(f)
end end
@ -34,7 +35,6 @@ module Entities
expose :notes expose :notes
journal_expose :created_on journal_expose :created_on
journal_expose :last_created_time
expose :user,using: Mobile::Entities::User do |f, opt| expose :user,using: Mobile::Entities::User do |f, opt|
f.user f.user
end end

View File

@ -213,7 +213,7 @@
<! } !> <! } !>
<! } !> <! } !>
<! if ((count + page * 10) < all_count) {!> <! if ((count + page * 10) < all_count) {!>
<div id="more_activities" class="more-events mt10" onclick="loadDataFromServer(868, <!= page+1 !>);">更多</div> <div id="more_activities" class="more-events mt10" onclick="loadDataFromServer(8686, <!= page+1 !>);">更多</div>
<! } !> <! } !>
</script> </script>

View File

@ -37,15 +37,16 @@
</div> </div>
<div class="post-interactive border-bottom"> <div class="post-interactive border-bottom">
<div class="post-interactive-column c-grey2">回复 (<!=issues.journals_count!>)</div> <div class="post-interactive-column c-grey2">回复 (<!=issues.journals_count!>)</div>
<div class="post-interactive-column c-grey2">赞 ()</div> <div class="post-interactive-column c-grey2">赞 (<!=issues.issue_praise_count!>)</div>
</div> </div>
<div id="all_issue_reply">
<! for(var j =0; j < issues.issue_journals.length; ++j){ !> <! for(var j =0; j < issues.issue_journals.length; ++j){ !>
<div class="post-reply-wrap border-bottom"> <div class="post-reply-wrap border-bottom">
<div class="post-reply-row"> <div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="<!=issues.issue_journals[j].user.img_url!>" width="45" height="45" class="border-radius" /></div> <div class="post-reply-avatar fl"><img src="<!=issues.issue_journals[j].user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="ml55"> <div class="ml55">
<div class="post-reply-user hidden"><!=issues.issue_journals[j].user.realname!></div> <div class="post-reply-user hidden"><!=issues.issue_journals[j].user.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=issue.issue_journals[j].notes!></div> <div class="post-reply-content c-grey2 mb10"><!:=issues.issue_journals[j].notes!></div>
<div class="post-reply-date fl"><!=issues.issue_journals[j].created_on!></div> <div class="post-reply-date fl"><!=issues.issue_journals[j].created_on!></div>
<div class="post-reply-trigger fr undis">回复</div> <div class="post-reply-trigger fr undis">回复</div>
</div> </div>
@ -53,6 +54,7 @@
</div> </div>
</div> </div>
<! } !> <! } !>
</div>
<div class="post-input-wrap"> <div class="post-input-wrap">
<div class="post-reply-row"> <div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="images/post-avatar.jpg" width="30" height="30" /></div> <div class="post-reply-avatar fl"><img src="images/post-avatar.jpg" width="30" height="30" /></div>
@ -67,6 +69,20 @@
</div> </div>
</script> </script>
<script id="t:issue-detail-reply" type="text/html">
<div class="post-reply-wrap border-bottom">
<div class="post-reply-row">
<div class="post-reply-avatar fl"><img src="<!=reply.user.img_url!>" width="45" height="45" class="border-radius" /></div>
<div class="ml55">
<div class="post-reply-user hidden"><!=reply.user.realname!></div>
<div class="post-reply-content c-grey2 mb10"><!:=reply.notes!></div>
<div class="post-reply-date fl"><!=reply.created_on!></div>
</div>
<div class="cl"></div>
</div>
</div>
</script>
<script src="/javascripts/jquery-1.3.2.js"></script> <script src="/javascripts/jquery-1.3.2.js"></script>
<script src="/javascripts/baiduTemplate.js"></script> <script src="/javascripts/baiduTemplate.js"></script>
<script src="/javascripts/wechat/issue_detail.js"></script> <script src="/javascripts/wechat/issue_detail.js"></script>

View File

@ -13,12 +13,19 @@ $(document).ready(function(){
var apiUrl = '/api/v1/'; var apiUrl = '/api/v1/';
var setReplyTemplate = function(data){
console.log(data);
var html=bt('t:issue-detail-reply',{reply: data});
$('#all_issue_reply').prepend(html);
};
var setTemplate = function(data){ var setTemplate = function(data){
console.log(data); console.log(data);
var html=bt('t:issue-detail',{issues: data}); var html=bt('t:issue-detail',{issues: data});
$('#issue-container').prepend(html); $('#issue-container').prepend(html);
$('.post-reply-submit').click(function(){ $('.post-reply-submit').click(function(){
replyInsert(); IssueReplyInsert();
}); });
/*$('post-interactive-praise').click(function(){ /*$('post-interactive-praise').click(function(){
praiseClick(); praiseClick();
@ -48,16 +55,16 @@ $(document).ready(function(){
loadDataFromServer(homeworkID); loadDataFromServer(homeworkID);
//点击回复按钮,插入回复内容 //点击回复按钮,插入回复内容
var replyInsert = function(){ var IssueReplyInsert = function(){
var replyContent = $("#postInput").val(); var replyContent = $("#postInput").val();
if (!replyContent){ if (!replyContent){
alert("请输入回复"); alert("请输入回复");
}else{ }else{
//将用户输入内容插入最后一条回复 //将用户输入内容插入最后一条回复
$(".post-reply-wrap:last").after('<div class="post-reply-wrap border-bottom"><div class="post-reply-row"><div class="post-reply-avatar fl"><img src="images/post-avatar.jpg" width="45" height="45" /></div><div class="ml55"><div class="post-reply-user hidden">Mrs. Ashford</div><div class="post-reply-content c-grey2 mb10"></div><div class="post-reply-date fl"></div><div class="post-reply-trigger fr undis">回复</div></div><div class="cl"></div></div> </div>'); /*$(".post-reply-wrap:last").after('<div class="post-reply-wrap border-bottom"><div class="post-reply-row"><div class="post-reply-avatar fl"><img src="images/post-avatar.jpg" width="45" height="45" /></div><div class="ml55"><div class="post-reply-user hidden">Mrs. Ashford</div><div class="post-reply-content c-grey2 mb10"></div><div class="post-reply-date fl"></div><div class="post-reply-trigger fr undis"></div></div><div class="cl"></div></div> </div>');
$(".post-reply-content:last").append(replyContent); $(".post-reply-content:last").append(replyContent);
$(".post-reply-date:last").append(Date()); $(".post-reply-date:last").append(Date());*/
var postInput = $("#postInput").val(); var postInput = $("#postInput").val();
$("#postInput").val(""); $("#postInput").val("");
//回复数目+1 //回复数目+1
@ -78,6 +85,7 @@ $(document).ready(function(){
data: userInfo, //参数如果没有可以为null data: userInfo, //参数如果没有可以为null
success: function (data) { //如果执行成功,那么执行此方法 success: function (data) { //如果执行成功,那么执行此方法
alert(data.result); //用data.d来获取后台传过来的json语句或者是单纯的语句 alert(data.result); //用data.d来获取后台传过来的json语句或者是单纯的语句
setReplyTemplate(data.data);
}, },
error: function (err) { //如果执行不成功,那么执行此方法 error: function (err) { //如果执行不成功,那么执行此方法
alert("err:" + err); alert("err:" + err);

View File

@ -2,5 +2,5 @@
* Created by root on 3/25/16. * Created by root on 3/25/16.
*/ */
$(document).ready(function(){ $(document).ready(function(){
loadDataFromServer(868, 0); loadDataFromServer(8686, 0);
}); });