docs: #347 finalizing UI for transfering meters

This commit is contained in:
Hamid Reza Mohammadi 2022-07-16 18:52:19 +04:30
parent d097c6473f
commit 7c617f7650
4 changed files with 46 additions and 13 deletions

View File

@ -17,13 +17,11 @@ else
{
<script>
function confirmAndFinalize() {
if (!confirm('آیا از حذف وزن انتخابی و انتقال شعرهای آن به وزن مقصد اطمینان دارید؟'))
return;
var rhythm_new = $('#rhythm-new').val();
var rhythm_new2 = $('#rhythm-new2').val();
if (!confirm('آیا از حذف وزن «'+rhythm_new+'» و انتقال شعرهای آن به وزن «'+rhythm_new2+'» اطمینان دارید؟'))
return;
$.ajax({
type: "POST",
@ -40,13 +38,13 @@ else
alert(e.responseText);
},
success: function(b) {
if(b == true){
if (b == true) {
alert('انتقال انجام شد.');
}
else{
alert('خطا رخ داد.');
else {
alert('خطا رخ داد.');
}
},
});
@ -62,7 +60,7 @@ else
<tr>
<td>
<label for="select-search">جستجوی وزن:</label><br />
<input type="text" id="select-search" value="" oninput="doSearchInRhythmsCombo('select-search', 'rhythm-new')" list="inputRhythms" autocomplete="off" size="50" />
<input type="text" id="select-search" value="@Model.InitialSourceMeter" oninput="doSearchInRhythmsCombo('select-search', 'rhythm-new')" list="inputRhythms" autocomplete="off" size="50" />
<datalist id="inputRhythms">
@if (Model.RhythmsByVerseCount != null)
@foreach (var rhythm in Model.RhythmsByVerseCount)
@ -78,9 +76,14 @@ else
<select id="rhythm-new" name="rhythm-new">
@foreach (var rhythm in Model.RhythmsAlphabetically)
{
<option value="@rhythm.Rhythm">@rhythm.Rhythm</option>
}
if (rhythm.Rhythm == Model.InitialSourceMeter)
{
<option value="@rhythm.Rhythm" selected>@rhythm.Rhythm</option>
}
else
{
<option value="@rhythm.Rhythm">@rhythm.Rhythm</option>
}
</select>
<a role="button" onclick="resetRhythm('rhythm-new')" class="pagebutton">پاک کردن وزن</a>

View File

@ -33,6 +33,8 @@ namespace GanjooRazor.Areas.Admin.Pages
/// </summary>
public bool CanEdit { get; set; }
public string InitialSourceMeter { get; set; }
/// <summary>
/// get
/// </summary>
@ -45,6 +47,12 @@ namespace GanjooRazor.Areas.Admin.Pages
FatalError = "";
CanEdit = Request.Cookies["CanEdit"] == "True";
InitialSourceMeter = "";
if (!string.IsNullOrEmpty(Request.Query["m"]))
{
InitialSourceMeter = Request.Query["m"];
}
using (HttpClient secureClient = new HttpClient())
{
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))

View File

@ -26,6 +26,16 @@
var stickyEnabled = cookieValue != "false";
</script>
@if(Model.CanEdit)
{
<script>
function redirectToTransferMeter(){
var meter = document.getElementById("v").value;
window.location.href = "/Admin/TransferMeter?m=" + encodeURIComponent(meter);
}
</script>
}
</head>
<body>
@ -162,8 +172,12 @@
<label for="g" class="width-100per">قافیه:</label>
<input type="text" name="g" id="g" class="width-100per" value="@Model.Rhyme" placeholder="حروف قافیه" />
<input type="submit" class="width-100per" value="اعمال ورودی‌ها" />
<input type="submit" class="width-100per margin-top-5px" value="اعمال ورودی‌ها" />
@if(Model.CanEdit)
{
<a onclick="redirectToTransferMeter()" class="pagebutton" role="button">انتقال وزن</a>
}
</form>
</div><!-- related-images-frame -->

View File

@ -71,6 +71,12 @@ namespace GanjooRazor.Pages
public string PagingToolsHtml { get; set; }
public string LastError { get; set; }
/// <summary>
/// can edit
/// </summary>
public bool CanEdit { get; set; }
private async Task<bool> preparePoets()
{
var cacheKey = $"/api/ganjoor/poets";
@ -155,6 +161,8 @@ namespace GanjooRazor.Pages
LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]);
CanEdit = Request.Cookies["CanEdit"] == "True";
PoetId = string.IsNullOrEmpty(Request.Query["a"]) ? 0 : int.Parse(Request.Query["a"]);
ViewData["GoogleAnalyticsCode"] = Configuration["GoogleAnalyticsCode"];