divan/GanjooRazor/Areas/Admin/Pages/Poets.cshtml
2026-08-06 20:29:57 +03:30

167 lines
5.9 KiB
Plaintext

@page
@model GanjooRazor.Areas.Admin.Pages.PoetsModel
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@{
Layout = "_AdminLayout";
ViewData["Title"] = "مدیریت سخنوران";
ViewData["WideShell"] = true;
}
<div class="up-page-header">
<h1>@ViewData["Title"]</h1>
</div>
@if (!string.IsNullOrEmpty(Model.LastMessage))
{
<div class="up-alert up-alert--info">@Model.LastMessage</div>
}
<script>
async function savePoetMeta(id, name) {
var ok = await upConfirm('آیا از ذخیرهٔ اطلاعات سال تولد و وفات و ترتیب برای ' + name + ' اطمینان دارید؟');
if (!ok) return;
$.ajax({
type: "POST",
url: '?handler=SavePoetMeta',
data: {
id: id,
birth: $('#birth-' + String(id)).val(),
death: $('#death-' + String(id)).val(),
pinorder: $('#pinorder-' + String(id)).val(),
validbirth: $('#birth-valid-' + String(id)).is(":checked"),
validdeath: $('#death-valid-' + String(id)).is(":checked"),
birthlocation: $('#birth-place-' + String(id)).val(),
deathlocation: $('#death-place-' + String(id)).val(),
},
error: function (e) {
upToast(e.responseText || 'خطا رخ داد.', 'error');
},
success: function () {
upToast('انجام شد.', 'success');
},
});
}
async function savePoetsMeta() {
var ok = await upConfirm('آیا از به‌روزرسانی گروه‌بندی بر اساس قرن اطمینان دارید؟');
if (!ok) return;
$.ajax({
type: "POST",
url: '?handler=UpdatePeriods',
success: function () {
upToast('انجام شد.', 'success');
},
error: function (e) {
upToast(e.responseText || 'خطا رخ داد.', 'error');
},
});
}
</script>
<div class="up-form-actions" style="margin-bottom:var(--up-space-3);">
<a href="/Admin/Poet" class="up-btn up-btn--success">سخنور جدید</a>
<a role="button" onclick="savePoetsMeta()" class="up-btn up-btn--ghost">ذخیرهٔ گروه‌بندی بر اساس قرن</a>
</div>
<table>
<tr>
<th>نام سخنور</th>
<th>زاده</th>
<th>درگذشته</th>
<th>چسبانی</th>
</tr>
@foreach (var poet in Model.Poets)
{
<tr>
<td>
<a href="/Admin/Poet?id=@poet.Id">@poet.Nickname</a>
</td>
<td>
<input type="text" name="@($"birth-{poet.Id}")" id="@($"birth-{poet.Id}")" value="@poet.BirthYearInLHijri" />
@if (poet.ValidBirthDate)
{
<input type="checkbox" name="@($"birth-valid-{poet.Id}")" id="@($"birth-valid-{poet.Id}")" checked />
}
else
{
<input type="checkbox" name="@($"birth-valid-{poet.Id}")" id="@($"birth-valid-{poet.Id}")" />
}
</td>
<td>
<input type="text" name="@($"death-{poet.Id}")" id="@($"death-{poet.Id}")" value="@poet.DeathYearInLHijri" />
@if (poet.ValidDeathDate)
{
<input type="checkbox" name="@($"death-valid-{poet.Id}")" id="@($"death-valid-{poet.Id}")" checked />
}
else
{
<input type="checkbox" name="@($"death-valid-{poet.Id}")" id="@($"death-valid-{poet.Id}")" />
}
</td>
<td>
<input type="text" name="@($"pinorder-{poet.Id}")" id="@($"pinorder-{poet.Id}")" value="@poet.PinOrder" />
</td>
</tr>
<tr>
<td>
<a href="/Admin/Locations" target="_blank">زادگاه</a>:
</td>
<td colspan="3">
<select id="@($"birth-place-{poet.Id}")">
@{
foreach (var location in Model.Locations)
{
if (location.Name == poet.BirthPlace)
{
<option value="@location.Name" selected>@location.Name</option>
}
else
{
<option value="@location.Name">@location.Name</option>
}
}
}
</select>
</td>
</tr>
<tr>
<td>
آرامگاه:
</td>
<td colspan="3">
<select id="@($"death-place-{poet.Id}")">
@{
foreach (var location in Model.Locations)
{
if (location.Name == poet.DeathPlace)
{
<option value="@location.Name" selected>@location.Name</option>
}
else
{
<option value="@location.Name">@location.Name</option>
}
}
}
</select>
</td>
</tr>
<tr>
<td colspan="4">
@Html.Raw(poet.Description)
</td>
</tr>
<tr>
<td colspan="4">
<a role="button" onclick="savePoetMeta(@poet.Id, '@poet.Nickname')" class="up-btn up-btn--success up-btn--sm">ذخیرهٔ @poet.Nickname</a>
</td>
</tr>
}
</table>
<div class="up-form-actions" style="margin-top:var(--up-space-3);">
<a role="button" onclick="exportAll()" class="up-btn up-btn--ghost">sqlite</a>
</div>