feat: Dodaj funkcjonalność usuwania produktów oraz aktualizację interfejsu użytkownika
This commit is contained in:
@@ -46,6 +46,7 @@
|
||||
<th scope="col">Min. ROAS</th>
|
||||
<th scope="col">CL3</th>
|
||||
<th scope="col">CL4</th>
|
||||
<th scope="col">Akcje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -143,11 +144,70 @@
|
||||
{ width: 'auto', name: 'roas' },
|
||||
{ width: '100px', name: 'min_roas' },
|
||||
{ width: 'auto', name: 'cl3', orderable: false },
|
||||
{ width: '200px', orderable: false }],
|
||||
{ width: '200px', orderable: false },
|
||||
{ width: '100px', orderable: false }],
|
||||
order: [ [ 5, 'desc' ] ]
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'click', '.delete-product', function(e)
|
||||
{
|
||||
e.preventDefault();
|
||||
var product_id = $( this ).attr( 'product_id' );
|
||||
var row = $( this ).closest('tr');
|
||||
|
||||
$.confirm({
|
||||
title: 'Potwierdzenie',
|
||||
content: 'Czy na pewno chcesz usunąć ten produkt?',
|
||||
buttons: {
|
||||
confirm: {
|
||||
text: 'Usuń',
|
||||
keys: ['enter'],
|
||||
action: function () {
|
||||
$.ajax({
|
||||
url: '/products/delete_product/',
|
||||
type: 'POST',
|
||||
data: {
|
||||
product_id: product_id
|
||||
},
|
||||
success: function( response ) {
|
||||
data = JSON.parse(response);
|
||||
if ( data.status == 'ok' )
|
||||
{
|
||||
// change to alert with auto close after 2 seconds
|
||||
$.alert({
|
||||
title: 'Sukces',
|
||||
content: 'Produkt został usunięty.',
|
||||
autoClose: 'ok|2000',
|
||||
buttons: {
|
||||
ok: function () {
|
||||
}
|
||||
}
|
||||
});
|
||||
// usuń wiersz z tabeli
|
||||
var table = $('#products').DataTable();
|
||||
table.row(row).remove().draw();
|
||||
}
|
||||
else
|
||||
{
|
||||
$.alert('Błąd: ' + response);
|
||||
}
|
||||
},
|
||||
error: function() {
|
||||
$.alert('Wystąpił błąd podczas usuwania produktu. Spróbuj ponownie.');
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
cancel: {
|
||||
text: 'Anuluj',
|
||||
action: function () {
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$( 'body' ).on( 'change', '.min_roas', function()
|
||||
{
|
||||
var input = $( this );
|
||||
|
||||
Reference in New Issue
Block a user