mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 12:26:15 +02:00
View Loading via singleton
This commit is contained in:
parent
4267b42a0a
commit
bda2a742ae
|
|
@ -81,9 +81,6 @@ view_eslint_config.globals = eslint_config.globals.concat([
|
|||
"RefreshLocaleNumberDisplay",
|
||||
"RefreshLocaleNumberInput",
|
||||
"LoadImagesLazy",
|
||||
"GetUriParam",
|
||||
"UpdateUriParam",
|
||||
"RemoveUriParam",
|
||||
"EmptyElementWhenMatches",
|
||||
"animateCSS"
|
||||
]);
|
||||
|
|
|
|||
24
js/grocy.js
24
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)
|
||||
|
|
|
|||
|
|
@ -655,8 +655,13 @@
|
|||
@if(!empty($__t('bootstrap-select_locale') && $__t('bootstrap-select_locale') != 'x'))<script src="{{ $U('/js/locales/bootstrap-select/', true) }}defaults-{{ $__t('bootstrap-select_locale') }}.js?v={{ $version }}"></script>@endif
|
||||
|
||||
<script src="{{ $U('/js/grocy.js?v=', true) }}{{ $version }}"></script>
|
||||
@hasSection('viewJsName')<script src="{{ $U('/viewjs', true) }}/@yield('viewJsName').js?v={{ $version }}"></script>@endif
|
||||
<script>
|
||||
GrocyClass.createSingleton(GrocyConfig);
|
||||
let viewjsname = null;
|
||||
@hasSection('viewJsName')
|
||||
viejsname = "@yield('viewJsName')";
|
||||
@endif
|
||||
GrocyClass.createSingleton(GrocyConfig, viewjsname);
|
||||
</script>
|
||||
@stack('pageScripts')
|
||||
|
||||
|
|
@ -690,7 +695,7 @@
|
|||
@endphp
|
||||
|
||||
@stack('componentScripts')
|
||||
@hasSection('viewJsName')<script src="{{ $U('/viewjs', true) }}/@yield('viewJsName').js?v={{ $version }}"></script>@endif
|
||||
|
||||
|
||||
@if(file_exists(GROCY_DATAPATH . '/custom_js.html'))
|
||||
@php include GROCY_DATAPATH . '/custom_js.html' @endphp
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user