mirror of
https://github.com/openvk/openvk
synced 2024-12-23 00:51:03 +03:00
Support: Allow users to rate support answers (#342)
* New feature: users can rate support answers Now users can rate support answers. They will see links "This is good answer" and "This is bad answer", like it was in original VK.
This commit is contained in:
parent
6d14f03573
commit
a082d84d54
9 changed files with 129 additions and 5 deletions
|
@ -108,5 +108,26 @@ class TicketComment extends RowModel
|
||||||
return false; # Кооостыыыль!!!
|
return false; # Кооостыыыль!!!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMark(): ?int
|
||||||
|
{
|
||||||
|
return $this->getRecord()->mark;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isLikedByUser(): ?bool
|
||||||
|
{
|
||||||
|
$mark = $this->getMark();
|
||||||
|
switch ($mark) {
|
||||||
|
case 0:
|
||||||
|
return false;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
return true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
use Traits\TRichText;
|
use Traits\TRichText;
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,6 +48,15 @@ class TicketComments
|
||||||
// {
|
// {
|
||||||
// return $this->toTicket($this->tickets->get($id));
|
// return $this->toTicket($this->tickets->get($id));
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
function get(int $id): ?TicketComment
|
||||||
|
{
|
||||||
|
$comment = $this->comments->get($id);;
|
||||||
|
if (!is_null($comment))
|
||||||
|
return new TicketComment($comment);
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
use \Nette\SmartObject;
|
use \Nette\SmartObject;
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,4 +225,23 @@ final class SupportPresenter extends OpenVKPresenter
|
||||||
$this->template->heading = $heading;
|
$this->template->heading = $heading;
|
||||||
$this->template->content = $parser->parse($content);
|
$this->template->content = $parser->parse($content);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
function renderRateAnswer(int $id, int $mark): void
|
||||||
|
{
|
||||||
|
$this->willExecuteWriteAction();
|
||||||
|
$this->assertUserLoggedIn();
|
||||||
|
|
||||||
|
$comment = $this->comments->get($id);
|
||||||
|
|
||||||
|
if($this->user->id !== $this->tickets->get($comment->getTicketId())->getUser()->getId())
|
||||||
|
exit(header("HTTP/1.1 403 Forbidden"));
|
||||||
|
|
||||||
|
if($mark === 1 || $mark === 2)
|
||||||
|
header("HTTP/1.1 200 OK");
|
||||||
|
else
|
||||||
|
exit(header("HTTP/1.1 400 Bad Request"));
|
||||||
|
|
||||||
|
$comment->setMark($mark);
|
||||||
|
$comment->save();
|
||||||
|
}
|
||||||
|
}
|
|
@ -109,6 +109,18 @@
|
||||||
<a href="/support/comment/{$comment->getId()}/delete">{_delete}</a>
|
<a href="/support/comment/{$comment->getId()}/delete">{_delete}</a>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{if $comment->getUType() === 1}
|
||||||
|
<div class="post-menu">
|
||||||
|
<strong>
|
||||||
|
{if $comment->isLikedByUser()}
|
||||||
|
{_support_good_answer_agent}
|
||||||
|
{else}
|
||||||
|
{_support_bad_answer_agent}
|
||||||
|
{/if}
|
||||||
|
</strong>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -6,6 +6,27 @@
|
||||||
{/block}
|
{/block}
|
||||||
|
|
||||||
{block content}
|
{block content}
|
||||||
|
<script>
|
||||||
|
function markAnswer(id, mark) {
|
||||||
|
let url = "/support/comment/" + id + "/rate/" + mark;
|
||||||
|
$.ajax(url, {
|
||||||
|
error: errorHandler,
|
||||||
|
success: success(id, mark)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function success(id, mark) {
|
||||||
|
if(mark == 1) {
|
||||||
|
document.getElementById("markText-" + id).innerHTML = {_support_good_answer_user};
|
||||||
|
} else {
|
||||||
|
document.getElementById("markText-" + id).innerHTML = {_support_bad_answer_user};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function errorHandler(id, mark) {
|
||||||
|
document.getElementById("markText-" + id).innerHTML = {_error};
|
||||||
|
}
|
||||||
|
</script>
|
||||||
{if $ticket->isDeleted() == 0 }
|
{if $ticket->isDeleted() == 0 }
|
||||||
<div class="post-author">
|
<div class="post-author">
|
||||||
<a href="#" style="font-size:13px;">
|
<a href="#" style="font-size:13px;">
|
||||||
|
@ -90,10 +111,29 @@
|
||||||
{$comment->getText()|noescape}
|
{$comment->getText()|noescape}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{if $comment->getUType() === 0}
|
{if $comment->getUType() === 0}
|
||||||
<div class="post-menu">
|
<div class="post-menu">
|
||||||
<a href="/support/comment/{$comment->getId()}/delete">{_delete}</a>
|
<a href="/support/comment/{$comment->getId()}/delete">{_delete}</a>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{if $comment->getUType() === 1}
|
||||||
|
<div class="post-menu">
|
||||||
|
<strong id="markText-{$comment->getId()}">
|
||||||
|
{if $comment->isLikedByUser()}
|
||||||
|
{_support_good_answer_user}
|
||||||
|
{else}
|
||||||
|
{_support_bad_answer_user}
|
||||||
|
{/if}
|
||||||
|
</strong>
|
||||||
|
{if $comment->isLikedByUser() === null}
|
||||||
|
<a onClick="markAnswer({$comment->getId()}, 1)">{_support_rate_good_answer}</a>
|
||||||
|
|
|
||||||
|
<a onClick="markAnswer({$comment->getId()}, 2)">{_support_rate_bad_answer}</a>
|
||||||
|
{/if}
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
@ -101,4 +141,4 @@
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{/if}
|
{/if}
|
||||||
{/block}
|
{/block}
|
|
@ -17,6 +17,8 @@ routes:
|
||||||
handler: "Support->AnswerTicket"
|
handler: "Support->AnswerTicket"
|
||||||
- url: "/support/view/{num}"
|
- url: "/support/view/{num}"
|
||||||
handler: "Support->view"
|
handler: "Support->view"
|
||||||
|
- url: "/support/comment/{num}/rate/{num}"
|
||||||
|
handler: "Support->rateAnswer"
|
||||||
- url: "/al_comments.pl/create/support/{num}"
|
- url: "/al_comments.pl/create/support/{num}"
|
||||||
handler: "Support->makeComment"
|
handler: "Support->makeComment"
|
||||||
- url: "/al_comments.pl/create/support/reply/{num}"
|
- url: "/al_comments.pl/create/support/reply/{num}"
|
||||||
|
|
1
install/sqls/00014-helpdesk-answers-evaluvating.sql
Normal file
1
install/sqls/00014-helpdesk-answers-evaluvating.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE `tickets_comments` ADD `mark` BOOLEAN NULL DEFAULT NULL;
|
|
@ -565,6 +565,16 @@
|
||||||
"support_new_title" = "Enter the topic of your ticket";
|
"support_new_title" = "Enter the topic of your ticket";
|
||||||
"support_new_content" = "Describe the issue or suggestion";
|
"support_new_content" = "Describe the issue or suggestion";
|
||||||
|
|
||||||
|
"support_rate_good_answer" = "This is good answer";
|
||||||
|
"support_rate_bad_answer" = "This is bad answer";
|
||||||
|
"support_good_answer_user" = "You left a positive feedback.";
|
||||||
|
"support_bad_answer_user" = "You left a negative feedback.";
|
||||||
|
"support_good_answer_agent" = "User left a positive feedback.";
|
||||||
|
"support_bad_answer_agent" = "User left a negative feedback.";
|
||||||
|
"support_rated_good" = "You left a positive feedback about the answer.";
|
||||||
|
"support_rated_bad" = "You left a negative feedback about the answer.";
|
||||||
|
"wrong_parameters" = "Invalid request parameters.";
|
||||||
|
|
||||||
"comment" = "Comment";
|
"comment" = "Comment";
|
||||||
"sender" = "Sender";
|
"sender" = "Sender";
|
||||||
|
|
||||||
|
|
|
@ -590,6 +590,16 @@
|
||||||
"support_new_title" = "Введите тему вашего обращения";
|
"support_new_title" = "Введите тему вашего обращения";
|
||||||
"support_new_content" = "Опишите проблему или предложение";
|
"support_new_content" = "Опишите проблему или предложение";
|
||||||
|
|
||||||
|
"support_rate_good_answer" = "Это хороший ответ";
|
||||||
|
"support_rate_bad_answer" = "Это плохой ответ";
|
||||||
|
"support_good_answer_user" = "Вы оставили положительный отзыв.";
|
||||||
|
"support_bad_answer_user" = "Вы оставили негативный отзыв.";
|
||||||
|
"support_good_answer_agent" = "Пользователь оставил положительный отзыв";
|
||||||
|
"support_bad_answer_agent" = "Пользователь оставил негативный отзыв";
|
||||||
|
"support_rated_good" = "Вы оставили положительный отзыв об ответе.";
|
||||||
|
"support_rated_bad" = "Вы оставили негативный отзыв об ответе.";
|
||||||
|
"wrong_parameters" = "Неверные параметры запроса.";
|
||||||
|
|
||||||
"comment" = "Комментарий";
|
"comment" = "Комментарий";
|
||||||
"sender" = "Отправитель";
|
"sender" = "Отправитель";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue