From 252fa3e35724fadca6be9a89013c519e8fabbccb Mon Sep 17 00:00:00 2001 From: NLilley Date: Wed, 30 Oct 2024 15:40:52 +0200 Subject: [PATCH 1/6] Move default behavior into passed-in configuration settings. --- .gitignore | 3 ++ Griddly/Scripts/griddly.js | 64 +++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 28 deletions(-) diff --git a/.gitignore b/.gitignore index ed31553..bb01cf9 100644 --- a/.gitignore +++ b/.gitignore @@ -50,3 +50,6 @@ _ReSharper*/ packages/ .vs #/.nuget/NuGet.exe + +# JetBrains Rider exclusion +/.idea \ No newline at end of file diff --git a/Griddly/Scripts/griddly.js b/Griddly/Scripts/griddly.js index 79bc9e1..0bcf344 100644 --- a/Griddly/Scripts/griddly.js +++ b/Griddly/Scripts/griddly.js @@ -50,7 +50,7 @@ return val; case "Date": - return String(val).replace(/[^0-9a-zA-Z-\/]/g, ""); + return $.fn.griddly.defaults.getCleanedDate(val); default: return val; } @@ -122,12 +122,7 @@ return val; case "Date": - val = parseForValidDate(val); - - if (val == null || !isFinite(val)) - return null; - else - return (val.getMonth() + 1) + "/" + val.getDate() + "/" + val.getFullYear(); + return $.fn.griddly.defaults.getFormattedDate(val); default: return val; } @@ -347,26 +342,7 @@ switch (datatype) { case "Date": - var date; - var pos; - - if (typeof (value) === "string" && (pos = value.indexOf("T")) != -1) - { - value = value.substr(0, pos); - - // Strip time, we only want date - var parts = value.split('-'); - - // new Date(year, month [, day [, hours[, minutes[, seconds[, ms]]]]]) - date = new Date(parts[0], parts[1] - 1, parts[2]); // Note: months are 0-based - } - else - date = new Date(value); - - date.setHours(0, 0, 0, 0); - - value = date.toLocaleDateString(); - + value = $.fn.griddly.defaults.getFilterDate(value); break; case "Currency": value = parseFloat(value).toFixed(2); @@ -2044,6 +2020,35 @@ return this; }; + const defaultCleanedDate = str => String(str).replace(/[^0-9a-zA-Z-\/]/g, ""); + const defaultFormatedDate = str => { + var val = parseForValidDate(str); + return (val == null || !isFinite(val)) + ? null + : (val.getMonth() + 1) + "/" + val.getDate() + "/" + val.getFullYear(); + }; + const defaultFilterDate = strOrDate => { + var date; + var pos; + + if (typeof (strOrDate) === "string" && (pos = strOrDate.indexOf("T")) != -1) + { + strOrDate = strOrDate.substr(0, pos); + + // Strip time, we only want date + var parts = strOrDate.split('-'); + + // new Date(year, month [, day [, hours[, minutes[, seconds[, ms]]]]]) + date = new Date(parts[0], parts[1] - 1, parts[2]); // Note: months are 0-based + } + else + date = new Date(strOrDate); + + date.setHours(0, 0, 0, 0); + + return date.toLocaleDateString(); + }; + $.fn.griddly.defaults = $.extend({}, { pageNumber: 0, @@ -2065,7 +2070,10 @@ serializeSkipEmpty: true, filtersSelector: "input[name], select[name]", exportCustomFunction: null, - exportFunction: null + exportFunction: null, + getCleanedDate: defaultCleanedDate, + getFormattedDate: defaultFormatedDate, + getFilterDate: defaultFilterDate }, $.fn.griddlyGlobalDefaults); var GriddlyFilterBar = function (element, options) From c73adb62201e56e9fe2946cf1a7b3367582ed614 Mon Sep 17 00:00:00 2001 From: NLilley Date: Wed, 30 Oct 2024 15:48:41 +0200 Subject: [PATCH 2/6] Actually build the app --- Griddly.NetCore.Razor/wwwroot/js/griddly.js | 64 ++++++++++++--------- 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/Griddly.NetCore.Razor/wwwroot/js/griddly.js b/Griddly.NetCore.Razor/wwwroot/js/griddly.js index 79bc9e1..0bcf344 100644 --- a/Griddly.NetCore.Razor/wwwroot/js/griddly.js +++ b/Griddly.NetCore.Razor/wwwroot/js/griddly.js @@ -50,7 +50,7 @@ return val; case "Date": - return String(val).replace(/[^0-9a-zA-Z-\/]/g, ""); + return $.fn.griddly.defaults.getCleanedDate(val); default: return val; } @@ -122,12 +122,7 @@ return val; case "Date": - val = parseForValidDate(val); - - if (val == null || !isFinite(val)) - return null; - else - return (val.getMonth() + 1) + "/" + val.getDate() + "/" + val.getFullYear(); + return $.fn.griddly.defaults.getFormattedDate(val); default: return val; } @@ -347,26 +342,7 @@ switch (datatype) { case "Date": - var date; - var pos; - - if (typeof (value) === "string" && (pos = value.indexOf("T")) != -1) - { - value = value.substr(0, pos); - - // Strip time, we only want date - var parts = value.split('-'); - - // new Date(year, month [, day [, hours[, minutes[, seconds[, ms]]]]]) - date = new Date(parts[0], parts[1] - 1, parts[2]); // Note: months are 0-based - } - else - date = new Date(value); - - date.setHours(0, 0, 0, 0); - - value = date.toLocaleDateString(); - + value = $.fn.griddly.defaults.getFilterDate(value); break; case "Currency": value = parseFloat(value).toFixed(2); @@ -2044,6 +2020,35 @@ return this; }; + const defaultCleanedDate = str => String(str).replace(/[^0-9a-zA-Z-\/]/g, ""); + const defaultFormatedDate = str => { + var val = parseForValidDate(str); + return (val == null || !isFinite(val)) + ? null + : (val.getMonth() + 1) + "/" + val.getDate() + "/" + val.getFullYear(); + }; + const defaultFilterDate = strOrDate => { + var date; + var pos; + + if (typeof (strOrDate) === "string" && (pos = strOrDate.indexOf("T")) != -1) + { + strOrDate = strOrDate.substr(0, pos); + + // Strip time, we only want date + var parts = strOrDate.split('-'); + + // new Date(year, month [, day [, hours[, minutes[, seconds[, ms]]]]]) + date = new Date(parts[0], parts[1] - 1, parts[2]); // Note: months are 0-based + } + else + date = new Date(strOrDate); + + date.setHours(0, 0, 0, 0); + + return date.toLocaleDateString(); + }; + $.fn.griddly.defaults = $.extend({}, { pageNumber: 0, @@ -2065,7 +2070,10 @@ serializeSkipEmpty: true, filtersSelector: "input[name], select[name]", exportCustomFunction: null, - exportFunction: null + exportFunction: null, + getCleanedDate: defaultCleanedDate, + getFormattedDate: defaultFormatedDate, + getFilterDate: defaultFilterDate }, $.fn.griddlyGlobalDefaults); var GriddlyFilterBar = function (element, options) From e90b61829e22ecb9e23a348b1791a60ec958b7e8 Mon Sep 17 00:00:00 2001 From: NLilley Date: Wed, 30 Oct 2024 16:09:47 +0200 Subject: [PATCH 3/6] Fix some bundler issues --- Griddly/Scripts/griddly.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Griddly/Scripts/griddly.js b/Griddly/Scripts/griddly.js index 0bcf344..c69a9aa 100644 --- a/Griddly/Scripts/griddly.js +++ b/Griddly/Scripts/griddly.js @@ -310,7 +310,6 @@ // http://stackoverflow.com/q/8098202 var parseForValidDate = function (text) { - var date = Date.parse(text); if (isNaN(date)) @@ -2020,14 +2019,14 @@ return this; }; - const defaultCleanedDate = str => String(str).replace(/[^0-9a-zA-Z-\/]/g, ""); - const defaultFormatedDate = str => { + var defaultCleanedDate = function(str) {return String(str).replace(/[^0-9a-zA-Z-\/]/g, "");}; + var defaultFormatedDate = function(str) { var val = parseForValidDate(str); return (val == null || !isFinite(val)) ? null : (val.getMonth() + 1) + "/" + val.getDate() + "/" + val.getFullYear(); }; - const defaultFilterDate = strOrDate => { + var defaultFilterDate = function(strOrDate) { var date; var pos; From 7febc0bcf12377bd596dbcd33276f021f5d29f9e Mon Sep 17 00:00:00 2001 From: NLilley Date: Wed, 30 Oct 2024 16:10:12 +0200 Subject: [PATCH 4/6] ...and remember to build --- Griddly.NetCore.Razor/wwwroot/js/griddly.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/Griddly.NetCore.Razor/wwwroot/js/griddly.js b/Griddly.NetCore.Razor/wwwroot/js/griddly.js index 0bcf344..c69a9aa 100644 --- a/Griddly.NetCore.Razor/wwwroot/js/griddly.js +++ b/Griddly.NetCore.Razor/wwwroot/js/griddly.js @@ -310,7 +310,6 @@ // http://stackoverflow.com/q/8098202 var parseForValidDate = function (text) { - var date = Date.parse(text); if (isNaN(date)) @@ -2020,14 +2019,14 @@ return this; }; - const defaultCleanedDate = str => String(str).replace(/[^0-9a-zA-Z-\/]/g, ""); - const defaultFormatedDate = str => { + var defaultCleanedDate = function(str) {return String(str).replace(/[^0-9a-zA-Z-\/]/g, "");}; + var defaultFormatedDate = function(str) { var val = parseForValidDate(str); return (val == null || !isFinite(val)) ? null : (val.getMonth() + 1) + "/" + val.getDate() + "/" + val.getFullYear(); }; - const defaultFilterDate = strOrDate => { + var defaultFilterDate = function(strOrDate) { var date; var pos; From 51bd12c51377205f98d5f448556200d3ad3e4a09 Mon Sep 17 00:00:00 2001 From: NLilley Date: Wed, 30 Oct 2024 18:16:55 +0200 Subject: [PATCH 5/6] Remember to bump version --- Build/CommonAssemblyInfo.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Build/CommonAssemblyInfo.cs b/Build/CommonAssemblyInfo.cs index a3886a9..cb7533a 100644 --- a/Build/CommonAssemblyInfo.cs +++ b/Build/CommonAssemblyInfo.cs @@ -12,7 +12,7 @@ // Minor Version // Build Number // Revision -[assembly: AssemblyVersion("3.7.8")] -[assembly: AssemblyFileVersion("3.7.8")] +[assembly: AssemblyVersion("3.8.0")] +[assembly: AssemblyFileVersion("3.8.0")] // Uncomment the informational version to create a pre-release package //[assembly: AssemblyInformationalVersion("3.7.8-beta")] From c23ceeef68037b672e9337181fad6797d08d5d3d Mon Sep 17 00:00:00 2001 From: NLilley Date: Thu, 31 Oct 2024 15:09:15 +0200 Subject: [PATCH 6/6] Fix version number --- Build/CommonAssemblyInfo.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Build/CommonAssemblyInfo.cs b/Build/CommonAssemblyInfo.cs index cb7533a..5ec4aab 100644 --- a/Build/CommonAssemblyInfo.cs +++ b/Build/CommonAssemblyInfo.cs @@ -12,7 +12,7 @@ // Minor Version // Build Number // Revision -[assembly: AssemblyVersion("3.8.0")] -[assembly: AssemblyFileVersion("3.8.0")] +[assembly: AssemblyVersion("3.7.9")] +[assembly: AssemblyFileVersion("3.7.9")] // Uncomment the informational version to create a pre-release package -//[assembly: AssemblyInformationalVersion("3.7.8-beta")] +//[assembly: AssemblyInformationalVersion("3.7.9-beta")]