update
This commit is contained in:
@@ -35,6 +35,10 @@
|
||||
<label for="products_search"><i class="fa-solid fa-magnifying-glass"></i> Szukaj</label>
|
||||
<input type="text" id="products_search" class="form-control" placeholder="Nazwa, ID oferty..." />
|
||||
</div>
|
||||
<div class="filter-group filter-group-cl1">
|
||||
<label for="products_cl1"><i class="fa-solid fa-tag"></i> CL1</label>
|
||||
<input type="text" id="products_cl1" class="form-control" placeholder="np. bestseller, deleted..." />
|
||||
</div>
|
||||
<div class="filter-group filter-group-cl4">
|
||||
<label for="products_cl4"><i class="fa-solid fa-tag"></i> CL4</label>
|
||||
<input type="text" id="products_cl4" class="form-control" placeholder="np. bestseller, deleted..." />
|
||||
@@ -117,7 +121,7 @@
|
||||
<th>Wart. konw.</th>
|
||||
<th>ROAS</th>
|
||||
<th>Min. ROAS</th>
|
||||
<th>CL3</th>
|
||||
<th>CL1</th>
|
||||
<th>CL4</th>
|
||||
<th>Akcje</th>
|
||||
</tr>
|
||||
@@ -541,6 +545,7 @@ $( function()
|
||||
d.ad_group_id = $( '#products_ad_group_id' ).val() || '';
|
||||
d.search_text = $( '#products_search' ).val() || '';
|
||||
d.filter_cl4 = $( '#products_cl4' ).val() || '';
|
||||
d.filter_cl1 = $( '#products_cl1' ).val() || '';
|
||||
}
|
||||
},
|
||||
processing: true,
|
||||
@@ -572,7 +577,7 @@ $( function()
|
||||
{ width: '90px', name: 'conversions_value', className: "dt-type-numeric" },
|
||||
{ width: '60px', name: 'roas' },
|
||||
{ width: '70px', name: 'min_roas' },
|
||||
{ width: '50px', name: 'custom_label_3' },
|
||||
{ width: '120px', name: 'custom_label_1' },
|
||||
{ width: '120px', orderable: false },
|
||||
{ width: '190px', orderable: false, className: 'dt-center' }
|
||||
],
|
||||
@@ -621,6 +626,14 @@ $( function()
|
||||
_cl4Timer = setTimeout( function() { reload_products_table(); }, 400 );
|
||||
});
|
||||
|
||||
// Filtr: custom_label_1 (debounce 400ms)
|
||||
var _cl1Timer = null;
|
||||
$( '#products_cl1' ).on( 'keyup', function() {
|
||||
localStorage.setItem( 'products_cl1', $( this ).val() || '' );
|
||||
clearTimeout( _cl1Timer );
|
||||
_cl1Timer = setTimeout( function() { reload_products_table(); }, 400 );
|
||||
});
|
||||
|
||||
function submit_delete_campaign_ad_group( campaign_id, ad_group_id, delete_scope, on_success )
|
||||
{
|
||||
function parse_json_loose( raw )
|
||||
@@ -1320,8 +1333,10 @@ $( function()
|
||||
localStorage.removeItem( 'products_ad_group_id' );
|
||||
localStorage.removeItem( 'products_search' );
|
||||
localStorage.removeItem( 'products_cl4' );
|
||||
localStorage.removeItem( 'products_cl1' );
|
||||
$( '#products_search' ).val( '' );
|
||||
$( '#products_cl4' ).val( '' );
|
||||
$( '#products_cl1' ).val( '' );
|
||||
update_delete_ad_group_button_state();
|
||||
load_client_bestseller_settings( client_id );
|
||||
|
||||
@@ -1435,6 +1450,7 @@ $( function()
|
||||
var savedAdGroup = localStorage.getItem( 'products_ad_group_id' ) || '';
|
||||
var savedSearch = localStorage.getItem( 'products_search' ) || '';
|
||||
var savedCl4 = localStorage.getItem( 'products_cl4' ) || '';
|
||||
var savedCl1 = localStorage.getItem( 'products_cl1' ) || '';
|
||||
|
||||
if ( savedClient && $( '#client_id option[value="' + savedClient + '"]' ).length )
|
||||
{
|
||||
@@ -1443,9 +1459,11 @@ $( function()
|
||||
|
||||
$( '#products_search' ).val( savedSearch );
|
||||
$( '#products_cl4' ).val( savedCl4 );
|
||||
$( '#products_cl1' ).val( savedCl1 );
|
||||
load_client_bestseller_settings( $( '#client_id' ).val() || '' );
|
||||
|
||||
load_cl4_suggestions( $( '#client_id' ).val() || '' );
|
||||
load_cl1_suggestions( $( '#client_id' ).val() || '' );
|
||||
|
||||
load_products_campaigns( $( '#client_id' ).val() || '', savedCampaign ).done( function() {
|
||||
var selected_campaign_id = $( '#products_campaign_id' ).val() || '';
|
||||
@@ -1771,6 +1789,113 @@ $( function()
|
||||
});
|
||||
});
|
||||
|
||||
// CL1 autocomplete — datalist z unikalnymi wartościami
|
||||
var cl1_values_cache = [];
|
||||
var cl1_datalist_id = 'cl1-suggestions';
|
||||
|
||||
function load_cl1_suggestions( client_id )
|
||||
{
|
||||
if ( !client_id )
|
||||
{
|
||||
cl1_values_cache = [];
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: '/products/get_distinct_cl1/client_id=' + client_id,
|
||||
type: 'GET',
|
||||
dataType: 'json'
|
||||
}).done( function( res ) {
|
||||
cl1_values_cache = ( res && res.values ) ? res.values : [];
|
||||
render_cl1_datalist();
|
||||
});
|
||||
}
|
||||
|
||||
function render_cl1_datalist()
|
||||
{
|
||||
var $dl = $( '#' + cl1_datalist_id );
|
||||
|
||||
if ( !$dl.length )
|
||||
{
|
||||
$dl = $( '<datalist id="' + cl1_datalist_id + '"></datalist>' );
|
||||
$( 'body' ).append( $dl );
|
||||
}
|
||||
|
||||
var html = '';
|
||||
|
||||
for ( var i = 0; i < cl1_values_cache.length; i++ )
|
||||
{
|
||||
html += '<option value="' + escape_html( cl1_values_cache[i] ) + '">';
|
||||
}
|
||||
|
||||
$dl.html( html );
|
||||
}
|
||||
|
||||
function bind_cl1_datalist()
|
||||
{
|
||||
$( '.custom_label_1' ).attr( 'list', cl1_datalist_id );
|
||||
}
|
||||
|
||||
// Podłącz datalist po każdym renderze tabeli
|
||||
$( '#products' ).on( 'draw.dt', function() {
|
||||
bind_cl1_datalist();
|
||||
});
|
||||
|
||||
// Załaduj sugestie po zmianie klienta
|
||||
$( 'body' ).on( 'change', '#client_id', function() {
|
||||
load_cl1_suggestions( $( this ).val() || '' );
|
||||
});
|
||||
|
||||
// Odśwież cache po zapisie CL1
|
||||
function refresh_cl1_cache_after_save()
|
||||
{
|
||||
var client_id = $( '#client_id' ).val() || '';
|
||||
if ( client_id )
|
||||
{
|
||||
load_cl1_suggestions( client_id );
|
||||
}
|
||||
}
|
||||
|
||||
// Zapis custom_label_1
|
||||
$( 'body' ).on( 'change', '.custom_label_1', function()
|
||||
{
|
||||
var product_id = $( this ).attr( 'product_id' );
|
||||
var custom_label_1 = $( this ).val();
|
||||
$.ajax({
|
||||
url: '/products/save_custom_label_1/',
|
||||
type: 'POST',
|
||||
data: { product_id: product_id, custom_label_1: custom_label_1 },
|
||||
success: function( response )
|
||||
{
|
||||
var data;
|
||||
|
||||
try
|
||||
{
|
||||
data = JSON.parse( response );
|
||||
}
|
||||
catch ( e )
|
||||
{
|
||||
show_toast( 'Custom Label 1: nieprawidłowa odpowiedź serwera.', 'error' );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( data.status === 'ok' )
|
||||
{
|
||||
show_toast( 'Custom Label 1 zapisany.', 'success' );
|
||||
refresh_cl1_cache_after_save();
|
||||
}
|
||||
else
|
||||
{
|
||||
show_toast( 'Custom Label 1: zapis nie powiódł się.', 'error' );
|
||||
}
|
||||
},
|
||||
error: function()
|
||||
{
|
||||
show_toast( 'Custom Label 1: błąd połączenia podczas zapisu.', 'error' );
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Edycja produktu (tytuł, opis, kategoria Google)
|
||||
$( 'body' ).on( 'click', '.edit-product-title', function( e )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user