- Per generare la sinossi è possibile estrarre con 1 click la descrizione sia da Amazon che da GruppoMacro.
- corretto piccolo bug sul catalogo.
This commit is contained in:
@@ -1,31 +1,34 @@
|
||||
import { PropType, computed, defineComponent, onMounted, ref, watch } from "vue";
|
||||
import draggable from 'vuedraggable'
|
||||
import {
|
||||
PropType,
|
||||
computed,
|
||||
defineComponent,
|
||||
onMounted,
|
||||
ref,
|
||||
watch,
|
||||
} from 'vue';
|
||||
import draggable from 'vuedraggable';
|
||||
|
||||
import { tools } from '@tools'
|
||||
import { tools } from '@tools';
|
||||
|
||||
import { useGlobalStore } from '@src/store/globalStore'
|
||||
import { useGlobalStore } from '@src/store/globalStore';
|
||||
|
||||
import { CMyEditorAI } from '@src/components/CMyEditorAI'
|
||||
import { CAITools } from '@src/components/CAITools'
|
||||
import { CMyEditorAI } from '@src/components/CMyEditorAI';
|
||||
import { CAITools } from '@src/components/CAITools';
|
||||
|
||||
import { costanti } from '@costanti'
|
||||
|
||||
import type {
|
||||
IMyScheda,
|
||||
IProduct,
|
||||
IRecFields
|
||||
} from '@src/model';
|
||||
import { shared_consts } from "app/src/common/shared_vuejs";
|
||||
import { useProducts } from "app/src/store/Products";
|
||||
import { useI18n } from "vue-i18n";
|
||||
import { useQuasar } from "quasar";
|
||||
import { costanti } from '@costanti';
|
||||
|
||||
import type { IMyScheda, IProduct, IRecFields } from '@src/model';
|
||||
import { shared_consts } from 'app/src/common/shared_vuejs';
|
||||
import { useProducts } from 'app/src/store/Products';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useQuasar } from 'quasar';
|
||||
|
||||
export default defineComponent({
|
||||
name: "CModifTrafiletto",
|
||||
name: 'CModifTrafiletto',
|
||||
emits: ['updateproductmodif', 'close', 'Savedb'],
|
||||
components: {
|
||||
CMyEditorAI, CAITools
|
||||
CMyEditorAI,
|
||||
CAITools,
|
||||
},
|
||||
props: {
|
||||
modelValue: {
|
||||
@@ -64,38 +67,57 @@ export default defineComponent({
|
||||
type: Number,
|
||||
required: false,
|
||||
default: 0,
|
||||
}
|
||||
},
|
||||
},
|
||||
setup(props, { emit }) {
|
||||
// Copia locale della lista_prodotti per manipolazione interna
|
||||
const $q = useQuasar()
|
||||
const { t } = useI18n()
|
||||
const $q = useQuasar();
|
||||
const { t } = useI18n();
|
||||
|
||||
const globalStore = useGlobalStore()
|
||||
const products = useProducts()
|
||||
const globalStore = useGlobalStore();
|
||||
const products = useProducts();
|
||||
|
||||
const mytab = ref('descr')
|
||||
const mytab = ref('descr');
|
||||
|
||||
const loading = ref(false)
|
||||
const loading = ref(false);
|
||||
|
||||
const updatetogm = ref(false)
|
||||
const field_updated_toGM = ref('')
|
||||
const updatetogm = ref(false);
|
||||
const field_updated_toGM = ref('');
|
||||
|
||||
const myproduct = ref<IProduct>({ ...props.modelValue })
|
||||
const myproduct = ref<IProduct>({ ...props.modelValue });
|
||||
|
||||
const id = computed(() => myproduct.value.productInfo._id)
|
||||
const id = computed(() => myproduct.value.productInfo._id);
|
||||
|
||||
const myvalue = computed<string>(() => {
|
||||
return myproduct.value.productInfo[props.mykey]
|
||||
})
|
||||
return myproduct.value.productInfo[props.mykey];
|
||||
});
|
||||
|
||||
watch(() => props.modelValue, (newVal) => {
|
||||
myproduct.value = { ...newVal };
|
||||
}, { deep: false });
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
(newVal) => {
|
||||
myproduct.value = { ...newVal };
|
||||
},
|
||||
{ deep: false }
|
||||
);
|
||||
|
||||
const loadMyScrapingBook = async () => {
|
||||
loading.value = true;
|
||||
try {
|
||||
const myscrapingbook = await products.loadMyScrapingBook(
|
||||
myproduct.value.isbn, false
|
||||
);
|
||||
myproduct.value.myscrapingbook = myscrapingbook;
|
||||
} catch (error) {
|
||||
console.error('Errore caricamento MyScrapingBook:', error);
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
async function mounted() {
|
||||
// carico anche altri dati del product
|
||||
|
||||
await loadMyScrapingBook();
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -110,45 +132,94 @@ export default defineComponent({
|
||||
|
||||
function updateproductmodif(element: any) {
|
||||
// console.log('CModifTrafiletto updateproductmodif ', element)
|
||||
emit('updateproductmodif', element)
|
||||
emit('updateproductmodif', element);
|
||||
}
|
||||
|
||||
function Savedb(element: any) {
|
||||
tools.saveInDBForTypes($q, props.mykey, element, props.type, true, props.table, props.mysubkey, id.value, null, '');
|
||||
tools.saveInDBForTypes(
|
||||
$q,
|
||||
props.mykey,
|
||||
element,
|
||||
props.type,
|
||||
true,
|
||||
props.table,
|
||||
props.mysubkey,
|
||||
id.value,
|
||||
null,
|
||||
''
|
||||
);
|
||||
}
|
||||
|
||||
async function updateproduct(load?: boolean) {
|
||||
myproduct.value = await products.getProductById(myproduct.value._id, load)
|
||||
|
||||
myproduct.value = await products.getProductById(
|
||||
myproduct.value._id,
|
||||
load
|
||||
);
|
||||
}
|
||||
|
||||
const copyToClipboard = (text) => {
|
||||
navigator.clipboard.writeText(text)
|
||||
navigator.clipboard
|
||||
.writeText(text)
|
||||
.then(() => {
|
||||
$q.notify({
|
||||
message: 'Testo copiato negli appunti!',
|
||||
color: 'positive',
|
||||
icon: 'check',
|
||||
position: 'top'
|
||||
position: 'top',
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
.catch((err) => {
|
||||
console.error('Errore durante la copia:', err);
|
||||
$q.notify({
|
||||
message: 'Errore nella copia',
|
||||
color: 'negative',
|
||||
icon: 'error',
|
||||
position: 'top'
|
||||
position: 'top',
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
function handleShowAndSave(payload: any) {
|
||||
Savedb(payload);
|
||||
updateproductmodif(payload);
|
||||
}
|
||||
|
||||
onMounted(mounted)
|
||||
function getPrompt() {
|
||||
// Prompt:
|
||||
let mydescr = 'Scrivimi la sinossi del seguente libro, che andrà nel catalogo libri, di massimo 680 battute, senza spiegazione, senza titolo iniziale, solo la sinossi. Togli eventuali riferimenti a chi ha fatto la prefazione. Rendilo un po\' accattivante, ma non troppo. \n\n';
|
||||
return mydescr
|
||||
}
|
||||
|
||||
function copyDescrizioneFromScrapingData() {
|
||||
let mydescr = '';
|
||||
|
||||
const data = myproduct?.value.myscrapingbook;
|
||||
if (!data) return false;
|
||||
|
||||
mydescr = getPrompt()
|
||||
mydescr += 'Titolo Libro: ' + data.titolo + '\n';
|
||||
mydescr += 'Autore Libro: ' + data.autore + '\n';
|
||||
|
||||
mydescr += 'DESCRIZIONE LIBRO: \n';
|
||||
mydescr += data.descrizione_lunga;
|
||||
|
||||
tools.copyStringToClipboard($q, mydescr, false);
|
||||
}
|
||||
|
||||
function copyDescrizioneFromGruppoMacro() {
|
||||
let mydescr = '';
|
||||
|
||||
mydescr = getPrompt()
|
||||
mydescr += 'Titolo Libro: ' + myproduct?.value.productInfo?.name + '\n';
|
||||
mydescr += 'Autore Libro: ' + products.getAutoriByArrayAuthors(myproduct?.productInfo?.authors) + '\n';
|
||||
|
||||
mydescr += 'DESCRIZIONE LIBRO: \n';
|
||||
mydescr += myproduct?.value.productInfo?.descrizione_completa_macro;
|
||||
|
||||
tools.copyStringToClipboard($q, mydescr, false);
|
||||
}
|
||||
|
||||
onMounted(mounted);
|
||||
|
||||
return {
|
||||
tools,
|
||||
@@ -167,6 +238,9 @@ export default defineComponent({
|
||||
copyToClipboard,
|
||||
myvalue,
|
||||
handleShowAndSave,
|
||||
}
|
||||
}
|
||||
})
|
||||
copyDescrizioneFromScrapingData,
|
||||
copyDescrizioneFromGruppoMacro,
|
||||
loading,
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user