Skip to content

Commit

Permalink
Applied code-review recommendations
Browse files Browse the repository at this point in the history
  • Loading branch information
rommmka committed Apr 11, 2023
1 parent 612d9e6 commit 4d733c1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 40 deletions.
3 changes: 1 addition & 2 deletions Block/Adminhtml/Config/Form/Field/VirtualCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@

class VirtualCheck extends \Magento\Config\Block\System\Config\Form\Field
{

protected $_template = 'config/field/virtual_check.phtml';

public function render(AbstractElement $element)
{
$this->assign('configElement', $element);
$html = $this->toHtml();

return $this->_decorateRowHtml($element, "<td class='themes-table' colspan=\"3\">$html</td>");
}

public function getVirtualThemes()
{
return ObjectManager::getInstance()->create(Collection::class)
->addFieldToFilter('type', 1);

}
}
38 changes: 17 additions & 21 deletions view/adminhtml/templates/config/field/virtual_check.phtml
Original file line number Diff line number Diff line change
@@ -1,25 +1,21 @@
<style>
#swissup_core_troubleshooting .button-container { margin-top: 20px; }

#swissup_core_troubleshooting .themes-table h4 {padding-left: 0}
#swissup_core_troubleshooting .themes-table table {max-width: 500px}
#swissup_core_troubleshooting .themes-table td { text-align-last: left; }
#swissup_core_troubleshooting .themes-table th { text-align-last: left; }
#swissup_core_troubleshooting .themes-table td.virtual::before {
display:inline-block;
content: '';
width: 15px;
height: 15px;
background-color: red;
border-radius: 50%;
margin-right: 10px;
vertical-align: middle;
}

#swissup_core_troubleshooting .button-container { margin-top: 20px; }
#swissup_core_troubleshooting .themes-table h4 {padding-left: 0}
#swissup_core_troubleshooting .themes-table table {max-width: 500px}
#swissup_core_troubleshooting .themes-table td { text-align-last: left; }
#swissup_core_troubleshooting .themes-table th { text-align-last: left; }
#swissup_core_troubleshooting .themes-table td.virtual::before {
display:inline-block;
content: '';
width: 15px;
height: 15px;
background-color: red;
border-radius: 50%;
margin-right: 10px;
vertical-align: middle;
}
</style>



<h4>Virtual Theme Check</h4>

<?php
Expand All @@ -30,8 +26,8 @@ if (!$block->getVirtualThemes()->getSize()): ?>
<tbody>
<?php foreach ($block->getVirtualThemes() as $theme): ?>
<tr>
<td scope="row"><?php echo $theme->getThemeTitle(); ?></th>
<td class="virtual">Virtual</th>
<td scope="row"><?php echo $theme->getThemeTitle(); ?></td>
<td class="virtual">Virtual</td>
</tr>
<?php endforeach; ?>
</tbody>
Expand Down
33 changes: 16 additions & 17 deletions view/adminhtml/web/js/virtualfix.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ define([
var self, url, cacheUrl;

return {
init: function(ajaxCallUrl, cacheUrlPath, assignBtn) {
init: function(ajaxCallUrl, cacheUrlPath, assignBtn) {
self = this;
url = ajaxCallUrl;
cacheUrl = cacheUrlPath;
Expand All @@ -17,22 +17,21 @@ define([
});
},
virtualfix: function() {
$.ajax({
url: url,
method: 'POST',
dataType: 'json',
showLoader: true,
data: {
form_key: window.FORM_KEY
}
})
.done(function(data) {
$('#row_swissup_core_troubleshooting_virtualcheck .themes-table table').hide();
$('#fix-all-themes').hide();
$('<tr><td>Success! Please, <a href="' + cacheUrl + '" target=_blank>clear the cache</a></td></tr>').insertAfter('#row_swissup_core_troubleshooting_virtualcheck');

})
.fail(function(jqXHR, textStatus, errorThrown) {
$.ajax({
url: url,
method: 'POST',
dataType: 'json',
showLoader: true,
data: {
form_key: window.FORM_KEY
}
})
.done(function(data) {
$('#row_swissup_core_troubleshooting_virtualcheck .themes-table table').hide();
$('#fix-all-themes').hide();
$('<tr><td>Success! Please, <a href="' + cacheUrl + '" target=_blank>clear the cache</a></td></tr>').insertAfter('#row_swissup_core_troubleshooting_virtualcheck');
})
.fail(function(jqXHR, textStatus, errorThrown) {
alert({
title: $.mage.__('Error'),
content: $.mage.__('An error occured: ') + errorThrown
Expand Down

0 comments on commit 4d733c1

Please sign in to comment.