Skip to content

Commit

Permalink
MAGETWO-50223: [Currency Rates] When user navigates to Currency Rates…
Browse files Browse the repository at this point in the history
… page, on the grid, no rate (text) fields are displayed.

- Updated matrix view to show a warning that would tell the user to configure the options before importing rates.
- Updated the view with a button to quickly access configuration options for currency rates.
  • Loading branch information
Hayder Sharhan committed Mar 10, 2016
1 parent e47f1a8 commit 706ea99
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@ protected function _prepareLayout()
]
);

$onClick = "setLocation('" . $this->getUrl('adminhtml/system_config/edit/section/currency') . "')";

$this->getToolbar()->addChild(
'options_button',
'Magento\Backend\Block\Widget\Button',
['label' => __('Options'), 'onclick' => $onClick]
);

$this->getToolbar()->addChild(
'reset_button',
'Magento\Backend\Block\Widget\Button',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,53 +17,57 @@ $_oldRates = $block->getOldRates();
$_newRates = $block->getNewRates();
$_rates = ($_newRates) ? $_newRates : $_oldRates;
?>
<form name="rateForm" id="rate-form" method="post" action="<?php /* @escapeNotVerified */ echo $block->getRatesFormAction(); ?>">
<?php echo $block->getBlockHtml('formkey')?>
<div class="admin__control-table-wrapper">
<table class="admin__control-table">
<thead>
<?php if (empty($_rates)): ?>
<div class="message message-error error"><p><?php echo __('You must first configure Currency Options.');?></p></div>
<?php else: ?>
<form name="rateForm" id="rate-form" method="post" action="<?php /* @escapeNotVerified */ echo $block->getRatesFormAction(); ?>">
<?php echo $block->getBlockHtml('formkey')?>
<div class="admin__control-table-wrapper">
<table class="admin__control-table">
<thead>
<tr>
<th>&nbsp;</th>
<?php $_i = 0; foreach ($block->getAllowedCurrencies() as $_currencyCode): ?>
<th><span><?php /* @escapeNotVerified */ echo $_currencyCode ?></span></th>
<?php endforeach; ?>
</tr>
</thead>
<?php $_j = 0; foreach ($block->getDefaultCurrencies() as $_currencyCode): ?>
<tr>
<th>&nbsp;</th>
<?php $_i = 0; foreach ($block->getAllowedCurrencies() as $_currencyCode): ?>
<th><span><?php /* @escapeNotVerified */ echo $_currencyCode ?></span></th>
<?php endforeach; ?>
<?php if (isset($_rates[$_currencyCode]) && is_array($_rates[$_currencyCode])): ?>
<?php foreach ($_rates[$_currencyCode] as $_rate => $_value): ?>
<?php if (++$_j == 1): ?>
<td><span class="admin__control-support-text"><?php /* @escapeNotVerified */ echo $_currencyCode ?></span></td>
<td>
<input type="text"
name="rate[<?php /* @escapeNotVerified */ echo $_currencyCode ?>][<?php /* @escapeNotVerified */ echo $_rate ?>]"
value="<?php echo($_currencyCode == $_rate) ? '1.0000' : ($_value>0 ? $_value : (isset($_oldRates[$_currencyCode][$_rate]) ? $_oldRates[$_currencyCode][$_rate] : '')) ?>"
class="admin__control-text"
<?php echo($_currencyCode == $_rate) ? ' disabled' : '' ?> />
<?php if (isset($_newRates) && $_currencyCode != $_rate && isset($_oldRates[$_currencyCode][$_rate])): ?>
<div class="admin__field-note"><?php /* @escapeNotVerified */ echo __('Old rate:') ?> <b><?php /* @escapeNotVerified */ echo $_oldRates[$_currencyCode][$_rate] ?></b></div>
<?php endif; ?>
</td>
<?php else: ?>
<td>
<input type="text"
name="rate[<?php /* @escapeNotVerified */ echo $_currencyCode ?>][<?php /* @escapeNotVerified */ echo $_rate ?>]"
value="<?php echo($_currencyCode == $_rate) ? '1.0000' : ($_value>0 ? $_value : (isset($_oldRates[$_currencyCode][$_rate]) ? $_oldRates[$_currencyCode][$_rate] : '')) ?>"
class="admin__control-text"
<?php echo($_currencyCode == $_rate) ? ' disabled' : '' ?> />
<?php if (isset($_newRates) && $_currencyCode != $_rate && isset($_oldRates[$_currencyCode][$_rate])): ?>
<div class="admin__field-note"><?php /* @escapeNotVerified */ echo __('Old rate:') ?> <b><?php /* @escapeNotVerified */ echo $_oldRates[$_currencyCode][$_rate] ?></b></div>
<?php endif; ?>
</td>
<?php endif; ?>
<?php endforeach; $_j = 0; ?>
<?php endif; ?>
</tr>
</thead>
<?php $_j = 0; foreach ($block->getDefaultCurrencies() as $_currencyCode): ?>
<tr>
<?php if (isset($_rates[$_currencyCode]) && is_array($_rates[$_currencyCode])): ?>
<?php foreach ($_rates[$_currencyCode] as $_rate => $_value): ?>
<?php if (++$_j == 1): ?>
<td><span class="admin__control-support-text"><?php /* @escapeNotVerified */ echo $_currencyCode ?></span></td>
<td>
<input type="text"
name="rate[<?php /* @escapeNotVerified */ echo $_currencyCode ?>][<?php /* @escapeNotVerified */ echo $_rate ?>]"
value="<?php echo($_currencyCode == $_rate) ? '1.0000' : ($_value>0 ? $_value : (isset($_oldRates[$_currencyCode][$_rate]) ? $_oldRates[$_currencyCode][$_rate] : '')) ?>"
class="admin__control-text"
<?php echo($_currencyCode == $_rate) ? ' disabled' : '' ?> />
<?php if (isset($_newRates) && $_currencyCode != $_rate && isset($_oldRates[$_currencyCode][$_rate])): ?>
<div class="admin__field-note"><?php /* @escapeNotVerified */ echo __('Old rate:') ?> <b><?php /* @escapeNotVerified */ echo $_oldRates[$_currencyCode][$_rate] ?></b></div>
<?php endif; ?>
</td>
<?php else: ?>
<td>
<input type="text"
name="rate[<?php /* @escapeNotVerified */ echo $_currencyCode ?>][<?php /* @escapeNotVerified */ echo $_rate ?>]"
value="<?php echo($_currencyCode == $_rate) ? '1.0000' : ($_value>0 ? $_value : (isset($_oldRates[$_currencyCode][$_rate]) ? $_oldRates[$_currencyCode][$_rate] : '')) ?>"
class="admin__control-text"
<?php echo($_currencyCode == $_rate) ? ' disabled' : '' ?> />
<?php if (isset($_newRates) && $_currencyCode != $_rate && isset($_oldRates[$_currencyCode][$_rate])): ?>
<div class="admin__field-note"><?php /* @escapeNotVerified */ echo __('Old rate:') ?> <b><?php /* @escapeNotVerified */ echo $_oldRates[$_currencyCode][$_rate] ?></b></div>
<?php endif; ?>
</td>
<?php endif; ?>
<?php endforeach; $_j = 0; ?>
<?php endif; ?>
</tr>
<?php endforeach; ?>
</table>
</div>
</form>
<?php endforeach; ?>
</table>
</div>
</form>
<?php endif; ?>
<script>
require(['jquery', "mage/mage"], function(jQuery){

Expand Down

0 comments on commit 706ea99

Please sign in to comment.