diff --git a/js/grocy.js b/js/grocy.js index 9debfddf..0ac8bc8a 100644 --- a/js/grocy.js +++ b/js/grocy.js @@ -378,6 +378,10 @@ class GrocyClass grocyProxy.Initialize(proxy); self.LoadView(data.viewJsName, "#" + scopeId, proxy); }, + onShown: () => + { + grocyProxy.FrontendHelpers.OnShown(); + }, onHide: () => { grocyProxy.Unload(); @@ -388,10 +392,16 @@ class GrocyClass } }); }, - error: (xhr, text, data) => { console.error(text); } + error: (xhr, text, data) => + { + console.error(text); + } }) + } - + Unload() + { + return; // root grocy instances never get unloaded. } UndoStockBooking(bookingId) diff --git a/js/helpers/frontend.js b/js/helpers/frontend.js index 90084be1..456ce53d 100644 --- a/js/helpers/frontend.js +++ b/js/helpers/frontend.js @@ -20,6 +20,7 @@ class GrocyFrontendHelpers } this.dropdowns = {} + this.dataTables = []; this.InitDropdowns(); } @@ -249,6 +250,7 @@ class GrocyFrontendHelpers InitDataTable(dataTable, searchFunction = null, clearFunction = null) { + this.dataTables.push(dataTable); dataTable.columns.adjust().draw(); var self = this; @@ -275,6 +277,16 @@ class GrocyFrontendHelpers self.$scope("#clear-filter-button").on("click", clearFunction || defaultClearFunction); } + // This method is called if this FrontendHelper is scoped to a modal + // and the modal is acutally shown. + OnShown() + { + for (let table of this.dataTables) + { + table.columns.adjust(); + } + } + MakeFilterForColumn(selector, column, table, filterFunction = null, transferCss = false, valueMod = null) { var self = this; diff --git a/js/lib/proxy.js b/js/lib/proxy.js index 4b6ec2a7..d97a7e52 100644 --- a/js/lib/proxy.js +++ b/js/lib/proxy.js @@ -44,6 +44,8 @@ class GrocyProxy Object.assign(this.config.UserSettings, RootGrocy.UserSettings); this.UserSettings = config.UserSettings; } + + this.unloaders = []; } Initialize(proxy) @@ -55,6 +57,11 @@ class GrocyProxy this.FrontendHelpers = new GrocyFrontendHelpers(proxy, this.RootGrocy.Api, this.scopeSelector); } + RegisterUnload(cb) + { + this.unloaders.push(cb); + } + Unload() { for (let component in this.Components) @@ -65,6 +72,13 @@ class GrocyProxy comp.Unload(); } } + + let unloader = this.unloaders.pop(); + while (unloader !== undefined) + { + unloader(); + unloader = this.unloaders.pop(); + } } Use(componentName, scope = null) diff --git a/js/viewjs/stockentries.js b/js/viewjs/stockentries.js index fd2b8f60..17114224 100644 --- a/js/viewjs/stockentries.js +++ b/js/viewjs/stockentries.js @@ -34,7 +34,7 @@ $scope('#stockentries-table tbody').removeClass("d-none"); stockEntriesTable.columns.adjust().draw(); - $.fn.dataTable.ext.search.push(function(settings, data, dataIndex) + var moreSearch = function(settings, data, dataIndex) { var productId = productpicker.GetValue(); @@ -44,6 +44,16 @@ } return false; + }; + + $.fn.dataTable.ext.search.push(moreSearch); + + + Grocy.RegisterUnload(() => + { + var funcIdx = $.fn.dataTable.ext.search.indexOf(moreSearch); + if (funcIdx !== -1) + $.fn.dataTable.ext.search.splice(funcIdx); }); $scope("#clear-filter-button").on("click", function() diff --git a/localization/strings.pot b/localization/strings.pot index de205034..8c0cd933 100644 --- a/localization/strings.pot +++ b/localization/strings.pot @@ -2150,3 +2150,9 @@ msgstr "" msgid "Unable to print" msgstr "" + +msgid "Datum 1" +msgstr "" + +msgid "Datum ohne Zeit" +msgstr "" diff --git a/views/stockjournalsummary.blade.php b/views/stockjournalsummary.blade.php index 93857d4b..3ac11cc1 100644 --- a/views/stockjournalsummary.blade.php +++ b/views/stockjournalsummary.blade.php @@ -4,12 +4,17 @@ @section('activeNav', '') @section('viewJsName', 'stockjournalsummary') +@php +$collapsed_none = $embedded ? '' : 'd-md-none'; +$collapsed_flex = $embedded ? '' : 'd-md-flex'; +@endphp + @section('content')

@yield('title')

-