diff --git a/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml b/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml index 5a999237..90295126 100644 --- a/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml +++ b/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml @@ -38,7 +38,7 @@ } } - function moderatePoemCorrections(verseCount, correctionId) { + function moderatePoemCorrections(verseCount, correctionId, geoTagCount) { $('#moderatecorrections').hide(); $('#saving').text('در حال بررسی ...'); @@ -133,6 +133,17 @@ } + var geoTagReviewResult = []; + var geoTagReviewNotes = []; + for (var g = 0; g < (geoTagCount || 0); g++) { + var geoElementId = '#geotag' + (g + 1).toString() + '_review_result_Approved'; + if ($(geoElementId).length > 0) { + var geoElementName = 'geotag' + (g + 1).toString() + '_review_result'; + geoTagReviewResult.push($('input[name=' + geoElementName + ']:checked').val()) + geoTagReviewNotes.push($('#geotag' + (g + 1).toString() + '_review_note').val()) + } + } + var url = '?handler=SendCorrectionsModeration'; var pms = {}; @@ -151,6 +162,8 @@ pms.verseReviewNotes= verseReviewNotes; pms.poemformatReviewResult= poemformatReviewResult; pms.poemformatReviewNote= $('#poemformat_review_note') == null ? null : $('#poemformat_review_note').val(); + pms.geoTagReviewResult= geoTagReviewResult; + pms.geoTagReviewNotes= geoTagReviewNotes; $.ajax({ type: "POST", @@ -195,7 +208,7 @@ else - بررسی + بررسی
@@ -755,6 +768,114 @@ else } + @if (Model.Correction.GeoDateTags != null) + @for (var gi = 0; gi < Model.Correction.GeoDateTags.Length; gi++) + { + var geoTag = Model.Correction.GeoDateTags[gi]; + var geoIndex = gi + 1; + + + برچسب جغرافیایی/تاریخی + @{ + var geoCouplet = geoTag.CoupletIndex == null ? null : (Model.Couplets ?? Array.Empty>()).Where(c => c.Item1 == geoTag.CoupletIndex).Select(c => c.Item2).FirstOrDefault(); + } + @if (geoTag.CoupletIndex != null) + { + + - بیت @((geoTag.CoupletIndex + 1).ToPersianNumbers()) + + } + + + @if (geoCouplet != null) + { + + +

@geoCouplet

+ + + } + @if (geoTag.MarkForDelete) + { + var existingTag = geoTag.ExistingTagId == null || Model.PageInformation.Poem.GeoDateTags == null + ? null + : Model.PageInformation.Poem.GeoDateTags.Where(t => t.Id == geoTag.ExistingTagId).FirstOrDefault(); + + +

+ درخواست حذف برچسب: + @if (existingTag != null) + { + @(existingTag.Location != null ? existingTag.Location.Name : "") + @(existingTag.LunarYear != null ? $" - سال {existingTag.LunarYear}" : "") + } +

+ + + } + else + { + + متن اولیه + پیشنهاد + + + +

-

+ + +

+ @if (geoTag.LocationId != null) + { + @(geoTag.Location != null ? geoTag.Location.Name : $"مکان #{geoTag.LocationId}") + } + else if (!string.IsNullOrEmpty(geoTag.SuggestedLocationName)) + { + @($"{geoTag.SuggestedLocationName} ({geoTag.SuggestedLatitude}, {geoTag.SuggestedLongitude}) [مکان جدید]") + } + @if (geoTag.LunarYear != null) + { + - سال @geoTag.LunarYear + if (geoTag.LunarMonth != null) + { + /@geoTag.LunarMonth + if (geoTag.LunarDay != null) + { + /@geoTag.LunarDay + } + } + } +

+ @if (!string.IsNullOrEmpty(geoTag.SuggestionNote)) + { +

یادداشت پیشنهاد دهنده: @geoTag.SuggestionNote

+ } + + + } + + +
+ + +
+
+ + +
+
+ + +
+
+ + +
+ + + + } + @if (Model.Correction.VerseOrderText != null) @foreach (var verse in Model.Correction.VerseOrderText) { diff --git a/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml.cs b/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml.cs index ab25a60b..53420ad4 100644 --- a/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml.cs +++ b/GanjooRazor/Areas/Admin/Pages/ReviewEdits.cshtml.cs @@ -56,6 +56,62 @@ namespace GanjooRazor.Areas.Admin.Pages public bool ApproveVersePositionChanges { get; set; } + /// + /// couplets of the poem, used to show which couplet a suggested geo/date tag belongs to + /// + public Tuple[] Couplets { get; set; } + + /// + /// groups verses into couplets - same logic as SuggestQuoted.cshtml.cs's/Editor.cshtml.cs's GetCouplets, + /// duplicated here rather than shared, so this page doesn't take on a cross-file dependency on those + /// + /// + /// + private Tuple[] GetCouplets(GanjoorVerseViewModel[] verses) + { + int coupetIndex = -1; + string coupletText = ""; + var couplets = new System.Collections.Generic.List>(); + int verseIndex = 0; + while (verseIndex < verses.Length) + { + switch (verses[verseIndex].VersePosition) + { + case VersePosition.Comment: + break; + case VersePosition.Paragraph: + case VersePosition.Single: + if (!string.IsNullOrEmpty(coupletText)) + { + couplets.Add(new Tuple(coupetIndex, coupletText)); + coupletText = ""; + } + coupetIndex++; + couplets.Add(new Tuple(coupetIndex, verses[verseIndex].Text)); + break; + case VersePosition.Right: + case VersePosition.CenteredVerse1: + if (!string.IsNullOrEmpty(coupletText)) + { + couplets.Add(new Tuple(coupetIndex, coupletText)); + } + coupetIndex++; + coupletText = verses[verseIndex].Text; + break; + case VersePosition.Left: + case VersePosition.CenteredVerse2: + coupletText += $" - {verses[verseIndex].Text}"; + break; + } + verseIndex++; + } + if (!string.IsNullOrEmpty(coupletText)) + { + couplets.Add(new Tuple(coupetIndex, coupletText)); + } + return couplets.ToArray(); + } + private async Task ReadLanguagesAsync(HttpClient secureClient) { HttpResponseMessage response = await secureClient.GetAsync($"{APIRoot.Url}/api/translations/languages"); @@ -117,6 +173,8 @@ namespace GanjooRazor.Areas.Admin.Pages } PageInformation = JObject.Parse(await pageQuery.Content.ReadAsStringAsync()).ToObject(); + Couplets = GetCouplets(PageInformation.Poem.Verses); + 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; @@ -318,6 +376,26 @@ namespace GanjooRazor.Areas.Admin.Pages } } + if (Correction.GeoDateTags != null && Correction.GeoDateTags.Length > 0) + { + if (pms.geoTagReviewResult == null || pms.geoTagReviewResult.Length != Correction.GeoDateTags.Length) + { + return new BadRequestObjectResult("لطفاً تکلیف بررسی تمام برچسب‌های جغرافیایی/تاریخی پیشنهادی را مشخص کنید."); + } + else + { + for (int i = 0; i < Correction.GeoDateTags.Length; i++) + { + if (pms.geoTagReviewResult[i] == null) + { + return new BadRequestObjectResult("لطفاً تکلیف بررسی تمام برچسب‌های جغرافیایی/تاریخی پیشنهادی را مشخص کنید."); + } + Correction.GeoDateTags[i].Result = (CorrectionReviewResult)Enum.Parse(typeof(CorrectionReviewResult), pms.geoTagReviewResult[i]); + Correction.GeoDateTags[i].ReviewNote = (pms.geoTagReviewNotes != null && i < pms.geoTagReviewNotes.Length) ? pms.geoTagReviewNotes[i] : null; + } + } + } + if (pms.verseReviewResult.Length != Correction.VerseOrderText.Length) { return new BadRequestObjectResult("لطفاً تکلیف بررسی تمام مصرعهای پیشنهادی را مشخص کنید."); diff --git a/GanjooRazor/Models/PoemMoerationStructure.cs b/GanjooRazor/Models/PoemMoerationStructure.cs index abbd440a..93eca773 100644 --- a/GanjooRazor/Models/PoemMoerationStructure.cs +++ b/GanjooRazor/Models/PoemMoerationStructure.cs @@ -16,5 +16,7 @@ public string[] verseReviewNotes { get; set; } public string poemformatReviewResult { get; set; } public string poemformatReviewNote { get; set; } + public string[] geoTagReviewResult { get; set; } + public string[] geoTagReviewNotes { get; set; } } } diff --git a/RMuseum/Services/Implementation/GanjoorService.cs b/RMuseum/Services/Implementation/GanjoorService.cs index 5ebf182a..6791df8d 100644 --- a/RMuseum/Services/Implementation/GanjoorService.cs +++ b/RMuseum/Services/Implementation/GanjoorService.cs @@ -2358,7 +2358,7 @@ namespace RMuseum.Services.Implementation public async Task> GetPoemEffectiveCorrections(int poemId, PagingParameterModel paging) { var source = from dbCorrection in - _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.GeoDateTags) + _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.GeoDateTags).ThenInclude(g => g.Location) where dbCorrection.PoemId == poemId && @@ -2445,7 +2445,7 @@ namespace RMuseum.Services.Implementation /// public async Task> GetCorrectionById(int id) { - var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.GeoDateTags).Include(c => c.User) + var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.GeoDateTags).ThenInclude(g => g.Location).Include(c => c.User) .Where(c => c.Id == id) .FirstOrDefaultAsync(); @@ -2502,7 +2502,7 @@ namespace RMuseum.Services.Implementation var systemUser = await _appUserService.FindUserByEmail(systemEmail); var systemUserId = systemUser.Result == null ? Guid.Empty : (Guid)systemUser.Result.Id; - var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.GeoDateTags).Include(c => c.User) + var dbCorrection = await _context.GanjoorPoemCorrections.AsNoTracking().Include(c => c.VerseOrderText).Include(c => c.GeoDateTags).ThenInclude(g => g.Location).Include(c => c.User) .Where(c => c.Reviewed == false && (onlyUserCorrections == false || c.UserId != systemUserId)) .OrderBy(c => c.Id) .Skip(skip)