From 677b43db021cac66af316b8afca9a9e1593f751f Mon Sep 17 00:00:00 2001 From: shopkeeperdev Date: Thu, 6 Nov 2025 14:23:40 -0500 Subject: [PATCH] Rename package to shopkeeper/module-vendor-notes and fix delete button issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Update package name from shopkeeper/vendornotes to shopkeeper/module-vendor-notes to follow naming conventions - Fix invalid CSS selector issue by prefixing numeric row IDs with 'row_' in getArrayRows() - Resolves JavaScript error: "Failed to execute 'querySelectorAll' on 'Document': 'tr#0 button.action-delete' is not a valid selector" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- Block/Adminhtml/Form/Field/VendorMapping.php | 36 ++++++++++++++++++-- composer.json | 2 +- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/Block/Adminhtml/Form/Field/VendorMapping.php b/Block/Adminhtml/Form/Field/VendorMapping.php index 35e3782..32abffb 100644 --- a/Block/Adminhtml/Form/Field/VendorMapping.php +++ b/Block/Adminhtml/Form/Field/VendorMapping.php @@ -6,6 +6,17 @@ use Magento\Framework\DataObject; class VendorMapping extends AbstractFieldArray { + /** + * Initialise form fields + * + * @return void + */ + protected function _construct() + { + parent::_construct(); + $this->setTemplate('Magento_Config::system/config/form/field/array.phtml'); + } + /** * Prepare rendering the new field by adding all the needed columns */ @@ -16,17 +27,38 @@ class VendorMapping extends AbstractFieldArray 'class' => 'required-entry', 'style' => 'width:200px' ]); - + $this->addColumn('note', [ 'label' => __('Note'), 'class' => 'required-entry', 'style' => 'width:400px' ]); - + $this->_addAfter = false; $this->_addButtonLabel = __('Add Vendor Note'); } + /** + * Obtain existing data from form element + * + * Each row will be instance of Varien_Object + * + * @return array + */ + public function getArrayRows() + { + $result = []; + /** @var DataObject $row */ + foreach (parent::getArrayRows() as $key => $row) { + // Ensure row IDs are prefixed with a non-numeric character + if (is_numeric($key)) { + $key = 'row_' . $key; + } + $result[$key] = $row; + } + return $result; + } + /** * Prepare existing row data object * diff --git a/composer.json b/composer.json index e16c5b6..7c52dc4 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "shopkeeper/vendornotes", + "name": "shopkeeper/module-vendor-notes", "description": "Magento 2 module that adds vendor notes to orders", "type": "magento2-module", "license": "MIT",