geotag: warning fix

This commit is contained in:
Hamid Reza Mohammadi 2026-09-25 11:55:54 +03:30
parent d39869f6e1
commit 2e43b67ba1
2 changed files with 13 additions and 1 deletions

View File

@ -119,7 +119,7 @@
// ---------- 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 = @Html.Raw(Model.MyLastEdit != null && Model.MyLastEdit.GeoDateTags != null ? Newtonsoft.Json.JsonConvert.SerializeObject(Model.MyLastEdit.GeoDateTags, new Newtonsoft.Json.JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() }) : "[]");
var geoDateTagSuggestions = @Html.Raw(Model.MyLastEditGeoDateTagsJson);
var geoDateTagCoupletTexts = @Html.Raw(Newtonsoft.Json.JsonConvert.SerializeObject(Model.Couplets.ToDictionary(c => c.Item1.ToString(), c => c.Item2)));
$(document).ready(function () {
renderPendingGeoDateTags();

View File

@ -22,6 +22,18 @@ namespace GanjooRazor.Areas.User.Pages
/// </summary>
public GanjoorPoemCorrectionViewModel MyLastEdit { get; set; }
/// <summary>
/// camelCase JSON of MyLastEdit.GeoDateTags, pre-serialized here (rather than inline in the .cshtml
/// script block) so the Razor page doesn't embed a C# object-initializer (with its own braces) inside
/// a JS statement - that combination was tripping the editor's JS/TS syntax check (TS1109) even though
/// it compiled and ran fine.
/// </summary>
public string MyLastEditGeoDateTagsJson =>
JsonConvert.SerializeObject(
MyLastEdit?.GeoDateTags ?? Array.Empty<GanjoorPoemGeoDateTagCorrection>(),
new JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() }
);
/// <summary>
/// page
/// </summary>