Skip to content

Commit c266b2a

Browse files
committed
Rewrote mage/adminhtml/sales.js without prototypejs
1 parent c402b97 commit c266b2a

File tree

7 files changed

+943
-932
lines changed

7 files changed

+943
-932
lines changed

app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Items.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* @package Mage_Adminhtml
77
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
88
* @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://openmage.org)
9-
* @copyright Copyright (c) 2024 Maho (https://mahocommerce.com)
9+
* @copyright Copyright (c) 2024-2025 Maho (https://mahocommerce.com)
1010
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1111
*/
1212

@@ -19,17 +19,18 @@ class Mage_Adminhtml_Block_Sales_Order_Create_Items extends Mage_Adminhtml_Block
1919
{
2020
/**
2121
* Contains button descriptions to be shown at the top of accordion
22-
* @var array
22+
* @var list<array>
2323
*/
2424
protected $_buttons = [];
2525

26-
/**
27-
* Define block ID
28-
*/
2926
public function __construct()
3027
{
3128
parent::__construct();
3229
$this->setId('sales_order_create_items');
30+
$this->addButton([
31+
'label' => Mage::helper('sales')->__('Add Products'),
32+
'onclick' => 'order.productGridShow()',
33+
]);
3334
}
3435

3536
/**

app/code/core/Mage/Adminhtml/Block/Sales/Order/Create/Search.php

Lines changed: 36 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* @package Mage_Adminhtml
77
* @copyright Copyright (c) 2006-2020 Magento, Inc. (https://magento.com)
88
* @copyright Copyright (c) 2022-2024 The OpenMage Contributors (https://openmage.org)
9+
* @copyright Copyright (c) 2025 Maho (https://mahocommerce.com)
910
* @license https://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
1011
*/
1112

@@ -16,10 +17,25 @@
1617
*/
1718
class Mage_Adminhtml_Block_Sales_Order_Create_Search extends Mage_Adminhtml_Block_Sales_Order_Create_Abstract
1819
{
20+
/**
21+
* Contains button descriptions to be shown at the top of accordion
22+
* @var list<array>
23+
*/
24+
protected $_buttons = [];
25+
1926
public function __construct()
2027
{
2128
parent::__construct();
2229
$this->setId('sales_order_create_search');
30+
$this->addButton([
31+
'label' => Mage::helper('sales')->__('Add Selected Product(s) to Order'),
32+
'onclick' => 'order.productGridAddSelected()',
33+
'class' => 'add',
34+
]);
35+
$this->addButton([
36+
'label' => Mage::helper('sales')->__('Cancel'),
37+
'onclick' => 'order.productGridHide()',
38+
]);
2339
}
2440

2541
/**
@@ -31,16 +47,30 @@ public function getHeaderText()
3147
}
3248

3349
/**
50+
* Add button to the items header
51+
*
52+
* @param array $args
53+
*/
54+
public function addButton($args)
55+
{
56+
$this->_buttons[] = $args;
57+
}
58+
59+
/**
60+
* Render buttons and return HTML code
61+
*
3462
* @return string
3563
*/
3664
public function getButtonsHtml()
3765
{
38-
$addButtonData = [
39-
'label' => Mage::helper('sales')->__('Add Selected Product(s) to Order'),
40-
'onclick' => 'order.productGridAddSelected()',
41-
'class' => 'add',
42-
];
43-
return $this->getLayout()->createBlock('adminhtml/widget_button')->setData($addButtonData)->toHtml();
66+
$html = '';
67+
// Make buttons to be rendered in opposite order of addition. This makes "Add products" the last one.
68+
$this->_buttons = array_reverse($this->_buttons);
69+
foreach ($this->_buttons as $buttonData) {
70+
$html .= $this->getLayout()->createBlock('adminhtml/widget_button')->setData($buttonData)->toHtml();
71+
}
72+
73+
return $html;
4474
}
4575

4676
/**

app/design/adminhtml/default/default/template/sales/order/create/abstract.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
?>
1414
<div class="entry-edit">
1515
<div class="entry-edit-head">
16-
<div style="float: right;"><?= $this->getButtonsHtml() ?></div>
17-
<h4 class="fieldset-legend <?= ($this->getHeaderCssClass()) ? $this->getHeaderCssClass().' icon-head' : '' ?>"><?= $this->getHeaderText() ?></h4>
16+
<h4 class="fieldset-legend <?= $this->getHeaderCssClass() ?: '' ?>"><?= $this->getHeaderText() ?></h4>
17+
<div class="form-buttons"><?= $this->getButtonsHtml() ?></div>
1818
</div>
1919
<div class="fieldset">
2020
<?= $this->getChildHtml('', true, true) ?>

public/js/mage/adminhtml/product/composite/configure.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,16 @@ class ProductConfigure // Maho.Admin.Controller.ProductConfigurePopup
491491
/**
492492
* Helper to find qty of currently confirmed item
493493
*/
494-
getCurrentConfirmedQtyElement() {
494+
getCurrentConfirmedBlock() {
495495
const { listType, itemId } = this.current;
496-
return this._getConfirmedBlock(listType, itemId).querySelector('input[name=qty]');
496+
return this._getConfirmedBlock(listType, itemId);
497+
}
498+
499+
/**
500+
* Helper to find qty of currently confirmed item
501+
*/
502+
getCurrentConfirmedQtyElement() {
503+
return this.getCurrentConfirmedBlock().querySelector('input[name=qty]');
497504
}
498505

499506
/**

0 commit comments

Comments
 (0)