remove freeform label support; fixes #6829
only support the 'starred' label, and that through its own field in responses and updates. remove label UI from conversations, leaving just stars. test-plan: - stars still work in conversations. - labels are gone. - ability to use freeform labels through API gone. Change-Id: I61704cf604e081e1894c516462d0112c7e88302c Reviewed-on: https://gerrit.instructure.com/8205 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Jon Jensen <jon@instructure.com>
This commit is contained in:
parent
6ff8c1ad49
commit
756315bf98
|
@ -4,7 +4,6 @@ $messages = []
|
|||
$message_list = []
|
||||
$form = []
|
||||
$selected_conversation = null
|
||||
$last_label = null
|
||||
page = {}
|
||||
MessageInbox = {}
|
||||
|
||||
|
@ -1065,13 +1064,11 @@ I18n.scoped 'conversations', (I18n) ->
|
|||
$conversation.find('span.date').text $.friendlyDatetime($.parseFromISO(data.last_message_at).datetime)
|
||||
move_direction = if $conversation.data('last_message_at') > data.last_message_at then 'down' else 'up'
|
||||
$conversation.data 'last_message_at', data.last_message_at
|
||||
$conversation.data 'label', (if data.starred then null else data.label)
|
||||
$conversation.data 'starred', data.starred
|
||||
$p = $conversation.find('p')
|
||||
$p.text data.last_message
|
||||
($conversation.addClass(property) for property in data.properties) if data.properties.length
|
||||
$conversation.addClass('private') if data['private']
|
||||
$conversation.addClass('labeled').addClass(data.label) if data.label && !data.starred
|
||||
$conversation.addClass('starred') if data.starred
|
||||
$conversation.addClass('unsubscribed') unless data.subscribed
|
||||
set_conversation_state $conversation, data.workflow_state
|
||||
|
@ -1132,9 +1129,6 @@ I18n.scoped 'conversations', (I18n) ->
|
|||
unarchive : $('#action_unarchive').parent()
|
||||
delete : $('#action_delete').parent()
|
||||
deleteAll : $('#action_delete_all').parent()
|
||||
labels:
|
||||
group: $('#conversation_actions .label_group')
|
||||
icon: $('#conversation_actions .label_icon')
|
||||
|
||||
page.activeActionMenu = elements.node
|
||||
|
||||
|
@ -1160,10 +1154,6 @@ I18n.scoped 'conversations', (I18n) ->
|
|||
else
|
||||
elements.actions.star.show()
|
||||
|
||||
elements.labels.group.show()
|
||||
elements.labels.icon.removeClass 'checked'
|
||||
elements.container.find('.label_icon.' + ($conversation.data('label') || 'none')).addClass('checked')
|
||||
|
||||
if elements.conversation.hasClass('private')
|
||||
elements.actions.subscribe.hide()
|
||||
elements.actions.unsubscribe.hide()
|
||||
|
@ -1240,11 +1230,6 @@ I18n.scoped 'conversations', (I18n) ->
|
|||
if state then $("#message_actions").slideDown(100) else $("#message_actions").slideUp(100)
|
||||
$form[if state then 'addClass' else 'removeClass']('disabled')
|
||||
|
||||
set_last_label = (label) ->
|
||||
$conversation_list.removeClass('red orange yellow green blue purple').addClass(label) # so that the label hover is correct
|
||||
$.cookie('last_label', label)
|
||||
$last_label = label
|
||||
|
||||
set_hash = (hash) ->
|
||||
if hash isnt location.hash
|
||||
location.hash = hash
|
||||
|
@ -1256,7 +1241,6 @@ I18n.scoped 'conversations', (I18n) ->
|
|||
$(document).ready () ->
|
||||
$conversations = $('#conversations')
|
||||
$conversation_list = $conversations.find("ul.conversations")
|
||||
set_last_label($.cookie('last_label') ? 'red')
|
||||
$messages = $('#messages')
|
||||
$message_list = $messages.find('ul.messages')
|
||||
$form = $('#create_message_form')
|
||||
|
@ -1404,66 +1388,17 @@ I18n.scoped 'conversations', (I18n) ->
|
|||
e.preventDefault()
|
||||
e.stopImmediatePropagation()
|
||||
starred = null
|
||||
current_label = null
|
||||
inbox_action $(this),
|
||||
method: 'PUT'
|
||||
before: ($node, options) ->
|
||||
current_label = $node.data('label')
|
||||
starred = $node.data('starred')
|
||||
if !starred
|
||||
$node.addClass('starred')
|
||||
$node.removeClass('labeled ' + current_label) if current_label
|
||||
!starred
|
||||
success: ($node, data) ->
|
||||
update_conversation($node, data)
|
||||
error: ($node) ->
|
||||
$node.removeClass('starred')
|
||||
$node.addClass('labeled ' + current_label) if current_label
|
||||
|
||||
$('.action_remove_label').click (e) ->
|
||||
e.preventDefault()
|
||||
e.stopImmediatePropagation()
|
||||
current_label = null
|
||||
inbox_action $(this),
|
||||
method: 'PUT'
|
||||
before: ($node) ->
|
||||
current_label = $node.data('label')
|
||||
$node.removeClass('labeled ' + current_label) if current_label
|
||||
current_label
|
||||
success: ($node, data) ->
|
||||
update_conversation($node, data)
|
||||
remove_conversation $node if MessageInbox.scope == 'labeled'
|
||||
error: ($node) ->
|
||||
$node.addClass('labeled ' + current_label)
|
||||
|
||||
$('.action_add_label').click (e) ->
|
||||
e.preventDefault()
|
||||
e.stopImmediatePropagation()
|
||||
label = null
|
||||
current_label = null
|
||||
starred = null
|
||||
inbox_action $(this),
|
||||
method: 'PUT'
|
||||
before: ($node, options) ->
|
||||
current_label = $node.data('label')
|
||||
label = options.url.match(/%5Blabel%5D=(.*)/)[1]
|
||||
starred = $node.data('starred')
|
||||
if label is 'last'
|
||||
label = $last_label
|
||||
options.url = options.url.replace(/%5Blabel%5D=last/, '%5Blabel%5D=' + label)
|
||||
if label isnt current_label
|
||||
$node.removeClass('labeled ' + current_label) if current_label
|
||||
$node.removeClass('starred') if starred
|
||||
$node.addClass('labeled').addClass(label)
|
||||
label isnt current_label
|
||||
success: ($node, data) ->
|
||||
update_conversation($node, data)
|
||||
set_last_label(label)
|
||||
remove_conversation $node if MessageInbox.label_scope and MessageInbox.label_scope isnt label
|
||||
error: ($node) ->
|
||||
$node.removeClass('labeled ' + label)
|
||||
$node.addClass('starred') if starred
|
||||
$node.addClass('labeled ' + current_label) if current_label
|
||||
|
||||
$('#action_add_recipients').click (e) ->
|
||||
e.preventDefault()
|
||||
|
|
|
@ -33,16 +33,12 @@ class ConversationsController < ApplicationController
|
|||
# @API
|
||||
# Returns the list of conversations for the current user, most recent ones first.
|
||||
#
|
||||
# @argument scope [optional, "unread"|"starred"|"labeled"|"archived"]
|
||||
# @argument scope [optional, "unread"|"starred"|"archived"]
|
||||
# When set, only return conversations of the specified type. For example,
|
||||
# set to "unread" to return only conversations that haven't been read.
|
||||
# The default behavior is to return all non-archived conversations (i.e.
|
||||
# read and unread).
|
||||
#
|
||||
# @argument label [optional, "red"|"orange"|"yellow"|"green"|"blue"|"purple"]
|
||||
# When scope is set to "labeled", you can use this argument to limit the
|
||||
# results to a particular label.
|
||||
#
|
||||
# @argument interleave_submissions Boolean, default false. If true, the
|
||||
# message_count will also include these submission-based messages in the
|
||||
# total. See the show action for more information.
|
||||
|
@ -59,7 +55,6 @@ class ConversationsController < ApplicationController
|
|||
# @response_field private Indicates whether this is a private conversation
|
||||
# (i.e. audience of one)
|
||||
# @response_field starred Whether the conversation is starred
|
||||
# @response_field label Current label for this conversation, if set
|
||||
# @response_field properties Additional conversation flags (last_author,
|
||||
# attachments, media_objects). Each listed property means the flag is
|
||||
# set to true (i.e. the current user is the most recent author, there
|
||||
|
@ -87,7 +82,6 @@ class ConversationsController < ApplicationController
|
|||
# "subscribed": true,
|
||||
# "private": true,
|
||||
# "starred": false,
|
||||
# "label": null,
|
||||
# "properties": ["attachments"],
|
||||
# "audience": [2],
|
||||
# "audience_contexts": {"courses": {"1": ["StudentEnrollment"]}, "groups": {}},
|
||||
|
@ -106,20 +100,6 @@ class ConversationsController < ApplicationController
|
|||
@view_name = I18n.t('index.inbox_views.starred', 'Starred')
|
||||
@no_messages = I18n.t('no_starred_messages', 'You have no starred messages')
|
||||
@current_user.conversations.starred
|
||||
when 'labeled'
|
||||
@label, @view_name = ConversationParticipant.labels.detect{ |l| l.first == params[:label] }
|
||||
@view_name ||= I18n.t('index.inbox_views.labeled', 'Labeled')
|
||||
@no_messages = case @label
|
||||
when 'starred'; I18n.t('no_starred_messages', 'You have no starred messages')
|
||||
when 'red'; I18n.t('no_red_messages', 'You have no red messages')
|
||||
when 'orange'; I18n.t('no_orange_messages', 'You have no orange messages')
|
||||
when 'yellow'; I18n.t('no_yellow_messages', 'You have no yellow messages')
|
||||
when 'green'; I18n.t('no_green_messages', 'You have no green messages')
|
||||
when 'blue'; I18n.t('no_blue_messages', 'You have no blue messages')
|
||||
when 'purple'; I18n.t('no_purple_messages', 'You have no purple messages')
|
||||
else I18n.t('no_labeled_messages', 'You have no labeled messages')
|
||||
end
|
||||
@current_user.conversations.labeled(@label)
|
||||
when 'archived'
|
||||
@view_name = I18n.t('index.inbox_views.archived', 'Archived')
|
||||
@no_messages = I18n.t('no_archived_messages', 'You have no archived messages')
|
||||
|
@ -225,7 +205,6 @@ class ConversationsController < ApplicationController
|
|||
# "subscribed": true,
|
||||
# "private": true,
|
||||
# "starred": false,
|
||||
# "label": null,
|
||||
# "properties": ["attachments"],
|
||||
# "audience": [2],
|
||||
# "audience_contexts": {"courses": {"1": ["StudentEnrollment"]}, "groups": {}},
|
||||
|
@ -297,8 +276,7 @@ class ConversationsController < ApplicationController
|
|||
#
|
||||
# @argument conversation[workflow_state] ["read"|"unread"|"archived"] Change the state of this conversation
|
||||
# @argument conversation[subscribed] [true|false] Toggle the current user's subscription to the conversation (only valid for group conversations). If unsubscribed, the user will still have access to the latest messages, but the conversation won't be automatically flagged as unread, nor will it jump to the top of the inbox.
|
||||
# @argument conversation[starred] [true|false] Toggle the starred state of the current user's view of the conversation. Takes precedence over labels; if starred is true, label is forced to null.
|
||||
# @argument conversation[label] ["red"|"orange"|"yellow"|"green"|"blue"|"purple"|null] Set/unset a flag on this conversation
|
||||
# @argument conversation[starred] [true|false] Toggle the starred state of the current user's view of the conversation.
|
||||
#
|
||||
# @example_response
|
||||
# {
|
||||
|
@ -310,22 +288,9 @@ class ConversationsController < ApplicationController
|
|||
# "subscribed": true,
|
||||
# "private": true,
|
||||
# "starred": false,
|
||||
# "label": null,
|
||||
# "properties": ["attachments"]
|
||||
# }
|
||||
def update
|
||||
# force label to 'starred' if starred is true. set label to nil (to unstar)
|
||||
# if starred is false, unless label is already set (if so, use the set
|
||||
# value). do nothing if starred is absent.
|
||||
starred = params[:conversation].delete(:starred)
|
||||
unless starred.nil?
|
||||
if ['true', true, '1', 1].include?(starred)
|
||||
params[:conversation][:label] = 'starred'
|
||||
else
|
||||
params[:conversation][:label] ||= nil
|
||||
end
|
||||
end
|
||||
|
||||
if @conversation.update_attributes(params[:conversation])
|
||||
render :json => @conversation
|
||||
else
|
||||
|
@ -356,7 +321,6 @@ class ConversationsController < ApplicationController
|
|||
# "subscribed": true,
|
||||
# "private": true,
|
||||
# "starred": false,
|
||||
# "label": null,
|
||||
# "properties": []
|
||||
# }
|
||||
def destroy
|
||||
|
@ -383,7 +347,6 @@ class ConversationsController < ApplicationController
|
|||
# "subscribed": true,
|
||||
# "private": false,
|
||||
# "starred": null,
|
||||
# "label": null,
|
||||
# "properties": [],
|
||||
# "audience": [2, 3, 4],
|
||||
# "audience_contexts": {"courses": {"1": []}, "groups": {}},
|
||||
|
@ -430,7 +393,6 @@ class ConversationsController < ApplicationController
|
|||
# "subscribed": true,
|
||||
# "private": false,
|
||||
# "starred": null,
|
||||
# "label": null,
|
||||
# "properties": [],
|
||||
# "audience": [2, 3],
|
||||
# "audience_contexts": {"courses": {"1": []}, "groups": {}},
|
||||
|
@ -477,7 +439,6 @@ class ConversationsController < ApplicationController
|
|||
# "subscribed": true,
|
||||
# "private": true,
|
||||
# "starred": null,
|
||||
# "label": null,
|
||||
# "properties": ["attachments"]
|
||||
# }
|
||||
def remove_messages
|
||||
|
|
|
@ -33,31 +33,13 @@ class ConversationParticipant < ActiveRecord::Base
|
|||
named_scope :unread, :conditions => "workflow_state = 'unread'"
|
||||
named_scope :archived, :conditions => "workflow_state = 'archived'"
|
||||
named_scope :starred, :conditions => "label = 'starred'"
|
||||
named_scope :labeled, lambda { |label|
|
||||
{:conditions => label ?
|
||||
["label = ?", label] :
|
||||
["label IS NOT NULL"]
|
||||
}
|
||||
}
|
||||
delegate :private?, :to => :conversation
|
||||
|
||||
before_update :update_unread_count
|
||||
|
||||
attr_accessible :subscribed, :label, :workflow_state
|
||||
attr_accessible :subscribed, :starred, :workflow_state
|
||||
|
||||
def self.labels
|
||||
(@labels ||= {})[I18n.locale] ||= [
|
||||
['starred', I18n.t('labels.starred', "Starred")],
|
||||
['red', I18n.t('labels.red', "Red")],
|
||||
['orange', I18n.t('labels.orange', "Orange")],
|
||||
['yellow', I18n.t('labels.yellow', "Yellow")],
|
||||
['green', I18n.t('labels.green', "Green")],
|
||||
['blue', I18n.t('labels.blue', "Blue")],
|
||||
['purple', I18n.t('labels.purple', "Purple")],
|
||||
]
|
||||
end
|
||||
|
||||
validates_inclusion_of :label, :in => labels.map(&:first), :allow_nil => true
|
||||
validates_inclusion_of :label, :in => ['starred'], :allow_nil => true
|
||||
|
||||
def as_json(options = {})
|
||||
latest = options[:last_message] || messages.human.first
|
||||
|
@ -70,8 +52,7 @@ class ConversationParticipant < ActiveRecord::Base
|
|||
:message_count => message_count,
|
||||
:subscribed => subscribed?,
|
||||
:private => private?,
|
||||
:starred => label == 'starred',
|
||||
:label => label != 'starred' ? label : nil,
|
||||
:starred => starred,
|
||||
:properties => properties(latest)
|
||||
}.with_indifferent_access
|
||||
end
|
||||
|
@ -180,8 +161,16 @@ class ConversationParticipant < ActiveRecord::Base
|
|||
subscribed?
|
||||
end
|
||||
|
||||
def label=(label)
|
||||
write_attribute(:label, label.present? ? label : nil)
|
||||
def starred
|
||||
read_attribute(:label) == 'starred'
|
||||
end
|
||||
|
||||
def starred=(val)
|
||||
# if starred were an actual boolean column, this is the method that would
|
||||
# be used to convert strings to appropriate boolean values (e.g. 'true' =>
|
||||
# true and 'false' => false)
|
||||
val = ActiveRecord::ConnectionAdapters::Column.value_to_boolean(val)
|
||||
write_attribute(:label, val ? 'starred' : nil)
|
||||
end
|
||||
|
||||
def one_on_one?
|
||||
|
@ -226,7 +215,7 @@ class ConversationParticipant < ActiveRecord::Base
|
|||
self.last_message_at = nil
|
||||
self.has_attachments = false
|
||||
self.has_media_objects = false
|
||||
self.label = nil
|
||||
self.starred = false
|
||||
end
|
||||
# note that last_authored_at doesn't know/care about messages you may
|
||||
# have deleted... this is because it is only used by other participants
|
||||
|
|
|
@ -122,27 +122,6 @@ body
|
|||
background-color: #05a5e9
|
||||
color: #fff
|
||||
text-shadow: 0px 1px 1px #0276aa
|
||||
li.label_group
|
||||
overflow: hidden
|
||||
padding: 2px 22px 2px 22px
|
||||
min-width: 110px
|
||||
a.label_icon
|
||||
overflow: hidden
|
||||
text-indent: -9999em
|
||||
float: left
|
||||
padding: 0
|
||||
margin: 2px
|
||||
top: 4px
|
||||
left: 24px
|
||||
height: 11px
|
||||
width: 11px
|
||||
z-index: 4
|
||||
background-color: #fff
|
||||
background-repeat: no-repeat
|
||||
border: 1px solid #aaa
|
||||
a:hover, a.checked
|
||||
border: 3px solid #05a5e9
|
||||
margin: 0
|
||||
|
||||
#conversation_actions
|
||||
font-size: 0.9em
|
||||
|
@ -161,8 +140,6 @@ body
|
|||
position: relative
|
||||
top: -1px
|
||||
left: 0
|
||||
li.label_group
|
||||
min-width: 120px
|
||||
|
||||
ul.messages, ul.conversations
|
||||
overflow: auto
|
||||
|
@ -524,14 +501,10 @@ button.button:hover, .ui-dialog .ui-dialog-buttonpane button.ui-button.ui-state-
|
|||
color: #636363
|
||||
.audience
|
||||
color: #222
|
||||
.action_remove_label, .action_add_label
|
||||
display: none
|
||||
// .action_remove_label, .action_add_label,
|
||||
.action_mark_as_read, .action_mark_as_unread, .action_star, .action_unstar
|
||||
text-indent: -9999em
|
||||
overflow: hidden
|
||||
position: absolute
|
||||
// .action_remove_label, .action_add_label,
|
||||
.action_star, .action_unstar
|
||||
top: -1px
|
||||
left: 0
|
||||
|
@ -544,7 +517,6 @@ button.button:hover, .ui-dialog .ui-dialog-buttonpane button.ui-button.ui-state-
|
|||
background-image: url(/images/messages/star.png)
|
||||
.action_unstar
|
||||
background-image: url(/images/messages/star-lit.png)
|
||||
// .action_remove_label,
|
||||
.action_unstar
|
||||
display: none
|
||||
.action_mark_as_read, .action_mark_as_unread
|
||||
|
@ -554,7 +526,6 @@ button.button:hover, .ui-dialog .ui-dialog-buttonpane button.ui-button.ui-state-
|
|||
height: 24px
|
||||
margin-top: -12px
|
||||
background: transparent url(/images/messages/new-replied-icon_sprite.png) 1px 0 no-repeat
|
||||
// .action_remove_label,
|
||||
.action_mark_as_read, .action_unstar
|
||||
display: none
|
||||
.action_mark_as_unread
|
||||
|
@ -586,12 +557,6 @@ button.button:hover, .ui-dialog .ui-dialog-buttonpane button.ui-button.ui-state-
|
|||
right: 17px
|
||||
.date
|
||||
visibility: hidden
|
||||
// > li.labeled
|
||||
.action_add_label
|
||||
display: none
|
||||
.action_remove_label
|
||||
background-position: 1px -24px
|
||||
display: block
|
||||
> li.starred
|
||||
.action_star
|
||||
display: none
|
||||
|
@ -600,35 +565,6 @@ button.button:hover, .ui-dialog .ui-dialog-buttonpane button.ui-button.ui-state-
|
|||
> li.attachments .attachments, > li.media_objects .media_objects
|
||||
display: inline
|
||||
|
||||
.label_icon
|
||||
background-repeat: no-repeat
|
||||
background-image: url(/images/messages/flag.png)
|
||||
background-position: 0 24px
|
||||
ul.red li .label_icon:hover
|
||||
background-position: 1px 1px
|
||||
li.red .label_icon, .red.label_icon
|
||||
background-position: 1px -23px !important
|
||||
ul.orange li .label_icon:hover
|
||||
background-position: 1px -47px
|
||||
li.orange .label_icon, .orange.label_icon
|
||||
background-position: 1px -71px !important
|
||||
ul.yellow li .label_icon:hover
|
||||
background-position: 1px -95px
|
||||
li.yellow .label_icon, .yellow.label_icon
|
||||
background-position: 1px -119px !important
|
||||
ul.green li .label_icon:hover
|
||||
background-position: 1px -143px
|
||||
li.green .label_icon, .green.label_icon
|
||||
background-position: 1px -167px !important
|
||||
ul.blue li .label_icon:hover
|
||||
background-position: 1px -191px
|
||||
li.blue .label_icon, .blue.label_icon
|
||||
background-position: 1px -215px !important
|
||||
ul.purple li .label_icon:hover
|
||||
background-position: 1px -239px
|
||||
li.purple .label_icon, .purple.label_icon
|
||||
background-position: 1px -263px !important
|
||||
|
||||
#message_blank
|
||||
display: none
|
||||
|
||||
|
|
|
@ -23,12 +23,6 @@
|
|||
<li class="<%= 'checked' if @scope == :inbox %>"><%= link_to t('inbox_views.inbox', "Inbox"), conversations_url %></li>
|
||||
<li class="<%= 'checked' if @scope == :unread %>"><%= link_to t('inbox_views.unread_messages', "Unread"), conversations_unread_url %></li>
|
||||
<li class="<%= 'checked' if @scope == :starred %>"><%= link_to t('inbox_views.starred_messages', "Starred"), conversations_starred_url %></li>
|
||||
<li class="label_group">
|
||||
<%= before_label t('labels.conversation_label', 'Label') %><br />
|
||||
<% ConversationParticipant.labels.each do |label, text| %>
|
||||
<%= link_to text, conversations_labeled_url(:label => label), :class => 'label_icon ' + label + (label == @label ? ' checked' : '') %>
|
||||
<% end %>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li class="<%= 'checked' if @scope == :archived %>"><%= link_to t('inbox_views.archived_messages', "Archived"), conversations_archived_url %></li>
|
||||
|
@ -108,8 +102,6 @@
|
|||
</div>
|
||||
<ul style="display:none">
|
||||
<li id="conversation_blank">
|
||||
<%= link_to t('inbox_actions.add_label', "Add Label"), conversation_url('{{ id }}', :conversation => {:label => 'last'}), :title => t('inbox_actions.add_label', "Add Label"), :class => 'action_add_label label_icon' %>
|
||||
<%= link_to t('inbox_actions.remove_label', "Remove Label"), conversation_url('{{ id }}', :conversation => {:label => ''}), :title => t('inbox_actions.remove_label', "Remove Label"), :class => 'action_remove_label label_icon' %>
|
||||
<%= link_to t('inbox_actions.mark_as_unread', "Mark as Unread"), conversation_url('{{ id }}', :conversation => {:workflow_state => "unread"}), :title => t('inbox_actions.mark_as_unread', "Mark as Unread"), :class => :action_mark_as_unread %>
|
||||
<%= link_to t('inbox_actions.mark_as_read', "Mark as Read"), conversation_url('{{ id }}', :conversation => {:workflow_state => "read"}), :title => t('inbox_actions.mark_as_read', "Mark as Read"), :class => :action_mark_as_read %>
|
||||
<%= link_to t('inbox_actions.star', "Star"), conversation_url('{{ id }}', :conversation => {:starred => true}), :title => t('inbox_actions.star', "Star"), :class => :action_star %>
|
||||
|
@ -182,13 +174,6 @@
|
|||
<li><%= link_to t('inbox_actions.mark_as_read', "Mark as Read"), conversation_url('{{ id }}', :conversation => {:workflow_state => "read"}), :id => 'action_mark_as_read', :class => :action_mark_as_read %></li>
|
||||
<li><%= link_to t('inbox_actions.unstar', "Unstar"), conversation_url('{{ id }}', :conversation => {:starred => false}), :id => 'action_unstar', :class => :action_unstar %></li>
|
||||
<li><%= link_to t('inbox_actions.star', "Star"), conversation_url('{{ id }}', :conversation => {:starred => true}), :id => 'action_star', :class => :action_star %></li>
|
||||
<li class="label_group">
|
||||
<%= before_label t('labels.conversation_label', 'Label') %><br />
|
||||
<% ConversationParticipant.labels.each do |label, text| %>
|
||||
<%= link_to text, conversation_url('{{ id }}', :conversation => {:label => label}), :class => 'action_add_label label_icon ' + label, :title => text %>
|
||||
<% end %>
|
||||
<%= link_to t('inbox_actions.no_label', "None"), conversation_url('{{ id }}', :conversation => {:label => ''}), :class => 'action_remove_label label_icon none', :title => t('inbox_actions.no_label', "None") %>
|
||||
</li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><%= link_to t('inbox_actions.unsubscribe', "Unsubscribe"), conversation_url('{{ id }}', :conversation => {:subscribed => 0}), :id => :action_unsubscribe %></li>
|
||||
|
@ -227,7 +212,6 @@
|
|||
MessageInbox.conversation_page_size = <%= @page_max %>;
|
||||
MessageInbox.initial_conversations_count = <%= @conversations_count %>;
|
||||
MessageInbox.scope = <%= raw @scope.to_json %>;
|
||||
MessageInbox.label_scope = <%= raw @label.to_json %>;
|
||||
<% # TODO: get note-enabled-ness per account, and cross reference with the recipient's associated account ids. this is already enforced in the model %>
|
||||
MessageInbox.notes_enabled = <%= raw @current_user.associated_accounts.any?{|a| a.enable_user_notes } %>;
|
||||
MessageInbox.can_add_notes_for_account = MessageInbox.notes_enabled && <%= raw @current_user.associated_accounts.any?{|a| a.grants_right?(@current_user, nil, :manage_students) } %>;
|
||||
|
|
|
@ -10,7 +10,6 @@ ActionController::Routing::Routes.draw do |map|
|
|||
map.discussion_replies 'conversations/discussion_replies', :controller => 'context', :action => 'discussion_replies'
|
||||
map.conversations_unread 'conversations/unread', :controller => 'conversations', :action => 'index', :scope => 'unread'
|
||||
map.conversations_starred 'conversations/starred', :controller => 'conversations', :action => 'index', :scope => 'starred'
|
||||
map.conversations_labeled 'conversations/labeled', :controller => 'conversations', :action => 'index', :scope => 'labeled'
|
||||
map.conversations_archived 'conversations/archived', :controller => 'conversations', :action => 'index', :scope => 'archived'
|
||||
map.conversations_find_recipients 'conversations/find_recipients', :controller => 'conversations', :action => 'find_recipients'
|
||||
map.conversations_mark_all_as_read 'conversations/mark_all_as_read', :controller => 'conversations', :action => 'mark_all_as_read', :conditions => {:method => :post}
|
||||
|
@ -746,7 +745,7 @@ ActionController::Routing::Routes.draw do |map|
|
|||
conversations.get 'conversations/find_recipients', :action => :find_recipients
|
||||
conversations.post 'conversations/mark_all_as_read', :action => :mark_all_as_read
|
||||
conversations.get 'conversations/:id', :action => :show
|
||||
conversations.put 'conversations/:id', :action => :update # stars, labels, subscribed-ness, workflow_state
|
||||
conversations.put 'conversations/:id', :action => :update # stars, subscribed-ness, workflow_state
|
||||
conversations.delete 'conversations/:id', :action => :destroy
|
||||
conversations.post 'conversations/:id/add_message', :action => :add_message
|
||||
conversations.post 'conversations/:id/add_recipients', :action => :add_recipients
|
||||
|
|
|
@ -45,7 +45,7 @@ describe ConversationsController, :type => :integration do
|
|||
|
||||
context "conversations" do
|
||||
it "should return the conversation list" do
|
||||
@c1 = conversation(@bob, :workflow_state => 'read', :label => "blue")
|
||||
@c1 = conversation(@bob, :workflow_state => 'read')
|
||||
@c2 = conversation(@bob, @billy, :workflow_state => 'unread', :subscribed => false)
|
||||
@c3 = conversation(@jane, :workflow_state => 'archived') # won't show up, since it's archived
|
||||
|
||||
|
@ -61,7 +61,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 1,
|
||||
"subscribed" => false,
|
||||
"private" => false,
|
||||
"label" => nil,
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"],
|
||||
"audience" => [@billy.id, @bob.id],
|
||||
|
@ -83,7 +82,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 1,
|
||||
"subscribed" => true,
|
||||
"private" => true,
|
||||
"label" => "blue",
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"],
|
||||
"audience" => [@bob.id],
|
||||
|
@ -116,12 +114,12 @@ describe ConversationsController, :type => :integration do
|
|||
end
|
||||
|
||||
it "should filter conversations by scope" do
|
||||
@c1 = conversation(@bob, :workflow_state => 'read', :label => "blue")
|
||||
@c2 = conversation(@bob, @billy, :workflow_state => 'unread', :subscribed => false, :label => "green")
|
||||
@c1 = conversation(@bob, :workflow_state => 'read')
|
||||
@c2 = conversation(@bob, @billy, :workflow_state => 'unread', :subscribed => false)
|
||||
@c3 = conversation(@jane, :workflow_state => 'read')
|
||||
|
||||
json = api_call(:get, "/api/v1/conversations.json?scope=labeled&label=green",
|
||||
{ :controller => 'conversations', :action => 'index', :format => 'json', :scope => 'labeled', :label => 'green' })
|
||||
json = api_call(:get, "/api/v1/conversations.json?scope=unread",
|
||||
{ :controller => 'conversations', :action => 'index', :format => 'json', :scope => 'unread' })
|
||||
json.each { |c| c.delete("avatar_url") }
|
||||
json.should eql [
|
||||
{
|
||||
|
@ -132,7 +130,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 1,
|
||||
"subscribed" => false,
|
||||
"private" => false,
|
||||
"label" => "green",
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"],
|
||||
"audience" => [@billy.id, @bob.id],
|
||||
|
@ -150,9 +147,9 @@ describe ConversationsController, :type => :integration do
|
|||
end
|
||||
|
||||
it "should include starred conversations in starred scope regardless of if read or archived" do
|
||||
@c1 = conversation(@bob, :workflow_state => 'unread', :label => "starred")
|
||||
@c2 = conversation(@billy, :workflow_state => 'read', :label => "starred")
|
||||
@c3 = conversation(@jane, :workflow_state => 'archived', :label => "starred")
|
||||
@c1 = conversation(@bob, :workflow_state => 'unread', :starred => true)
|
||||
@c2 = conversation(@billy, :workflow_state => 'read', :starred => true)
|
||||
@c3 = conversation(@jane, :workflow_state => 'archived', :starred => true)
|
||||
|
||||
json = api_call(:get, "/api/v1/conversations.json?scope=starred",
|
||||
{ :controller => 'conversations', :action => 'index', :format => 'json', :scope => 'starred' })
|
||||
|
@ -162,7 +159,7 @@ describe ConversationsController, :type => :integration do
|
|||
|
||||
it "should not include unstarred conversations in starred scope regardless of if read or archived" do
|
||||
@c1 = conversation(@bob, :workflow_state => 'unread')
|
||||
@c2 = conversation(@billy, :workflow_state => 'read', :label => "blue")
|
||||
@c2 = conversation(@billy, :workflow_state => 'read')
|
||||
@c3 = conversation(@jane, :workflow_state => 'archived')
|
||||
|
||||
json = api_call(:get, "/api/v1/conversations.json?scope=starred",
|
||||
|
@ -205,7 +202,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 1,
|
||||
"subscribed" => true,
|
||||
"private" => true,
|
||||
"label" => nil,
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"],
|
||||
"audience" => [@bob.id],
|
||||
|
@ -244,7 +240,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 1,
|
||||
"subscribed" => true,
|
||||
"private" => false,
|
||||
"label" => nil,
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"],
|
||||
"audience" => [@billy.id, @bob.id],
|
||||
|
@ -287,7 +282,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 2, # two messages total now, though we'll only get the latest one in the response
|
||||
"subscribed" => true,
|
||||
"private" => true,
|
||||
"label" => nil,
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"],
|
||||
"audience" => [@bob.id],
|
||||
|
@ -346,7 +340,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 1,
|
||||
"subscribed" => true,
|
||||
"private" => true,
|
||||
"label" => nil,
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"],
|
||||
"audience" => [@billy.id],
|
||||
|
@ -624,7 +617,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 2,
|
||||
"subscribed" => true,
|
||||
"private" => true,
|
||||
"label" => nil,
|
||||
"starred" => false,
|
||||
"properties" => ["last_author", "attachments", "media_objects"],
|
||||
"audience" => [@bob.id],
|
||||
|
@ -668,23 +660,15 @@ describe ConversationsController, :type => :integration do
|
|||
|
||||
it "should properly flag if starred in the response" do
|
||||
conversation1 = conversation(@bob)
|
||||
conversation2 = conversation(@billy, :label => "starred")
|
||||
conversation3 = conversation(@jane, :label => "blue")
|
||||
conversation2 = conversation(@billy, :starred => true)
|
||||
|
||||
json = api_call(:get, "/api/v1/conversations/#{conversation1.conversation_id}",
|
||||
{ :controller => 'conversations', :action => 'show', :id => conversation1.conversation_id.to_s, :format => 'json' })
|
||||
json["label"].should be_nil
|
||||
json["starred"].should be_false
|
||||
|
||||
json = api_call(:get, "/api/v1/conversations/#{conversation2.conversation_id}",
|
||||
{ :controller => 'conversations', :action => 'show', :id => conversation2.conversation_id.to_s, :format => 'json' })
|
||||
json["label"].should be_nil
|
||||
json["starred"].should be_true
|
||||
|
||||
json = api_call(:get, "/api/v1/conversations/#{conversation3.conversation_id}",
|
||||
{ :controller => 'conversations', :action => 'show', :id => conversation3.conversation_id.to_s, :format => 'json' })
|
||||
json["label"].should == "blue"
|
||||
json["starred"].should be_false
|
||||
end
|
||||
|
||||
context "submission comments" do
|
||||
|
@ -766,7 +750,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 2, # two messages total now, though we'll only get the latest one in the response
|
||||
"subscribed" => true,
|
||||
"private" => true,
|
||||
"label" => nil,
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"],
|
||||
"audience" => [@bob.id],
|
||||
|
@ -803,7 +786,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 1,
|
||||
"subscribed" => true,
|
||||
"private" => false,
|
||||
"label" => nil,
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"],
|
||||
"audience" => [@billy.id, @bob.id, @jane.id, @joe.id, @tommy.id],
|
||||
|
@ -830,7 +812,7 @@ describe ConversationsController, :type => :integration do
|
|||
|
||||
json = api_call(:put, "/api/v1/conversations/#{conversation.conversation_id}",
|
||||
{ :controller => 'conversations', :action => 'update', :id => conversation.conversation_id.to_s, :format => 'json' },
|
||||
{ :conversation => {:subscribed => false, :workflow_state => 'archived', :label => 'red'} })
|
||||
{ :conversation => {:subscribed => false, :workflow_state => 'archived'} })
|
||||
conversation.reload
|
||||
|
||||
json.should eql({
|
||||
|
@ -841,7 +823,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 1,
|
||||
"subscribed" => false,
|
||||
"private" => false,
|
||||
"label" => 'red',
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"]
|
||||
})
|
||||
|
@ -853,50 +834,27 @@ describe ConversationsController, :type => :integration do
|
|||
json = api_call(:put, "/api/v1/conversations/#{conversation.conversation_id}",
|
||||
{ :controller => 'conversations', :action => 'update', :id => conversation.conversation_id.to_s, :format => 'json' },
|
||||
{ :conversation => {:starred => true} })
|
||||
json["label"].should be_nil
|
||||
json["starred"].should be_true
|
||||
end
|
||||
|
||||
it "should be able to unstar the conversation via update" do
|
||||
conversation = conversation(@bob, @billy, :label => "starred")
|
||||
conversation = conversation(@bob, @billy, :starred => true)
|
||||
|
||||
json = api_call(:put, "/api/v1/conversations/#{conversation.conversation_id}",
|
||||
{ :controller => 'conversations', :action => 'update', :id => conversation.conversation_id.to_s, :format => 'json' },
|
||||
{ :conversation => {:starred => false} })
|
||||
json["label"].should be_nil
|
||||
json["starred"].should be_false
|
||||
end
|
||||
|
||||
it "should prefer stars over labels if both present in update" do
|
||||
conversation = conversation(@bob, @billy)
|
||||
it "should leave starryness alone when left out of update" do
|
||||
conversation = conversation(@bob, @billy, :starred => true)
|
||||
|
||||
json = api_call(:put, "/api/v1/conversations/#{conversation.conversation_id}",
|
||||
{ :controller => 'conversations', :action => 'update', :id => conversation.conversation_id.to_s, :format => 'json' },
|
||||
{ :conversation => {:starred => true, :label => "red"} })
|
||||
json["label"].should be_nil
|
||||
{ :conversation => {:workflow_state => 'read'} })
|
||||
json["starred"].should be_true
|
||||
end
|
||||
|
||||
it "should use any provided label when unstarring via update" do
|
||||
conversation = conversation(@bob, @billy, :label => "starred")
|
||||
|
||||
json = api_call(:put, "/api/v1/conversations/#{conversation.conversation_id}",
|
||||
{ :controller => 'conversations', :action => 'update', :id => conversation.conversation_id.to_s, :format => 'json' },
|
||||
{ :conversation => {:starred => false, :label => "red"} })
|
||||
json["label"].should == "red"
|
||||
json["starred"].should be_false
|
||||
end
|
||||
|
||||
it "should respect provided label when no starryness specified for update" do
|
||||
conversation = conversation(@bob, @billy, :label => "starred")
|
||||
|
||||
json = api_call(:put, "/api/v1/conversations/#{conversation.conversation_id}",
|
||||
{ :controller => 'conversations', :action => 'update', :id => conversation.conversation_id.to_s, :format => 'json' },
|
||||
{ :conversation => {:label => "red"} })
|
||||
json["label"].should == "red"
|
||||
json["starred"].should be_false
|
||||
end
|
||||
|
||||
it "should delete messages from the conversation" do
|
||||
conversation = conversation(@bob)
|
||||
message = conversation.add_message("another one")
|
||||
|
@ -913,7 +871,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 1,
|
||||
"subscribed" => true,
|
||||
"private" => true,
|
||||
"label" => nil,
|
||||
"starred" => false,
|
||||
"properties" => ["last_author"]
|
||||
})
|
||||
|
@ -932,7 +889,6 @@ describe ConversationsController, :type => :integration do
|
|||
"message_count" => 0,
|
||||
"subscribed" => true,
|
||||
"private" => true,
|
||||
"label" => nil,
|
||||
"starred" => false,
|
||||
"properties" => []
|
||||
})
|
||||
|
|
|
@ -157,12 +157,12 @@ describe ConversationsController do
|
|||
course_with_student_logged_in(:active_all => true)
|
||||
conversation(2).update_attribute(:workflow_state, "unread")
|
||||
|
||||
post 'update', :id => @conversation.conversation_id, :conversation => {:subscribed => "0", :workflow_state => "archived", :label => "red"}
|
||||
post 'update', :id => @conversation.conversation_id, :conversation => {:subscribed => "0", :workflow_state => "archived", :starred => "1"}
|
||||
response.should be_success
|
||||
@conversation.reload
|
||||
@conversation.subscribed?.should be_false
|
||||
@conversation.should be_archived
|
||||
@conversation.label.should eql 'red'
|
||||
@conversation.starred.should be_true
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -60,4 +60,36 @@ describe ConversationParticipant do
|
|||
conversation.update_attribute(:workflow_state, 'unread')
|
||||
sender.reload.updated_at.should_not eql updated_at
|
||||
end
|
||||
|
||||
it "should support starred/starred=" do
|
||||
sender = user
|
||||
recipient = user
|
||||
conversation = sender.initiate_conversation([recipient.id])
|
||||
|
||||
conversation.starred = true
|
||||
conversation.save
|
||||
conversation.reload
|
||||
conversation.starred.should be_true
|
||||
|
||||
conversation.starred = false
|
||||
conversation.save
|
||||
conversation.reload
|
||||
conversation.starred.should be_false
|
||||
end
|
||||
|
||||
it "should support :starred in update_attributes" do
|
||||
sender = user
|
||||
recipient = user
|
||||
conversation = sender.initiate_conversation([recipient.id])
|
||||
|
||||
conversation.update_attributes(:starred => true)
|
||||
conversation.save
|
||||
conversation.reload
|
||||
conversation.starred.should be_true
|
||||
|
||||
conversation.update_attributes(:starred => false)
|
||||
conversation.save
|
||||
conversation.reload
|
||||
conversation.starred.should be_false
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue