OpenMage / magento-lts

Official OpenMage LTS codebase | Migrate easily from Magento Community Edition in minutes! Download the source code for free or contribute to OpenMage LTS | Security vulnerability patches, bug fixes, performance improvements and more.
https://www.openmage.org
Open Software License 3.0
863 stars 438 forks source link

New Feature for developers: Copyable cells in grids #4029

Closed kiatng closed 3 weeks ago

kiatng commented 3 weeks ago

Description (*)

Add copyable property to grid column. When the property is set to true, render the clickable copy icon in the cell:

image

Related Pull Requests

See the main PR #3960 that renders the copy icon and the js that copies the target text. See the enhanced PR #4019 that copies text in the grid without navigating to the edit/view page.

Manual testing scenarios (*)

On any grid class, set 'copyable' => true,`; for example

class Company_Module_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Sales_Order_Grid
{
    protected function _prepareColumns()
    {
        // ...
        parent::_prepareColumns();
        $this->getColumn('real_order_id')->setCopyable(true); // Using setter.

        $this->addColumnAfter('ext_order_id', [
            'header'    => $this->__('STARS Order#'),
            'index'     => 'ext_order_id',
            'copyable'  => true, // Normal use.
        ], 'store_id');
       // ...

Comments

In order for the legacy theme to work, I copy the related CSS from the openmage theme to the default/boxes.css.

kiatng commented 3 weeks ago

Question: should the js be moved from js\varien\js.js to js\mage\adminhtml\tools.js since it's only available in backend.

fballiano commented 3 weeks ago

@kiatng probably yes, I don't see that function be helpful on the frontend :-)

luigifab commented 3 weeks ago

Beautiful!

fballiano commented 3 weeks ago

don't know if i'm seing this right but, at it is now, what was implemented in https://github.com/OpenMage/magento-lts/pull/3960 doesn't seem to work anymore, I don't see any copy-icons in the sales-order page

fballiano commented 3 weeks ago

my fault, sorry, without HTTPS navigator.clipboard is disabled so the whole thing doesn't work.

I don't remember how I tested this feature previously :-\

kiatng commented 3 weeks ago

Modern browsers require https to access the clipboard. For insecure http, you need to use Chrome. In the address bar, enter "chrome://flags/#Insecure-origins-treated-as-secure". Then input the URLs separated with a space in the box of Insecure origins treated as secure

fballiano commented 3 weeks ago

tested, working perfectly

fballiano commented 3 weeks ago

since we didn't get any more feedback I'll merge