mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 12:26:15 +02:00
scoping: Add proxy class, move UriParam functions
This commit is contained in:
parent
2fbcefa8fd
commit
843b3f28af
|
|
@ -1,5 +1,3 @@
|
||||||
import { GetUriParam, RemoveUriParam } from '../helpers/extensions';
|
|
||||||
|
|
||||||
function productpicker(Grocy)
|
function productpicker(Grocy)
|
||||||
{
|
{
|
||||||
Grocy.Use('barcodescanner');
|
Grocy.Use('barcodescanner');
|
||||||
|
|
@ -41,12 +39,12 @@ function productpicker(Grocy)
|
||||||
|
|
||||||
Grocy.Components.ProductPicker.InProductAddWorkflow = function()
|
Grocy.Components.ProductPicker.InProductAddWorkflow = function()
|
||||||
{
|
{
|
||||||
return GetUriParam('flow') == "InplaceNewProductWithName";
|
return Grocy.GetUriParam('flow') == "InplaceNewProductWithName";
|
||||||
}
|
}
|
||||||
|
|
||||||
Grocy.Components.ProductPicker.InProductModifyWorkflow = function()
|
Grocy.Components.ProductPicker.InProductModifyWorkflow = function()
|
||||||
{
|
{
|
||||||
return GetUriParam('flow') == "InplaceAddBarcodeToExistingProduct";
|
return Grocy.GetUriParam('flow') == "InplaceAddBarcodeToExistingProduct";
|
||||||
}
|
}
|
||||||
|
|
||||||
Grocy.Components.ProductPicker.InAnyFlow = function()
|
Grocy.Components.ProductPicker.InAnyFlow = function()
|
||||||
|
|
@ -56,9 +54,9 @@ function productpicker(Grocy)
|
||||||
|
|
||||||
Grocy.Components.ProductPicker.FinishFlow = function()
|
Grocy.Components.ProductPicker.FinishFlow = function()
|
||||||
{
|
{
|
||||||
RemoveUriParam("flow");
|
Grocy.RemoveUriParam("flow");
|
||||||
RemoveUriParam("barcode");
|
Grocy.RemoveUriParam("barcode");
|
||||||
RemoveUriParam("product-name");
|
Grocy.RemoveUriParam("product-name");
|
||||||
}
|
}
|
||||||
|
|
||||||
Grocy.Components.ProductPicker.ShowCustomError = function(text)
|
Grocy.Components.ProductPicker.ShowCustomError = function(text)
|
||||||
|
|
@ -96,7 +94,7 @@ function productpicker(Grocy)
|
||||||
var this_product_picker = Grocy.Components.ProductPicker.GetPicker();
|
var this_product_picker = Grocy.Components.ProductPicker.GetPicker();
|
||||||
var productpicker_doFocus = false;
|
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();
|
var prefillProduct2 = this_product_picker.parent().data('prefill-by-name').toString();
|
||||||
if (!prefillProduct2.isEmpty())
|
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();
|
var prefillProductId2 = this_product_picker.parent().data('prefill-by-id').toString();
|
||||||
if (!prefillProductId2.isEmpty())
|
if (!prefillProductId2.isEmpty())
|
||||||
{
|
{
|
||||||
|
|
@ -138,9 +136,9 @@ function productpicker(Grocy)
|
||||||
.focus();
|
.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');
|
$('#flow-info-InplaceAddBarcodeToExistingProduct').removeClass('d-none');
|
||||||
$('#barcode-lookup-disabled-hint').removeClass('d-none');
|
$('#barcode-lookup-disabled-hint').removeClass('d-none');
|
||||||
$('#barcode-lookup-hint').addClass('d-none');
|
$('#barcode-lookup-hint').addClass('d-none');
|
||||||
|
|
@ -174,7 +172,7 @@ function productpicker(Grocy)
|
||||||
possibleOptionElement = $("#product_id option[data-additional-searchdata*=\"" + input + ",\"]").first();
|
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').val(possibleOptionElement.val());
|
||||||
$('#product_id').attr("barcode", input);
|
$('#product_id').attr("barcode", input);
|
||||||
|
|
@ -189,7 +187,7 @@ function productpicker(Grocy)
|
||||||
}
|
}
|
||||||
|
|
||||||
var optionElement = $("#product_id option:contains(\"" + input + "\")").first();
|
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 = "";
|
var addProductWorkflowsAdditionalCssClasses = "";
|
||||||
if (Grocy.Components.ProductPicker.GetPicker().parent().data('disallow-add-product-workflows').toString() === "true")
|
if (Grocy.Components.ProductPicker.GetPicker().parent().data('disallow-add-product-workflows').toString() === "true")
|
||||||
|
|
@ -198,7 +196,7 @@ function productpicker(Grocy)
|
||||||
}
|
}
|
||||||
|
|
||||||
var embedded = "";
|
var embedded = "";
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
embedded = "embedded";
|
embedded = "embedded";
|
||||||
}
|
}
|
||||||
|
|
|
||||||
59
js/grocy.js
59
js/grocy.js
|
|
@ -111,7 +111,7 @@ class GrocyClass
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static createSingleton(config)
|
static createSingleton(config, view)
|
||||||
{
|
{
|
||||||
if (window.Grocy === undefined)
|
if (window.Grocy === undefined)
|
||||||
{
|
{
|
||||||
|
|
@ -146,27 +146,30 @@ class GrocyClass
|
||||||
window.RemoveUriParam = RemoveUriParam;
|
window.RemoveUriParam = RemoveUriParam;
|
||||||
window.EmptyElementWhenMatches = EmptyElementWhenMatches;
|
window.EmptyElementWhenMatches = EmptyElementWhenMatches;
|
||||||
window.animateCSS = animateCSS;
|
window.animateCSS = animateCSS;
|
||||||
|
|
||||||
|
// load the view
|
||||||
|
grocy.LoadView(view);
|
||||||
}
|
}
|
||||||
return window.Grocy;
|
return window.Grocy;
|
||||||
}
|
}
|
||||||
|
|
||||||
translate(text, ...placeholderValues)
|
translate(text, ...placeholderValues)
|
||||||
{
|
{
|
||||||
/*if (this.Mode === "dev")
|
if (this.Mode === "dev")
|
||||||
{
|
{
|
||||||
var text2 = text;
|
var text2 = text;
|
||||||
this.Api.Post('system/log-missing-localization', { "text": text2 });
|
this.Api.Post('system/log-missing-localization', { "text": text2 });
|
||||||
}*/
|
}
|
||||||
|
|
||||||
return this.Translator.__(text, ...placeholderValues)
|
return this.Translator.__(text, ...placeholderValues)
|
||||||
}
|
}
|
||||||
translaten(number, singularForm, pluralForm)
|
translaten(number, singularForm, pluralForm)
|
||||||
{
|
{
|
||||||
/*if (this.Mode === "dev")
|
if (this.Mode === "dev")
|
||||||
{
|
{
|
||||||
var singularForm2 = singularForm;
|
var singularForm2 = singularForm;
|
||||||
this.Api.Post('system/log-missing-localization', { "text": singularForm2 });
|
this.Api.Post('system/log-missing-localization', { "text": singularForm2 });
|
||||||
}*/
|
}
|
||||||
|
|
||||||
return this.Translator.n__(singularForm, pluralForm, number, number)
|
return this.Translator.n__(singularForm, pluralForm, number, number)
|
||||||
}
|
}
|
||||||
|
|
@ -224,7 +227,8 @@ class GrocyClass
|
||||||
{
|
{
|
||||||
// add-then-init to resolve circular dependencies
|
// add-then-init to resolve circular dependencies
|
||||||
this.initComponents.push(componentName);
|
this.initComponents.push(componentName);
|
||||||
components[componentName](this);
|
var component = components[componentName](this);
|
||||||
|
this.components[component.key] = component;
|
||||||
}
|
}
|
||||||
else
|
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)
|
UndoStockBooking(bookingId)
|
||||||
{
|
{
|
||||||
var self = this;
|
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.
|
// also set on the Window object, just because.
|
||||||
|
|
|
||||||
|
|
@ -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)
|
function BoolVal(test)
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,21 @@
|
||||||
|
|
||||||
class GrocyFrontendHelpers
|
class GrocyFrontendHelpers
|
||||||
{
|
{
|
||||||
constructor(Grocy, Api)
|
constructor(Grocy, Api, scope = null)
|
||||||
{
|
{
|
||||||
this.Grocy = Grocy;
|
this.Grocy = Grocy;
|
||||||
this.Api = Api;
|
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)
|
Delay(callable, delayMilliseconds)
|
||||||
|
|
@ -25,22 +36,23 @@ class GrocyFrontendHelpers
|
||||||
|
|
||||||
ValidateForm(formId)
|
ValidateForm(formId)
|
||||||
{
|
{
|
||||||
var form = document.getElementById(formId);
|
|
||||||
if (form === null || form === undefined)
|
var form = this.$scope("#" + formId);
|
||||||
|
if (form.length == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form.checkValidity() === true)
|
if (form[0].checkValidity() === true)
|
||||||
{
|
{
|
||||||
$(form).find(':submit').removeClass('disabled');
|
form.find(':submit').removeClass('disabled');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$(form).find(':submit').addClass('disabled');
|
form.find(':submit').addClass('disabled');
|
||||||
}
|
}
|
||||||
|
|
||||||
$(form).addClass('was-validated');
|
form.addClass('was-validated');
|
||||||
}
|
}
|
||||||
|
|
||||||
BeginUiBusy(formId = null)
|
BeginUiBusy(formId = null)
|
||||||
|
|
@ -49,7 +61,7 @@ class GrocyFrontendHelpers
|
||||||
|
|
||||||
if (formId !== null)
|
if (formId !== null)
|
||||||
{
|
{
|
||||||
$("#" + formId + " :input").attr("disabled", true);
|
this.$scope("#" + formId + " :input").attr("disabled", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -59,7 +71,7 @@ class GrocyFrontendHelpers
|
||||||
|
|
||||||
if (formId !== null)
|
if (formId !== null)
|
||||||
{
|
{
|
||||||
$("#" + formId + " :input").attr("disabled", false);
|
this.$scope("#" + formId + " :input").attr("disabled", false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -158,21 +170,22 @@ class GrocyFrontendHelpers
|
||||||
|
|
||||||
var defaultClearFunction = function()
|
var defaultClearFunction = function()
|
||||||
{
|
{
|
||||||
$("#search").val("");
|
self.$scope("#search").val("");
|
||||||
dataTable.search("").draw();
|
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)
|
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 value = $(this).val();
|
||||||
var text = $(selector + " option:selected").text();
|
var text = self.$scope(selector + " option:selected").text();
|
||||||
if (value === "all")
|
if (value === "all")
|
||||||
{
|
{
|
||||||
text = "";
|
text = "";
|
||||||
|
|
@ -185,14 +198,14 @@ class GrocyFrontendHelpers
|
||||||
if (transferCss)
|
if (transferCss)
|
||||||
{
|
{
|
||||||
// Transfer CSS classes of selected element to dropdown element (for background)
|
// 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();
|
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();
|
table.column(column).search("").draw();
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -202,7 +215,8 @@ class GrocyFrontendHelpers
|
||||||
}
|
}
|
||||||
MakeValueFilter(key, column, dataTable, resetValue = "all")
|
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();
|
var value = $(this).val();
|
||||||
if (value === "all")
|
if (value === "all")
|
||||||
|
|
@ -211,22 +225,22 @@ class GrocyFrontendHelpers
|
||||||
}
|
}
|
||||||
|
|
||||||
// Transfer CSS classes of selected element to dropdown element (for background)
|
// 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();
|
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");
|
var value = $(this).data(key + "-filter");
|
||||||
$("#" + key + "-filter").val(value);
|
self.$scope("#" + key + "-filter").val(value);
|
||||||
$("#" + key + "-filter").trigger("change");
|
self.$scope("#" + key + "-filter").trigger("change");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#clear-filter-button").on("click", function()
|
this.$scope("#clear-filter-button").on("click", function()
|
||||||
{
|
{
|
||||||
$("#" + key + "-filter").val(resetValue);
|
self.$scope("#" + key + "-filter").val(resetValue);
|
||||||
$("#" + key + "-filter").trigger("change");
|
self.$scope("#" + key + "-filter").trigger("change");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -234,7 +248,7 @@ class GrocyFrontendHelpers
|
||||||
{
|
{
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
$(document).on('click', selector, function(e)
|
this.scope.on('click', selector, function(e)
|
||||||
{
|
{
|
||||||
message = message instanceof Function ? message(e) : message;
|
message = message instanceof Function ? message(e) : message;
|
||||||
bootbox.confirm({
|
bootbox.confirm({
|
||||||
|
|
@ -268,7 +282,7 @@ class GrocyFrontendHelpers
|
||||||
}
|
}
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
$(document).on('click', selector, function(e)
|
this.scope.on('click', selector, function(e)
|
||||||
{
|
{
|
||||||
var target = $(e.currentTarget);
|
var target = $(e.currentTarget);
|
||||||
var objectName = attrName instanceof Function ? attrName(target) : target.attr(attrName);
|
var objectName = attrName instanceof Function ? attrName(target) : target.attr(attrName);
|
||||||
|
|
|
||||||
184
js/lib/proxy.js
Normal file
184
js/lib/proxy.js
Normal file
|
|
@ -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 &
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,7 +12,7 @@
|
||||||
$(this).parent().next().collapse("toggle");
|
$(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");
|
$scope(".nav-tabs a[href='#changelog']").tab("show");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -47,9 +47,9 @@
|
||||||
$scope("#barcodescanner-start-button").addClass("disabled");
|
$scope("#barcodescanner-start-button").addClass("disabled");
|
||||||
}, 200);
|
}, 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()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
$scope("#expected_barcode").keyup();
|
$scope("#expected_barcode").keyup();
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (GetUriParam('include_disabled'))
|
if (Grocy.GetUriParam('include_disabled'))
|
||||||
{
|
{
|
||||||
$scope("#show-disabled").prop('checked', true);
|
$scope("#show-disabled").prop('checked', true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
Grocy.FrontendHelpers.InitDataTable(batteriesJournalTable);
|
Grocy.FrontendHelpers.InitDataTable(batteriesJournalTable);
|
||||||
Grocy.FrontendHelpers.MakeFilterForColumn("#battery-filter", 1, 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");
|
$scope("#battery-filter").trigger("change");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ function batteryformView(Grocy, scope = null)
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -55,7 +55,7 @@ function batteryformView(Grocy, scope = null)
|
||||||
{
|
{
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (GetUriParam('include_disabled'))
|
if (Grocy.GetUriParam('include_disabled'))
|
||||||
{
|
{
|
||||||
$scope("#show-disabled").prop('checked', true);
|
$scope("#show-disabled").prop('checked', true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@
|
||||||
Grocy.FrontendHelpers.InitDataTable(choresJournalTable);
|
Grocy.FrontendHelpers.InitDataTable(choresJournalTable);
|
||||||
Grocy.FrontendHelpers.MakeFilterForColumn("#chore-filter", 1, 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");
|
$scope("#chore-filter").trigger("change");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,11 +30,11 @@
|
||||||
var user = $(this).val();
|
var user = $(this).val();
|
||||||
if (user !== null && !user.isEmpty())
|
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
|
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");
|
$scope("#user-filter").trigger("change");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,10 +65,10 @@ function consumeView(Grocy, scope = null)
|
||||||
|
|
||||||
bookingResponse = result;
|
bookingResponse = result;
|
||||||
|
|
||||||
if (GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
|
if (Grocy.GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
|
||||||
{
|
{
|
||||||
var jsonDataBarcode = {};
|
var jsonDataBarcode = {};
|
||||||
jsonDataBarcode.barcode = GetUriParam("barcode");
|
jsonDataBarcode.barcode = Grocy.GetUriParam("barcode");
|
||||||
jsonDataBarcode.product_id = jsonForm.product_id;
|
jsonDataBarcode.product_id = jsonForm.product_id;
|
||||||
|
|
||||||
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
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) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="Grocy.UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
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) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="Grocy.UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), 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();
|
$scope("#use_specific_stock_entry").click();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
stockId = GetUriParam('stockId');
|
stockId = Grocy.GetUriParam('stockId');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -568,9 +568,9 @@ function consumeView(Grocy, scope = null)
|
||||||
RefreshForm();
|
RefreshForm();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
var locationId = GetUriParam('locationId');
|
var locationId = Grocy.GetUriParam('locationId');
|
||||||
|
|
||||||
if (typeof locationId === 'undefined')
|
if (typeof locationId === 'undefined')
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -66,10 +66,10 @@ function inventoryView(Grocy, scope = null)
|
||||||
{
|
{
|
||||||
bookingResponse = result;
|
bookingResponse = result;
|
||||||
|
|
||||||
if (GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
|
if (Grocy.GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
|
||||||
{
|
{
|
||||||
var jsonDataBarcode = {};
|
var jsonDataBarcode = {};
|
||||||
jsonDataBarcode.barcode = GetUriParam("barcode");
|
jsonDataBarcode.barcode = Grocy.GetUriParam("barcode");
|
||||||
jsonDataBarcode.product_id = jsonForm.product_id;
|
jsonDataBarcode.product_id = jsonForm.product_id;
|
||||||
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_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)) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="Grocy.UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
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)) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="Grocy.UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), 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");
|
$scope(".input-group-productamountpicker").trigger("change");
|
||||||
Grocy.FrontendHelpers.ValidateForm('inventory-form');
|
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();
|
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ function locationformView(Grocy, scope = null)
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -54,7 +54,7 @@ function locationformView(Grocy, scope = null)
|
||||||
{
|
{
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
$scope('#username').focus();
|
$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').text(__t('Invalid credentials, please try again'));
|
||||||
$scope('#login-error').removeClass('d-none');
|
$scope('#login-error').removeClass('d-none');
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ function manageapikeysView(Grocy, scope = null)
|
||||||
$scope('#apikeys-table tbody').removeClass("d-none");
|
$scope('#apikeys-table tbody').removeClass("d-none");
|
||||||
Grocy.FrontendHelpers.InitDataTable(apiKeysTable);
|
Grocy.FrontendHelpers.InitDataTable(apiKeysTable);
|
||||||
|
|
||||||
var createdApiKeyId = GetUriParam('CreatedApiKeyId');
|
var createdApiKeyId = Grocy.GetUriParam('CreatedApiKeyId');
|
||||||
if (createdApiKeyId !== undefined)
|
if (createdApiKeyId !== undefined)
|
||||||
{
|
{
|
||||||
animateCSS("#apiKeyRow_" + createdApiKeyId, "pulse");
|
animateCSS("#apiKeyRow_" + createdApiKeyId, "pulse");
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ function mealplanView(Grocy, scope = null)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
UpdateUriParam("week", start.format("YYYY-MM-DD"));
|
Grocy.UpdateUriParam("week", start.format("YYYY-MM-DD"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope(".fc-day-header").prepend('\
|
$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;
|
// this triggers a re-render, so we can't do that in the callback;
|
||||||
// but it works here no problem.
|
// 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)
|
top.on("click", ".add-recipe-button", function(e)
|
||||||
|
|
|
||||||
|
|
@ -37,8 +37,8 @@ function productbarcodeformView(Grocy, scope = null)
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save()
|
Grocy.Components.UserfieldsForm.Save()
|
||||||
|
|
||||||
window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), U("/product/" + GetUriParam("product")));
|
window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), U("/product/" + Grocy.GetUriParam("product")));
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + Grocy.GetUriParam("product")));
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
|
|
@ -53,8 +53,8 @@ function productbarcodeformView(Grocy, scope = null)
|
||||||
Grocy.Api.Put('objects/product_barcodes/' + Grocy.EditObjectId, jsonData,
|
Grocy.Api.Put('objects/product_barcodes/' + Grocy.EditObjectId, jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), U("/product/" + GetUriParam("product")));
|
window.parent.postMessage(WindowMessageBag("ProductBarcodesChanged"), U("/product/" + Grocy.GetUriParam("product")));
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + Grocy.GetUriParam("product")));
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -31,14 +31,14 @@ function productformView(Grocy, scope = null)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var returnTo = GetUriParam('returnto');
|
var returnTo = Grocy.GetUriParam('returnto');
|
||||||
if (GetUriParam("closeAfterCreation") !== undefined)
|
if (Grocy.GetUriParam("closeAfterCreation") !== undefined)
|
||||||
{
|
{
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
else if (returnTo !== undefined)
|
else if (returnTo !== undefined)
|
||||||
{
|
{
|
||||||
if (GetUriParam("flow") !== undefined)
|
if (Grocy.GetUriParam("flow") !== undefined)
|
||||||
{
|
{
|
||||||
window.location.href = U(returnTo) + '&product-name=' + encodeURIComponent($scope('#name').val());
|
window.location.href = U(returnTo) + '&product-name=' + encodeURIComponent($scope('#name').val());
|
||||||
}
|
}
|
||||||
|
|
@ -69,14 +69,14 @@ function productformView(Grocy, scope = null)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var returnTo = GetUriParam('returnto');
|
var returnTo = Grocy.GetUriParam('returnto');
|
||||||
if (GetUriParam("closeAfterCreation") !== undefined)
|
if (Grocy.GetUriParam("closeAfterCreation") !== undefined)
|
||||||
{
|
{
|
||||||
window.close();
|
window.close();
|
||||||
}
|
}
|
||||||
else if (returnTo !== undefined)
|
else if (returnTo !== undefined)
|
||||||
{
|
{
|
||||||
if (GetUriParam("flow") !== undefined)
|
if (Grocy.GetUriParam("flow") !== undefined)
|
||||||
{
|
{
|
||||||
window.location.href = U(returnTo) + '&product-name=' + encodeURIComponent($scope('#name').val());
|
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();
|
$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-hint").addClass("d-none");
|
||||||
$scope(".save-product-button[data-location='return']").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)
|
function(sourceProduct)
|
||||||
{
|
{
|
||||||
if (sourceProduct.parent_product_id != null)
|
if (sourceProduct.parent_product_id != null)
|
||||||
|
|
|
||||||
|
|
@ -25,9 +25,9 @@
|
||||||
})
|
})
|
||||||
|
|
||||||
Grocy.FrontendHelpers.MakeFilterForColumn("#product-group-filter", 6, productsTable);
|
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");
|
$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);
|
$scope("#show-disabled").prop('checked', true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,10 +109,10 @@ function purchaseView(Grocy, scope = null)
|
||||||
Grocy.UISound.Success();
|
Grocy.UISound.Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetUriParam("flow") == "InplaceAddBarcodeToExistingProduct")
|
if (Grocy.GetUriParam("flow") == "InplaceAddBarcodeToExistingProduct")
|
||||||
{
|
{
|
||||||
var jsonDataBarcode = {};
|
var jsonDataBarcode = {};
|
||||||
jsonDataBarcode.barcode = GetUriParam("barcode");
|
jsonDataBarcode.barcode = Grocy.GetUriParam("barcode");
|
||||||
jsonDataBarcode.product_id = jsonForm.product_id;
|
jsonDataBarcode.product_id = jsonForm.product_id;
|
||||||
jsonDataBarcode.shopping_location_id = jsonForm.shopping_location_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("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("ShowSuccessMessage", successMessage), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Ready"), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), 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('#display_amount').val(parseFloat(Grocy.UserSettings.stock_default_purchase_amount));
|
||||||
$scope(".input-group-productamountpicker").trigger("change");
|
$scope(".input-group-productamountpicker").trigger("change");
|
||||||
|
|
||||||
if (GetUriParam("flow") === "shoppinglistitemtostock")
|
if (Grocy.GetUriParam("flow") === "shoppinglistitemtostock")
|
||||||
{
|
{
|
||||||
Grocy.Components.ProductAmountPicker.SetQuantityUnit(GetUriParam("quId"));
|
Grocy.Components.ProductAmountPicker.SetQuantityUnit(Grocy.GetUriParam("quId"));
|
||||||
$scope('#display_amount').val(parseFloat(GetUriParam("amount") * $scope("#qu_id option:selected").attr("data-qu-factor")));
|
$scope('#display_amount').val(parseFloat(Grocy.GetUriParam("amount") * $scope("#qu_id option:selected").attr("data-qu-factor")));
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope(".input-group-productamountpicker").trigger("change");
|
$scope(".input-group-productamountpicker").trigger("change");
|
||||||
|
|
@ -346,7 +346,7 @@ function purchaseView(Grocy, scope = null)
|
||||||
$scope("#display_amount").focus();
|
$scope("#display_amount").focus();
|
||||||
|
|
||||||
Grocy.FrontendHelpers.ValidateForm('purchase-form');
|
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();
|
$scope("#save-purchase-button").click();
|
||||||
}
|
}
|
||||||
|
|
@ -425,7 +425,7 @@ function purchaseView(Grocy, scope = null)
|
||||||
|
|
||||||
if (Grocy.Components.ProductPicker)
|
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();
|
Grocy.Components.ProductPicker.GetInputElement().focus();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,21 +50,21 @@ function quantityunitconversionformView(Grocy, scope = null)
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
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);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.location.href = U("/quantityunit/" + GetUriParam("qu-unit"));
|
window.location.href = U("/quantityunit/" + Grocy.GetUriParam("qu-unit"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product")));
|
window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + Grocy.GetUriParam("product")));
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + GetUriParam("product")));
|
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + Grocy.GetUriParam("product")));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
@ -77,21 +77,21 @@ function quantityunitconversionformView(Grocy, scope = null)
|
||||||
}
|
}
|
||||||
else
|
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);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.location.href = U("/quantityunit/" + GetUriParam("qu-unit"));
|
window.location.href = U("/quantityunit/" + Grocy.GetUriParam("qu-unit"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product")));
|
window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + Grocy.GetUriParam("product")));
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + 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()
|
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);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.location.href = U("/quantityunit/" + GetUriParam("qu-unit"));
|
window.location.href = U("/quantityunit/" + Grocy.GetUriParam("qu-unit"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + GetUriParam("product")));
|
window.parent.postMessage(WindowMessageBag("ProductQUConversionChanged"), U("/product/" + Grocy.GetUriParam("product")));
|
||||||
window.parent.postMessage(WindowMessageBag("CloseAllModals"), U("/product/" + 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();
|
$scope('#from_qu_id').focus();
|
||||||
Grocy.FrontendHelpers.ValidateForm('quconversion-form');
|
Grocy.FrontendHelpers.ValidateForm('quconversion-form');
|
||||||
|
|
||||||
if (GetUriParam("qu-unit") !== undefined)
|
if (Grocy.GetUriParam("qu-unit") !== undefined)
|
||||||
{
|
{
|
||||||
$scope("#from_qu_id").attr("disabled", "");
|
$scope("#from_qu_id").attr("disabled", "");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -72,7 +72,7 @@
|
||||||
{
|
{
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,9 +38,9 @@
|
||||||
$scope("#result").text(__n(amount, singularForm, pluralForm));
|
$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");
|
$scope("#qu_id").trigger("change");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,12 +46,12 @@
|
||||||
$scope("#status-filter").trigger("change");
|
$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");
|
$scope(".nav-tabs a[href='#gallery']").tab("show");
|
||||||
}
|
}
|
||||||
|
|
||||||
var recipe = GetUriParam("recipe");
|
var recipe = Grocy.GetUriParam("recipe");
|
||||||
if (typeof recipe !== "undefined")
|
if (typeof recipe !== "undefined")
|
||||||
{
|
{
|
||||||
$scope("#recipes-table tr").removeClass("selected");
|
$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()
|
setTimeout(function()
|
||||||
{
|
{
|
||||||
$scope("#search").keyup();
|
$scope("#search").keyup();
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ function shoppinglistitemformView(Grocy, scope = null)
|
||||||
|
|
||||||
Grocy.FrontendHelpers.BeginUiBusy("shoppinglist-form");
|
Grocy.FrontendHelpers.BeginUiBusy("shoppinglist-form");
|
||||||
|
|
||||||
if (GetUriParam("updateexistingproduct") !== undefined)
|
if (Grocy.GetUriParam("updateexistingproduct") !== undefined)
|
||||||
{
|
{
|
||||||
jsonData.product_amount = jsonData.amount;
|
jsonData.product_amount = jsonData.amount;
|
||||||
delete jsonData.amount;
|
delete jsonData.amount;
|
||||||
|
|
@ -42,7 +42,7 @@ function shoppinglistitemformView(Grocy, scope = null)
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save();
|
Grocy.Components.UserfieldsForm.Save();
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
Grocy.Api.Get('stock/products/' + jsonData.product_id,
|
Grocy.Api.Get('stock/products/' + jsonData.product_id,
|
||||||
function(productDetails)
|
function(productDetails)
|
||||||
|
|
@ -77,7 +77,7 @@ function shoppinglistitemformView(Grocy, scope = null)
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save();
|
Grocy.Components.UserfieldsForm.Save();
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
if (jsonData.product_id)
|
if (jsonData.product_id)
|
||||||
{
|
{
|
||||||
|
|
@ -119,7 +119,7 @@ function shoppinglistitemformView(Grocy, scope = null)
|
||||||
{
|
{
|
||||||
Grocy.Components.UserfieldsForm.Save();
|
Grocy.Components.UserfieldsForm.Save();
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
if (jsonData.product_id)
|
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();
|
RefreshLocaleNumberInput();
|
||||||
$scope(".input-group-productamountpicker").trigger("change");
|
$scope(".input-group-productamountpicker").trigger("change");
|
||||||
Grocy.FrontendHelpers.ValidateForm('shoppinglist-form');
|
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');
|
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||||
$scope("#display_amount").focus();
|
$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');
|
Grocy.Components.ProductPicker.GetPicker().trigger('change');
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ function shoppinglocationformView(Grocy, scope = null)
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -54,7 +54,7 @@ function shoppinglocationformView(Grocy, scope = null)
|
||||||
{
|
{
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@
|
||||||
Grocy.FrontendHelpers.MakeFilterForColumn("#location-filter", 5, stockJournalTable);
|
Grocy.FrontendHelpers.MakeFilterForColumn("#location-filter", 5, stockJournalTable);
|
||||||
Grocy.FrontendHelpers.MakeFilterForColumn("#user-filter", 6, 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");
|
$scope("#product-filter").trigger("change");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
{
|
{
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
{
|
{
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (GetUriParam('include_done'))
|
if (Grocy.GetUriParam('include_done'))
|
||||||
{
|
{
|
||||||
$scope("#show-done-tasks").prop('checked', true);
|
$scope("#show-done-tasks").prop('checked', true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,10 +46,10 @@ function transferView(Grocy, scope = null)
|
||||||
{
|
{
|
||||||
bookingResponse = result;
|
bookingResponse = result;
|
||||||
|
|
||||||
if (GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
|
if (Grocy.GetUriParam("flow") === "InplaceAddBarcodeToExistingProduct")
|
||||||
{
|
{
|
||||||
var jsonDataBarcode = {};
|
var jsonDataBarcode = {};
|
||||||
jsonDataBarcode.barcode = GetUriParam("barcode");
|
jsonDataBarcode.barcode = Grocy.GetUriParam("barcode");
|
||||||
jsonDataBarcode.product_id = jsonForm.product_id;
|
jsonDataBarcode.product_id = jsonForm.product_id;
|
||||||
|
|
||||||
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
Grocy.Api.Post('objects/product_barcodes', jsonDataBarcode,
|
||||||
|
|
@ -91,7 +91,7 @@ function transferView(Grocy, scope = null)
|
||||||
$scope('option:selected', "#location_id_to").text()
|
$scope('option:selected', "#location_id_to").text()
|
||||||
) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="Grocy.UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
) + '<br><a class="btn btn-secondary btn-sm mt-2" href="#" onclick="Grocy.UndoStockTransaction(\'' + bookingResponse[0].transaction_id + '\')"><i class="fas fa-undo"></i> ' + __t("Undo") + '</a>';
|
||||||
|
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("ProductChanged", jsonForm.product_id), Grocy.BaseUrl);
|
||||||
window.parent.postMessage(WindowMessageBag("ShowSuccessMessage", successMessage), 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)
|
Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
|
||||||
{
|
{
|
||||||
$scope("#specific_stock_entry").find("option").remove().end().append("<option></option>");
|
$scope("#specific_stock_entry").find("option").remove().end().append("<option></option>");
|
||||||
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("#use_specific_stock_entry").click();
|
||||||
}
|
}
|
||||||
$scope("#location_id_to").val("");
|
$scope("#location_id_to").val("");
|
||||||
if (GetUriParam("stockId") == null)
|
if (Grocy.GetUriParam("stockId") == null)
|
||||||
{
|
{
|
||||||
$scope("#location_id_from").val("");
|
$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");
|
$scope("#location_id_from").trigger("change");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -315,13 +315,13 @@ function transferView(Grocy, scope = null)
|
||||||
$scope("#location_id_to").val("");
|
$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("<option></option>");
|
$scope("#specific_stock_entry").find("option").remove().end().append("<option></option>");
|
||||||
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("#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')
|
if (typeof locationId === 'undefined')
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ function userentityformView(Grocy, scope = null)
|
||||||
Grocy.Api.Post('objects/userentities', jsonData,
|
Grocy.Api.Post('objects/userentities', jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -48,7 +48,7 @@ function userentityformView(Grocy, scope = null)
|
||||||
Grocy.Api.Put('objects/userentities/' + Grocy.EditObjectId, jsonData,
|
Grocy.Api.Put('objects/userentities/' + Grocy.EditObjectId, jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,9 @@ function userfieldformView(Grocy, scope = null)
|
||||||
Grocy.FrontendHelpers.BeginUiBusy("userfield-form");
|
Grocy.FrontendHelpers.BeginUiBusy("userfield-form");
|
||||||
|
|
||||||
var redirectUrl = U("/userfields");
|
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')
|
if (Grocy.EditMode === 'create')
|
||||||
|
|
@ -33,7 +33,7 @@ function userfieldformView(Grocy, scope = null)
|
||||||
Grocy.Api.Post('objects/userfields', jsonData,
|
Grocy.Api.Post('objects/userfields', jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -54,7 +54,7 @@ function userfieldformView(Grocy, scope = null)
|
||||||
Grocy.Api.Put('objects/userfields/' + Grocy.EditObjectId, jsonData,
|
Grocy.Api.Put('objects/userfields/' + Grocy.EditObjectId, jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -117,9 +117,9 @@ function userfieldformView(Grocy, scope = null)
|
||||||
|
|
||||||
$scope('#entity').focus();
|
$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("#entity").trigger("change");
|
||||||
$scope('#name').focus();
|
$scope('#name').focus();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,9 +44,9 @@
|
||||||
'/userfields'
|
'/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("#entity-filter").trigger("change");
|
||||||
$scope("#name").focus();
|
$scope("#name").focus();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (GetUriParam("changepw") === "true")
|
if (Grocy.GetUriParam("changepw") === "true")
|
||||||
{
|
{
|
||||||
$scope('#password').focus();
|
$scope('#password').focus();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ function userobjectformView(Grocy, scope = null)
|
||||||
Grocy.EditObjectId = result.created_object_id;
|
Grocy.EditObjectId = result.created_object_id;
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
@ -56,7 +56,7 @@ function userobjectformView(Grocy, scope = null)
|
||||||
{
|
{
|
||||||
Grocy.Components.UserfieldsForm.Save(function()
|
Grocy.Components.UserfieldsForm.Save(function()
|
||||||
{
|
{
|
||||||
if (GetUriParam("embedded") !== undefined)
|
if (Grocy.GetUriParam("embedded") !== undefined)
|
||||||
{
|
{
|
||||||
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
window.parent.postMessage(WindowMessageBag("Reload"), Grocy.BaseUrl);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user