diff --git a/GanjooRazor/Areas/User/Pages/Editor.cshtml b/GanjooRazor/Areas/User/Pages/Editor.cshtml index ce37061b..4ddd239c 100644 --- a/GanjooRazor/Areas/User/Pages/Editor.cshtml +++ b/GanjooRazor/Areas/User/Pages/Editor.cshtml @@ -116,6 +116,115 @@ + // ---------- geo/date tag suggestions ---------- + // staged client-side until the main save; each item matches + // GanjoorPoemGeoDateTagCorrection's shape so it can be sent as-is + var geoDateTagSuggestions = []; + var geoDateTagMap = null; + var geoDateTagMarker = null; + + function toggleNewLocationMap() { + var widget = document.getElementById('new-location-widget'); + var isHidden = widget.style.display === 'none' || widget.style.display === ''; + widget.style.display = isHidden ? 'block' : 'none'; + if (isHidden && geoDateTagMap == null) { + geoDateTagMap = L.map('geotag-map').setView([32.4279, 53.6880], 5); // Iran-centered default + L.tileLayer.provider('OpenStreetMap').addTo(geoDateTagMap); + geoDateTagMap.on('click', function (e) { + if (geoDateTagMarker != null) { + geoDateTagMap.removeLayer(geoDateTagMarker); + } + geoDateTagMarker = L.marker(e.latlng).addTo(geoDateTagMap); + document.getElementById('geotag-new-location-lat').value = e.latlng.lat; + document.getElementById('geotag-new-location-lng').value = e.latlng.lng; + }); + } + if (isHidden && geoDateTagMap != null) { + setTimeout(function () { geoDateTagMap.invalidateSize(); }, 100); + } + } + + function renderPendingGeoDateTags() { + var container = document.getElementById('pending-geotag-suggestions'); + if (geoDateTagSuggestions.length == 0) { + container.innerHTML = ''; + return; + } + var html = ''; + for (var i = 0; i < geoDateTagSuggestions.length; i++) { + var s = geoDateTagSuggestions[i]; + var status = s.markForDelete ? '🗑️ درخواست حذف' : '➕ پیشنهاد جدید'; + var locationText = s.markForDelete ? '' : (s.locationId ? $('#geotag-location-select option[value="' + s.locationId + '"]').text() : (s.suggestedLocationName || '')); + html += '' + + ''; + } + html += '
وضعیتمکانسالماهروز#
' + status + '' + locationText + '' + (s.lunarYear || '') + '' + (s.lunarMonth || '') + '' + (s.lunarDay || '') + '✕ حذف از فهرست
'; + container.innerHTML = html; + } + + function removeGeoDateTagSuggestion(index) { + geoDateTagSuggestions.splice(index, 1); + renderPendingGeoDateTags(); + } + + function requestDeleteExistingGeoDateTag(existingTagId, el) { + geoDateTagSuggestions.push({ + markForDelete: true, + existingTagId: existingTagId + }); + $(el).closest('tr').hide(); + renderPendingGeoDateTags(); + } + + function addGeoDateTagSuggestion() { + var locationId = $('#geotag-location-select').val(); + var newLocationName = $('#geotag-new-location-name').val(); + var newLocationLat = $('#geotag-new-location-lat').val(); + var newLocationLng = $('#geotag-new-location-lng').val(); + var year = $('#geotag-year').val(); + var month = $('#geotag-month').val(); + var day = $('#geotag-day').val(); + + var hasLocation = (locationId && locationId != '') || (newLocationName && newLocationLat && newLocationLng); + var hasDate = year && year != ''; + + if (!hasLocation && !hasDate) { + upToast('لطفاً حداقل یک مکان یا سال وارد کنید.', 'error'); + return; + } + + geoDateTagSuggestions.push({ + markForDelete: false, + locationId: (locationId && locationId != '') ? parseInt(locationId) : null, + suggestedLocationName: (!locationId || locationId == '') ? (newLocationName || null) : null, + suggestedLatitude: (!locationId || locationId == '') && newLocationLat ? parseFloat(newLocationLat) : null, + suggestedLongitude: (!locationId || locationId == '') && newLocationLng ? parseFloat(newLocationLng) : null, + lunarYear: year ? parseInt(year) : null, + lunarMonth: month ? parseInt(month) : null, + lunarDay: day ? parseInt(day) : null, + ignoreInCategory: $('#geotag-ignore-in-category').is(':checked'), + suggestionNote: $('#geotag-note').val() || null + }); + + // reset the form for the next entry + $('#geotag-location-select').val(''); + $('#geotag-new-location-name').val(''); + $('#geotag-new-location-lat').val(''); + $('#geotag-new-location-lng').val(''); + $('#geotag-year').val(''); + $('#geotag-month').val(''); + $('#geotag-day').val(''); + $('#geotag-ignore-in-category').prop('checked', false); + $('#geotag-note').val(''); + if (geoDateTagMarker != null && geoDateTagMap != null) { + geoDateTagMap.removeLayer(geoDateTagMarker); + geoDateTagMarker = null; + } + + renderPendingGeoDateTags(); + upToast('به فهرست پیشنهادها افزوده شد. برای ثبت نهایی، دکمهٔ «ذخیره» را بزنید.'); + } + function savePoemCorrections(id, verseCount) { var verseOrderText = []; var verseOrderMarkedForDelete = []; @@ -173,7 +282,7 @@ section_format = null; } - if (verseOrderText.length == 0 && verseOrderSummaries.length == 0) { + if (verseOrderText.length == 0 && verseOrderSummaries.length == 0 && geoDateTagSuggestions.length == 0) { if (rhythm_new == null && rhythm_new2 == null && rhyme_letters == null && section_format == null) { upToast('شما هیچ تغییری در اطلاعات نداده‌اید!', 'error'); return; @@ -196,6 +305,7 @@ pcs.verseLanguages = verseLanguages; pcs.note = $('#note').val(); pcs.hideMyName = $('#hide-my-name').is(":checked"); + pcs.geoDateTags = geoDateTagSuggestions; var url = '?handler=SendPoemCorrections'; @@ -1526,6 +1636,156 @@ else

 

+
+

🗺️ برچسب‌های زمان و مکان (پیشنهادی)

+

می‌توانید پیشنهاد دهید که این شعر به مکان یا تاریخ خاصی اشاره دارد. پیشنهادهای شما پس از بررسی ناظران اعمال خواهد شد. با دکمهٔ «ذخیره» بالا همراه با بقیهٔ تغییرات ثبت می‌شود.

+ + @if (Model.PoemGeoDateTags != null && Model.PoemGeoDateTags.Any()) + { + + + + + + + + + @foreach (var tag in Model.PoemGeoDateTags) + { + + + + + + + + } +
مکانسالماهروز#
@($"{(tag.Location == null ? "" : tag.Location.Name)}")@tag.LunarYear + @{ + switch (tag.LunarMonth) + { + case 1: + @("محرم") + ; + break; + case 2: + @("صفر") + ; + break; + case 3: + @("ربیع‌الاول") + ; + break; + case 4: + @("ربیع‌الثانی") + ; + break; + case 5: + @("جمادی‌الاول") + ; + break; + case 6: + @("جمادی‌الثانی") + ; + break; + case 7: + @("رجب") + ; + break; + case 8: + @("شعبان") + ; + break; + case 9: + @("رمضان") + ; + break; + case 10: + @("شوال") + ; + break; + case 11: + @("ذیقعده") + ; + break; + case 12: + @("ذیحجه") + ; + break; + } + } + @tag.LunarDay + 🗑️ درخواست حذف +
+ } + +
+ +
+ + + 📍 مکان جدید پیشنهاد بده +
+ + + +
+
+ + +
+
+ + +
+
+ + +
+
+ +
+ + +
+ +
+ + +
+ + ➕ افزودن به فهرست پیشنهادها +
+ @if (Model.ShowAdminOps) {
diff --git a/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs b/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs index 6b1cb402..408cb523 100644 --- a/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs +++ b/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs @@ -314,6 +314,7 @@ namespace GanjooRazor.Areas.User.Pages public string[] verseLanguages { get; set; } public string note { get; set; } public bool hideMyName { get; set; } + public RMuseum.Models.Ganjoor.GanjoorPoemGeoDateTagCorrection[] geoDateTags { get; set; } } public async Task OnPostSendPoemCorrectionsAsync([FromBody] PoemCorrectionStructure pcs) @@ -470,7 +471,8 @@ namespace GanjooRazor.Areas.User.Pages PoemFormat = string.IsNullOrEmpty(pcs.format) ? (GanjoorPoemFormat?)null : (GanjoorPoemFormat)Enum.Parse(typeof(GanjoorPoemFormat), pcs.format), PoemSummary = poemSummary, Note = pcs.note, - HideMyName = pcs.hideMyName + HideMyName = pcs.hideMyName, + GeoDateTags = pcs.geoDateTags }; HttpResponseMessage response = await secureClient.PostAsync( diff --git a/GanjooRazor/Pages/Shared/_UserPanelLayout.cshtml b/GanjooRazor/Pages/Shared/_UserPanelLayout.cshtml index 69161c6c..443c06e7 100644 --- a/GanjooRazor/Pages/Shared/_UserPanelLayout.cshtml +++ b/GanjooRazor/Pages/Shared/_UserPanelLayout.cshtml @@ -11,9 +11,12 @@ + + +