-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from avadev/release/2.4.2
release/2.4.2
- Loading branch information
Showing
65 changed files
with
1,323 additions
and
5,651 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
<?php | ||
|
||
/** | ||
* ClassyLlama_AvaTax | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* | ||
* @copyright Copyright (c) 2016 Avalara, Inc. | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
namespace ClassyLlama\AvaTax\Block\Adminhtml\System\Config; | ||
|
||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
|
||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class AvaTax extends ExpandedFieldSet | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function getConfigSearchParamsJson() | ||
{ | ||
$params = []; | ||
if ($this->getRequest()->getParam('section')) { | ||
$params['section'] = $this->getRequest()->getParam('section'); | ||
} | ||
if ($this->getRequest()->getParam('expanded')) { | ||
$params['group'] = $this->getRequest()->getParam('expanded'); | ||
} | ||
if ($this->getRequest()->getParam('field')) { | ||
$params['field'] = $this->getRequest()->getParam('field'); | ||
} | ||
return json_encode($params); | ||
} | ||
|
||
/** | ||
* @inheritDoc | ||
*/ | ||
public function render(AbstractElement $element) | ||
{ | ||
$params = $this->getConfigSearchParamsJson(); | ||
$html = parent::render($element); | ||
$html .= "<script> | ||
require([ | ||
'jquery', | ||
'uiRegistry', | ||
'Magento_Ui/js/modal/confirm', | ||
'mage/translate', | ||
'mage/mage', | ||
'prototype', | ||
'mage/adminhtml/form', | ||
'domReady!', | ||
'jquery/ui' | ||
], function (jQuery) { | ||
var previousTimerOfScroll = false; | ||
function navigateToElementAndScroll(searchRequest, count) { | ||
try { | ||
if ('section' in searchRequest) { | ||
var section = searchRequest.section; | ||
} | ||
if ('group' in searchRequest) { | ||
var group = searchRequest.group; | ||
} | ||
if ('field' in searchRequest) { | ||
var field = searchRequest.field; | ||
} | ||
if (typeof section === 'undefined') { | ||
return; | ||
} | ||
if (typeof group !== 'undefined') { | ||
var groupElementSelector = '#' + group; | ||
var groupElement = jQuery(groupElementSelector); | ||
var headerHeight = jQuery('.page-main-actions').offset().top; | ||
var scrollToTop = groupElement.offset().top - headerHeight; | ||
jQuery('html, body').animate({ | ||
scrollTop: scrollToTop | ||
}, 1000); | ||
if (Math.abs(jQuery(window).scrollTop() - scrollToTop) > 50 && count < 3) { | ||
count = count + 1; | ||
clearTimeout(previousTimerOfScroll); | ||
previousTimerOfScroll = setTimeout(function(){ | ||
navigateToElementAndScroll(searchRequest, count); | ||
},100); | ||
} else { | ||
clearTimeout(previousTimerOfScroll); | ||
} | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
try { | ||
navigateToElementAndScroll(".$params.", 1); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}); | ||
</script>"; | ||
|
||
return $html; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
/** | ||
* ClassyLlama_AvaTax | ||
* | ||
* NOTICE OF LICENSE | ||
* | ||
* This source file is subject to the Open Software License (OSL 3.0) | ||
* that is bundled with this package in the file LICENSE.txt. | ||
* It is also available through the world-wide-web at this URL: | ||
* http://opensource.org/licenses/osl-3.0.php | ||
* | ||
* @copyright Copyright (c) 2016 Avalara, Inc. | ||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) | ||
*/ | ||
namespace ClassyLlama\AvaTax\Block\Adminhtml\System\Config; | ||
|
||
use Magento\Framework\Data\Form\Element\AbstractElement; | ||
|
||
/** | ||
* @api | ||
*/ | ||
/** | ||
* @codeCoverageIgnore | ||
*/ | ||
class ExpandedFieldSet extends \Magento\Config\Block\System\Config\Form\Fieldset | ||
{ | ||
const PARENT_AVATAX_CONFIGURATION_ID = 'tax_avatax_configuration'; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getConfigSearchParams() | ||
{ | ||
$expanded = self::PARENT_AVATAX_CONFIGURATION_ID; | ||
if ($this->getRequest()->getParam('expanded')) { | ||
$expanded = $this->getRequest()->getParam('expanded'); | ||
} | ||
return $expanded; | ||
} | ||
|
||
/** | ||
* Collapsed or expanded fieldset when page loaded? | ||
* | ||
* @param AbstractElement $element | ||
* @return bool | ||
*/ | ||
protected function _isCollapseState($element) | ||
{ | ||
$expanded = $this->getConfigSearchParams(); | ||
/** To Open Requested Group */ | ||
if ($element->getId() == $expanded) { | ||
return true; | ||
} | ||
/** To Open Parent of Requested Group */ | ||
if ($element->getId() == self::PARENT_AVATAX_CONFIGURATION_ID && $expanded != self::PARENT_AVATAX_CONFIGURATION_ID) { | ||
return true; | ||
} | ||
return parent::_isCollapseState($element); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.