diff --git a/js/components/BasePicker.js b/js/components/BasePicker.js index ab718b49..53faba76 100644 --- a/js/components/BasePicker.js +++ b/js/components/BasePicker.js @@ -10,7 +10,7 @@ class BasePicker this.$ = scopeSelector != null ? $(scopeSelector).find : $; this.picker = null; - this.input_element; + this.input_element = null; this.basename = basename; } diff --git a/js/components/barcodescanner.js b/js/components/barcodescanner.js index c5e86196..79cbb8c0 100644 --- a/js/components/barcodescanner.js +++ b/js/components/barcodescanner.js @@ -139,7 +139,7 @@ class barcodescanner setTimeout(function() { - this.$scope(".barcodescanner-input:visible").each(function() + self.$(".barcodescanner-input:visible").each(function() { if ($(this).hasAttr("disabled")) { diff --git a/js/components/numberpicker.js b/js/components/numberpicker.js index 5843b821..dfd7630d 100644 --- a/js/components/numberpicker.js +++ b/js/components/numberpicker.js @@ -41,9 +41,11 @@ class numberpicker var observer = new MutationObserver((mutations) => self.handleObservedChange(mutations)); - this.$(".numberpicker").each(() => observer.observe(this, { - attributes: true - })); + var elements = this.$(".numberpicker"); + for (let element of elements) + { + observer.observe(element, { attributes: true }); + } this.$(".numberpicker").attr("data-initialised", "true"); // Dummy change to trigger MutationObserver above once } diff --git a/js/components/productpicker.js b/js/components/productpicker.js index 4518021d..5af0340a 100644 --- a/js/components/productpicker.js +++ b/js/components/productpicker.js @@ -10,7 +10,7 @@ class productpicker extends BasePicker this.Grocy.Use('barcodescanner'); this.picker = this.$('#product_id'); - this.inputElement = this.$('#product_id_text_input'); + this.input_element = this.$('#product_id_text_input'); var self = this; @@ -142,14 +142,14 @@ class productpicker extends BasePicker Disable() { - this.inputElement.attr("disabled", ""); + this.input_element.attr("disabled", ""); this.$("#barcodescanner-start-button").attr("disabled", ""); this.$("#barcodescanner-start-button").addClass("disabled"); } Enable() { - this.inputElement.removeAttr("disabled"); + this.input_element.removeAttr("disabled"); this.$("#barcodescanner-start-button").removeAttr("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... - this.inputElement + this.input_element .focusout() .focus() .blur(); - this.inputElement.val(barcode); + this.input_element.val(barcode); setTimeout(function() { - self.inputElement + self.input_element .focusout() .focus() .blur(); diff --git a/js/components/shoppinglocationpicker.js b/js/components/shoppinglocationpicker.js index 77441ca4..807e5444 100644 --- a/js/components/shoppinglocationpicker.js +++ b/js/components/shoppinglocationpicker.js @@ -10,7 +10,7 @@ class shoppinglocationpicker extends BasePicker this.picker = this.$(this.basename); this.input_element = this.$(this.basename + '_text_input'); - this.initCombobox('.recipe-combobox'); + this.initCombobox('.shopping-location-combobox'); this.prefill(); } } diff --git a/js/components/userpicker.js b/js/components/userpicker.js index 6762f345..d9ff2467 100644 --- a/js/components/userpicker.js +++ b/js/components/userpicker.js @@ -9,7 +9,7 @@ class userpicker extends BasePicker this.picker = this.$(this.basename); this.input_element = this.$(this.basename + '_text_input'); - this.initCombobox('.recipe-combobox'); + this.initCombobox('.user-combobox'); this.prefill(); } diff --git a/js/grocy.js b/js/grocy.js index 4025c6c2..7de7435e 100644 --- a/js/grocy.js +++ b/js/grocy.js @@ -221,14 +221,14 @@ class GrocyClass let scopeName = scope || ""; // initialize Components only once per scope 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)) { // add-then-init to resolve circular dependencies this.initComponents.push(componentName); - var component = components[componentName](this, scope); - this.components[componentName + scopeName] = component; + var component = new components[componentName](this, scope); + this.Components[componentName + scopeName] = component; return component; } else diff --git a/js/lib/proxy.js b/js/lib/proxy.js index 65eaf073..511ae436 100644 --- a/js/lib/proxy.js +++ b/js/lib/proxy.js @@ -85,14 +85,14 @@ class GrocyProxy let scopeName = scope || ""; // initialize Components only once per scope 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)) { // add-then-init to resolve circular dependencies this.initComponents.push(componentName); - var component = components[componentName](this, scope); - this.components[componentName + scopeName] = component; + var component = new components[componentName](this, scope); + this.Components[componentName + scopeName] = component; return component; } else diff --git a/js/viewjs/tasks.js b/js/viewjs/tasks.js index 28d8e440..207c4d90 100644 --- a/js/viewjs/tasks.js +++ b/js/viewjs/tasks.js @@ -8,8 +8,6 @@ $scope = $(scope).find; } - Grocy.Use("userpicker"); - var tasksTable = $scope('#tasks-table').DataTable({ 'order': [[2, 'asc']], 'columnDefs': [ diff --git a/views/layout/default.blade.php b/views/layout/default.blade.php index f8dc686e..3525e5ad 100644 --- a/views/layout/default.blade.php +++ b/views/layout/default.blade.php @@ -659,7 +659,7 @@ diff --git a/views/productform.blade.php b/views/productform.blade.php index 3d8d9a50..64045a9d 100644 --- a/views/productform.blade.php +++ b/views/productform.blade.php @@ -585,6 +585,7 @@ + @if($mode == 'edit')