Skip to content

Commit 33de0f4

Browse files
committed
fix "more options" link from dashboard into inbox, closes #5459
Change-Id: I3b368d10646c08db6a0486a944f4276ae8c47328 Reviewed-on: https://gerrit.instructure.com/5361 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Jacob Fugal <jacob@instructure.com>
1 parent ce2a7fb commit 33de0f4

4 files changed

Lines changed: 21 additions & 15 deletions

File tree

app/coffeescripts/messages.coffee

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -564,11 +564,11 @@ I18n.scoped 'conversations', (I18n) ->
564564
is_selected = ($conversation) ->
565565
$selected_conversation && $selected_conversation.attr('id') == $conversation?.attr('id')
566566

567-
select_unloaded_conversation = (conversation_id) ->
567+
select_unloaded_conversation = (conversation_id, params) ->
568568
$.ajaxJSON '/conversations/' + conversation_id, 'GET', { include_conversation: 1 }, (data) ->
569569
add_conversation data.conversation, true
570570
$("#conversation_" + conversation_id).hide()
571-
select_conversation $("#conversation_" + conversation_id), data: data
571+
select_conversation $("#conversation_" + conversation_id), $.extend(params, {data: data})
572572

573573
select_conversation = ($conversation, params={}) ->
574574
toggle_message_actions(off)
@@ -593,13 +593,14 @@ I18n.scoped 'conversations', (I18n) ->
593593

594594
if $selected_conversation || $('#action_compose_message').length
595595
show_message_form()
596+
$form.find('#body').val(params.message) if params.message
596597
else
597598
$form.parent().hide()
598599

599600
if $selected_conversation
600601
$selected_conversation.scrollIntoView()
601602
else
602-
if params and params.user_id and params.user_name
603+
if params.user_id and params.user_name
603604
$('#recipients').data('token_input').add_token value: params.user_id, text: params.user_name, data: {id: params.user_id, name: params.user_name, can_add_notes: params.can_add_notes}
604605
$('#from_conversation_id').val(params.from_conversation_id)
605606
return
@@ -1470,11 +1471,12 @@ I18n.scoped 'conversations', (I18n) ->
14701471

14711472
$(window).bind 'hashchange', ->
14721473
hash = location.hash
1473-
if match = hash.match(/^#\/conversations\/(\d+)$/)
1474+
if match = hash.match(/^#\/conversations\/(\d+)(\?(.*))?/)
1475+
params = if match[3] then parse_query_string(match[3]) else {}
14741476
if ($c = $('#conversation_' + match[1])) and $c.length
1475-
select_conversation($c)
1477+
select_conversation($c, params)
14761478
else
1477-
select_unloaded_conversation(match[1])
1479+
select_unloaded_conversation(match[1], params)
14781480
else if $('#action_compose_message').length
14791481
params = {}
14801482
if match = hash.match(/^#\/conversations\?(.*)$/)

app/controllers/conversations_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def create
9999
end
100100

101101
def show
102-
return redirect_to "/conversations/#/conversations/#{@conversation.conversation_id}" unless request.xhr?
102+
return redirect_to "/conversations/#/conversations/#{@conversation.conversation_id}" + (params[:message] ? '?message=' + URI.encode(params[:message], Regexp.new("[^#{URI::PATTERN::UNRESERVED}]")) : '') unless request.xhr?
103103

104104
@conversation.mark_as_read! if @conversation.unread?
105105
submissions = []

public/javascripts/compiled/messages.js

Lines changed: 11 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/javascripts/instructure.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ jQuery(function($) {
639639
} else {
640640
params = {message: ($form.find("textarea:visible:first").val() || "")};
641641
}
642-
location.href = $(this).attr('href') + (params ? JSON.stringify(params) : "");
642+
location.href = $(this).attr('href') + "?message=" + encodeURIComponent(params.message);
643643
});
644644
$(".communication_message.new_activity_message").ifExists(function(){
645645
this.find(".message_type img").click(function() {

0 commit comments

Comments
 (0)