Improve message threads (by @paroga)

This commit is contained in:
wvengen 2016-03-04 17:24:28 +01:00
parent 673448a5ac
commit 6b32d0c960
13 changed files with 89 additions and 27 deletions

View file

@ -0,0 +1,11 @@
- message_threads = Message.pub.threads.where(group: group).order(created_at: :desc).limit(5)
- unless message_threads.empty?
%section
%h3
= name
%small
= link_to message_thread_path(id) do
= t '.show_message_threads'
%i.icon.icon-chevron-right
= render 'message_threads', message_threads: message_threads, pagination: false
= link_to_top

View file

@ -5,15 +5,23 @@
- unless message_threads.empty?
%table.table.table-striped
%thead
%tr
%th= heading_helper Message, :subject
%th= t '.started_at'
%th= t '.started_by'
%th= t '.last_reply_at'
%th= t '.last_reply_by'
%tbody
- for message in message_threads
%tr
%td
%b= link_to message.subject, message_thread_path(message)
%td= h(message.sender_name)
%b= link_to message.subject, thread_message_path(message)
%td= format_time message.created_at
%td= show_user message.sender
- if message.last_reply
%td= format_time(message.last_reply.created_at)
%td= h(message.last_reply.sender_name)
%td= format_time message.last_reply.created_at
%td= show_user message.last_reply.sender
- else
%td{:colspan => "2"}
// %td= link_to t('.reply'), new_message_path(:message => {:reply_to => message.id}), class: 'btn'

View file

@ -3,5 +3,8 @@
- 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
= render 'groupmessage_threads', group: nil, name: t('.other'), id: 0
- for group in @groups
= render 'groupmessage_threads', group: group, name: group.name, id: group.id

View file

@ -1,16 +1,7 @@
- if @messages.first.group
- title @messages.first.subject + ' (' + @messages.first.group.name + ')'
- if @group.nil?
- title t '.other'
- else
- title @messages.first.subject
- title @group.name
- 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
#message_threads
= render 'message_threads', message_threads: @message_threads, pagination: true

View file

@ -0,0 +1,17 @@
- thread_message = @messages.first
- if thread_message.group
- title thread_message.subject + ' (' + thread_message.group.name + ')'
- else
- title thread_message.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 => thread_message.id}), class: 'btn'
|
= link_to t('.all_message_threads'), message_threads_path