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')