diff --git a/js/components/batterycard.js b/js/components/batterycard.js index 321b2ae7..1419b59c 100644 --- a/js/components/batterycard.js +++ b/js/components/batterycard.js @@ -9,7 +9,8 @@ class batterycard this.scopeSelector = scopeSelector; this.scope = scopeSelector != null ? $(scopeSelector) : $(document); - var jScope = this.scope; \n\tthis.$ = scopeSelector != null ? (selector) => jScope.find(selector) : $; + var jScope = this.scope; + this.$ = scopeSelector != null ? (selector) => jScope.find(selector) : $; } Refresh(batteryId) diff --git a/js/components/calendarcard.js b/js/components/calendarcard.js index 9ec73e00..1fa65e18 100644 --- a/js/components/calendarcard.js +++ b/js/components/calendarcard.js @@ -6,7 +6,8 @@ class calendarcard this.scopeSelector = scopeSelector; this.scope = scopeSelector != null ? $(scopeSelector) : $(document); - var jScope = this.scope; \n\tthis.$ = scopeSelector != null ? (selector) => jScope.find(selector) : $; + var jScope = this.scope; + this.$ = scopeSelector != null ? (selector) => jScope.find(selector) : $; this.$('#calendar').datetimepicker( { diff --git a/js/components/chorecard.js b/js/components/chorecard.js index 16bc725e..441c5ff0 100644 --- a/js/components/chorecard.js +++ b/js/components/chorecard.js @@ -9,7 +9,8 @@ class chorecard this.scopeSelector = scopeSelector; this.scope = scopeSelector != null ? $(scopeSelector) : $(document); - var jScope = this.scope; \n\tthis.$ = scopeSelector != null ? (selector) => jScope.find(selector) : $; + var jScope = this.scope; + this.$ = scopeSelector != null ? (selector) => jScope.find(selector) : $; } Refresh(choreId) diff --git a/js/grocy.js b/js/grocy.js index 7de7435e..9776f3b4 100644 --- a/js/grocy.js +++ b/js/grocy.js @@ -46,6 +46,9 @@ class GrocyClass this.RecipePictureFileName = config.RecipePictureFileName; this.InstructionManualFileNameName = config.InstructionManualFileNameName; this.Locale = config.Locale; + this.fullcalendarEventSources = config.fullcalendarEventSources; + this.internalRecipes = config.internalRecipes; + this.recipesResolved = config.recipesResolved; this.Components = {}; this.initComponents = []; diff --git a/js/viewjs/calendar.js b/js/viewjs/calendar.js index f941364c..0e4c779f 100644 --- a/js/viewjs/calendar.js +++ b/js/viewjs/calendar.js @@ -1,6 +1,4 @@  -/* global fullcalendarEventSources */ - import { Calendar } from '@fullcalendar/core'; import dayGridPlugin from '@fullcalendar/daygrid'; import bootstrapPlugin from '@fullcalendar/bootstrap'; @@ -38,7 +36,7 @@ function calendarView(Grocy, scope = null) firstDay: firstDay, eventLimit: false, height: "auto", - events: fullcalendarEventSources, + events: Grocy.fullcalendarEventSources, // fullcalendar 4 doesn't translate the default view names (?) // so we have to supply our own. views: { diff --git a/js/viewjs/mealplan.js b/js/viewjs/mealplan.js index 0e975d29..96c9fad5 100644 --- a/js/viewjs/mealplan.js +++ b/js/viewjs/mealplan.js @@ -1,6 +1,4 @@ -/* global fullcalendarEventSources, internalRecipes, recipesResolved */ - -import { Calendar } from '@fullcalendar/core'; +import { Calendar } from '@fullcalendar/core'; import dayGridPlugin from '@fullcalendar/daygrid'; import bootstrapPlugin from '@fullcalendar/bootstrap'; import momentPlugin from '@fullcalendar/moment/main'; @@ -57,7 +55,7 @@ function mealplanView(Grocy, scope = null) }, weekNumbers: false, eventLimit: false, - events: fullcalendarEventSources, + events: Grocy.fullcalendarEventSources, defaultView: (viewport.width() < 768) ? "dayGridDay" : "dayGridWeek", firstDay: firstDay, height: "auto", @@ -85,7 +83,7 @@ function mealplanView(Grocy, scope = null) '); var weekRecipeName = start.year() + "-" + ((start.week() - 1).toString().padStart(2, "0")).toString(); - var weekRecipe = internalRecipes.find(elem => elem.name == weekRecipeName); + var weekRecipe = Grocy.internalRecipes.find(elem => elem.name == weekRecipeName); var weekCosts = 0; var weekRecipeOrderMissingButtonHtml = ""; @@ -93,7 +91,7 @@ function mealplanView(Grocy, scope = null) var weekCostsHtml = ""; if (weekRecipe !== null && weekRecipe !== undefined) // Array.prototype.find returns undefined if not found. { - var recipes = recipesResolved.find(elem => elem.recipe_id == weekRecipe.id); + var recipes = Grocy.recipesResolved.find(elem => elem.recipe_id == weekRecipe.id); if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_STOCK_PRICE_TRACKING) { weekCosts = recipes.costs; @@ -130,8 +128,8 @@ function mealplanView(Grocy, scope = null) if (event.type != "note") { var dayRecipeName = toMoment(info.event.start, calendar).format("YYYY-MM-DD"); - var dayRecipe = internalRecipes.find(elem => elem.name == dayRecipeName); - var dayRecipeResolved = recipesResolved.find(elem => elem.recipe_id == dayRecipe.id); + var dayRecipe = Grocy.internalRecipes.find(elem => elem.name == dayRecipeName); + var dayRecipeResolved = Grocy.recipesResolved.find(elem => elem.recipe_id == dayRecipe.id); if (!$scope("#day-summary-" + dayRecipeName).length) // This runs for every event/recipe, so maybe multiple times per day, so only add the day summary once { @@ -158,7 +156,7 @@ function mealplanView(Grocy, scope = null) return false; } - var resolvedRecipe = recipesResolved.find(elem => elem.recipe_id == recipe.id); + var resolvedRecipe = Grocy.recipesResolved.find(elem => elem.recipe_id == recipe.id); element.attr("data-recipe", event.recipe); diff --git a/views/batteryform.blade.php b/views/batteryform.blade.php index 610b1984..a7dbe1f7 100644 --- a/views/batteryform.blade.php +++ b/views/batteryform.blade.php @@ -8,6 +8,13 @@ @section('viewJsName', 'batteryform') +@section('grocyConfigProps') +EditMode: '{{ $mode }}', +@if($mode == 'edit') +EditObjectId: {{ $battery->id }}, +@endif +@endsection + @section('content')
@@ -19,17 +26,6 @@
- - - - @if($mode == 'edit') - - @endif -
diff --git a/views/calendar.blade.php b/views/calendar.blade.php index c3489f95..a3d2b257 100644 --- a/views/calendar.blade.php +++ b/views/calendar.blade.php @@ -9,6 +9,9 @@ rel="stylesheet"> @endpush +@section('grocyConfigProps') + fullcalendarEventSources: {!! json_encode([ "events" => $fullcalendarEventSources]) !!}, +@endsection @section('content')
@@ -35,10 +38,6 @@
- -
diff --git a/views/choreform.blade.php b/views/choreform.blade.php index 4fd4d1a9..df7a9d51 100644 --- a/views/choreform.blade.php +++ b/views/choreform.blade.php @@ -8,6 +8,13 @@ @section('viewJsName', 'choreform') +@section('grocyConfigProps') +EditMode: '{{ $mode }}', +@if($mode == 'edit') +EditObjectId: {{ $chore->id }}, +@endif +@endsection + @section('content')
@@ -19,16 +26,6 @@
- - - @if($mode == 'edit') - - @endif - diff --git a/views/consume.blade.php b/views/consume.blade.php index a089bbe6..62d1aac6 100644 --- a/views/consume.blade.php +++ b/views/consume.blade.php @@ -4,13 +4,19 @@ @section('activeNav', 'consume') @section('viewJsName', 'consume') -@section('content') - +@section('grocyConfigProps') + QuantityUnits: {!! json_encode($quantityUnits) !!}, + QuantityUnitConversionsResolved: {!! json_encode($quantityUnitConversionsResolved) !!}, + DefaultMinAmount: '{{$DEFAULT_MIN_AMOUNT}}', +@endsection +@section('forceUserSettings') + @if($embedded) + scan_mode_consume_enabled: false, + @endif +@endsection + +@section('content')
diff --git a/views/equipmentform.blade.php b/views/equipmentform.blade.php index 595ae044..da674860 100644 --- a/views/equipmentform.blade.php +++ b/views/equipmentform.blade.php @@ -8,6 +8,16 @@ @section('viewJsName', 'equipmentform') +@section('grocyConfigProps') +EditMode: '{{ $mode }}', +@if($mode == 'edit') +EditObjectId: {{ $equipment->id }}, + @if(!empty($equipment->instruction_manual_file_name)) +InstructionManualFileNameName: '{{ $equipment->instruction_manual_file_name }}', + @endif +@endif +@endsection + @section('content')
@@ -19,22 +29,6 @@
- - - @if($mode == 'edit') - - - @if(!empty($equipment->instruction_manual_file_name)) - - @endif - @endif - diff --git a/views/inventory.blade.php b/views/inventory.blade.php index 90f1898f..114c05db 100644 --- a/views/inventory.blade.php +++ b/views/inventory.blade.php @@ -4,13 +4,13 @@ @section('activeNav', 'inventory') @section('viewJsName', 'inventory') -@section('content') - +@section('grocyConfigProps') + QuantityUnits: {!! json_encode($quantityUnits) !!}, + QuantityUnitConversionsResolved: {!! json_encode($quantityUnitConversionsResolved) !!}, + DefaultMinAmount: '{{$DEFAULT_MIN_AMOUNT}}', +@endsection +@section('content')

@yield('title')

diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index 3525e5ad..5ebbfec2 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -88,6 +88,17 @@ UserId: -1, @endif }; + @hasSection('grocyConfigProps') + Object.assign(GrocyConfig, { + @yield('grocyConfigProps') + }); + @endif + + @hasSection('forceUserSettings') + Object.assign(GrocyConfig.UserSettings, { + @yield('forceUserSettings') + }); + @endif diff --git a/views/locationform.blade.php b/views/locationform.blade.php index 2034db37..21d68564 100644 --- a/views/locationform.blade.php +++ b/views/locationform.blade.php @@ -8,6 +8,13 @@ @section('viewJsName', 'locationform') +@section('grocyConfigProps') +EditMode: '{{ $mode }}', +@if($mode == 'edit') +EditObjectId: {{ $location->id }}, +@endif +@endsection + @section('content')
@@ -19,15 +26,6 @@
- - - @if($mode == 'edit') - - @endif diff --git a/views/manageapikeys.blade.php b/views/manageapikeys.blade.php index 60638917..13bcebf3 100644 --- a/views/manageapikeys.blade.php +++ b/views/manageapikeys.blade.php @@ -4,10 +4,6 @@ @section('activeNav', '') @section('viewJsName', 'manageapikeys') -@push('pageScripts') - -@endpush - @section('content')
diff --git a/views/mealplan.blade.php b/views/mealplan.blade.php index 4eabed79..7b01cb4b 100644 --- a/views/mealplan.blade.php +++ b/views/mealplan.blade.php @@ -9,18 +9,18 @@ rel="stylesheet"> @endpush +@section('grocyConfigProps') + fullcalendarEventSources: {!! json_encode([ "events" => $fullcalendarEventSources ]) !!}, + internalRecipes: {!! json_encode($internalRecipes) !!}, + recipesResolved: {!! json_encode($recipesResolved) !!}, + + QuantityUnits: {!! json_encode($quantityUnits) !!}, + QuantityUnitConversionsResolved: {!! json_encode($quantityUnitConversionsResolved) !!}, + + MealPlanFirstDayOfWeek: '{{ GROCY_MEAL_PLAN_FIRST_DAY_OF_WEEK }}', +@endsection + @section('content') - -

@yield('title')

diff --git a/views/productbarcodeform.blade.php b/views/productbarcodeform.blade.php index b7876483..e2261f14 100644 --- a/views/productbarcodeform.blade.php +++ b/views/productbarcodeform.blade.php @@ -8,12 +8,18 @@ @section('viewJsName', 'productbarcodeform') -@section('content') - +@section('grocyConfigProps') + QuantityUnits: {!! json_encode($quantityUnits) !!}, + QuantityUnitConversionsResolved: {!! json_encode($quantityUnitConversionsResolved) !!}, + EditMode: '{{ $mode }}', +@if($mode == 'edit') + EditObjectId: {{ $barcode->id }}, + EditObject: {!! json_encode($barcode) !!}, +@endif + EditObjectProduct: {!! json_encode($product) !!}, +@endsection +@section('content')