diff --git a/js/components/productpicker.js b/js/components/productpicker.js
index 1c24e775..1e818335 100644
--- a/js/components/productpicker.js
+++ b/js/components/productpicker.js
@@ -1,5 +1,3 @@
-import { GetUriParam, RemoveUriParam } from '../helpers/extensions';
-
function productpicker(Grocy)
{
Grocy.Use('barcodescanner');
@@ -41,12 +39,12 @@ function productpicker(Grocy)
Grocy.Components.ProductPicker.InProductAddWorkflow = function()
{
- return GetUriParam('flow') == "InplaceNewProductWithName";
+ return Grocy.GetUriParam('flow') == "InplaceNewProductWithName";
}
Grocy.Components.ProductPicker.InProductModifyWorkflow = function()
{
- return GetUriParam('flow') == "InplaceAddBarcodeToExistingProduct";
+ return Grocy.GetUriParam('flow') == "InplaceAddBarcodeToExistingProduct";
}
Grocy.Components.ProductPicker.InAnyFlow = function()
@@ -56,9 +54,9 @@ function productpicker(Grocy)
Grocy.Components.ProductPicker.FinishFlow = function()
{
- RemoveUriParam("flow");
- RemoveUriParam("barcode");
- RemoveUriParam("product-name");
+ Grocy.RemoveUriParam("flow");
+ Grocy.RemoveUriParam("barcode");
+ Grocy.RemoveUriParam("product-name");
}
Grocy.Components.ProductPicker.ShowCustomError = function(text)
@@ -96,7 +94,7 @@ function productpicker(Grocy)
var this_product_picker = Grocy.Components.ProductPicker.GetPicker();
var productpicker_doFocus = false;
- var prefillProduct = GetUriParam('product-name');
+ var prefillProduct = Grocy.GetUriParam('product-name');
var prefillProduct2 = this_product_picker.parent().data('prefill-by-name').toString();
if (!prefillProduct2.isEmpty())
{
@@ -117,7 +115,7 @@ function productpicker(Grocy)
}
}
- var prefillProductId = GetUriParam("product");
+ var prefillProductId = Grocy.GetUriParam("product");
var prefillProductId2 = this_product_picker.parent().data('prefill-by-id').toString();
if (!prefillProductId2.isEmpty())
{
@@ -138,9 +136,9 @@ function productpicker(Grocy)
.focus();
}
- if (GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
+ if (Grocy.GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
{
- $('#InplaceAddBarcodeToExistingProduct').text(GetUriParam("barcode"));
+ $('#InplaceAddBarcodeToExistingProduct').text(Grocy.GetUriParam("barcode"));
$('#flow-info-InplaceAddBarcodeToExistingProduct').removeClass('d-none');
$('#barcode-lookup-disabled-hint').removeClass('d-none');
$('#barcode-lookup-hint').addClass('d-none');
@@ -174,7 +172,7 @@ function productpicker(Grocy)
possibleOptionElement = $("#product_id option[data-additional-searchdata*=\"" + input + ",\"]").first();
}
- if (GetUriParam('flow') === undefined && input.length > 0 && possibleOptionElement.length > 0)
+ if (Grocy.GetUriParam('flow') === undefined && input.length > 0 && possibleOptionElement.length > 0)
{
$('#product_id').val(possibleOptionElement.val());
$('#product_id').attr("barcode", input);
@@ -189,7 +187,7 @@ function productpicker(Grocy)
}
var optionElement = $("#product_id option:contains(\"" + input + "\")").first();
- if (input.length > 0 && optionElement.length === 0 && GetUriParam('flow') === undefined && Grocy.Components.ProductPicker.GetPicker().parent().data('disallow-all-product-workflows').toString() === "false")
+ if (input.length > 0 && optionElement.length === 0 && Grocy.GetUriParam('flow') === undefined && Grocy.Components.ProductPicker.GetPicker().parent().data('disallow-all-product-workflows').toString() === "false")
{
var addProductWorkflowsAdditionalCssClasses = "";
if (Grocy.Components.ProductPicker.GetPicker().parent().data('disallow-add-product-workflows').toString() === "true")
@@ -198,7 +196,7 @@ function productpicker(Grocy)
}
var embedded = "";
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
embedded = "embedded";
}
diff --git a/js/grocy.js b/js/grocy.js
index d86406ad..26df66fb 100644
--- a/js/grocy.js
+++ b/js/grocy.js
@@ -111,7 +111,7 @@ class GrocyClass
}
}
- static createSingleton(config)
+ static createSingleton(config, view)
{
if (window.Grocy === undefined)
{
@@ -146,27 +146,30 @@ class GrocyClass
window.RemoveUriParam = RemoveUriParam;
window.EmptyElementWhenMatches = EmptyElementWhenMatches;
window.animateCSS = animateCSS;
+
+ // load the view
+ grocy.LoadView(view);
}
return window.Grocy;
}
translate(text, ...placeholderValues)
{
- /*if (this.Mode === "dev")
+ if (this.Mode === "dev")
{
var text2 = text;
this.Api.Post('system/log-missing-localization', { "text": text2 });
- }*/
+ }
return this.Translator.__(text, ...placeholderValues)
}
translaten(number, singularForm, pluralForm)
{
- /*if (this.Mode === "dev")
+ if (this.Mode === "dev")
{
var singularForm2 = singularForm;
this.Api.Post('system/log-missing-localization', { "text": singularForm2 });
- }*/
+ }
return this.Translator.n__(singularForm, pluralForm, number, number)
}
@@ -224,7 +227,8 @@ class GrocyClass
{
// add-then-init to resolve circular dependencies
this.initComponents.push(componentName);
- components[componentName](this);
+ var component = components[componentName](this);
+ this.components[component.key] = component;
}
else
{
@@ -232,6 +236,19 @@ class GrocyClass
}
}
+ LoadView(viewName)
+ {
+ if (Object.prototype.hasOwnProperty.call(window, viewName + "View"))
+ {
+ window[viewName + "View"](this);
+ }
+ }
+
+ PreloadView(viewName)
+ {
+ $.getScript(this.FormatUrl('/viewjs/' + viewName + '.js'));
+ }
+
UndoStockBooking(bookingId)
{
var self = this;
@@ -329,6 +346,36 @@ class GrocyClass
}
}
}
+
+ GetUriParam(key)
+ {
+ var currentUri = window.location.search.substring(1);
+ var vars = currentUri.split('&');
+
+ for (var i = 0; i < vars.length; i++)
+ {
+ var currentParam = vars[i].split('=');
+
+ if (currentParam[0] === key)
+ {
+ return currentParam[1] === undefined ? true : decodeURIComponent(currentParam[1]);
+ }
+ }
+ }
+
+ UpdateUriParam(key, value)
+ {
+ var queryParameters = new URLSearchParams(window.location.search);
+ queryParameters.set(key, value);
+ window.history.replaceState({}, "", decodeURIComponent(`${window.location.pathname}?${queryParameters}`));
+ }
+
+ RemoveUriParam(key)
+ {
+ var queryParameters = new URLSearchParams(window.location.search);
+ queryParameters.delete(key);
+ window.history.replaceState({}, "", decodeURIComponent(`${window.location.pathname}?${queryParameters}`));
+ }
}
// also set on the Window object, just because.
diff --git a/js/helpers/extensions.js b/js/helpers/extensions.js
index a1e96458..951d6937 100644
--- a/js/helpers/extensions.js
+++ b/js/helpers/extensions.js
@@ -6,35 +6,6 @@ function EmptyElementWhenMatches(selector, text)
}
}
-function GetUriParam(key)
-{
- var currentUri = window.location.search.substring(1);
- var vars = currentUri.split('&');
-
- for (var i = 0; i < vars.length; i++)
- {
- var currentParam = vars[i].split('=');
-
- if (currentParam[0] === key)
- {
- return currentParam[1] === undefined ? true : decodeURIComponent(currentParam[1]);
- }
- }
-}
-
-function UpdateUriParam(key, value)
-{
- var queryParameters = new URLSearchParams(window.location.search);
- queryParameters.set(key, value);
- window.history.replaceState({}, "", decodeURIComponent(`${window.location.pathname}?${queryParameters}`));
-}
-
-function RemoveUriParam(key)
-{
- var queryParameters = new URLSearchParams(window.location.search);
- queryParameters.delete(key);
- window.history.replaceState({}, "", decodeURIComponent(`${window.location.pathname}?${queryParameters}`));
-}
function BoolVal(test)
diff --git a/js/helpers/frontend.js b/js/helpers/frontend.js
index f478646c..1ed4bed2 100644
--- a/js/helpers/frontend.js
+++ b/js/helpers/frontend.js
@@ -1,10 +1,21 @@
class GrocyFrontendHelpers
{
- constructor(Grocy, Api)
+ constructor(Grocy, Api, scope = null)
{
this.Grocy = Grocy;
this.Api = Api;
+ if (scope != null)
+ {
+ this.$scope = $(scope).find;
+ this.scope = $(scope);
+ this.scopeSelector = scope;
+ }
+ else
+ {
+ this.$scope = $;
+ this.scope = $(document);
+ }
}
Delay(callable, delayMilliseconds)
@@ -25,22 +36,23 @@ class GrocyFrontendHelpers
ValidateForm(formId)
{
- var form = document.getElementById(formId);
- if (form === null || form === undefined)
+
+ var form = this.$scope("#" + formId);
+ if (form.length == 0)
{
return;
}
- if (form.checkValidity() === true)
+ if (form[0].checkValidity() === true)
{
- $(form).find(':submit').removeClass('disabled');
+ form.find(':submit').removeClass('disabled');
}
else
{
- $(form).find(':submit').addClass('disabled');
+ form.find(':submit').addClass('disabled');
}
- $(form).addClass('was-validated');
+ form.addClass('was-validated');
}
BeginUiBusy(formId = null)
@@ -49,7 +61,7 @@ class GrocyFrontendHelpers
if (formId !== null)
{
- $("#" + formId + " :input").attr("disabled", true);
+ this.$scope("#" + formId + " :input").attr("disabled", true);
}
}
@@ -59,7 +71,7 @@ class GrocyFrontendHelpers
if (formId !== null)
{
- $("#" + formId + " :input").attr("disabled", false);
+ this.$scope("#" + formId + " :input").attr("disabled", false);
}
}
@@ -158,21 +170,22 @@ class GrocyFrontendHelpers
var defaultClearFunction = function()
{
- $("#search").val("");
+ self.$scope("#search").val("");
dataTable.search("").draw();
};
- $("#search").on("keyup", self.Delay(searchFunction || defaultSearchFunction, 200));
+ self.$scope("#search").on("keyup", self.Delay(searchFunction || defaultSearchFunction, 200));
- $("#clear-filter-button").on("click", clearFunction || defaultClearFunction);
+ self.$scope("#clear-filter-button").on("click", clearFunction || defaultClearFunction);
}
MakeFilterForColumn(selector, column, table, filterFunction = null, transferCss = false, valueMod = null)
{
- $(selector).on("change", filterFunction || function()
+ var self = this;
+ this.$scope(selector).on("change", filterFunction || function()
{
var value = $(this).val();
- var text = $(selector + " option:selected").text();
+ var text = self.$scope(selector + " option:selected").text();
if (value === "all")
{
text = "";
@@ -185,14 +198,14 @@ class GrocyFrontendHelpers
if (transferCss)
{
// Transfer CSS classes of selected element to dropdown element (for background)
- $(this).attr("class", $("#" + $(this).attr("id") + " option[value='" + value + "']").attr("class") + " form-control");
+ $(this).attr("class", self.$scope("#" + $(this).attr("id") + " option[value='" + value + "']").attr("class") + " form-control");
}
table.column(column).search(text).draw();
});
- $("#clear-filter-button").on('click', () =>
+ self.$scope("#clear-filter-button").on('click', () =>
{
- $(selector).val("");
+ self.$scope(selector).val("");
table.column(column).search("").draw();
})
}
@@ -202,7 +215,8 @@ class GrocyFrontendHelpers
}
MakeValueFilter(key, column, dataTable, resetValue = "all")
{
- $("#" + key + "-filter").on("change", function()
+ var self = this;
+ this.$scope("#" + key + "-filter").on("change", function()
{
var value = $(this).val();
if (value === "all")
@@ -211,22 +225,22 @@ class GrocyFrontendHelpers
}
// Transfer CSS classes of selected element to dropdown element (for background)
- $(this).attr("class", $("#" + $(this).attr("id") + " option[value='" + value + "']").attr("class") + " form-control");
+ $(this).attr("class", self.$scope("#" + $(this).attr("id") + " option[value='" + value + "']").attr("class") + " form-control");
dataTable.column(column).search(value).draw();
});
- $("." + key + "-filter-message").on("click", function()
+ this.$scope("." + key + "-filter-message").on("click", function()
{
var value = $(this).data(key + "-filter");
- $("#" + key + "-filter").val(value);
- $("#" + key + "-filter").trigger("change");
+ self.$scope("#" + key + "-filter").val(value);
+ self.$scope("#" + key + "-filter").trigger("change");
});
- $("#clear-filter-button").on("click", function()
+ this.$scope("#clear-filter-button").on("click", function()
{
- $("#" + key + "-filter").val(resetValue);
- $("#" + key + "-filter").trigger("change");
+ self.$scope("#" + key + "-filter").val(resetValue);
+ self.$scope("#" + key + "-filter").trigger("change");
});
}
@@ -234,7 +248,7 @@ class GrocyFrontendHelpers
{
var self = this;
- $(document).on('click', selector, function(e)
+ this.scope.on('click', selector, function(e)
{
message = message instanceof Function ? message(e) : message;
bootbox.confirm({
@@ -268,7 +282,7 @@ class GrocyFrontendHelpers
}
var self = this;
- $(document).on('click', selector, function(e)
+ this.scope.on('click', selector, function(e)
{
var target = $(e.currentTarget);
var objectName = attrName instanceof Function ? attrName(target) : target.attr(attrName);
diff --git a/js/lib/proxy.js b/js/lib/proxy.js
new file mode 100644
index 00000000..5df1156a
--- /dev/null
+++ b/js/lib/proxy.js
@@ -0,0 +1,184 @@
+
+import { GrocyFrontendHelpers } from '../helpers/frontend';
+import * as components from '../components';
+
+class GrocyProxy
+{
+
+ constructor(RootGrocy, scopeSelector, config, url)
+ {
+ this.rootGrocy = RootGrocy;
+
+ // proxy-local members, because they might not be set globally.
+ this.QuantityUnits = config.QuantityUnits;
+ this.QuantityUnitConversionsResolved = config.QuantityUnitConversionsResolved || [];
+ this.QuantityUnitEditFormRedirectUri = config.QuantityUnitEditFormRedirectUri;
+ this.MealPlanFirstDayOfWeek = config.MealPlanFirstDayOfWeek;
+ this.EditMode = config.EditMode;
+ this.EditObjectId = config.EditObjectId;
+ this.DefaultMinAmount = config.DefaultMinAmount;
+ this.UserPictureFileName = config.UserPictureFileName;
+ this.EditObjectParentId = config.EditObjectParentId;
+ this.EditObjectParentName = config.EditObjectParentName;
+ this.EditObject = config.EditObject;
+ this.EditObjectProduct = config.EditObjectProduct;
+ this.RecipePictureFileName = config.RecipePictureFileName;
+ this.InstructionManualFileNameName = config.InstructionManualFileNameName;
+
+ // components are always local
+ this.Components = {};
+ this.initComponents = [];
+
+ // scoping
+ this.scopeSelector = scopeSelector;
+ this.scope = $(scope);
+ this.$scope = this.scope.find;
+ var queryString = url.split('?', 2);
+ this.virtualUrl = queryString.length == 2 ? queryString[1] : ""; // maximum two parts
+
+ this.config = config;
+
+ // scoped variants of some helpers
+ this.FrontendHelpers = new GrocyFrontendHelpers(this, this.Api, this.scopeSelector);
+
+ this.configProxy = Proxy.revocable(this.config, {
+ get: function(target, prop, receiver)
+ {
+ if (Object.prototype.hasOwnProperty.call(target, prop))
+ {
+ return Reflect.get(...arguments);
+ }
+ else
+ {
+ return Reflect.get(rootGrocy.config, prop, target);
+ }
+ }
+ })
+
+ // This is where the magic happens!
+ // basically, this Proxy object checks if a member
+ // is defined in this proxy class, and returns it
+ // if so.
+ // If not, the prop is handed over to the root
+ // grocy instance.
+ this.grocyProxy = Proxy.revocable(this, {
+ get: function(target, prop, receiver)
+ {
+ if (Object.prototype.hasOwnProperty.call(target, prop))
+ {
+ return Reflect.get(...arguments)
+ }
+ else
+ {
+ return Reflect.get(RootGrocy, prop, receiver);
+ }
+ }
+ });
+ }
+
+ Unload()
+ {
+ this.grocyProxy.revoke();
+ this.configProxy.revoke();
+ }
+
+ Use(componentName)
+ {
+ // initialize Components only once
+ if (this.initComponents.find(elem => elem == componentName))
+ return;
+
+ if (Object.prototype.hasOwnProperty.call(components, componentName))
+ {
+ // add-then-init to resolve circular dependencies
+ this.initComponents.push(componentName);
+ var component = components[componentName](this, this.scopeSelector);
+ this.components[component.key] = component;
+ }
+ else
+ {
+ console.error("Unable to find component " + componentName);
+ }
+ }
+
+ LoadView(viewName)
+ {
+ if (Object.prototype.hasOwnProperty.call(window, viewName + "View"))
+ {
+ window[viewName + "View"](this, this.scopeSelector);
+ }
+ }
+
+ // URI params on integrated components don't work because they
+ // don't have an URL. So let's fake it.
+ GetUriParam(key)
+ {
+ var currentUri = this.virtualUrl;
+ var vars = currentUri.split('&');
+
+ for (var i = 0; i < vars.length; i++)
+ {
+ var currentParam = vars[i].split('=');
+
+ if (currentParam[0] === key)
+ {
+ return currentParam[1] === undefined ? true : decodeURIComponent(currentParam[1]);
+ }
+ }
+ }
+
+ UpdateUriParam(key, value)
+ {
+ params = {}
+ var vars = this.virtualUrl.split("&");
+
+ for (part of vars)
+ {
+ var lkey, lvalue;
+ [lkey, lvalue = null] = part.split('=');
+
+ params[lkey] = lvalue;
+ }
+
+ params[key] = value;
+
+ var vurl = ""
+ for ([key, value] of params)
+ {
+ vurl += "&" + key
+ if (value != null)
+ {
+ vurl += '=' + encodeURIComponent(value);
+ }
+ }
+ this.virtualUrl = vurl.substring(1); // remove leading &
+ }
+
+ RemoveUriParam(key)
+ {
+ params = {}
+ var vars = this.virtualUrl.split("&");
+
+ for (part of vars)
+ {
+ var lkey, lvalue;
+ [lkey, lvalue = null] = part.split('=');
+
+ if (lkey == key)
+ continue;
+
+ params[lkey] = lvalue;
+ }
+
+ var vurl = ""
+ for ([key, value] of params)
+ {
+ vurl += "&" + key
+ if (value != null)
+ {
+ vurl += '=' + encodeURIComponent(value);
+ }
+ }
+ this.virtualUrl = vurl.substring(1); // remove leading &
+ }
+}
\ No newline at end of file
diff --git a/js/viewjs/about.js b/js/viewjs/about.js
index a5ba7792..4e2c6657 100644
--- a/js/viewjs/about.js
+++ b/js/viewjs/about.js
@@ -12,7 +12,7 @@
$(this).parent().next().collapse("toggle");
});
- if ((typeof GetUriParam("tab") !== "undefined" && GetUriParam("tab") === "changelog"))
+ if ((typeof Grocy.GetUriParam("tab") !== "undefined" && Grocy.GetUriParam("tab") === "changelog"))
{
$scope(".nav-tabs a[href='#changelog']").tab("show");
}
diff --git a/js/viewjs/barcodescannertesting.js b/js/viewjs/barcodescannertesting.js
index ad96a721..cc2ace6c 100644
--- a/js/viewjs/barcodescannertesting.js
+++ b/js/viewjs/barcodescannertesting.js
@@ -47,9 +47,9 @@
$scope("#barcodescanner-start-button").addClass("disabled");
}, 200);
- if (GetUriParam("barcode") !== undefined)
+ if (Grocy.GetUriParam("barcode") !== undefined)
{
- $scope("#expected_barcode").val(GetUriParam("barcode"));
+ $scope("#expected_barcode").val(Grocy.GetUriParam("barcode"));
setTimeout(function()
{
$scope("#expected_barcode").keyup();
diff --git a/js/viewjs/batteries.js b/js/viewjs/batteries.js
index 1102fddc..ff4699d1 100644
--- a/js/viewjs/batteries.js
+++ b/js/viewjs/batteries.js
@@ -43,7 +43,7 @@
}
});
- if (GetUriParam('include_disabled'))
+ if (Grocy.GetUriParam('include_disabled'))
{
$scope("#show-disabled").prop('checked', true);
}
diff --git a/js/viewjs/batteriesjournal.js b/js/viewjs/batteriesjournal.js
index 0243959e..b370be25 100644
--- a/js/viewjs/batteriesjournal.js
+++ b/js/viewjs/batteriesjournal.js
@@ -18,9 +18,9 @@
Grocy.FrontendHelpers.InitDataTable(batteriesJournalTable);
Grocy.FrontendHelpers.MakeFilterForColumn("#battery-filter", 1, batteriesJournalTable);
- if (typeof GetUriParam("battery") !== "undefined")
+ if (typeof Grocy.GetUriParam("battery") !== "undefined")
{
- $scope("#battery-filter").val(GetUriParam("battery"));
+ $scope("#battery-filter").val(Grocy.GetUriParam("battery"));
$scope("#battery-filter").trigger("change");
}
diff --git a/js/viewjs/batteryform.js b/js/viewjs/batteryform.js
index 856910b3..07fddcef 100644
--- a/js/viewjs/batteryform.js
+++ b/js/viewjs/batteryform.js
@@ -31,7 +31,7 @@ function batteryformView(Grocy, scope = null)
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
@@ -55,7 +55,7 @@ function batteryformView(Grocy, scope = null)
{
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
diff --git a/js/viewjs/chores.js b/js/viewjs/chores.js
index 6093fef0..68a332a2 100644
--- a/js/viewjs/chores.js
+++ b/js/viewjs/chores.js
@@ -42,7 +42,7 @@
}
});
- if (GetUriParam('include_disabled'))
+ if (Grocy.GetUriParam('include_disabled'))
{
$scope("#show-disabled").prop('checked', true);
}
diff --git a/js/viewjs/choresjournal.js b/js/viewjs/choresjournal.js
index 07610509..f708e250 100644
--- a/js/viewjs/choresjournal.js
+++ b/js/viewjs/choresjournal.js
@@ -18,9 +18,9 @@
Grocy.FrontendHelpers.InitDataTable(choresJournalTable);
Grocy.FrontendHelpers.MakeFilterForColumn("#chore-filter", 1, choresJournalTable);
- if (typeof GetUriParam("chore") !== "undefined")
+ if (typeof Grocy.GetUriParam("chore") !== "undefined")
{
- $scope("#chore-filter").val(GetUriParam("chore"));
+ $scope("#chore-filter").val(Grocy.GetUriParam("chore"));
$scope("#chore-filter").trigger("change");
}
diff --git a/js/viewjs/choresoverview.js b/js/viewjs/choresoverview.js
index 706d68b3..03082e8b 100644
--- a/js/viewjs/choresoverview.js
+++ b/js/viewjs/choresoverview.js
@@ -30,11 +30,11 @@
var user = $(this).val();
if (user !== null && !user.isEmpty())
{
- UpdateUriParam("user", $scope("#user-filter option:selected").data("user-id"));
+ Grocy.UpdateUriParam("user", $scope("#user-filter option:selected").data("user-id"));
}
else
{
- RemoveUriParam("user")
+ Grocy.RemoveUriParam("user")
}
});
@@ -183,9 +183,9 @@
);
}
- if (GetUriParam("user") !== undefined)
+ if (Grocy.GetUriParam("user") !== undefined)
{
- $scope("#user-filter").val("xx" + GetUriParam("user") + "xx");
+ $scope("#user-filter").val("xx" + Grocy.GetUriParam("user") + "xx");
$scope("#user-filter").trigger("change");
}
diff --git a/js/viewjs/consume.js b/js/viewjs/consume.js
index 77136317..12354839 100644
--- a/js/viewjs/consume.js
+++ b/js/viewjs/consume.js
@@ -65,10 +65,10 @@ function consumeView(Grocy, scope = null)
bookingResponse = result;
- if (GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
+ if (Grocy.GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
{
var jsonDataBarcode = {};
- jsonDataBarcode.barcode = GetUriParam("barcode");
+ jsonDataBarcode.barcode = Grocy.GetUriParam("barcode");
jsonDataBarcode.product_id = jsonForm.product_id;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
@@ -103,7 +103,7 @@ function consumeView(Grocy, scope = null)
successMessage = __t('Removed %1$s of %2$s from stock', Math.abs(jsonForm.amount) + " " + __n(jsonForm.amount, productDetails.quantity_unit_stock.name, productDetails.quantity_unit_stock.name_plural), productDetails.product.name) + '
' + __t("Undo") + '';
}
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
@@ -238,9 +238,9 @@ function consumeView(Grocy, scope = null)
$scope("#use_specific_stock_entry").click();
}
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
- stockId = GetUriParam('stockId');
+ stockId = Grocy.GetUriParam('stockId');
}
else
{
@@ -568,9 +568,9 @@ function consumeView(Grocy, scope = null)
RefreshForm();
});
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
- var locationId = GetUriParam('locationId');
+ var locationId = Grocy.GetUriParam('locationId');
if (typeof locationId === 'undefined')
{
diff --git a/js/viewjs/inventory.js b/js/viewjs/inventory.js
index ca065745..14f860f4 100644
--- a/js/viewjs/inventory.js
+++ b/js/viewjs/inventory.js
@@ -66,10 +66,10 @@ function inventoryView(Grocy, scope = null)
{
bookingResponse = result;
- if (GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
+ if (Grocy.GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
{
var jsonDataBarcode = {};
- jsonDataBarcode.barcode = GetUriParam("barcode");
+ jsonDataBarcode.barcode = Grocy.GetUriParam("barcode");
jsonDataBarcode.product_id = jsonForm.product_id;
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id;
@@ -94,7 +94,7 @@ function inventoryView(Grocy, scope = null)
{
var successMessage = __t('Stock amount of %1$s is now %2$s', result.product.name, result.stock_amount + " " + __n(result.stock_amount, result.quantity_unit_stock.name, result.quantity_unit_stock.name_plural)) + '
' + __t("Undo") + '';
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
@@ -257,7 +257,7 @@ function inventoryView(Grocy, scope = null)
$scope(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('inventory-form');
- if (Grocy.Components.ProductPicker.InAnyFlow() === false && GetUriParam("embedded") === undefined)
+ if (Grocy.Components.ProductPicker.InAnyFlow() === false && Grocy.GetUriParam("embedded") === undefined)
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}
diff --git a/js/viewjs/locationform.js b/js/viewjs/locationform.js
index 5ad764d2..0281c602 100644
--- a/js/viewjs/locationform.js
+++ b/js/viewjs/locationform.js
@@ -30,7 +30,7 @@ function locationformView(Grocy, scope = null)
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
@@ -54,7 +54,7 @@ function locationformView(Grocy, scope = null)
{
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
diff --git a/js/viewjs/login.js b/js/viewjs/login.js
index d7e12b95..30e5ae4e 100644
--- a/js/viewjs/login.js
+++ b/js/viewjs/login.js
@@ -8,7 +8,7 @@
$scope('#username').focus();
- if (GetUriParam('invalid') === 'true')
+ if (Grocy.GetUriParam('invalid') === 'true')
{
$scope('#login-error').text(__t('Invalid credentials, please try again'));
$scope('#login-error').removeClass('d-none');
diff --git a/js/viewjs/manageapikeys.js b/js/viewjs/manageapikeys.js
index 31c18dba..29096f10 100644
--- a/js/viewjs/manageapikeys.js
+++ b/js/viewjs/manageapikeys.js
@@ -18,7 +18,7 @@ function manageapikeysView(Grocy, scope = null)
$scope('#apikeys-table tbody').removeClass("d-none");
Grocy.FrontendHelpers.InitDataTable(apiKeysTable);
- var createdApiKeyId = GetUriParam('CreatedApiKeyId');
+ var createdApiKeyId = Grocy.GetUriParam('CreatedApiKeyId');
if (createdApiKeyId !== undefined)
{
animateCSS("#apiKeyRow_" + createdApiKeyId, "pulse");
diff --git a/js/viewjs/mealplan.js b/js/viewjs/mealplan.js
index 97e27f17..df37cfc8 100644
--- a/js/viewjs/mealplan.js
+++ b/js/viewjs/mealplan.js
@@ -70,7 +70,7 @@ function mealplanView(Grocy, scope = null)
}
else
{
- UpdateUriParam("week", start.format("YYYY-MM-DD"));
+ Grocy.UpdateUriParam("week", start.format("YYYY-MM-DD"));
}
$scope(".fc-day-header").prepend('\
@@ -318,9 +318,9 @@ function mealplanView(Grocy, scope = null)
// this triggers a re-render, so we can't do that in the callback;
// but it works here no problem.
- if (GetUriParam("week") !== undefined)
+ if (Grocy.GetUriParam("week") !== undefined)
{
- calendar.gotoDate(GetUriParam("week"));
+ calendar.gotoDate(Grocy.GetUriParam("week"));
}
top.on("click", ".add-recipe-button", function(e)
diff --git a/js/viewjs/productbarcodeform.js b/js/viewjs/productbarcodeform.js
index 56d170d8..e5964913 100644
--- a/js/viewjs/productbarcodeform.js
+++ b/js/viewjs/productbarcodeform.js
@@ -37,8 +37,8 @@ function productbarcodeformView(Grocy, scope = null)
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save()
- window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), U("/product/" + GetUriParam("product")));
- window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
+ window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), U("/product/" + Grocy.GetUriParam("product")));
+ window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + Grocy.GetUriParam("product")));
},
function(xhr)
{
@@ -53,8 +53,8 @@ function productbarcodeformView(Grocy, scope = null)
Grocy.Api.Put('objects/product_barcodes/' + Grocy.EditObjectId, jsonData,
function(result)
{
- window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), U("/product/" + GetUriParam("product")));
- window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
+ window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), U("/product/" + Grocy.GetUriParam("product")));
+ window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + Grocy.GetUriParam("product")));
},
function(xhr)
{
diff --git a/js/viewjs/productform.js b/js/viewjs/productform.js
index da4a688e..e5e3ce72 100644
--- a/js/viewjs/productform.js
+++ b/js/viewjs/productform.js
@@ -31,14 +31,14 @@ function productformView(Grocy, scope = null)
return
}
- var returnTo = GetUriParam('returnto');
- if (GetUriParam("closeAfterCreation") !== undefined)
+ var returnTo = Grocy.GetUriParam('returnto');
+ if (Grocy.GetUriParam("closeAfterCreation") !== undefined)
{
window.close();
}
else if (returnTo !== undefined)
{
- if (GetUriParam("flow") !== undefined)
+ if (Grocy.GetUriParam("flow") !== undefined)
{
window.location.href = U(returnTo) + '&product-name=' + encodeURIComponent($scope('#name').val());
}
@@ -69,14 +69,14 @@ function productformView(Grocy, scope = null)
return
}
- var returnTo = GetUriParam('returnto');
- if (GetUriParam("closeAfterCreation") !== undefined)
+ var returnTo = Grocy.GetUriParam('returnto');
+ if (Grocy.GetUriParam("closeAfterCreation") !== undefined)
{
window.close();
}
else if (returnTo !== undefined)
{
- if (GetUriParam("flow") !== undefined)
+ if (Grocy.GetUriParam("flow") !== undefined)
{
window.location.href = U(returnTo) + '&product-name=' + encodeURIComponent($scope('#name').val());
}
@@ -172,13 +172,13 @@ function productformView(Grocy, scope = null)
);
}
- if (GetUriParam("flow") == "InplaceNewProductWithName")
+ if (Grocy.GetUriParam("flow") == "InplaceNewProductWithName")
{
- $scope('#name').val(GetUriParam("name"));
+ $scope('#name').val(Grocy.GetUriParam("name"));
$scope('#name').focus();
}
- if (GetUriParam("flow") !== undefined || GetUriParam("returnto") !== undefined)
+ if (Grocy.GetUriParam("flow") !== undefined || Grocy.GetUriParam("returnto") !== undefined)
{
$scope("#save-hint").addClass("d-none");
$scope(".save-product-button[data-location='return']").addClass("d-none");
@@ -397,9 +397,9 @@ function productformView(Grocy, scope = null)
}
});
- if (Grocy.EditMode == "create" && GetUriParam("copy-of") != undefined)
+ if (Grocy.EditMode == "create" && Grocy.GetUriParam("copy-of") != undefined)
{
- Grocy.Api.Get('objects/products/' + GetUriParam("copy-of"),
+ Grocy.Api.Get('objects/products/' + Grocy.GetUriParam("copy-of"),
function(sourceProduct)
{
if (sourceProduct.parent_product_id != null)
diff --git a/js/viewjs/products.js b/js/viewjs/products.js
index 6bf90e22..9ea423b5 100644
--- a/js/viewjs/products.js
+++ b/js/viewjs/products.js
@@ -25,9 +25,9 @@
})
Grocy.FrontendHelpers.MakeFilterForColumn("#product-group-filter", 6, productsTable);
- if (typeof GetUriParam("product-group") !== "undefined")
+ if (typeof Grocy.GetUriParam("product-group") !== "undefined")
{
- $scope("#product-group-filter").val(GetUriParam("product-group"));
+ $scope("#product-group-filter").val(Grocy.GetUriParam("product-group"));
$scope("#product-group-filter").trigger("change");
}
@@ -57,7 +57,7 @@
}
});
- if (GetUriParam('include_disabled'))
+ if (Grocy.GetUriParam('include_disabled'))
{
$scope("#show-disabled").prop('checked', true);
}
diff --git a/js/viewjs/purchase.js b/js/viewjs/purchase.js
index b2928b55..fe776bfd 100644
--- a/js/viewjs/purchase.js
+++ b/js/viewjs/purchase.js
@@ -109,10 +109,10 @@ function purchaseView(Grocy, scope = null)
Grocy.UISound.Success();
}
- if (GetUriParam("flow") == "InplaceAddBarcodeToExistingProduct")
+ if (Grocy.GetUriParam("flow") == "InplaceAddBarcodeToExistingProduct")
{
var jsonDataBarcode = {};
- jsonDataBarcode.barcode = GetUriParam("barcode");
+ jsonDataBarcode.barcode = Grocy.GetUriParam("barcode");
jsonDataBarcode.product_id = jsonForm.product_id;
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_id;
@@ -163,10 +163,10 @@ function purchaseView(Grocy, scope = null)
}
}
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
- window.parent.postMessage(WindowMessageBag("AfterItemAdded", GetUriParam("listitemid")), Grocy.BaseUrl);
+ window.parent.postMessage(WindowMessageBag("AfterItemAdded", Grocy.GetUriParam("listitemid")), Grocy.BaseUrl);
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
window.parent.postMessage(WindowMessageBag("CloseAllModals"), Grocy.BaseUrl);
@@ -256,10 +256,10 @@ function purchaseView(Grocy, scope = null)
$scope('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount));
$scope(".input-group-productamountpicker").trigger("change");
- if (GetUriParam("flow") === "shoppinglistitemtostock")
+ if (Grocy.GetUriParam("flow") === "shoppinglistitemtostock")
{
- Grocy.Components.ProductAmountPicker.SetQuantityUnit(GetUriParam("quId"));
- $scope('#display_amount').val(parseFloat(GetUriParam("amount") * $scope("#qu_id option:selected").attr("data-qu-factor")));
+ Grocy.Components.ProductAmountPicker.SetQuantityUnit(Grocy.GetUriParam("quId"));
+ $scope('#display_amount').val(parseFloat(Grocy.GetUriParam("amount") * $scope("#qu_id option:selected").attr("data-qu-factor")));
}
$scope(".input-group-productamountpicker").trigger("change");
@@ -346,7 +346,7 @@ function purchaseView(Grocy, scope = null)
$scope("#display_amount").focus();
Grocy.FrontendHelpers.ValidateForm('purchase-form');
- if (GetUriParam("flow") === "shoppinglistitemtostock" && BoolVal(Grocy.UserSettings.shopping_list_to_stock_workflow_auto_submit_when_prefilled) && document.getElementById("purchase-form").checkValidity() === true)
+ if (Grocy.GetUriParam("flow") === "shoppinglistitemtostock" && BoolVal(Grocy.UserSettings.shopping_list_to_stock_workflow_auto_submit_when_prefilled) && document.getElementById("purchase-form").checkValidity() === true)
{
$scope("#save-purchase-button").click();
}
@@ -425,7 +425,7 @@ function purchaseView(Grocy, scope = null)
if (Grocy.Components.ProductPicker)
{
- if (Grocy.Components.ProductPicker.InAnyFlow() === false && GetUriParam("embedded") === undefined)
+ if (Grocy.Components.ProductPicker.InAnyFlow() === false && Grocy.GetUriParam("embedded") === undefined)
{
Grocy.Components.ProductPicker.GetInputElement().focus();
}
diff --git a/js/viewjs/quantityunitconversionform.js b/js/viewjs/quantityunitconversionform.js
index 0340bfa3..630d3a25 100644
--- a/js/viewjs/quantityunitconversionform.js
+++ b/js/viewjs/quantityunitconversionform.js
@@ -50,21 +50,21 @@ function quantityunitconversionformView(Grocy, scope = null)
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save(function()
{
- if (typeof GetUriParam("qu-unit") !== "undefined")
+ if (typeof Grocy.GetUriParam("qu-unit") !== "undefined")
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
else
{
- window.location.href = U("/quantityunit/" + GetUriParam("qu-unit"));
+ window.location.href = U("/quantityunit/" + Grocy.GetUriParam("qu-unit"));
}
}
else
{
- window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product")));
- window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
+ window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + Grocy.GetUriParam("product")));
+ window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + Grocy.GetUriParam("product")));
}
});
},
@@ -77,21 +77,21 @@ function quantityunitconversionformView(Grocy, scope = null)
}
else
{
- if (typeof GetUriParam("qu-unit") !== "undefined")
+ if (typeof Grocy.GetUriParam("qu-unit") !== "undefined")
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
else
{
- window.location.href = U("/quantityunit/" + GetUriParam("qu-unit"));
+ window.location.href = U("/quantityunit/" + Grocy.GetUriParam("qu-unit"));
}
}
else
{
- window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product")));
- window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
+ window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + Grocy.GetUriParam("product")));
+ window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + Grocy.GetUriParam("product")));
}
}
});
@@ -110,21 +110,21 @@ function quantityunitconversionformView(Grocy, scope = null)
{
Grocy.Components.UserfieldsForm.Save(function()
{
- if (typeof GetUriParam("qu-unit") !== "undefined")
+ if (typeof Grocy.GetUriParam("qu-unit") !== "undefined")
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
else
{
- window.location.href = U("/quantityunit/" + GetUriParam("qu-unit"));
+ window.location.href = U("/quantityunit/" + Grocy.GetUriParam("qu-unit"));
}
}
else
{
- window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product")));
- window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
+ window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + Grocy.GetUriParam("product")));
+ window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + Grocy.GetUriParam("product")));
}
});
},
@@ -215,7 +215,7 @@ function quantityunitconversionformView(Grocy, scope = null)
$scope('#from_qu_id').focus();
Grocy.FrontendHelpers.ValidateForm('quconversion-form');
- if (GetUriParam("qu-unit") !== undefined)
+ if (Grocy.GetUriParam("qu-unit") !== undefined)
{
$scope("#from_qu_id").attr("disabled", "");
}
diff --git a/js/viewjs/quantityunitform.js b/js/viewjs/quantityunitform.js
index 688023b4..2a388b65 100644
--- a/js/viewjs/quantityunitform.js
+++ b/js/viewjs/quantityunitform.js
@@ -36,7 +36,7 @@
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
@@ -72,7 +72,7 @@
{
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
diff --git a/js/viewjs/quantityunitpluraltesting.js b/js/viewjs/quantityunitpluraltesting.js
index 87b4d892..b0544e16 100644
--- a/js/viewjs/quantityunitpluraltesting.js
+++ b/js/viewjs/quantityunitpluraltesting.js
@@ -38,9 +38,9 @@
$scope("#result").text(__n(amount, singularForm, pluralForm));
}
- if (GetUriParam("qu") !== undefined)
+ if (Grocy.GetUriParam("qu") !== undefined)
{
- $scope("#qu_id").val(GetUriParam("qu"));
+ $scope("#qu_id").val(Grocy.GetUriParam("qu"));
$scope("#qu_id").trigger("change");
}
diff --git a/js/viewjs/recipes.js b/js/viewjs/recipes.js
index b2d64467..dc9853a8 100644
--- a/js/viewjs/recipes.js
+++ b/js/viewjs/recipes.js
@@ -46,12 +46,12 @@
$scope("#status-filter").trigger("change");
})
- if ((typeof GetUriParam("tab") !== "undefined" && GetUriParam("tab") === "gallery") || window.localStorage.getItem("recipes_last_tab_id") == "gallery-tab")
+ if ((typeof Grocy.GetUriParam("tab") !== "undefined" && Grocy.GetUriParam("tab") === "gallery") || window.localStorage.getItem("recipes_last_tab_id") == "gallery-tab")
{
$scope(".nav-tabs a[href='#gallery']").tab("show");
}
- var recipe = GetUriParam("recipe");
+ var recipe = Grocy.GetUriParam("recipe");
if (typeof recipe !== "undefined")
{
$scope("#recipes-table tr").removeClass("selected");
@@ -68,9 +68,9 @@
}
}
- if (GetUriParam("search") !== undefined)
+ if (Grocy.GetUriParam("search") !== undefined)
{
- $scope("#search").val(GetUriParam("search"));
+ $scope("#search").val(Grocy.GetUriParam("search"));
setTimeout(function()
{
$scope("#search").keyup();
diff --git a/js/viewjs/shoppinglistitemform.js b/js/viewjs/shoppinglistitemform.js
index 5b97ff0f..37122c8c 100644
--- a/js/viewjs/shoppinglistitemform.js
+++ b/js/viewjs/shoppinglistitemform.js
@@ -31,7 +31,7 @@ function shoppinglistitemformView(Grocy, scope = null)
Grocy.FrontendHelpers.BeginUiBusy("shoppinglist-form");
- if (GetUriParam("updateexistingproduct") !== undefined)
+ if (Grocy.GetUriParam("updateexistingproduct") !== undefined)
{
jsonData.product_amount = jsonData.amount;
delete jsonData.amount;
@@ -42,7 +42,7 @@ function shoppinglistitemformView(Grocy, scope = null)
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save();
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
Grocy.Api.Get('stock/products/' + jsonData.product_id,
function(productDetails)
@@ -77,7 +77,7 @@ function shoppinglistitemformView(Grocy, scope = null)
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save();
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
if (jsonData.product_id)
{
@@ -119,7 +119,7 @@ function shoppinglistitemformView(Grocy, scope = null)
{
Grocy.Components.UserfieldsForm.Save();
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
if (jsonData.product_id)
{
@@ -236,22 +236,22 @@ function shoppinglistitemformView(Grocy, scope = null)
}
});
- if (GetUriParam("list") !== undefined)
+ if (Grocy.GetUriParam("list") !== undefined)
{
- $scope("#shopping_list_id").val(GetUriParam("list"));
+ $scope("#shopping_list_id").val(Grocy.GetUriParam("list"));
}
- if (GetUriParam("amount") !== undefined)
+ if (Grocy.GetUriParam("amount") !== undefined)
{
- $scope("#display_amount").val(parseFloat(GetUriParam("amount")));
+ $scope("#display_amount").val(parseFloat(Grocy.GetUriParam("amount")));
RefreshLocaleNumberInput();
$scope(".input-group-productamountpicker").trigger("change");
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
}
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
- if (GetUriParam("product") !== undefined)
+ if (Grocy.GetUriParam("product") !== undefined)
{
Grocy.Components.ProductPicker.GetPicker().trigger('change');
$scope("#display_amount").focus();
@@ -271,7 +271,7 @@ function shoppinglistitemformView(Grocy, scope = null)
});
- if (GetUriParam("product-name") != null)
+ if (Grocy.GetUriParam("product-name") != null)
{
Grocy.Components.ProductPicker.GetPicker().trigger('change');
}
diff --git a/js/viewjs/shoppinglocationform.js b/js/viewjs/shoppinglocationform.js
index 0655ae58..2aa38bbd 100644
--- a/js/viewjs/shoppinglocationform.js
+++ b/js/viewjs/shoppinglocationform.js
@@ -30,7 +30,7 @@ function shoppinglocationformView(Grocy, scope = null)
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
@@ -54,7 +54,7 @@ function shoppinglocationformView(Grocy, scope = null)
{
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
diff --git a/js/viewjs/stockjournal.js b/js/viewjs/stockjournal.js
index 593c9297..a017f7cb 100644
--- a/js/viewjs/stockjournal.js
+++ b/js/viewjs/stockjournal.js
@@ -23,9 +23,9 @@
Grocy.FrontendHelpers.MakeFilterForColumn("#location-filter", 5, stockJournalTable);
Grocy.FrontendHelpers.MakeFilterForColumn("#user-filter", 6, stockJournalTable);
- if (typeof GetUriParam("product") !== "undefined")
+ if (typeof Grocy.GetUriParam("product") !== "undefined")
{
- $scope("#product-filter").val(GetUriParam("product"));
+ $scope("#product-filter").val(Grocy.GetUriParam("product"));
$scope("#product-filter").trigger("change");
}
diff --git a/js/viewjs/taskcategoryform.js b/js/viewjs/taskcategoryform.js
index 0b9f3fde..a9e4e7dd 100644
--- a/js/viewjs/taskcategoryform.js
+++ b/js/viewjs/taskcategoryform.js
@@ -28,7 +28,7 @@
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
@@ -52,7 +52,7 @@
{
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
diff --git a/js/viewjs/taskform.js b/js/viewjs/taskform.js
index d316c3b7..4232a2bb 100644
--- a/js/viewjs/taskform.js
+++ b/js/viewjs/taskform.js
@@ -35,7 +35,7 @@
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
@@ -59,7 +59,7 @@
{
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
diff --git a/js/viewjs/tasks.js b/js/viewjs/tasks.js
index 0880ecbf..e7297da0 100644
--- a/js/viewjs/tasks.js
+++ b/js/viewjs/tasks.js
@@ -131,7 +131,7 @@
}
});
- if (GetUriParam('include_done'))
+ if (Grocy.GetUriParam('include_done'))
{
$scope("#show-done-tasks").prop('checked', true);
}
diff --git a/js/viewjs/transfer.js b/js/viewjs/transfer.js
index 640b948d..c0e43f61 100644
--- a/js/viewjs/transfer.js
+++ b/js/viewjs/transfer.js
@@ -46,10 +46,10 @@ function transferView(Grocy, scope = null)
{
bookingResponse = result;
- if (GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
+ if (Grocy.GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
{
var jsonDataBarcode = {};
- jsonDataBarcode.barcode = GetUriParam("barcode");
+ jsonDataBarcode.barcode = Grocy.GetUriParam("barcode");
jsonDataBarcode.product_id = jsonForm.product_id;
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
@@ -91,7 +91,7 @@ function transferView(Grocy, scope = null)
$scope('option:selected', "#location_id_to").text()
) + '
' + __t("Undo") + '';
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
@@ -154,12 +154,12 @@ function transferView(Grocy, scope = null)
Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
{
$scope("#specific_stock_entry").find("option").remove().end().append("");
- if ($scope("#use_specific_stock_entry").is(":checked") && GetUriParam("stockId") == null)
+ if ($scope("#use_specific_stock_entry").is(":checked") && Grocy.GetUriParam("stockId") == null)
{
$scope("#use_specific_stock_entry").click();
}
$scope("#location_id_to").val("");
- if (GetUriParam("stockId") == null)
+ if (Grocy.GetUriParam("stockId") == null)
{
$scope("#location_id_from").val("");
}
@@ -217,9 +217,9 @@ function transferView(Grocy, scope = null)
}
});
- if (GetUriParam("locationId") != null)
+ if (Grocy.GetUriParam("locationId") != null)
{
- $scope("#location_id_from").val(GetUriParam("locationId"));
+ $scope("#location_id_from").val(Grocy.GetUriParam("locationId"));
$scope("#location_id_from").trigger("change");
}
},
@@ -315,13 +315,13 @@ function transferView(Grocy, scope = null)
$scope("#location_id_to").val("");
}
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
- stockId = GetUriParam('stockId');
+ stockId = Grocy.GetUriParam('stockId');
}
$scope("#specific_stock_entry").find("option").remove().end().append("");
- if ($scope("#use_specific_stock_entry").is(":checked") && GetUriParam("stockId") == null)
+ if ($scope("#use_specific_stock_entry").is(":checked") && Grocy.GetUriParam("stockId") == null)
{
$scope("#use_specific_stock_entry").click();
}
@@ -469,9 +469,9 @@ function transferView(Grocy, scope = null)
});
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
- var locationId = GetUriParam('locationId');
+ var locationId = Grocy.GetUriParam('locationId');
if (typeof locationId === 'undefined')
{
diff --git a/js/viewjs/userentityform.js b/js/viewjs/userentityform.js
index a962a788..5caade24 100644
--- a/js/viewjs/userentityform.js
+++ b/js/viewjs/userentityform.js
@@ -27,7 +27,7 @@ function userentityformView(Grocy, scope = null)
Grocy.Api.Post('objects/userentities', jsonData,
function(result)
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
@@ -48,7 +48,7 @@ function userentityformView(Grocy, scope = null)
Grocy.Api.Put('objects/userentities/' + Grocy.EditObjectId, jsonData,
function(result)
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
diff --git a/js/viewjs/userfieldform.js b/js/viewjs/userfieldform.js
index a64e2276..38346e24 100644
--- a/js/viewjs/userfieldform.js
+++ b/js/viewjs/userfieldform.js
@@ -23,9 +23,9 @@ function userfieldformView(Grocy, scope = null)
Grocy.FrontendHelpers.BeginUiBusy("userfield-form");
var redirectUrl = U("/userfields");
- if (typeof GetUriParam("entity") !== "undefined" && !GetUriParam("entity").isEmpty())
+ if (typeof Grocy.GetUriParam("entity") !== "undefined" && !Grocy.GetUriParam("entity").isEmpty())
{
- redirectUrl = U("/userfields?entity=" + GetUriParam("entity"));
+ redirectUrl = U("/userfields?entity=" + Grocy.GetUriParam("entity"));
}
if (Grocy.EditMode === 'create')
@@ -33,7 +33,7 @@ function userfieldformView(Grocy, scope = null)
Grocy.Api.Post('objects/userfields', jsonData,
function(result)
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
@@ -54,7 +54,7 @@ function userfieldformView(Grocy, scope = null)
Grocy.Api.Put('objects/userfields/' + Grocy.EditObjectId, jsonData,
function(result)
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
@@ -117,9 +117,9 @@ function userfieldformView(Grocy, scope = null)
$scope('#entity').focus();
- if (typeof GetUriParam("entity") !== "undefined" && !GetUriParam("entity").isEmpty())
+ if (typeof Grocy.GetUriParam("entity") !== "undefined" && !Grocy.GetUriParam("entity").isEmpty())
{
- $scope("#entity").val(GetUriParam("entity"));
+ $scope("#entity").val(Grocy.GetUriParam("entity"));
$scope("#entity").trigger("change");
$scope('#name').focus();
}
diff --git a/js/viewjs/userfields.js b/js/viewjs/userfields.js
index a829b226..a894d8e3 100644
--- a/js/viewjs/userfields.js
+++ b/js/viewjs/userfields.js
@@ -44,9 +44,9 @@
'/userfields'
);
- if (GetUriParam("entity") != undefined && !GetUriParam("entity").isEmpty())
+ if (Grocy.GetUriParam("entity") != undefined && !Grocy.GetUriParam("entity").isEmpty())
{
- $scope("#entity-filter").val(GetUriParam("entity"));
+ $scope("#entity-filter").val(Grocy.GetUriParam("entity"));
$scope("#entity-filter").trigger("change");
$scope("#name").focus();
}
diff --git a/js/viewjs/userform.js b/js/viewjs/userform.js
index 61b301a0..c1df64ae 100644
--- a/js/viewjs/userform.js
+++ b/js/viewjs/userform.js
@@ -124,7 +124,7 @@
}
});
- if (GetUriParam("changepw") === "true")
+ if (Grocy.GetUriParam("changepw") === "true")
{
$scope('#password').focus();
}
diff --git a/js/viewjs/userobjectform.js b/js/viewjs/userobjectform.js
index b5e50ccc..7990b7af 100644
--- a/js/viewjs/userobjectform.js
+++ b/js/viewjs/userobjectform.js
@@ -32,7 +32,7 @@ function userobjectformView(Grocy, scope = null)
Grocy.EditObjectId = result.created_object_id;
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}
@@ -56,7 +56,7 @@ function userobjectformView(Grocy, scope = null)
{
Grocy.Components.UserfieldsForm.Save(function()
{
- if (GetUriParam("embedded") !== undefined)
+ if (Grocy.GetUriParam("embedded") !== undefined)
{
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
}