Skip to content

Commit

Permalink
https://github.com/opencart/opencart/issues/13881
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed Apr 23, 2024
1 parent 672b700 commit 51ba9f2
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions upload/admin/controller/design/theme.php
Expand Up @@ -392,6 +392,10 @@ public function delete(): void {
$selected = [];
}

if (isset($this->request->get['theme_id'])) {
$selected[] = (int)$this->request->get['theme_id'];
}

// Check user has permission
if (!$this->user->hasPermission('modify', 'design/theme')) {
$json['error'] = $this->language->get('error_permission');
Expand Down
35 changes: 35 additions & 0 deletions upload/admin/view/template/design/theme.twig
Expand Up @@ -26,5 +26,40 @@ $('#theme').on('click', 'thead a, .pagination a', function(e) {
$('#theme').load(this.href);
});
$('#theme').on('click', 'button', function(e) {
e.preventDefault();
var element = this;
$.ajax({
url: $(element).val(),
dataType: 'json',
beforeSend: function() {
$(element).button('loading');
},
complete: function() {
$(element).button('reset');
},
success: function(json) {
console.log(json);
$('.alert-dismissible').remove();
if (json['error']) {
$('#alert').prepend('<div class="alert alert-danger alert-dismissible"><i class="fa-solid fa-circle-exclamation"></i> ' + json['error'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
}
if (json['success']) {
$('#theme').load($('#form-theme').attr('data-oc-load'));
$('#alert').prepend('<div class="alert alert-success alert-dismissible"><i class="fa-solid fa-circle-check"></i> ' + json['success'] + ' <button type="button" class="btn-close" data-bs-dismiss="alert"></button></div>');
}
},
error: function(xhr, ajaxOptions, thrownError) {
console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
});
//--></script>
{{ footer }}
2 changes: 1 addition & 1 deletion upload/admin/view/template/design/theme_list.twig
Expand Up @@ -20,7 +20,7 @@
<td class="text-start">{{ theme.store }}</td>
<td class="text-start">{{ theme.status }}</td>
<td class="text-start">{{ theme.date_added }}</td>
<td class="text-end text-nowrap"><a href="{{ theme.edit }}" data-bs-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa-solid fa-pencil"></i></a> <a href="{{ theme.delete }}" data-bs-toggle="tooltip" title="{{ button_delete }}" class="btn btn-danger"><i class="fa-regular fa-trash-can"></i></a></td>
<td class="text-end text-nowrap"><a href="{{ theme.edit }}" data-bs-toggle="tooltip" title="{{ button_edit }}" class="btn btn-primary"><i class="fa-solid fa-pencil"></i></a> <button type="button" value="{{ theme.delete }}" data-bs-toggle="tooltip" title="{{ button_delete }}" class="btn btn-danger"><i class="fa-regular fa-trash-can"></i></button></td>
</tr>
{% endfor %}
{% else %}
Expand Down

0 comments on commit 51ba9f2

Please sign in to comment.