From 2e43b67ba1341a3b83f14ce4f3dad91fe9926172 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Fri, 25 Sep 2026 11:55:54 +0330 Subject: [PATCH] geotag: warning fix --- GanjooRazor/Areas/User/Pages/Editor.cshtml | 2 +- GanjooRazor/Areas/User/Pages/Editor.cshtml.cs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/GanjooRazor/Areas/User/Pages/Editor.cshtml b/GanjooRazor/Areas/User/Pages/Editor.cshtml index ca24b7ea..657405c9 100644 --- a/GanjooRazor/Areas/User/Pages/Editor.cshtml +++ b/GanjooRazor/Areas/User/Pages/Editor.cshtml @@ -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(); diff --git a/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs b/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs index a0568e5b..796f9ed1 100644 --- a/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs +++ b/GanjooRazor/Areas/User/Pages/Editor.cshtml.cs @@ -22,6 +22,18 @@ namespace GanjooRazor.Areas.User.Pages /// public GanjoorPoemCorrectionViewModel MyLastEdit { get; set; } + /// + /// 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. + /// + public string MyLastEditGeoDateTagsJson => + JsonConvert.SerializeObject( + MyLastEdit?.GeoDateTags ?? Array.Empty(), + new JsonSerializerSettings { ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver() } + ); + /// /// page ///