Skip to content

Commit

Permalink
Allow to hide or show customized config elements
Browse files Browse the repository at this point in the history
  • Loading branch information
luigifab committed May 25, 2022
1 parent ff70662 commit 5111889
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
3 changes: 1 addition & 2 deletions app/code/core/Mage/Sales/Model/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,7 @@ public function prepareProductEditFormRecurringProfile($observer)
'adminhtml_recurring_profile_edit_form_dependence'
)->addFieldMap('is_recurring', 'product[is_recurring]')
->addFieldMap($profileElement->getHtmlId(), $profileElement->getName())
->addFieldDependence($profileElement->getName(), 'product[is_recurring]', '1')
->addConfigOptions(array('levels_up' => 2));
->addFieldDependence($profileElement->getName(), 'product[is_recurring]', '1');
$observer->getEvent()->getResult()->output .= $dependencies->toHtml();
}

Expand Down
12 changes: 5 additions & 7 deletions js/mage/adminhtml/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,7 @@ FormElementDependenceController.prototype = {
* Misc. config options
* Keys are underscored intentionally
*/
_config : {
levels_up : 1 // how many levels up to travel when toggling element
},
_config : {},

getSelectValues : function(select) {
var result = [];
Expand Down Expand Up @@ -563,22 +561,22 @@ FormElementDependenceController.prototype = {
// toggle target row
if (shouldShowUp) {
var currentConfig = this._config;
$(idTo).up(this._config.levels_up).select('input', 'select', 'td').each(function (item) {
$(idTo).closest('tr').select('input', 'select', 'td').each(function (item) {
// don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
if ((!item.type || item.type != 'hidden') && !($(item.id+'_inherit') && $(item.id+'_inherit').checked)
&& !(currentConfig.can_edit_price != undefined && !currentConfig.can_edit_price)) {
item.disabled = false;
}
});
$(idTo).up(this._config.levels_up).show();
$(idTo).closest('tr').show();
} else {
$(idTo).up(this._config.levels_up).select('input', 'select', 'td').each(function (item){
$(idTo).closest('tr').select('input', 'select', 'td').each(function (item){
// don't touch hidden inputs (and Use Default inputs too), bc they may have custom logic
if ((!item.type || item.type != 'hidden') && !($(item.id+'_inherit') && $(item.id+'_inherit').checked)) {
item.disabled = true;
}
});
$(idTo).up(this._config.levels_up).hide();
$(idTo).closest('tr').hide();
}
}
};

0 comments on commit 5111889

Please sign in to comment.