- ordinamento tabella titoli
- migliorata la lista degli argomenti
This commit is contained in:
@@ -72,6 +72,10 @@ export default defineComponent({
|
||||
|
||||
const modifOn = ref(false)
|
||||
|
||||
const sortAttribute = ref('')
|
||||
const sortDirection = ref(1)
|
||||
|
||||
|
||||
const optionscatalogo = ref(<any>{maxlength: 0})
|
||||
|
||||
const editOn = computed({
|
||||
@@ -255,6 +259,37 @@ export default defineComponent({
|
||||
|
||||
}
|
||||
|
||||
const sortTable = (sortAttributeToSort: string) => {
|
||||
|
||||
if (!props.optcatalogo.showListaArgomenti)
|
||||
return false
|
||||
|
||||
if (sortAttributeToSort) {
|
||||
if (sortAttribute.value === sortAttributeToSort) {
|
||||
sortDirection.value = -sortDirection.value
|
||||
} else {
|
||||
sortAttribute.value = sortAttributeToSort
|
||||
sortDirection.value = 1
|
||||
}
|
||||
internalProducts.value = internalProducts.value.sort((a: any, b: any) => {
|
||||
const aVal = a.productInfo?.[sortAttributeToSort] ?? ''
|
||||
const bVal = b.productInfo?.[sortAttributeToSort] ?? ''
|
||||
if (aVal instanceof Date && bVal instanceof Date) {
|
||||
return sortDirection.value === 1 ? aVal.getTime() - bVal.getTime() : bVal.getTime() - aVal.getTime()
|
||||
}
|
||||
if (typeof aVal === 'number' && typeof bVal === 'number') {
|
||||
return sortDirection.value === 1 ? aVal - bVal : bVal - aVal
|
||||
}
|
||||
if (typeof aVal === 'string' && typeof bVal === 'string') {
|
||||
return sortDirection.value === 1 ? aVal.localeCompare(bVal) : bVal.localeCompare(aVal)
|
||||
}
|
||||
return sortDirection.value === 1 ? String(aVal).localeCompare(String(bVal)) : String(bVal).localeCompare(String(aVal))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
onMounted(mounted)
|
||||
|
||||
return {
|
||||
@@ -287,6 +322,9 @@ export default defineComponent({
|
||||
optionscatalogo,
|
||||
t,
|
||||
products,
|
||||
sortTable,
|
||||
sortAttribute,
|
||||
sortDirection,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user