From 9b31496a8c7ef2018f59bec2cdade97013457f4f Mon Sep 17 00:00:00 2001 From: yanxd Date: Sat, 17 May 2014 15:25:52 +0800 Subject: [PATCH 1/2] =?UTF-8?q?edit=20=E5=9B=BE=E6=A0=87=E4=B8=A2=E5=A4=B1?= =?UTF-8?q?=20bid=E4=BF=AE=E6=94=B9=E6=96=87=E4=BB=B6=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Client.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Client.html b/Client.html index 5ba9775f1..fbb7cec52 100644 --- a/Client.html +++ b/Client.html @@ -1,4 +1,4 @@ - + @@ -8,15 +8,15 @@ Client <body> <hr /> - <h2>һͼƬ</h2> + <h2>这是一张图片</h2> <p>photo<a href="http://10.0.47.15:3000/shares/new?access_token='2d3dda45dsd'&comment='verygood'&title=davide&share_type=1&url=http://www.baidu.com"> Share A </a></p> <hr /> - <h2>һƵ</h2> + <h2>这是一段视频</h2> <p>Text<a href="http://10.0.47.15:3000/shares/new?access_token=2d3dda45dsd&comment=verygood&title=kaka&share_type=2&url=http://www.sina.com"> Share B </a></p> <hr /> - <h2>һƪ</h2> + <h2>这是一篇文章</h2> <p>Text<a href="http://10.0.47.15:3000/shares/new?access_token=2d3dda45dsd&comment=verygood&title=pepe&share_type=3&url=http://www.sina.com"> Share C </a></p> <hr /> From 6c9b9841b83f8c7bfc7a7fb8f89fde108c1114c8 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 17 May 2014 15:39:18 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=95=99=E8=A8=80=E5=A2=9E=E5=8A=A0=E5=9B=9E=E5=A4=8D=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E5=9B=9E=E5=A4=8D=E7=9A=84=E8=AF=84=E8=AE=BA=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 29 +++++++++++++ app/controllers/words_controller.rb | 8 +++- app/models/homework_attach.rb | 6 +++ app/models/journals_for_message.rb | 3 +- .../homework_attach/_add_jour_reply.html.erb | 14 +++++++ .../homework_attach/_jour_reply.html.erb | 6 +++ .../_journal_reply_items.html.erb | 34 +++++++++++++++ app/views/homework_attach/_showjour.html.erb | 41 +++++++++++-------- .../homework_attach/add_jour_reply.js.erb | 14 +++++++ app/views/homework_attach/destroy.js.erb | 3 +- config/routes.rb | 2 + 11 files changed, 140 insertions(+), 20 deletions(-) create mode 100644 app/views/homework_attach/_add_jour_reply.html.erb create mode 100644 app/views/homework_attach/_jour_reply.html.erb create mode 100644 app/views/homework_attach/_journal_reply_items.html.erb create mode 100644 app/views/homework_attach/add_jour_reply.js.erb diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 01578eab3..8dc5d80a0 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -26,6 +26,13 @@ class HomeworkAttachController < ApplicationController #删除留言 def destroy @journal_destroyed = JournalsForMessage.delete_message(params[:object_id]) + @homework = HomeworkAttach.find(params[:id]) + @jours = @homework.journals_for_messages.order("created_on DESC") + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] respond_to do |format| format.js end @@ -57,5 +64,27 @@ class HomeworkAttachController < ApplicationController #result = percent * 1.0 / stars_reates_count #result end + + #添加回复 + def add_jour_reply + parent_id = params[:reference_id] + author_id = User.current.id + reply_user_id = params[:reference_user_id] + reply_id = params[:reference_message_id] # 暂时不实现 + content = params[:user_notes] + options = {:user_id => author_id, + :m_parent_id => parent_id, + :m_reply_id => reply_id, + :reply_id => reply_user_id, + :notes => content, + :is_readed => false} + @jfm = JournalsForMessage.new(options) + @jfm.save + respond_to do |format| + format.js{ + @save_succ = true if @jfm.errors.empty? + } + end + end end diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index c83c123fc..bfc1eacb4 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -193,7 +193,9 @@ class WordsController < ApplicationController elsif ( referer.match(/contests/) || referer.match(/contests/) ) #new added obj = Contest.find_by_id(obj_id) elsif ( referer.match(/softapplications/) || referer.match(/softapplications/) ) #new added - obj = Softapplication.find_by_id(obj_id) + obj = Softapplication.find_by_id(obj_id) + elsif ( referer.match(/homework_attach/) || referer.match(/homework_attach/) ) #new added + obj = HomeworkAttach.find_by_id(obj_id) else raise 'create reply obj unknow type.' end @@ -211,7 +213,9 @@ class WordsController < ApplicationController elsif obj.kind_of? Contest obj.add_jour(nil, nil, obj.id, options) #new added elsif obj.kind_of? Softapplication - obj.add_jour(nil, nil, obj.id, options) #new added + obj.add_jour(nil, nil, obj.id, options) #new added + elsif obj.kind_of? HomeworkAttach + obj.add_jour(nil, nil, obj.id, options) #new added else raise 'create reply obj unknow type.' end diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index d112ead50..4bac58449 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -24,4 +24,10 @@ class HomeworkAttach < ActiveRecord::Base result = percent * 1.0 / stars_reates.count result end + + def add_jours options + jfm = self.journals_for_messages.build(options) + jfm.save + jfm + end end diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 575737401..7356b7373 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -74,7 +74,8 @@ class JournalsForMessage < ActiveRecord::Base def self.reference_message(user_id) @user = User.find(user_id) - message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id} or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))") + message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id} + or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))") message end diff --git a/app/views/homework_attach/_add_jour_reply.html.erb b/app/views/homework_attach/_add_jour_reply.html.erb new file mode 100644 index 000000000..1e202e6a4 --- /dev/null +++ b/app/views/homework_attach/_add_jour_reply.html.erb @@ -0,0 +1,14 @@ + +<%= form_tag({:controller => 'homework_attach', :action => 'add_jour_reply'}, :remote => true) do %> +<%= text_area_tag 'user_notes', "", :class => 'noline', + :style => "resize: none;", :rows => 4, + :placeholder => l(:label_projects_feedback_respond_content), + :maxlength => 250 %> +<span style="float: left; margin-top: 1px; margin-right: 4px;"></span> +<%= hidden_field_tag 'reference_id', params[:reference_id], :value => journal.id %> +<%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => m_reply_id.user.id %> +<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => m_reply_id.id %> +<%= submit_tag l(:button_projects_feedback_respond), + :name => nil , :class => "enterprise", :style => "float: right; margin-top: 1px; margin-right: 4px;"%> + +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/_jour_reply.html.erb b/app/views/homework_attach/_jour_reply.html.erb new file mode 100644 index 000000000..0dd56f442 --- /dev/null +++ b/app/views/homework_attach/_jour_reply.html.erb @@ -0,0 +1,6 @@ +<% id = "journal_reply_ul_" + journal.id.to_s%> +<ul class="messages-for-user-reply" id = '<%= id %>' > + <% journal.children.each do |reply|%> + <%= render :partial => "journal_reply_items", :locals => {:reply => reply, :journal => journal, :m_reply_id => reply} %> + <% end %> +</ul> \ No newline at end of file diff --git a/app/views/homework_attach/_journal_reply_items.html.erb b/app/views/homework_attach/_journal_reply_items.html.erb new file mode 100644 index 000000000..85f7fa304 --- /dev/null +++ b/app/views/homework_attach/_journal_reply_items.html.erb @@ -0,0 +1,34 @@ +<% reply_allow = JournalsForMessage.create_by_user? User.current %> +<% ids_r = 'reply_respond_form_'+ reply.id.to_s %> +<li id='word_li_<%=reply.id.to_s%>' onmouseover="$('#<%= ids_r %>').show()" onmouseout="$('#<%= ids_r %>').hide()"> + <span class="portrait"> + <%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %> + </span> + <div class="message-body"> + <% id = 'project_respond_form_'+ reply.id.to_s %> + <p> + <span><%= link_to reply.user.name, user_path(reply.user) %>: </span> + <span class="message-notes"> <%= reply.notes %></span> + </p> + <p> + <span class="time"><%= format_time reply.created_on %></span> + <span style="display: none; margin-left: 4px;" id='<%=ids_r%>' > + <% if reply_allow %> + <%= link_to l(:label_projects_feedback_respond),'', + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), '#{l(:label_reply_plural)} #{m_reply_id.user.name}: '); return false;"} + %> + <% end %> + <% if @user == User.current || User.current.admin? || reply.user.id == User.current.id %> + <%= link_to(l(:label_newfeedback_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => reply, :user_id => reply.user}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> + <% end %> + </span> + </p> + </div> + <div id='<%=id %>' class="respond-form"> + <% if reply_allow %> + <%= render :partial => "add_jour_reply", :locals => {:journal => journal, :m_reply_id => m_reply_id} %> + <% end %> + </div> + <div style="clear: both;"></div> +</li> \ No newline at end of file diff --git a/app/views/homework_attach/_showjour.html.erb b/app/views/homework_attach/_showjour.html.erb index f810082c9..dbd7f2547 100644 --- a/app/views/homework_attach/_showjour.html.erb +++ b/app/views/homework_attach/_showjour.html.erb @@ -40,24 +40,33 @@ <% for journal in jour%> <li id='word_li_<%= journal.id.to_s %>' class="outer-message-for-user"> <span class="portrait"><%= image_tag(url_to_avatar(journal.user), :class => "avatar") %></span> - <span class="body"> - <span class="user"><%= link_to journal.user, user_path(journal.user)%></span> - <span class="font_lighter"><% label = l(:label_contest_requirement) %></span> - <div> <%= textilizable journal.notes%> </div> - <span class="font_lighter"><%= l(:label_bids_published) %> -  <%= time_tag(journal.created_on).html_safe %>  - <%= l(:label_bids_published_ago) %> + <span class="body"> + <span class="user"><%= link_to journal.user, user_path(journal.user)%></span> + <span class="font_lighter"><% label = l(:label_contest_requirement) %></span> + <div> <%= textilizable journal.notes%> </div> + <span class="font_lighter"><%= l(:label_bids_published) %> +  <%= time_tag(journal.created_on).html_safe %>  + <%= l(:label_bids_published_ago) %> + </span> + <% ids = 'project_respond_form_'+ journal.id.to_s%> + <span> + <%= link_to l(:label_projects_feedback_respond),'', + {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.name}: '); $('##{ids} textarea') ;return false;"} + %> + <% if journal.user==User.current|| User.current.admin? %> + <%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => journal, :user_id => journal.user}, + :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> + <% end %> + </span> </span> - <% ids = 'project_respond_form_'+ journal.id.to_s%> - <span> - - <% if journal.user==User.current|| User.current.admin? %> - <%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => journal, :user_id => journal.user}, - :remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %> - <% end %> - </span> - </span> <div style="clear: both;"></div> + <div id='<%= ids %>' class="respond-form"> + <%= render :partial => 'add_jour_reply', :locals => {:journal => journal, :m_reply_id => journal} %> + </div> + <div style="clear: both;"></div> + <div> + <%= render :partial => "jour_reply", :locals => {:journal => journal } %> + </div> </li> <% end %> </ul> diff --git a/app/views/homework_attach/add_jour_reply.js.erb b/app/views/homework_attach/add_jour_reply.js.erb new file mode 100644 index 000000000..564229d81 --- /dev/null +++ b/app/views/homework_attach/add_jour_reply.js.erb @@ -0,0 +1,14 @@ +<% if @save_succ %> +var pre_append = $('<%= j( + render :partial => "journal_reply_items", + :locals => {:reply => @jfm, :journal => @jfm.parent, :m_reply_id => @jfm} + ) %>').hide(); +$('#journal_reply_ul_<%=@jfm.m_parent_id%>').append(pre_append); +pre_append.fadeIn(600); +var textarea = $('#project_respond_form_<%=@jfm.m_reply_id.to_s%> textarea'); +textarea.val(''); +$('#project_respond_form_<%=@jfm.m_reply_id.to_s%>').hide(); +setMaxLengthItem(pre_append.find('textarea')[0]); +<% else %> +alert("<%= l(:label_feedback_fail) %>"); +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/destroy.js.erb b/app/views/homework_attach/destroy.js.erb index f3d9a7bef..9691a6aee 100644 --- a/app/views/homework_attach/destroy.js.erb +++ b/app/views/homework_attach/destroy.js.erb @@ -6,6 +6,7 @@ destroyedItem.remove(); }); <% else %> - $('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour => @jour, :state => false})) %>'); + + $('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour => @jours, :state => false})) %>'); $('#new_form_reference_user_id').val(""); <% end %> diff --git a/config/routes.rb b/config/routes.rb index b5defb117..ea1b70e35 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -24,6 +24,8 @@ RedmineApp::Application.routes.draw do resources :homework_attach match 'homework_attach/addjours', :controller => 'homework_attach', :action => 'addjours', :via => [:get,:post] + match 'homework_attach/add_jour_reply', :controller => 'homework_attach', :action => 'add_jour_reply', :via => [:get,:post] + resources :open_source_projects do collection do match 'search', via: [:get, :post]