Fix some implementation errors

This commit is contained in:
Katharina Bogad 2021-06-23 23:38:59 +02:00
parent bda2a742ae
commit 6b5440cf7a
11 changed files with 24 additions and 22 deletions

View File

@ -10,7 +10,7 @@ class BasePicker
this.$ = scopeSelector != null ? $(scopeSelector).find : $; this.$ = scopeSelector != null ? $(scopeSelector).find : $;
this.picker = null; this.picker = null;
this.input_element; this.input_element = null;
this.basename = basename; this.basename = basename;
} }

View File

@ -139,7 +139,7 @@ class barcodescanner
setTimeout(function() setTimeout(function()
{ {
this.$scope(".barcodescanner-input:visible").each(function() self.$(".barcodescanner-input:visible").each(function()
{ {
if ($(this).hasAttr("disabled")) if ($(this).hasAttr("disabled"))
{ {

View File

@ -41,9 +41,11 @@ class numberpicker
var observer = new MutationObserver((mutations) => self.handleObservedChange(mutations)); var observer = new MutationObserver((mutations) => self.handleObservedChange(mutations));
this.$(".numberpicker").each(() => observer.observe(this, { var elements = this.$(".numberpicker");
attributes: true for (let element of elements)
})); {
observer.observe(element, { attributes: true });
}
this.$(".numberpicker").attr("data-initialised", "true"); // Dummy change to trigger MutationObserver above once this.$(".numberpicker").attr("data-initialised", "true"); // Dummy change to trigger MutationObserver above once
} }

View File

@ -10,7 +10,7 @@ class productpicker extends BasePicker
this.Grocy.Use('barcodescanner'); this.Grocy.Use('barcodescanner');
this.picker = this.$('#product_id'); this.picker = this.$('#product_id');
this.inputElement = this.$('#product_id_text_input'); this.input_element = this.$('#product_id_text_input');
var self = this; var self = this;
@ -142,14 +142,14 @@ class productpicker extends BasePicker
Disable() Disable()
{ {
this.inputElement.attr("disabled", ""); this.input_element.attr("disabled", "");
this.$("#barcodescanner-start-button").attr("disabled", ""); this.$("#barcodescanner-start-button").attr("disabled", "");
this.$("#barcodescanner-start-button").addClass("disabled"); this.$("#barcodescanner-start-button").addClass("disabled");
} }
Enable() Enable()
{ {
this.inputElement.removeAttr("disabled"); this.input_element.removeAttr("disabled");
this.$("#barcodescanner-start-button").removeAttr("disabled"); this.$("#barcodescanner-start-button").removeAttr("disabled");
this.$("#barcodescanner-start-button").removeClass("disabled"); this.$("#barcodescanner-start-button").removeClass("disabled");
} }
@ -330,16 +330,16 @@ class productpicker extends BasePicker
} }
// Don't know why the blur event does not fire immediately ... this works... // Don't know why the blur event does not fire immediately ... this works...
this.inputElement this.input_element
.focusout() .focusout()
.focus() .focus()
.blur(); .blur();
this.inputElement.val(barcode); this.input_element.val(barcode);
setTimeout(function() setTimeout(function()
{ {
self.inputElement self.input_element
.focusout() .focusout()
.focus() .focus()
.blur(); .blur();

View File

@ -10,7 +10,7 @@ class shoppinglocationpicker extends BasePicker
this.picker = this.$(this.basename); this.picker = this.$(this.basename);
this.input_element = this.$(this.basename + '_text_input'); this.input_element = this.$(this.basename + '_text_input');
this.initCombobox('.recipe-combobox'); this.initCombobox('.shopping-location-combobox');
this.prefill(); this.prefill();
} }
} }

View File

@ -9,7 +9,7 @@ class userpicker extends BasePicker
this.picker = this.$(this.basename); this.picker = this.$(this.basename);
this.input_element = this.$(this.basename + '_text_input'); this.input_element = this.$(this.basename + '_text_input');
this.initCombobox('.recipe-combobox'); this.initCombobox('.user-combobox');
this.prefill(); this.prefill();
} }

View File

@ -221,14 +221,14 @@ class GrocyClass
let scopeName = scope || ""; let scopeName = scope || "";
// initialize Components only once per scope // initialize Components only once per scope
if (this.initComponents.find(elem => elem == componentName + scopeName)) if (this.initComponents.find(elem => elem == componentName + scopeName))
return this.components[componentName + scopeName]; return this.Components[componentName + scopeName];
if (Object.prototype.hasOwnProperty.call(components, componentName)) if (Object.prototype.hasOwnProperty.call(components, componentName))
{ {
// add-then-init to resolve circular dependencies // add-then-init to resolve circular dependencies
this.initComponents.push(componentName); this.initComponents.push(componentName);
var component = components[componentName](this, scope); var component = new components[componentName](this, scope);
this.components[componentName + scopeName] = component; this.Components[componentName + scopeName] = component;
return component; return component;
} }
else else

View File

@ -85,14 +85,14 @@ class GrocyProxy
let scopeName = scope || ""; let scopeName = scope || "";
// initialize Components only once per scope // initialize Components only once per scope
if (this.initComponents.find(elem => elem == componentName + scopeName)) if (this.initComponents.find(elem => elem == componentName + scopeName))
return this.components[componentName + scopeName]; return this.Components[componentName + scopeName];
if (Object.prototype.hasOwnProperty.call(components, componentName)) if (Object.prototype.hasOwnProperty.call(components, componentName))
{ {
// add-then-init to resolve circular dependencies // add-then-init to resolve circular dependencies
this.initComponents.push(componentName); this.initComponents.push(componentName);
var component = components[componentName](this, scope); var component = new components[componentName](this, scope);
this.components[componentName + scopeName] = component; this.Components[componentName + scopeName] = component;
return component; return component;
} }
else else

View File

@ -8,8 +8,6 @@
$scope = $(scope).find; $scope = $(scope).find;
} }
Grocy.Use("userpicker");
var tasksTable = $scope('#tasks-table').DataTable({ var tasksTable = $scope('#tasks-table').DataTable({
'order': [[2, 'asc']], 'order': [[2, 'asc']],
'columnDefs': [ 'columnDefs': [

View File

@ -659,7 +659,7 @@
<script> <script>
let viewjsname = null; let viewjsname = null;
@hasSection('viewJsName') @hasSection('viewJsName')
viejsname = "@yield('viewJsName')"; viewjsname = "@yield('viewJsName')";
@endif @endif
GrocyClass.createSingleton(GrocyConfig, viewjsname); GrocyClass.createSingleton(GrocyConfig, viewjsname);
</script> </script>

View File

@ -585,6 +585,7 @@
</div> </div>
</div> </div>
@if($mode == 'edit')
<div class="row mt-2"> <div class="row mt-2">
<div class="col clearfix"> <div class="col clearfix">
<div class="title-related-links"> <div class="title-related-links">
@ -612,6 +613,7 @@
</div> </div>
</div> </div>
</div> </div>
@endif
<div class="row @if(GROCY_FEATURE_FLAG_STOCK) mt-5 @endif"> <div class="row @if(GROCY_FEATURE_FLAG_STOCK) mt-5 @endif">
<div class="col"> <div class="col">