diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index 53558612..b35b6b65 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -81,9 +81,6 @@ view_eslint_config.globals = eslint_config.globals.concat([
"RefreshLocaleNumberDisplay",
"RefreshLocaleNumberInput",
"LoadImagesLazy",
- "GetUriParam",
- "UpdateUriParam",
- "RemoveUriParam",
"EmptyElementWhenMatches",
"animateCSS"
]);
diff --git a/js/grocy.js b/js/grocy.js
index 81490179..4025c6c2 100644
--- a/js/grocy.js
+++ b/js/grocy.js
@@ -237,17 +237,33 @@ class GrocyClass
}
}
- LoadView(viewName)
+ LoadView(viewName, scope = null)
{
if (Object.prototype.hasOwnProperty.call(window, viewName + "View"))
{
- window[viewName + "View"](this);
+ window[viewName + "View"](this, scope);
+ }
+ else
+ {
+ console.error("Could not load view " + viewName + ', not loaded yet.');
}
}
- PreloadView(viewName)
+ PreloadView(viewName, cb = () => { })
{
- $.getScript(this.FormatUrl('/viewjs/' + viewName + '.js'));
+ if (!Object.prototype.hasOwnProperty.call(window, viewName + "View"))
+ {
+ $.ajax({
+ dataType: "script",
+ cache: true,
+ url: this.FormatUrl('/viewjs/' + viewName + '.js'),
+ success: cb
+ });
+ }
+ else
+ {
+ cb();
+ }
}
UndoStockBooking(bookingId)
diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php
index a81cd939..f8dc686e 100644
--- a/views/layout/default.blade.php
+++ b/views/layout/default.blade.php
@@ -655,8 +655,13 @@
@if(!empty($__t('bootstrap-select_locale') && $__t('bootstrap-select_locale') != 'x'))@endif
+ @hasSection('viewJsName')@endif
@stack('pageScripts')
@@ -690,7 +695,7 @@
@endphp
@stack('componentScripts')
- @hasSection('viewJsName')@endif
+
@if(file_exists(GROCY_DATAPATH . '/custom_js.html'))
@php include GROCY_DATAPATH . '/custom_js.html' @endphp