- 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,
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -25,8 +25,21 @@
|
||||
<th
|
||||
v-if="isColumnVisible(col.name)"
|
||||
:key="col.name"
|
||||
@click="sortTable(col.name)"
|
||||
>
|
||||
{{ col.label }}
|
||||
<q-icon
|
||||
v-if="(sortAttribute === col.name) && optcatalogo.showListaArgomenti"
|
||||
:name="sortDirection === 1 ? 'arrow_drop_up' : 'arrow_drop_down'"
|
||||
size="16px"
|
||||
class="q-ml-xs"
|
||||
/>
|
||||
<q-icon
|
||||
v-else-if="optcatalogo.showListaArgomenti"
|
||||
name="arrow_drop_up"
|
||||
size="16px"
|
||||
class="q-ml-xs"
|
||||
/>
|
||||
</th>
|
||||
</template>
|
||||
</tr>
|
||||
|
||||
Reference in New Issue
Block a user