mirror of
https://github.com/grocy/grocy.git
synced 2026-04-07 13:26:14 +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",
|
"RefreshLocaleNumberDisplay",
|
||||||
"RefreshLocaleNumberInput",
|
"RefreshLocaleNumberInput",
|
||||||
"LoadImagesLazy",
|
"LoadImagesLazy",
|
||||||
"GetUriParam",
|
|
||||||
"UpdateUriParam",
|
|
||||||
"RemoveUriParam",
|
|
||||||
"EmptyElementWhenMatches",
|
"EmptyElementWhenMatches",
|
||||||
"animateCSS"
|
"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"))
|
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)
|
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
|
@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>
|
<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>
|
<script>
|
||||||
GrocyClass.createSingleton(GrocyConfig);
|
let viewjsname = null;
|
||||||
|
@hasSection('viewJsName')
|
||||||
|
viejsname = "@yield('viewJsName')";
|
||||||
|
@endif
|
||||||
|
GrocyClass.createSingleton(GrocyConfig, viewjsname);
|
||||||
</script>
|
</script>
|
||||||
@stack('pageScripts')
|
@stack('pageScripts')
|
||||||
|
|
||||||
|
|
@ -690,7 +695,7 @@
|
||||||
@endphp
|
@endphp
|
||||||
|
|
||||||
@stack('componentScripts')
|
@stack('componentScripts')
|
||||||
@hasSection('viewJsName')<script src="{{ $U('/viewjs', true) }}/@yield('viewJsName').js?v={{ $version }}"></script>@endif
|
|
||||||
|
|
||||||
@if(file_exists(GROCY_DATAPATH . '/custom_js.html'))
|
@if(file_exists(GROCY_DATAPATH . '/custom_js.html'))
|
||||||
@php include GROCY_DATAPATH . '/custom_js.html' @endphp
|
@php include GROCY_DATAPATH . '/custom_js.html' @endphp
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user