@innertia-solutions/nuxt-theme-spark 0.1.119 → 0.1.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -3,21 +3,27 @@ const props = defineProps({
|
|
|
3
3
|
endpoint: { type: String, required: true },
|
|
4
4
|
})
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const
|
|
6
|
+
const api = useApi()
|
|
7
|
+
const events = ref([])
|
|
8
|
+
const pending = ref(false)
|
|
9
|
+
const error = ref(null)
|
|
8
10
|
|
|
9
|
-
const
|
|
11
|
+
const fetchHistory = async () => {
|
|
12
|
+
pending.value = true
|
|
13
|
+
error.value = null
|
|
14
|
+
try {
|
|
15
|
+
const data = await api.get(props.endpoint)
|
|
16
|
+
events.value = Array.isArray(data) ? data : (data.data ?? [])
|
|
17
|
+
} catch (e) {
|
|
18
|
+
error.value = e
|
|
19
|
+
} finally {
|
|
20
|
+
pending.value = false
|
|
21
|
+
}
|
|
22
|
+
}
|
|
10
23
|
|
|
11
|
-
const
|
|
12
|
-
watch: [url],
|
|
13
|
-
key: computed(() => `timeline-${props.endpoint}`),
|
|
14
|
-
})
|
|
24
|
+
const refresh = fetchHistory
|
|
15
25
|
|
|
16
|
-
|
|
17
|
-
const d = rawData.value
|
|
18
|
-
if (!d) return []
|
|
19
|
-
return Array.isArray(d) ? d : (d.data ?? [])
|
|
20
|
-
})
|
|
26
|
+
watch(() => props.endpoint, fetchHistory, { immediate: true })
|
|
21
27
|
|
|
22
28
|
const typeConfig = {
|
|
23
29
|
created: { color: 'bg-green-500', label: 'Creado', textColor: 'text-green-600 dark:text-green-400' },
|
|
@@ -17,7 +17,6 @@ const props = defineProps({
|
|
|
17
17
|
showExport: { type: Boolean, default: true },
|
|
18
18
|
filters: { type: Array, default: () => [] },
|
|
19
19
|
splitRatio: { type: Number, default: 60 },
|
|
20
|
-
historyEndpoint: { type: Function, default: null },
|
|
21
20
|
})
|
|
22
21
|
|
|
23
22
|
const resolvedEndpoint = computed(() => props.table?.endpoint ?? props.endpoint)
|
|
@@ -64,10 +63,14 @@ const previewCacheKey = computed(() => `table-preview-${resolvedName.value}`)
|
|
|
64
63
|
const previewFromCache = ref(false)
|
|
65
64
|
const closePreview = () => { previewRow.value = null }
|
|
66
65
|
|
|
67
|
-
const previewTab
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
)
|
|
66
|
+
const previewTab = ref('datos')
|
|
67
|
+
const tableMeta = ref(null)
|
|
68
|
+
|
|
69
|
+
const hasHistory = computed(() => !!tableMeta.value?.has_history)
|
|
70
|
+
const resolvedHistoryEndpoint = computed(() => {
|
|
71
|
+
if (!hasHistory.value || !previewRow.value?.id || !tableMeta.value?.entity_type) return null
|
|
72
|
+
return `history/${tableMeta.value.entity_type}/${previewRow.value.id}`
|
|
73
|
+
})
|
|
71
74
|
|
|
72
75
|
watch(previewRow, () => { previewTab.value = 'datos' })
|
|
73
76
|
|
|
@@ -89,6 +92,7 @@ watch(previewRow, (row) => {
|
|
|
89
92
|
// When data reloads, update previewRow with fresh data — close silently if deleted
|
|
90
93
|
const handleLoaded = (res) => {
|
|
91
94
|
emit('loaded', res)
|
|
95
|
+
if (res?.meta) tableMeta.value = res.meta
|
|
92
96
|
if (previewRow.value && Array.isArray(res?.data)) {
|
|
93
97
|
const fresh = res.data.find(r => r.id === previewRow.value.id)
|
|
94
98
|
if (fresh) previewRow.value = fresh
|
|
@@ -349,7 +353,7 @@ defineExpose({ getSelectedRows, reload, clearCache, exportTable, tableRef })
|
|
|
349
353
|
</div>
|
|
350
354
|
|
|
351
355
|
<!-- Tabs — bottom -->
|
|
352
|
-
<div v-if="
|
|
356
|
+
<div v-if="hasHistory" class="shrink-0 flex border-t border-card-line">
|
|
353
357
|
<button
|
|
354
358
|
type="button"
|
|
355
359
|
@click="previewTab = 'datos'"
|