From 1180a91a3f2b303ced3128e9a1657be767981e3b Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Sun, 5 Jun 2022 12:29:56 +0430 Subject: [PATCH] docs: #327 marking verses to be deleted in the editor --- GanjooRazor/Areas/User/Pages/Editor.cshtml | 72 +++++++++++---- GanjooRazor/Areas/User/Pages/Editor.cshtml.cs | 5 +- GanjooRazor/Areas/User/Pages/Edits.cshtml | 87 ++++++++++++------- 3 files changed, 115 insertions(+), 49 deletions(-) diff --git a/GanjooRazor/Areas/User/Pages/Editor.cshtml b/GanjooRazor/Areas/User/Pages/Editor.cshtml index 15c40a56..1855c1cf 100644 --- a/GanjooRazor/Areas/User/Pages/Editor.cshtml +++ b/GanjooRazor/Areas/User/Pages/Editor.cshtml @@ -17,14 +17,20 @@ function savePoemCorrections(id, verseCount) { var verseOrderText = []; + var verseOrderMarkedForDelete = []; for (var i = 0; i <= verseCount; i++) { var oldElementName = '#original-' + i.toString(); var newElementName = '#id-' + i.toString(); - if ($(newElementName).text() != $(oldElementName).text()) { + var checkVIndex = '#marked-for-delete-' + i.toString(); + if ($(newElementName).text() != $(oldElementName).text() || $(checkVIndex).is(":checked")) { verseOrderText.push(i.toString() + 'TextSeparator' + $(newElementName).text()); + verseOrderMarkedForDelete.push(i); } } + + + if (verseOrderText.length == 0) { if ($('#rhythm-old').text() == $('#rhythm-new').val() && $('#rhythm-old2').text() == $('#rhythm-new2').val()) { alert('شما هیچ تغییری در متن نداده‌اید!'); @@ -53,6 +59,7 @@ data: { poemid: id, verseOrderText: verseOrderText, + verseOrderMarkedForDelete: verseOrderMarkedForDelete, rhythm: rhythm_new, rhythm2: rhythm_new2, note: $('#note').val() @@ -248,7 +255,20 @@ else @if (Model.MyLastEdit.VerseOrderText != null) @foreach (var verse in Model.MyLastEdit.VerseOrderText) { - + @if (verse.MarkForDelete) + { + + +

@verse.OriginalText

+ + +

باید حذف شود

+ + + } + else + { +

@verse.OriginalText

@@ -256,6 +276,8 @@ else

@verse.Text

+ } + } @if (!string.IsNullOrEmpty(Model.MyLastEdit.Note)) { @@ -471,6 +493,20 @@ else

@verse.Text

+ + + @if (Model.MyLastEdit != null && Model.MyLastEdit.VerseOrderText != null && Model.MyLastEdit.VerseOrderText.Where(v => v.VORder == verse.VOrder && v.MarkForDelete).Any()) + { + + + } + else + { + + + } + + @if (Model.ShowAdminOps && verse.VOrder > 1 && verse.VersePosition != RMuseum.Models.Ganjoor.VersePosition.Left) { @@ -655,7 +691,7 @@ else - + @if (Model.PageInformation.Poem.Sections.Count(s => s.SectionType == RMuseum.Models.Ganjoor.PoemSectionType.WholePoem && s.VerseType == RMuseum.Models.Ganjoor.VersePoemSectionType.First) > 1) { @@ -711,7 +747,7 @@ else - + همهٔ قطعات شعر @@ -733,35 +769,35 @@ else } - @if(Model.ShowAdminOps && Model.GanjoorMetre1 != null && !string.IsNullOrEmpty(Model.RhymeLetters)) + @if (Model.ShowAdminOps && Model.GanjoorMetre1 != null && !string.IsNullOrEmpty(Model.RhymeLetters)) { - + بازسازی فهرست اشعار هم‌آهنگ با وزن اول } - @if(Model.ShowAdminOps && Model.GanjoorMetre2 != null && !string.IsNullOrEmpty(Model.RhymeLetters)) + @if (Model.ShowAdminOps && Model.GanjoorMetre2 != null && !string.IsNullOrEmpty(Model.RhymeLetters)) { - + بازسازی فهرست اشعار هم‌آهنگ با وزن دوم } - @if(Model.ShowAdminOps) - { - - برای حذف شعر از قسمت مدیریت بخش اقدام کنید. - - } - - @if(Model.CanEdit && !Model.ShowAdminOps) + @if (Model.ShowAdminOps) { - + + برای حذف شعر از قسمت مدیریت بخش اقدام کنید. + + } + + @if (Model.CanEdit && !Model.ShowAdminOps) + { + امکانات مدیریتی } - + ذخیره diff --git a/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs b/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs index 9f745cc7..5394d286 100644 --- a/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs +++ b/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs @@ -218,7 +218,7 @@ namespace GanjooRazor.Areas.User.Pages return new BadRequestObjectResult("لطفا از گنجور خارج و مجددا به آن وارد شوید."); } - public async Task OnPostSendPoemCorrectionsAsync(int poemid, string[] verseOrderText, string rhythm, string rhythm2, string note) + public async Task OnPostSendPoemCorrectionsAsync(int poemid, string[] verseOrderText, int[] verseOrderMarkedForDelete, string rhythm, string rhythm2, string note) { using (HttpClient secureClient = new HttpClient()) { @@ -239,7 +239,8 @@ namespace GanjooRazor.Areas.User.Pages new GanjoorVerseVOrderText() { VORder = vOrder, - Text = vParts[1].Replace("ۀ", "هٔ").Replace("ك", "ک") + Text = vParts[1].Replace("ۀ", "هٔ").Replace("ك", "ک"), + MarkForDelete = verseOrderMarkedForDelete.Any(v => v == vOrder), } ); } diff --git a/GanjooRazor/Areas/User/Pages/Edits.cshtml b/GanjooRazor/Areas/User/Pages/Edits.cshtml index 1358194c..8b350fa8 100644 --- a/GanjooRazor/Areas/User/Pages/Edits.cshtml +++ b/GanjooRazor/Areas/User/Pages/Edits.cshtml @@ -83,12 +83,12 @@ else

@correction.Title

- @if (correction.Result == CorrectionReviewResult.Approved) + @if (correction.Result == CorrectionReviewResult.NotReviewed) {

@CorrectionReviewResultConvertor.GetString(correction.Result)

} else - @if (correction.Result == CorrectionReviewResult.Approved) + @if (correction.Result == CorrectionReviewResult.Approved) {

@CorrectionReviewResultConvertor.GetString(correction.Result)

} @@ -117,12 +117,12 @@ else

@correction.Rhythm

- @if (correction.RhythmResult == CorrectionReviewResult.Approved) + @if (correction.RhythmResult == CorrectionReviewResult.NotReviewed) {

@CorrectionReviewResultConvertor.GetString(correction.RhythmResult)

} else - @if (correction.RhythmResult == CorrectionReviewResult.Approved) + @if (correction.RhythmResult == CorrectionReviewResult.Approved) {

@CorrectionReviewResultConvertor.GetString(correction.RhythmResult)

} @@ -156,12 +156,12 @@ else

@correction.Rhythm2

- @if (correction.Rhythm2Result == CorrectionReviewResult.Approved) + @if (correction.Rhythm2Result == CorrectionReviewResult.NotReviewed) {

@CorrectionReviewResultConvertor.GetString(correction.Rhythm2Result)

} else - @if (correction.Rhythm2Result == CorrectionReviewResult.Approved) + @if (correction.Rhythm2Result == CorrectionReviewResult.Approved) {

@CorrectionReviewResultConvertor.GetString(correction.Rhythm2Result)

} @@ -183,29 +183,58 @@ else @if (correction.VerseOrderText != null) @foreach (var verse in correction.VerseOrderText) { - - -

@verse.OriginalText

- - -

@verse.Text

- - - @if (verse.Result == CorrectionReviewResult.Approved) - { -

@CorrectionReviewResultConvertor.GetString(verse.Result)

- } - else - if (verse.Result == CorrectionReviewResult.Approved) - { -

@CorrectionReviewResultConvertor.GetString(verse.Result)

- } - else - { -

@CorrectionReviewResultConvertor.GetString(verse.Result)

- } - - + @if (verse.MarkForDelete) + { + + +

@verse.OriginalText

+ + +

باید حذف شود

+ + + @if (verse.MarkForDeleteResult == CorrectionReviewResult.NotReviewed) + { +

@CorrectionReviewResultConvertor.GetString(verse.MarkForDeleteResult)

+ } + else + if (verse.MarkForDeleteResult == CorrectionReviewResult.Approved) + { +

@CorrectionReviewResultConvertor.GetString(verse.MarkForDeleteResult)

+ } + else + { +

@CorrectionReviewResultConvertor.GetString(verse.MarkForDeleteResult)

+ } + + + } + else + { + + +

@verse.OriginalText

+ + +

@verse.Text

+ + + @if (verse.Result == CorrectionReviewResult.NotReviewed) + { +

@CorrectionReviewResultConvertor.GetString(verse.Result)

+ } + else + if (verse.Result == CorrectionReviewResult.Approved) + { +

@CorrectionReviewResultConvertor.GetString(verse.Result)

+ } + else + { +

@CorrectionReviewResultConvertor.GetString(verse.Result)

+ } + + + } @if (!string.IsNullOrEmpty(verse.ReviewNote)) {