Лавка ОВК Тестерс 2.0?

This commit is contained in:
n1rwana 2022-08-21 23:30:25 +03:00
parent 1699af5c40
commit b479e7a70d
4 changed files with 28 additions and 15 deletions

View file

@ -38,4 +38,9 @@ class BugReportComment extends RowModel
{
return $this->getRecord()->label;
}
function getBalanceChanges(): ?int
{
return $this->getRecord()->point_actions;
}
}

View file

@ -90,7 +90,7 @@ final class BugtrackerPresenter extends OpenVKPresenter
$report->save();
$this->createComment($report, $comment, tr("bug_tracker_new_report_status") . "$list[$status]", TRUE);
$this->createComment($report, $comment, tr("bug_tracker_new_report_status") . "$list[$status]", TRUE, FALSE, $points);
$this->flashFail("succ", tr("changes_saved"), tr("bug_tracker_new_report_status") . "$list[$status]");
}
@ -119,11 +119,11 @@ final class BugtrackerPresenter extends OpenVKPresenter
$report->save();
$this->createComment($report, $comment, tr("bug_tracker_new_report_priority") . "$list[$priority]", TRUE);
$this->createComment($report, $comment, tr("bug_tracker_new_report_priority") . "$list[$priority]", TRUE, FALSE, $points);
$this->flashFail("succ", tr("changes_saved"), tr("bug_tracker_new_report_priority") . "$list[$priority]");
}
function createComment(?BugReport $report, string $text, string $label = "", bool $is_moder = FALSE, bool $is_hidden = FALSE)
function createComment(?BugReport $report, string $text, string $label = "", bool $is_moder = FALSE, bool $is_hidden = FALSE, string $point_actions = NULL)
{
$moder = $this->user->identity->getChandlerUser()->can("admin")->model('openvk\Web\Models\Repositories\BugtrackerReports')->whichBelongsTo(NULL);
@ -138,6 +138,7 @@ final class BugtrackerPresenter extends OpenVKPresenter
"author" => $this->user->identity->getId(),
"is_moder" => $moder === $is_moder,
"is_hidden" => $moder === $is_hidden,
"point_actions" => $point_actions,
"text" => $text,
"label" => $label
]);

View file

@ -39,11 +39,11 @@
</tr>
<tr>
<td class="label"><span class="nobold">{_status}:</span></td>
<td class="data"><a href="#" n:attr='onClick => $canAdminBugTracker ? "showBtStatusChangeDialog({$bug->getId()}, \"{$csrfToken}\");" : false'>{$bug->getStatus()}</a></td>
<td class="data"><a href="#" n:attr='onClick => $canAdminBugTracker ? "showBtStatusChangeDialog({$bug->getId()}, {$reporter->getCoins()}, \"{$csrfToken}\");" : false'>{$bug->getStatus()}</a></td>
</tr>
<tr>
<td class="label"><span class="nobold">{_bug_tracker_priority}:</span></td>
<td class="data"><a href="#" n:attr='onClick => $canAdminBugTracker ? "showBtPriorityChangeDialog({$bug->getId()}, \"{$csrfToken}\");" : false'>{$bug->getPriority()}</a></td>
<td class="data"><a href="#" n:attr='onClick => $canAdminBugTracker ? "showBtPriorityChangeDialog({$bug->getId()}, {$reporter->getCoins()}, \"{$csrfToken}\");" : false'>{$bug->getPriority()}</a></td>
</tr>
<tr>
<td class="label"><span class="nobold">{_bug_tracker_device}:</span></td>
@ -52,8 +52,8 @@
</tbody>
</table>
<hr color="#DAE1E8" size="1">
<button n:if="$canAdminBugTracker" class="button" onClick="showBtStatusChangeDialog({$bug->getId()}, {$csrfToken})">{_bug_tracker_change_status}</button>
<button n:if="$canAdminBugTracker" class="button" onClick="showBtPriorityChangeDialog({$bug->getId()}, {$csrfToken})">{_bug_tracker_change_priority}</button>
<button n:if="$canAdminBugTracker" class="button" onClick="showBtStatusChangeDialog({$bug->getId()}, {$reporter->getCoins()}, {$csrfToken})">{_bug_tracker_change_status}</button>
<button n:if="$canAdminBugTracker" class="button" onClick="showBtPriorityChangeDialog({$bug->getId()}, {$reporter->getCoins()}, {$csrfToken})">{_bug_tracker_change_priority}</button>
<a n:if="$bug->getReporter()->getId() !== $user->identity->getId()" class="button" href="/bug{$bug->getId()}/reproduce">
{_bug_tracker_reproduced}
<span n:if="$bug->getReproducedCount() > 0">({$bug->getReproducedCount()})</span>
@ -80,6 +80,7 @@
<div>
{$comment->getText()}
</div>
<b n:if="$canAdminBugTracker AND $comment->getBalanceChanges()">(действия с балансом: {$comment->getBalanceChanges() > 0 ? "+" : false}{$comment->getBalanceChanges()})</b>
</div>
</div>
<hr color="#DAE1E8" size="1">

View file

@ -440,7 +440,7 @@ $(document).on("scroll", () => {
}
})
function showBtStatusChangeDialog(report, hash) {
function showBtStatusChangeDialog(report, currentBalance, hash) {
MessageBox("Изменить статус", `<form action="/bug${report}/setStatus" method="post" id="status_change_dialog">
<table>
<tbody>
@ -482,10 +482,13 @@ function showBtStatusChangeDialog(report, hash) {
<h4>Вы можете прокомментировать изменение статуса</h4>
<textarea name="text" style="width: 100%;resize: vertical;"></textarea>
<br><br>
<div style="display: flex;">
Начислить
У тестировщика сейчас ${currentBalance} голосов.
<br>
<div style="display: inline;">
Вы можете начислить &nbsp;
<input style="width: 45px; height: 9px;" type="number" name="points-count" value="0">
голосов
&nbsp;голосов
<span class="nobold">(отрицательные значения поддерживаются)</span>
</div>
<input type="hidden" name="hash" value="${hash}" />
</form>
@ -497,7 +500,7 @@ function showBtStatusChangeDialog(report, hash) {
]);
}
function showBtPriorityChangeDialog(report, hash) {
function showBtPriorityChangeDialog(report, currentBalance, hash) {
MessageBox("Изменить приоритет", `<form action="/bug${report}/setPriority" method="post" id="priority_change_dialog">
<table>
<tbody>
@ -531,10 +534,13 @@ function showBtPriorityChangeDialog(report, hash) {
<h4>Вы можете прокомментировать изменение приоритета</h4>
<textarea name="text" style="width: 100%;resize: vertical;"></textarea>
<br><br>
<div style="display: flex;">
Начислить
У тестировщика сейчас ${currentBalance} голосов.
<br>
<div style="display: inline;">
Вы можете начислить &nbsp;
<input style="width: 45px; height: 9px;" type="number" name="points-count" value="0">
голосов
&nbsp;голосов
<span class="nobold">(отрицательные значения поддерживаются)</span>
</div>
<input type="hidden" name="hash" value="${hash}" />
</form>