ordenar Listas watcheffect
This commit is contained in:
@@ -11,7 +11,8 @@
|
|||||||
<div class="q-pa-md">
|
<div class="q-pa-md">
|
||||||
<div class="q-gutter-md">
|
<div class="q-gutter-md">
|
||||||
|
|
||||||
<q-btn color="secondary" label="Menú">
|
<q-btn flat>
|
||||||
|
<q-icon name="menu" />
|
||||||
<q-menu>
|
<q-menu>
|
||||||
<q-list style="min-width: 100px">
|
<q-list style="min-width: 100px">
|
||||||
<q-item clickable v-close-popup @click="openDialogNewList"
|
<q-item clickable v-close-popup @click="openDialogNewList"
|
||||||
@@ -42,7 +43,7 @@
|
|||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
<q-card-section class="q-pt-none">
|
<q-card-section class="q-pt-none">
|
||||||
<q-input dense v-model="nameList" autofocus @keyup.enter="dialogNewList = false" />
|
<q-input dense v-model="nameList" autofocus @keyup.enter="newLista" />
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
<q-card-actions align="right" class="text-primary">
|
<q-card-actions align="right" class="text-primary">
|
||||||
@@ -101,6 +102,7 @@ const newLista = async () => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
dialogNewList.value = false
|
||||||
}
|
}
|
||||||
|
|
||||||
const openDialogNewList = () => {
|
const openDialogNewList = () => {
|
||||||
|
|||||||
@@ -47,6 +47,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import { watchEffect } from 'vue'
|
||||||
import useSupabase from '../boot/supabase'
|
import useSupabase from '../boot/supabase'
|
||||||
import { useQuasar } from 'quasar'
|
import { useQuasar } from 'quasar'
|
||||||
import { onMounted } from 'vue'
|
import { onMounted } from 'vue'
|
||||||
@@ -59,6 +60,10 @@ const store = supabaseStore()
|
|||||||
const ordenarArray = (array) => {
|
const ordenarArray = (array) => {
|
||||||
array.sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at));
|
array.sort((a, b) => new Date(b.updated_at) - new Date(a.updated_at));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
ordenarArray(store.listas)
|
||||||
|
})
|
||||||
const getListas = async () => {
|
const getListas = async () => {
|
||||||
try {
|
try {
|
||||||
let { data: listas, error } = await supabase
|
let { data: listas, error } = await supabase
|
||||||
@@ -66,7 +71,6 @@ const getListas = async () => {
|
|||||||
.select(`*, profiles(*),items(is_done)`)
|
.select(`*, profiles(*),items(is_done)`)
|
||||||
if (error) throw error
|
if (error) throw error
|
||||||
store.listas = listas
|
store.listas = listas
|
||||||
ordenarArray(store.listas)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
$q.notify({
|
$q.notify({
|
||||||
@@ -119,7 +123,6 @@ const changeNameList = async (id, nombre) => {
|
|||||||
}
|
}
|
||||||
store.listas.filter(l => l.id === id)[0].nombre = data
|
store.listas.filter(l => l.id === id)[0].nombre = data
|
||||||
store.listas.filter(l => l.id === id)[0].updated_at = ahora
|
store.listas.filter(l => l.id === id)[0].updated_at = ahora
|
||||||
ordenarArray(store.listas)
|
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (error instanceof Error) {
|
if (error instanceof Error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user