From 292cfdf74930c79018af8110caf4fa4e5b5a8e1e Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 26 Feb 2024 20:40:35 +0100 Subject: [PATCH 1/5] converters / datetime - when an epoch is offered as number, make sure to convert to moment() before sending it to the client. Adds support for datetime fields as integer/float data. --- src/public.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/public.js b/src/public.js index b5b3e88..7015126 100644 --- a/src/public.js +++ b/src/public.js @@ -264,6 +264,9 @@ Grid.defaults = { return value ? moment(parseInt(value)*1000) : ""; }, to: function (value) { + if (!Object.is(value)) { + value = moment(parseInt(value)*1000); + } return value ? value.format("lll") : ""; } }, From 96d071b1f19316c6a706a509eb593d83c7d13868 Mon Sep 17 00:00:00 2001 From: Stephan de Wit Date: Wed, 17 Apr 2024 16:32:34 +0200 Subject: [PATCH 2/5] converters / datetime - fix object check (#7) Object.is() checks equality between two parameters, not whether the variable is an object, better to use the built-in moment method for this. --- src/public.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public.js b/src/public.js index 7015126..02256f2 100644 --- a/src/public.js +++ b/src/public.js @@ -264,7 +264,7 @@ Grid.defaults = { return value ? moment(parseInt(value)*1000) : ""; }, to: function (value) { - if (!Object.is(value)) { + if (!moment.isMoment(value)) { value = moment(parseInt(value)*1000); } return value ? value.format("lll") : ""; From c12ecbbf684b1cee75292a367ba50579d146f97f Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Wed, 17 Apr 2024 16:35:28 +0200 Subject: [PATCH 3/5] dist: sync with https://github.com/opnsense/jquery-bootgrid/pull/7 --- dist/jquery.bootgrid.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js index d8b6e72..6d2a001 100644 --- a/dist/jquery.bootgrid.js +++ b/dist/jquery.bootgrid.js @@ -1239,6 +1239,9 @@ Grid.defaults = { return value ? moment(parseInt(value)*1000) : ""; }, to: function (value) { + if (!moment.isMoment(value)) { + value = moment(parseInt(value)*1000); + } return value ? value.format("lll") : ""; } }, From 6a7d7284a233fc2ae5ee3fef17debc9a48c05999 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Mon, 2 Dec 2024 16:55:20 +0100 Subject: [PATCH 4/5] use fontawesome 6 icons --- dist/jquery.bootgrid.css | 8 +++++--- src/public.js | 12 ++++++------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/dist/jquery.bootgrid.css b/dist/jquery.bootgrid.css index 1803491..18111da 100644 --- a/dist/jquery.bootgrid.css +++ b/dist/jquery.bootgrid.css @@ -18,12 +18,14 @@ vertical-align: middle; width: 180px; } -.bootgrid-header .search .glyphicon, -.bootgrid-footer .search .glyphicon { +.bootgrid-header .search .fa-solid, +.bootgrid-footer .search .fa-solid { top: 0; } .bootgrid-header .search .fa, -.bootgrid-footer .search .fa { +.bootgrid-header .search .fa-solid, +.bootgrid-footer .search .fa, +.bootgrid-footer .search .fa-solid { display: table-cell; } .bootgrid-header .search.search-field::-ms-clear, diff --git a/src/public.js b/src/public.js index 02256f2..2d143c4 100644 --- a/src/public.js +++ b/src/public.js @@ -327,12 +327,12 @@ Grid.defaults = { dropDownMenuText: "dropdown-text", // must be a unique class name or constellation of class names within the actionDropDown footer: "bootgrid-footer container-fluid", header: "bootgrid-header container-fluid", - icon: "icon glyphicon", - iconColumns: "glyphicon-th-list", - iconDown: "glyphicon-chevron-down", - iconRefresh: "glyphicon-refresh", - iconSearch: "glyphicon-search", - iconUp: "glyphicon-chevron-up", + icon: "icon fa-solid", + iconColumns: "fa-list", + iconDown: "fa-chevron-down", + iconRefresh: "fa-arrows-rotate", + iconSearch: "fa-magnifying-glass", + iconUp: "fa-chevron-up", infos: "infos", // must be a unique class name or constellation of class names within the header and footer, left: "text-left", pagination: "pagination", // must be a unique class name or constellation of class names within the header and footer From 747890a640e859adc0e1e10f54a0f0e502e96962 Mon Sep 17 00:00:00 2001 From: Stephan de Wit Date: Wed, 19 Mar 2025 09:08:40 +0100 Subject: [PATCH 5/5] provide option for initial search phrase (#8) --- dist/jquery.bootgrid.js | 7 +++++-- src/internal.js | 5 ++++- src/public.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/dist/jquery.bootgrid.js b/dist/jquery.bootgrid.js index 6d2a001..5b3769d 100644 --- a/dist/jquery.bootgrid.js +++ b/dist/jquery.bootgrid.js @@ -728,12 +728,15 @@ function renderSearchField() var that = this, tpl = this.options.templates, timer = null, // fast keyup detection - currentValue = "", + currentValue = this.searchPhrase, searchFieldSelector = getCssSelector(css.searchField), search = $(tpl.search.resolve(getParams.call(this))), searchField = (search.is(searchFieldSelector)) ? search : search.find(searchFieldSelector); + // populate search field if initial search phrase provided + $(searchField).val(currentValue); + searchField.on("keyup" + namespace, function (e) { e.stopPropagation(); @@ -1000,7 +1003,7 @@ var Grid = function(element, options) this.converter = null; // The converter for the column that is marked as identifier this.rowCount = ($.isArray(rowCount)) ? rowCount[0] : rowCount; this.rows = []; - this.searchPhrase = ""; + this.searchPhrase = this.options.initialSearchPhrase || ""; this.selectedRows = []; this.sortDictionary = {}; this.total = 0; diff --git a/src/internal.js b/src/internal.js index 0cebaf7..98a648e 100644 --- a/src/internal.js +++ b/src/internal.js @@ -718,12 +718,15 @@ function renderSearchField() var that = this, tpl = this.options.templates, timer = null, // fast keyup detection - currentValue = "", + currentValue = this.searchPhrase, searchFieldSelector = getCssSelector(css.searchField), search = $(tpl.search.resolve(getParams.call(this))), searchField = (search.is(searchFieldSelector)) ? search : search.find(searchFieldSelector); + // populate search field if initial search phrase provided + $(searchField).val(currentValue); + searchField.on("keyup" + namespace, function (e) { e.stopPropagation(); diff --git a/src/public.js b/src/public.js index 2d143c4..62bd50a 100644 --- a/src/public.js +++ b/src/public.js @@ -25,7 +25,7 @@ var Grid = function(element, options) this.converter = null; // The converter for the column that is marked as identifier this.rowCount = ($.isArray(rowCount)) ? rowCount[0] : rowCount; this.rows = []; - this.searchPhrase = ""; + this.searchPhrase = this.options.initialSearchPhrase || ""; this.selectedRows = []; this.sortDictionary = {}; this.total = 0;