Skip to content

Commit

Permalink
Edit conversation subject - closes #43
Browse files Browse the repository at this point in the history
  • Loading branch information
freescout-help-desk committed Sep 21, 2020
1 parent 3461a2d commit 8827fae
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 1 deletion.
22 changes: 22 additions & 0 deletions app/Http/Controllers/ConversationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,28 @@ public function ajax(Request $request)

break;

case 'update_subject':
$conversation = Conversation::find($request->conversation_id);

if (!$conversation) {
$response['msg'] = __('Conversation not found');
}
if (!$response['msg'] && !$conversation->mailbox->userHasAccess($user->id)) {
$response['msg'] = __('Not enough permissions');
}

$subject = $request->value ?? '';
$subject = trim($subject);

if (!$response['msg'] && $subject) {
$conversation->subject = $subject;
$conversation->save();

$response['status'] = 'success';
}

break;

// case 'save_settings':
// $conversation = Conversation::find($request->conversation_id);

Expand Down
8 changes: 8 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1724,8 +1724,16 @@ button.conv-checkbox-clear {
line-height: 30px;
word-wrap: break-word;
margin-right: 8px;
width: 100%;
max-width: 100%;
}
.conv-subj-editor,
.conv-subj-editing > span {
display: none;
}
.conv-subj-editing .conv-subj-editor {
display: table;
}
.conv-numnav {
margin: 0;
position: absolute;
Expand Down
29 changes: 29 additions & 0 deletions public/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1128,6 +1128,35 @@ function initConversation()
e.preventDefault();
});

// Edit subject
jQuery(".conv-subjtext").click(function(e){
$(this).addClass('conv-subj-editing');
});

// Save subject
jQuery(".conv-subj-editor button:first").click(function(e){
var button = $(this);
button.button('loading');
var value = $('#conv-subj-value').val();
fsAjax(
{
action: 'update_subject',
conversation_id: getGlobalAttr('conversation_id'),
value: value
},
laroute.route('conversations.ajax'),
function(response) {
if (isAjaxSuccess(response)) {
$('.conv-subjtext > span:first').text(value);
} else {
showAjaxError(response);
}
button.parents('.conv-subj-editing:first').removeClass('conv-subj-editing');
button.button('reset');
}, true
);
});

starConversationInit();
maybeShowStoredNote();
maybeShowDraft();
Expand Down
8 changes: 7 additions & 1 deletion resources/views/conversations/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,13 @@
<div class="conv-subj-block">
<div class="conv-subjwrap">
<div class="conv-subjtext">
{{ $conversation->getSubject() }}
<span>{{ $conversation->getSubject() }}</span>
<div class="input-group input-group-lg conv-subj-editor">
<input type="text" id="conv-subj-value" class="form-control" value="{{ $conversation->getSubject() }}" />
<span class="input-group-btn">
<button class="btn btn-primary" type="button" data-loading-text=""><i class="glyphicon glyphicon-ok"></i></button>
</span>
</div>
</div>
@action('conversation.after_subject', $conversation, $mailbox)
<div class="conv-numnav">
Expand Down

0 comments on commit 8827fae

Please sign in to comment.