docs: #328 client UI - update related sections of a poem
This commit is contained in:
parent
861a1abed4
commit
7d477b71d7
@ -164,6 +164,29 @@
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function updateRelatedSections(meterId, rhymeletters) {
|
||||
var url = '?handler=UpdateRelatedSections';
|
||||
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: url,
|
||||
data: {
|
||||
meterId: meterId,
|
||||
rhyme: rhymeletters,
|
||||
},
|
||||
success: function() {
|
||||
alert('انجام شد.');
|
||||
},
|
||||
error: function(e) {
|
||||
if (e.responseText == null)
|
||||
alert(e);
|
||||
else
|
||||
alert(e.responseText);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@if (!string.IsNullOrEmpty(Model.FatalError))
|
||||
{
|
||||
@ -717,15 +740,29 @@ else
|
||||
<td><a href="/User/Editor?id=@Model.PageInformation.Poem.Next.Id" role="button" class="pagebutton">ویرایش شعر بعد</a></td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@if(Model.ShowAdminOps && Model.GanjoorMetre1 != null && !string.IsNullOrEmpty(Model.RhymeLetters))
|
||||
{
|
||||
<tr>
|
||||
<td><a role="button" onclick="updateRelatedSections(@Model.GanjoorMetre1.Id, '@Model.RhymeLetters')" class="pagebutton">بازسازی فهرست اشعار همآهنگ با وزن اول</a></td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@if(Model.ShowAdminOps && Model.GanjoorMetre2 != null && !string.IsNullOrEmpty(Model.RhymeLetters))
|
||||
{
|
||||
<tr>
|
||||
<td><a role="button" onclick="updateRelatedSections(@Model.GanjoorMetre2.Id, '@Model.RhymeLetters')" class="pagebutton">بازسازی فهرست اشعار همآهنگ با وزن دوم</a></td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
@if(Model.CanEdit && !Model.ShowAdminOps)
|
||||
{
|
||||
<tr>
|
||||
<td><a role="button" href="/User/Editor?id=@Model.PageInformation.Id&admin=1" class="pagebutton">امکانات مدیریتی</a></td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
|
||||
@if (Model.CanEdit)
|
||||
{
|
||||
<div class="related-images-frame">
|
||||
<p>
|
||||
<a role="button" href="/User/Editor?id=@Model.PageInformation.Id&admin=1" class="pagebutton">امکانات مدیریتی</a>
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -78,6 +78,8 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
|
||||
public GanjoorMetre GanjoorMetre2 { get; set; }
|
||||
|
||||
public string RhymeLetters { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// can edit
|
||||
/// </summary>
|
||||
@ -155,6 +157,11 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
}
|
||||
PageInformation = JObject.Parse(await pageQuery.Content.ReadAsStringAsync()).ToObject<GanjoorPageCompleteViewModel>();
|
||||
|
||||
if (PageInformation.Poem.Sections.Where(s => s.SectionType == PoemSectionType.WholePoem && !string.IsNullOrEmpty(s.RhymeLetters)).Any())
|
||||
{
|
||||
RhymeLetters = PageInformation.Poem.Sections.Where(s => s.SectionType == PoemSectionType.WholePoem && !string.IsNullOrEmpty(s.RhymeLetters)).OrderBy(s => s.VerseType).First().RhymeLetters;
|
||||
}
|
||||
|
||||
if (PageInformation.Poem.Sections.Where(s => s.SectionType == PoemSectionType.WholePoem && s.GanjoorMetre != null).Any())
|
||||
{
|
||||
GanjoorMetre1 = PageInformation.Poem.Sections.Where(s => s.SectionType == PoemSectionType.WholePoem && s.GanjoorMetre != null).OrderBy(s => s.VerseType).First().GanjoorMetre;
|
||||
@ -314,5 +321,28 @@ namespace GanjooRazor.Areas.User.Pages
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<IActionResult> OnPostUpdateRelatedSectionsAsync(int meterId, string rhyme)
|
||||
{
|
||||
using (HttpClient secureClient = new HttpClient())
|
||||
{
|
||||
if (await GanjoorSessionChecker.PrepareClient(secureClient, Request, Response))
|
||||
{
|
||||
HttpResponseMessage response = await secureClient.PostAsync(
|
||||
$"{APIRoot.Url}/api/ganjoor/sections/updaterelated?metreId={meterId}&rhyme={rhyme}",
|
||||
null
|
||||
);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
{
|
||||
return new BadRequestObjectResult(JsonConvert.DeserializeObject<string>(await response.Content.ReadAsStringAsync()));
|
||||
}
|
||||
return new OkResult();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user