Support: Ability to respond with configurable quick replies to tickets

This commit is contained in:
Maxim Leshchenko 2021-12-26 19:15:32 +02:00
parent 33836d8a2e
commit 9d89a67a91
No known key found for this signature in database
GPG key ID: BB9C44A8733FBEEE
7 changed files with 76 additions and 14 deletions

View file

@ -167,6 +167,7 @@ final class SupportPresenter extends OpenVKPresenter
$this->template->ticket = $ticket; $this->template->ticket = $ticket;
$this->template->comments = $ticketComments; $this->template->comments = $ticketComments;
$this->template->id = $id; $this->template->id = $id;
$this->template->fastAnswers = OPENVK_ROOT_CONF["openvk"]["preferences"]["support"]["fastAnswers"];
} }
function renderAnswerTicketReply(int $id): void function renderAnswerTicketReply(int $id): void

View file

@ -24,18 +24,24 @@
</div><br/> </div><br/>
<div> <div>
<form action="/al_comments.pl/create/support/reply/{$id}" method="post" style="margin:0;"> <form action="/al_comments.pl/create/support/reply/{$id}" method="post" style="margin:0;">
<textarea name="text" style="width: 100%;resize: vertical;"></textarea> <textarea name="text" id="answer_text" style="width: 100%;resize: vertical;"></textarea>
<div> <div>
<!-- padding to fix <br/> bug --> <!-- padding to fix <br/> bug -->
</div> </div>
<input type="hidden" name="hash" value="{$csrfToken}" /> <input type="hidden" name="hash" value="{$csrfToken}" />
<br> <br />
<div style="float: left;">
<input type="submit" value="{_write}" class="button"> <input type="submit" value="{_write}" class="button">
<select name="status" style="width: unset;"> <select name="status" style="width: unset;">
<option value="1">{_support_status_1}</option> <option value="1">{_support_status_1}</option>
<option value="2">{_support_status_2}</option> <option value="2">{_support_status_2}</option>
<option value="0">{_support_status_0}</option> <option value="0">{_support_status_0}</option>
</select> </select>
</div>
<div n:if="!is_null($fastAnswers)" style="float: right;">
<a class="button" href="javascript:showSupportFastAnswerDialog(fastAnswers)">{_fast_answers}</a>
</div>
<br />
</form> </form>
</div> </div>
<br/> <br/>
@ -126,4 +132,12 @@
</tr> </tr>
</tbody> </tbody>
</table> </table>
<script>
const fastAnswers = [
{foreach $fastAnswers as $answer}
{$answer},
{/foreach}
];
</script>
{/block} {/block}

View file

@ -1776,3 +1776,16 @@ body.scrolled .toTop:hover {
margin: -20px; margin: -20px;
padding: 10px; padding: 10px;
} }
.hover-box {
background-color: white;
padding: 10px;
margin: 5px;
border: 1px solid #C0CAD5;
cursor: pointer;
user-select: none;
}
.hover-box:hover {
background-color: #C0CAD5;
}

View file

@ -265,3 +265,27 @@ function autoTab(original, next, previous) {
else if(original.value.length == 0 && previous !== undefined) else if(original.value.length == 0 && previous !== undefined)
previous.focus(); previous.focus();
} }
function showSupportFastAnswerDialog(answers) {
let html = "";
for(const [index, answer] of Object.entries(answers)) {
html += `
<div class="hover-box" onclick="supportFastAnswerDialogOnClick(fastAnswers[${index}])">
${answer.replace(/\n/g, "<br />")}
</div>
`;
}
MessageBox(tr("fast_answers"), html, [tr("close")], [
Function.noop
]);
}
function supportFastAnswerDialogOnClick(answer) {
u("body").removeClass("dimmed");
u(".ovk-diag-cont").remove();
const answerInput = document.querySelector("#answer_text");
answerInput.value = answer;
answerInput.focus();
}

View file

@ -610,6 +610,8 @@
"support_rated_bad" = "You left a negative feedback about the answer."; "support_rated_bad" = "You left a negative feedback about the answer.";
"wrong_parameters" = "Invalid request parameters."; "wrong_parameters" = "Invalid request parameters.";
"fast_answers" = "Fast answers";
"comment" = "Comment"; "comment" = "Comment";
"sender" = "Sender"; "sender" = "Sender";
@ -764,6 +766,7 @@
"cancel" = "Cancel"; "cancel" = "Cancel";
"edit_action" = "Change"; "edit_action" = "Change";
"transfer" = "Transfer"; "transfer" = "Transfer";
"close" = "Close";
"warning" = "Warning"; "warning" = "Warning";
"question_confirm" = "This action can't be undone. Do you really wanna do it?"; "question_confirm" = "This action can't be undone. Do you really wanna do it?";

View file

@ -639,6 +639,8 @@
"support_rated_bad" = "Вы оставили негативный отзыв об ответе."; "support_rated_bad" = "Вы оставили негативный отзыв об ответе.";
"wrong_parameters" = "Неверные параметры запроса."; "wrong_parameters" = "Неверные параметры запроса.";
"fast_answers" = "Быстрые ответы";
"comment" = "Комментарий"; "comment" = "Комментарий";
"sender" = "Отправитель"; "sender" = "Отправитель";
@ -799,6 +801,7 @@
"cancel" = "Отмена"; "cancel" = "Отмена";
"edit_action" = "Изменить"; "edit_action" = "Изменить";
"transfer" = "Передать"; "transfer" = "Передать";
"close" = "Закрыть";
"warning" = "Внимание"; "warning" = "Внимание";
"question_confirm" = "Это действие нельзя отменить. Вы действительно уверены в том что хотите сделать?"; "question_confirm" = "Это действие нельзя отменить. Вы действительно уверены в том что хотите сделать?";

View file

@ -31,6 +31,10 @@ openvk:
support: support:
supportName: "Moderator" supportName: "Moderator"
adminAccount: 1 # Change this ok adminAccount: 1 # Change this ok
fastAnswers:
- "This is a list of quick answers to common questions for support. Post your responses here and agents can send it quickly with just 3 clicks"
- "There can be as many answers as you want, but it is best to have a maximum of 10.\n\nYou can also remove all answers from the list to disable this feature"
- "Good luck filling! If you are a regular support agent, inform the administrator that he forgot to fill the config"
messages: messages:
strict: false strict: false
wall: wall: