Add message threads #394

This new view sorts the messages by threads based on the reply_to.
Now we store only the message which started a new thread in the reply_to
field to avoid recursive queries.
This commit is contained in:
Patrick Gansterer 2016-02-18 11:00:03 +01:00 committed by wvengen
parent d56828fa4d
commit 8ac1471a89
12 changed files with 180 additions and 0 deletions

View file

@ -0,0 +1,19 @@
- if pagination
- if Message.pub.count > 20
= items_per_page
= pagination_links_remote message_threads
- unless message_threads.empty?
%table.table.table-striped
%tbody
- for message in message_threads
%tr
%td
%b= link_to message.subject, message_thread_path(message)
%td= h(message.sender_name)
- if message.last_reply
%td= format_time(message.last_reply.created_at)
%td= h(message.last_reply.sender_name)
- else
%td{:colspan => "2"}
// %td= link_to t('.reply'), new_message_path(:message => {:reply_to => message.id}), class: 'btn'

View file

@ -0,0 +1,7 @@
- title t('.title')
- content_for :actionbar do
= link_to t('.messages'), messages_path, class: 'btn'
= link_to t('.new'), new_message_path, class: 'btn btn-primary'
#message_threads
= render 'message_threads', message_threads: @message_threads, pagination: true

View file

@ -0,0 +1 @@
$('#message_threads').html('#{j(render('message_threads', message_threads: @message_threads, pagination: true))}');

View file

@ -0,0 +1,16 @@
- if @messages.first.group
- title @messages.first.subject + ' (' + @messages.first.group.name + ')'
- else
- title @messages.first.subject
- for message in @messages
.panel.panel-default{:style => "width:40em"}
.panel-heading
%b= h(message.sender_name)
= format_time(message.created_at)
.panel-body= simple_format(h(message.body))
%p
= link_to t('.reply'), new_message_path(:message => {:reply_to => @messages.first.id}), class: 'btn'
|
= link_to t('.all_message_threads'), message_threads_path

View file

@ -1,6 +1,7 @@
- title t('.title')
- content_for :actionbar do
= link_to t('.message_threads'), message_threads_path, class: 'btn'
= link_to t('.new'), new_message_path, class: 'btn btn-primary'
#messages
= render 'messages', messages: @messages, pagination: true