divan/GanjooRazor/Areas/User/Pages/AwaitingComments.cshtml
2026-08-05 16:55:42 +03:30

120 lines
4.9 KiB
Plaintext

@page
@model GanjooRazor.Areas.User.Pages.AwaitingCommentsModel
@using DNTPersianUtils.Core
@{
Layout = "_UserPanelLayout";
ViewData["Title"] = "حاشیه‌های در انتظار تأیید";
await GanjooRazor.Utils.GanjoorSessionChecker.ApplyPermissionsToViewData(Request, Response, ViewData);
}
<div class="up-page-header">
<h1>@ViewData["Title"]</h1>
</div>
@if (Model.LastError != "")
{
<div class="up-alert up-alert--danger">@Model.LastError</div>
}
else
{
<script>
async function deleteAwaitingComment(commentId) {
var ok = await upConfirm('آیا از حذف این حاشیه اطمینان دارید؟');
if (!ok) return;
$.ajax({
type: "DELETE",
url: '?handler=Comment',
data: { id: commentId },
error: function (e) {
upToast(e.responseText || 'خطا رخ داد.', 'error');
},
success: function () {
$('#comment-' + commentId).remove();
upToast('حاشیه حذف شد.', 'success');
},
});
}
async function publishAwaitingComment(commentId) {
var ok = await upConfirm('آیا از انتشار این حاشیه اطمینان دارید؟', { danger: false, okText: 'بله، منتشر شود' });
if (!ok) return;
$.ajax({
type: "PUT",
url: '?handler=Approve',
data: { id: commentId },
error: function (e) {
upToast(e.responseText || 'خطا رخ داد.', 'error');
},
success: function () {
$('#comment-' + commentId).remove();
upToast('حاشیه منتشر شد.', 'success');
},
});
}
function switchOption(start) {
document.getElementById('switch-tracking-button').style.visibility = 'hidden';
document.getElementById('processing').innerHTML = 'در حال پردازش ...';
$.ajax({
type: "POST",
url: start ? '?handler=StartKeeping' : '?handler=StopKeeping',
error: function () {
upToast('خطا رخ داد.', 'error');
location.reload();
},
success: function () {
location.reload();
},
});
}
</script>
<partial name="_Pagination" model="Model.PaginationLinks" />
<div class="up-card">
@if (Model.KeepFirstTimeUsersComments)
{
<div class="up-alert up-alert--success up-text-center">نگه داشتن حاشیه‌های حاشیه‌گذاران بدون سابقه فعال است.</div>
<div class="up-form-actions" style="justify-content:center;">
<a role="button" onclick="switchOption(false)" id="switch-tracking-button" class="up-btn up-btn--ghost">غیرفعال کردن</a>
</div>
}
else
{
<p class="up-text-center">نگه داشتن حاشیه‌های حاشیه‌گذاران بدون سابقه غیرفعال است.</p>
<div class="up-form-actions" style="justify-content:center;">
<a role="button" onclick="switchOption(true)" id="switch-tracking-button" class="up-btn up-btn--success">فعال کردن</a>
</div>
}
<p id="processing" class="up-text-center"></p>
</div>
@if (Model.Comments.Count == 0)
{
<partial name="_EmptyState" model="@("موردی وجود ندارد.")" />
}
else
{
<div class="up-list">
@foreach (var comment in Model.Comments)
{
<div class="up-list-item" id="comment-@comment.Id">
<div id="comment-text-@comment.Id">
@Html.Raw(comment.HtmlComment)
</div>
<div class="up-list-item__meta">
<a href="/Admin/ExamineUser?id=@comment.UserId">@comment.AuthorName</a> در @comment.CommentDate.ToFriendlyPersianDateTextify() دربارهٔ <a href="@comment.Poem.UrlSlug#comment-@comment.Id">@comment.Poem.Title</a>
</div>
<div class="up-list-item__actions">
<a role="button" onclick="deleteAwaitingComment(@comment.Id)" class="up-icon-btn" title="حذف حاشیه" aria-label="حذف این حاشیه"><i class="noindent-info-button delete-icon"></i></a>
<a role="button" onclick="publishAwaitingComment(@comment.Id)" class="up-icon-btn" title="انتشار حاشیه" aria-label="انتشار این حاشیه"><i class="noindent-info-button done-icon"></i></a>
</div>
</div>
}
</div>
}
<partial name="_Pagination" model="Model.PaginationLinks" />
}