diff --git a/app/api/mobile/apis/new_comment.rb b/app/api/mobile/apis/new_comment.rb index 7977a1e8a..cbd739e8c 100644 --- a/app/api/mobile/apis/new_comment.rb +++ b/app/api/mobile/apis/new_comment.rb @@ -24,6 +24,7 @@ module Mobile if (feedback.errors.empty?) homework_common.update_attributes(:updated_at => Time.now) data = homework_common.journals_for_messages.last + present :data, data, with: Mobile::Entities::Jours result = 2 else result = 3 @@ -81,7 +82,9 @@ module Mobile is_jour.notes = params[:content] is_jour.journalized = 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 else result = 3 @@ -110,7 +113,6 @@ module Mobile else result = 4 end - present :data, data, with: Mobile::Entities::Jours present :result, result present :status, 0 end diff --git a/app/api/mobile/entities/activity.rb b/app/api/mobile/entities/activity.rb index 82d021248..8c6b07281 100644 --- a/app/api/mobile/entities/activity.rb +++ b/app/api/mobile/entities/activity.rb @@ -27,7 +27,7 @@ module Mobile elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" ac.nil? || ac.act.nil? ? 0 : ac.act.children.count 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 when :subject if ac.act_type == "HomeworkCommon" diff --git a/app/api/mobile/entities/issue.rb b/app/api/mobile/entities/issue.rb index 777bb1ce8..d0bb0fa0d 100644 --- a/app/api/mobile/entities/issue.rb +++ b/app/api/mobile/entities/issue.rb @@ -23,9 +23,11 @@ module Mobile when :issue_status IssueStatus.find(issue.status_id).name when :journals_count - issue.journals.where("notes != null").count + issue.journals.where("notes is not null and notes != ''").count when :project_name issue.project.name + when :issue_praise_count + get_activity_praise_num(issue) end end end @@ -41,9 +43,10 @@ module Mobile issue_expose :issue_status issue_expose :journals_count issue_expose :project_name + issue_expose :issue_praise_count expose :issue_journals, using: Mobile::Entities::Journal do |f, opt| if f.is_a?(::Issue) - f.journals.where("notes != null") + f.journals.where("notes is not null and notes != ''") end end end diff --git a/app/api/mobile/entities/journal.rb b/app/api/mobile/entities/journal.rb index 83dbb9e00..787cdf1a4 100644 --- a/app/api/mobile/entities/journal.rb +++ b/app/api/mobile/entities/journal.rb @@ -1,6 +1,7 @@ module Mobile module Entities class Journal -
更多
+
更多
diff --git a/public/assets/wechat/issue_detail.html b/public/assets/wechat/issue_detail.html index 575349686..964ea7d5b 100644 --- a/public/assets/wechat/issue_detail.html +++ b/public/assets/wechat/issue_detail.html @@ -36,16 +36,17 @@
-
回复 ()
-
()
+
回复 ()
+
()
- +
+ = 0; --j){ !>
-
+
回复
@@ -53,6 +54,7 @@
+
@@ -65,6 +67,20 @@
+ + diff --git a/public/javascripts/wechat/homework_detail.js b/public/javascripts/wechat/homework_detail.js index b22cb3521..39d016133 100644 --- a/public/javascripts/wechat/homework_detail.js +++ b/public/javascripts/wechat/homework_detail.js @@ -80,7 +80,6 @@ $(document).ready(function(){ url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 data: userInfo, //参数,如果没有,可以为null success: function (data) { //如果执行成功,那么执行此方法 - alert(data.result); //用data.d来获取后台传过来的json语句,或者是单纯的语句 setReplyTemplate(data.data); }, error: function (err) { //如果执行不成功,那么执行此方法 diff --git a/public/javascripts/wechat/issue_detail.js b/public/javascripts/wechat/issue_detail.js index 3e1d06183..03ebda233 100644 --- a/public/javascripts/wechat/issue_detail.js +++ b/public/javascripts/wechat/issue_detail.js @@ -13,12 +13,19 @@ $(document).ready(function(){ var apiUrl = '/api/v1/'; + var setReplyTemplate = function(data){ + console.log(data); + var html=bt('t:issue-detail-reply',{issue_reply: data}); + $('#all_issue_reply').prepend(html); + }; + + var setTemplate = function(data){ console.log(data); var html=bt('t:issue-detail',{issues: data}); $('#issue-container').prepend(html); $('.post-reply-submit').click(function(){ - replyInsert(); + IssueReplyInsert(); }); /*$('post-interactive-praise').click(function(){ praiseClick(); @@ -42,22 +49,22 @@ $(document).ready(function(){ }; - var homeworkUrl = window.location.search; - var homeworkID = homeworkUrl.split("=")[1]; + var IssueUrl = window.location.search; + var IssueID = IssueUrl.split("=")[1]; - loadDataFromServer(homeworkID); + loadDataFromServer(IssueID); //点击回复按钮,插入回复内容 - var replyInsert = function(){ + var IssueReplyInsert = function(){ var replyContent = $("#postInput").val(); if (!replyContent){ alert("请输入回复"); }else{ //将用户输入内容插入最后一条回复 - $(".post-reply-wrap:last").after('
回复
'); + /*$(".post-reply-wrap:last").after('
回复
'); $(".post-reply-content:last").append(replyContent); - $(".post-reply-date:last").append(Date()); + $(".post-reply-date:last").append(Date());*/ var postInput = $("#postInput").val(); $("#postInput").val(""); //回复数目+1 @@ -74,10 +81,10 @@ $(document).ready(function(){ $.ajax({ type: "POST", //提交方式 dataType: "json", //类型 - url: apiUrl + 'new_comment/' + homeworkID, //提交的页面,方法名 + url: apiUrl + 'new_comment/' + IssueID, //提交的页面,方法名 data: userInfo, //参数,如果没有,可以为null success: function (data) { //如果执行成功,那么执行此方法 - alert(data.result); //用data.d来获取后台传过来的json语句,或者是单纯的语句 + setReplyTemplate(data.data); }, error: function (err) { //如果执行不成功,那么执行此方法 alert("err:" + err);