diff --git a/CMSAdmin/Controllers/CmsAdminApiController.cs b/CMSAdmin/Controllers/CmsAdminApiController.cs index 4ee2e66..8f8e07b 100644 --- a/CMSAdmin/Controllers/CmsAdminApiController.cs +++ b/CMSAdmin/Controllers/CmsAdminApiController.cs @@ -671,6 +671,7 @@ public string GenerateCategoryTagSlug(string TheSlug, string ItemID, string Mode try { Guid currentItemGuid = new Guid(ItemID); var theSlug = CMSConfigHelper.DecodeBase64(TheSlug); + var originalSlug = theSlug; theSlug = ContentPageHelper.ScrubSlug(theSlug).ToLowerInvariant(); var matches = 0; var count = 0; @@ -681,8 +682,10 @@ public string GenerateCategoryTagSlug(string TheSlug, string ItemID, string Mode if (matches > 0) { count = 1; while (count < 2000 && matches > 0) { - theSlug = string.Format("{0}-{1}", theSlug, count); + theSlug = string.Format("{0}-{1}", originalSlug, count); + theSlug = ContentPageHelper.ScrubSlug(theSlug).ToLowerInvariant(); matches = ContentCategory.GetSimilar(siteid, currentItemGuid, theSlug); + count++; } } } @@ -691,8 +694,10 @@ public string GenerateCategoryTagSlug(string TheSlug, string ItemID, string Mode if (matches > 0) { count = 1; while (count < 2000 && matches > 0) { - theSlug = string.Format("{0}-{1}", theSlug, count); + theSlug = string.Format("{0}-{1}", originalSlug, count); + theSlug = ContentPageHelper.ScrubSlug(theSlug).ToLowerInvariant(); matches = ContentTag.GetSimilar(siteid, currentItemGuid, theSlug); + count++; } } } diff --git a/CMSAdmin/Models/ContentPageModel.cs b/CMSAdmin/Models/ContentPageModel.cs index 357662c..f4a72b9 100644 --- a/CMSAdmin/Models/ContentPageModel.cs +++ b/CMSAdmin/Models/ContentPageModel.cs @@ -37,6 +37,7 @@ public ContentPageModel() { public Guid? VersionID { get; set; } public Guid? ParentID { get; set; } public string Mode { get; set; } + public string? SerialCache { get; set; } = string.Empty; public bool VisitPage { get; set; } public Dictionary VersionHistory { get; set; } diff --git a/CMSAdmin/Views/CmsAdmin/BlogPostAddEdit.cshtml b/CMSAdmin/Views/CmsAdmin/BlogPostAddEdit.cshtml index b9b3da0..9616f2d 100644 --- a/CMSAdmin/Views/CmsAdmin/BlogPostAddEdit.cshtml +++ b/CMSAdmin/Views/CmsAdmin/BlogPostAddEdit.cshtml @@ -12,7 +12,7 @@ bool bLocked = Model.ContentPage.IsPageLocked && Model.ContentPage.Heartbeat_UserId.HasValue; } -@section scripts{ +@section scripts { - + + + + *@ @* diff --git a/CMSAdmin/wwwroot/Assets/Admin/Includes/common-utils.js b/CMSAdmin/wwwroot/Assets/Admin/Includes/common-utils.js index 715db3a..d5c0f3c 100644 --- a/CMSAdmin/wwwroot/Assets/Admin/Includes/common-utils.js +++ b/CMSAdmin/wwwroot/Assets/Admin/Includes/common-utils.js @@ -747,8 +747,43 @@ function cmsSetFileNameReturn(v) { //=========================== var cmsConfirmLeavingPage = true; +var cmsContentFormSerial = ''; + +function cmsSerializeForm(frmName) { + if (tinymce) { + tinymce.triggerSave(); + } + return '' + $(frmName + ' input:not(.non-serial-data)').serialize() + '&' + + $(frmName + ' textarea:not(.non-serial-data)').serialize() + ''; +} + +$(document).ready(function () { + setTimeout(function () { + + if ($('#contentForm').length > 0) { + if ($('#SerialCache').val().length < 10) { + cmsContentFormSerial = cmsSerializeForm('#contentForm'); + $('#SerialCache').val(cmsContentFormSerial); + } else { + cmsContentFormSerial = $('#SerialCache').val(); + } + } + }, 500); +}); function cmsGetPageStatus() { + if (cmsConfirmLeavingPage == true) { + var currentSerial = ''; + if (cmsContentFormSerial.length > 0) { + currentSerial = cmsSerializeForm('#contentForm'); + //console.log((currentSerial == cmsContentFormSerial)); + //console.log(currentSerial); + //console.log(cmsContentFormSerial); + + return !(currentSerial == cmsContentFormSerial); + } + } + return cmsConfirmLeavingPage; }