feat: Add product name retrieval and enhance supplemental feed offer ID normalization
This commit is contained in:
@@ -1559,7 +1559,13 @@ $( function()
|
||||
( AI_CLAUDE_ENABLED ? '<button type="button" class="btn btn-sm btn-ai-suggest btn-ai-claude" data-field="title" data-provider="claude" title="Zaproponuj tytuł przez Claude"><i class="fa-solid fa-brain"></i> Claude</button>' : '' ) +
|
||||
( AI_GEMINI_ENABLED ? '<button type="button" class="btn btn-sm btn-ai-suggest btn-ai-gemini" data-field="title" data-provider="gemini" title="Zaproponuj tytuł przez Gemini"><i class="fa-solid fa-diamond"></i> Gemini</button>' : '' ) +
|
||||
'</div>' +
|
||||
'<small class="js-title-char-count">0/150 znaków</small>' +
|
||||
'<div class="original-title-row" style="display:flex;align-items:center;gap:8px;margin-top:6px;">' +
|
||||
'<small class="text-muted">Oryginalny tytul:</small>' +
|
||||
'<small class="js-original-product-title" style="flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;" title="' + escape_html( current_product_name ) + '">' + escape_html( current_product_name ) + '</small>' +
|
||||
'<button type="button" class="btn btn-xs btn-default js-copy-original-title" title="Kopiuj oryginalny tytul" aria-label="Kopiuj oryginalny tytul">' +
|
||||
'<i class="fa-regular fa-copy"></i>' +
|
||||
'</button>' +
|
||||
'</div>' +
|
||||
'<div class="title-ai-alternatives" style="margin-top:8px;display:none;"></div>' +
|
||||
'</div>' +
|
||||
'<div class="form-group">' +
|
||||
@@ -1652,18 +1658,18 @@ $( function()
|
||||
var jc = this;
|
||||
var $form = this.$content.find( 'form' );
|
||||
var $inputField = this.$content.find( '.name' );
|
||||
var $charCount = this.$content.find( '.js-title-char-count' );
|
||||
var $originalTitle = this.$content.find( '.js-original-product-title' );
|
||||
var $description = this.$content.find( '.description' );
|
||||
var $productUrl = this.$content.find( '.product-url' );
|
||||
var $googleCategory = this.$content.find( '.google-category' );
|
||||
var $titleAlternatives = this.$content.find( '.title-ai-alternatives' );
|
||||
var originalProductName = current_product_name;
|
||||
var product_id = $inputField.attr( 'product_id' );
|
||||
|
||||
function set_title_value( value ) {
|
||||
value = String( value || '' );
|
||||
$inputField.val( value );
|
||||
var len = value.length;
|
||||
$charCount.text( len + '/150 znaków' );
|
||||
$inputField.toggleClass( 'is-invalid', len > 150 );
|
||||
}
|
||||
|
||||
@@ -1713,6 +1719,10 @@ $( function()
|
||||
success: function( response ) {
|
||||
var data = JSON.parse( response );
|
||||
if ( data.status == 'ok' ) {
|
||||
if ( data.product_details.name ) {
|
||||
originalProductName = String( data.product_details.name );
|
||||
$originalTitle.text( originalProductName ).attr( 'title', originalProductName );
|
||||
}
|
||||
if ( data.product_details.title ) {
|
||||
set_title_value( data.product_details.title );
|
||||
}
|
||||
@@ -1744,7 +1754,6 @@ $( function()
|
||||
|
||||
$inputField.on( 'input', function() {
|
||||
var len = $( this ).val().length;
|
||||
$charCount.text( len + '/150 znaków' );
|
||||
$( this ).toggleClass( 'is-invalid', len > 150 );
|
||||
});
|
||||
|
||||
@@ -1831,12 +1840,49 @@ $( function()
|
||||
: '<i class="fa-solid fa-list"></i> Pokaż alternatywy (' + $list.find( '.js-title-alt-apply' ).length + ')'
|
||||
);
|
||||
} );
|
||||
|
||||
this.$content.on( 'click', '.js-title-alt-apply', function() {
|
||||
var selectedTitle = $( this ).attr( 'data-title-alt' ) || '';
|
||||
set_title_value( selectedTitle );
|
||||
} );
|
||||
|
||||
this.$content.on( 'click', '.js-copy-original-title', function() {
|
||||
var originalTitle = $.trim( String( originalProductName || '' ) );
|
||||
|
||||
if ( !originalTitle ) {
|
||||
show_toast( 'Brak oryginalnego tytulu do skopiowania.', 'error' );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( navigator.clipboard && typeof navigator.clipboard.writeText === 'function' ) {
|
||||
navigator.clipboard.writeText( originalTitle )
|
||||
.then( function() {
|
||||
show_toast( 'Oryginalny tytul skopiowany.', 'success' );
|
||||
} )
|
||||
.catch( function() {
|
||||
show_toast( 'Nie udalo sie skopiowac tytulu.', 'error' );
|
||||
} );
|
||||
return;
|
||||
}
|
||||
|
||||
var $tmp = $( '<textarea>' ).css({
|
||||
position: 'fixed',
|
||||
opacity: 0,
|
||||
pointerEvents: 'none'
|
||||
}).val( originalTitle ).appendTo( 'body' );
|
||||
|
||||
$tmp.trigger( 'focus' );
|
||||
$tmp.trigger( 'select' );
|
||||
|
||||
try {
|
||||
var copied = document.execCommand( 'copy' );
|
||||
show_toast( copied ? 'Oryginalny tytul skopiowany.' : 'Nie udalo sie skopiowac tytulu.', copied ? 'success' : 'error' );
|
||||
} catch ( err ) {
|
||||
show_toast( 'Nie udalo sie skopiowac tytulu.', 'error' );
|
||||
}
|
||||
|
||||
$tmp.remove();
|
||||
} );
|
||||
|
||||
$form.on( 'submit', function( e ) {
|
||||
e.preventDefault();
|
||||
jc.$$formSubmit.trigger( 'click' );
|
||||
|
||||
Reference in New Issue
Block a user