Skip to content

Commit

Permalink
ADD: option to drag the usp item position
Browse files Browse the repository at this point in the history
  • Loading branch information
allrude committed Dec 29, 2024
1 parent 2a17994 commit 119da1b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions Block/Adminhtml/Form/Field/Usps.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
namespace Siteation\StoreInfoUsps\Block\Adminhtml\Form\Field;

use Magento\Config\Block\System\Config\Form\Field\FieldArray\AbstractFieldArray;
use Magento\Framework\Data\Form\Element\AbstractElement;

class Usps extends AbstractFieldArray
{
Expand All @@ -22,4 +23,28 @@ protected function _prepareToRender()
$this->_addAfter = false;
$this->_addButtonLabel = __('Add');
}

protected function _getElementHtml(AbstractElement $element): string
{
$id = $element['html_id'];
$html = parent::_getElementHtml($element);

$script = "<script>
document.addEventListener('DOMContentLoaded', function(event) {
require(['jquery', 'Magento_Theme/js/sortable'], function ($) {
$('#" . $id . "').sortable({
containment: 'parent',
items: 'tbody tr',
tolerance: 'pointer'
});
$('#" . $id . " tbody tr td:last-child').prepend('<span class=\"draggable-handle\" style=\"display: inline-flex; justify-content: center; align-items: center; margin-block: 0.5rem; margin-inline-end: 2rem; vertical-align: baseline;\"></span>');
});
});
</script>";

$html .= $script;

return $html;
}
}
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

[Unreleased]: https://github.com/Siteation/magento2-storeinfo/compare/1.0.0...main

### Added
- Option to drag the usp item position

### Fixed
- Double landmark names

Expand Down

0 comments on commit 119da1b

Please sign in to comment.