pgo-ui 1.0.39 → 1.0.41

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.
@@ -7,13 +7,13 @@
7
7
  :show-print="true"
8
8
  title="View Document"
9
9
  />
10
- <Button @click="handlePdfView('../../../public/Sex_offenders.pdf')">View</Button>
10
+ <!-- <Button @click="handlePdfView('../../../public/Sex_offenders.pdf')">View</Button> -->
11
11
  <!-- <Button @click="handlePdfView('../../../public/1_ref_20251120_050755.pdf')">View</Button> -->
12
12
  <template v-if="items">
13
13
  <slot name="topSlot" :items="items" />
14
14
 
15
15
  <!-- <hr class="border-input-border my-2" /> -->
16
- <Card
16
+ <Card
17
17
  card-class="border-none"
18
18
  bg="vts-bg-surface-elevated"
19
19
  padding="p-3"
@@ -21,7 +21,7 @@
21
21
  shadow="shadow-lg"
22
22
  >
23
23
  <slot name="toolbar" :toolbar="LToolbar" :filterSection="LFilterSection">
24
- <Toolbar
24
+ <Toolbar
25
25
  v-if="items.componentSettings?.toolbar"
26
26
  :elevation="false"
27
27
  color="none"
@@ -47,8 +47,8 @@
47
47
  leave-from-class="transform translate-y-0 opacity-100"
48
48
  leave-to-class="transform -translate-y-4 opacity-0"
49
49
  >
50
-
51
- <Card
50
+
51
+ <Card
52
52
  v-if="LFilterSection && showFilters"
53
53
  card-class="border-dashed"
54
54
  rounded="lg"
@@ -94,12 +94,25 @@
94
94
  @delete="handleDelete"
95
95
  @viewpdf="handlePdfView"
96
96
  />
97
- <div v-else class="p-8">
98
- <p>No headers found</p>
99
- </div>
100
97
  </slot>
101
98
 
102
-
99
+ <slot name="card" :card="LCard">
100
+ <CardView
101
+ v-if="items.componentSettings?.card"
102
+ :items="tableData?.data"
103
+ :settings="LCard"
104
+ :server-side-options="options"
105
+ :loading="tableLoading"
106
+ :lang="lang"
107
+ @update:options="handleOptionsUpdate"
108
+ />
109
+ </slot>
110
+
111
+ <div v-if="!items.componentSettings?.table && !items.componentSettings?.card" class="p-8">
112
+ <p>No display component configured</p>
113
+ </div>
114
+
115
+
103
116
  </template>
104
117
  <div v-else class="flex items-center justify-center p-8">
105
118
  <p>No data</p>
@@ -107,7 +120,7 @@
107
120
 
108
121
  <!-- FORM -->
109
122
  <slot name="form" :form="LForm">
110
- <DynamicForm
123
+ <DynamicForm
111
124
  v-if="showDynamicForm && items.componentSettings?.form"
112
125
  :form="LForm"
113
126
  rounded="sm"
@@ -131,7 +144,7 @@
131
144
  @confirm="handleDeleteConfirm"
132
145
  @cancel="showConfirmation = false; DeleteItem = null"
133
146
  >
134
- <div
147
+ <div
135
148
  v-if="LTable?.delete?.message"
136
149
  v-for="(message, key) in LTable?.delete?.message"
137
150
  :key="key"
@@ -146,7 +159,7 @@
146
159
 
147
160
  <script setup>
148
161
  import { ref, computed, watch, inject } from 'vue'
149
- import { DynamicForm, Toolbar, FilterSection, DataTable, SearchBox, ConfirmationModal } from '../../components/pgo'
162
+ import { DynamicForm, Toolbar, FilterSection, DataTable, CardView, SearchBox, ConfirmationModal } from '../../components/pgo'
150
163
  import { useLanguageSelected } from '../lib/componentConfig'
151
164
  import { useRoute, useRouter } from 'vue-router'
152
165
  import DocumentViewer from '@/components/pgo/DocumentViewer.vue'
@@ -190,6 +203,7 @@ const formMode = ref('')
190
203
  const editItemId = ref(null)
191
204
  const pdfSrc = ref(null)
192
205
  const LTable =ref({})
206
+ const LCard = ref({})
193
207
  const LFilterSection = ref({})
194
208
  const LToolbar = ref({})
195
209
  const LForm = ref({})
@@ -229,10 +243,10 @@ const tableFetch = async (tableurl) => {
229
243
  if (LTable.value?.pagination) {
230
244
  options.value = {
231
245
  ...options.value,
232
- page: LTable.value?.pagination.current_page,
246
+ page: LTable.value?.pagination.current_page,
233
247
  }
234
248
  }
235
- }
249
+ }
236
250
 
237
251
  console.log('Table settings fetched:', LTable.value)
238
252
  } catch (error) {
@@ -241,7 +255,40 @@ const tableFetch = async (tableurl) => {
241
255
  } finally {
242
256
  tableLoading.value = false
243
257
  }
244
-
258
+
259
+ }
260
+
261
+ const cardFetch = async (cardUrl) => {
262
+ try {
263
+ tableLoading.value = true
264
+
265
+ const params = new URLSearchParams({
266
+ lang: language.value || 'dv'
267
+ })
268
+
269
+ const isFullUrl = /^https?:\/\//i.test(cardUrl)
270
+ const url = isFullUrl ? cardUrl + params.toString() : computedBaseUrl.value + '/ccs/' + cardUrl + '?' + params.toString()
271
+
272
+ const response = await api.get(url)
273
+ LCard.value = response
274
+
275
+ if (LCard.value?.datalink) {
276
+ fetchData()
277
+ if (LCard.value?.pagination) {
278
+ options.value = {
279
+ ...options.value,
280
+ page: LCard.value?.pagination.current_page,
281
+ }
282
+ }
283
+ }
284
+
285
+ console.log('Card settings fetched:', LCard.value)
286
+ } catch (error) {
287
+ const errormsg = error.response?.data?.error || 'Error fetching data'
288
+ snackbar.show({ message: errormsg, variant: 'error' })
289
+ } finally {
290
+ tableLoading.value = false
291
+ }
245
292
  }
246
293
 
247
294
  const filterSectionFetch = async (filterSectionUrl) => {
@@ -310,7 +357,7 @@ const deleteFetch = async (deleteUrl) => {
310
357
  const fetchData = async (queryParams = {}) => {
311
358
  try {
312
359
  tableLoading.value = true
313
-
360
+
314
361
  // Build query string from params
315
362
  const params = new URLSearchParams({
316
363
  ...queryParams
@@ -318,15 +365,15 @@ const fetchData = async (queryParams = {}) => {
318
365
 
319
366
  // console.log('Fetching with params:', params.toString())
320
367
 
321
- // Get the datalink from props
322
- const datalink = LTable.value?.datalink || ''
368
+ // Get the datalink from table or card settings
369
+ const datalink = LTable.value?.datalink || LCard.value?.datalink || ''
323
370
 
324
371
  // Check if datalink is a full URL
325
372
  const isFullUrl = /^https?:\/\//i.test(datalink)
326
373
  const url = isFullUrl ? datalink : computedBaseUrl.value + '/' + datalink
327
374
 
328
375
  const response = await api.get(url + (params.toString() ? '&' + params.toString() : ''))
329
- // const response = await api.get(`${props.items.componentSettings?.table.datalink}` + (params.toString() ? '&' + params.toString() : '')) // uncomment this line to use real API)
376
+ // const response = await api.get(`${props.items.componentSettings?.table.datalink}` + (params.toString() ? '&' + params.toString() : '')) // uncomment this line to use real API)
330
377
  // const response = person // comment this line to use real API
331
378
  tableData.value = response
332
379
  if (response?.pagination) {
@@ -337,7 +384,7 @@ const fetchData = async (queryParams = {}) => {
337
384
  itemsLength: response?.pagination.total
338
385
  }
339
386
  }
340
-
387
+
341
388
  console.log('Table Fetched data:', tableData.value)
342
389
  // snackbar.show({ message: 'Data fetched successfully', variant: 'success' })
343
390
  } catch (error) {
@@ -357,16 +404,16 @@ const formClose = () => {
357
404
  // Handle options update from DataTable
358
405
  const handleOptionsUpdate = (newOptions) => {
359
406
  // console.log('Options updated:', newOptions)
360
-
407
+
361
408
  // Update local options
362
409
  options.value = { ...options.value, ...newOptions }
363
-
410
+
364
411
  // Build query params
365
412
  const queryParams = {
366
413
  page: newOptions.page,
367
414
  per_page: newOptions.itemsPerPage
368
415
  }
369
-
416
+
370
417
  // Add sorting if exists
371
418
  if (newOptions.sortBy && newOptions.sortBy.length > 0) {
372
419
  const sortParams = newOptions.sortBy.map((field, index) => {
@@ -400,17 +447,17 @@ const handleSearch = (filters) => {
400
447
  filterString = filterPairs.join(',')
401
448
  }
402
449
  }
403
-
450
+
404
451
  // Build query params
405
452
  const queryParams = {
406
453
  page: 1,
407
454
  per_page: options.value.itemsPerPage
408
455
  }
409
-
456
+
410
457
  if (filterString) {
411
458
  queryParams.filter = filterString
412
459
  }
413
-
460
+
414
461
  // Update options and emit
415
462
  options.value = { ...options.value, page: 1 }
416
463
  fetchData(queryParams)
@@ -423,7 +470,7 @@ const handleShowFilterSection = () => {
423
470
  }
424
471
  const handleFormSubmit = (msg) => {
425
472
  snackbar.show({ message: msg, variant: 'success' })
426
- showDynamicForm.value = false;
473
+ showDynamicForm.value = false;
427
474
  editItemId.value = null
428
475
  fetchData({ page: options.value.page, per_page: options.value.itemsPerPage })
429
476
  }
@@ -515,14 +562,14 @@ const deleteItemRequest = async (id) => {
515
562
  snackbar.show({ message: 'Delete action not configured', variant: 'error' })
516
563
  return
517
564
  }
518
-
565
+
519
566
  // Replace {id} in the template with the actual id
520
567
  // const deleteLink = deleteLinkTemplate.replace('{id}', id)
521
-
568
+
522
569
  // Check if deleteLink is a full URL
523
570
  const isFullUrl = /^https?:\/\//i.test(deleteLink)
524
571
  const url = isFullUrl ? deleteLink : baseUrl + '/' + deleteLink
525
-
572
+
526
573
  await api.delete(url+`/${id}`)
527
574
  snackbar.show({ message: 'Item deleted successfully', variant: 'success' })
528
575
  fetchData({ page: options.value.page, per_page: options.value.itemsPerPage }) // Refresh the table after deletion
@@ -535,13 +582,19 @@ const deleteItemRequest = async (id) => {
535
582
 
536
583
  // Update options from server response
537
584
  watch(() => props.items, (newItems) => {
538
- tableFetch(newItems?.componentSettings?.table)
539
- toolbarFetch(newItems?.componentSettings?.toolbar)
540
- console.log('Watching items change:', LTable.value)
541
-
542
-
585
+ if (newItems?.componentSettings?.table) {
586
+ tableFetch(newItems.componentSettings.table)
587
+ }
588
+ if (newItems?.componentSettings?.card) {
589
+ cardFetch(newItems.componentSettings.card)
590
+ }
591
+ if (newItems?.componentSettings?.toolbar) {
592
+ toolbarFetch(newItems.componentSettings.toolbar)
593
+ }
594
+ console.log('Watching items change:', LTable.value, LCard.value)
595
+
543
596
  emit('items', newItems)
544
597
  }, { immediate: true, deep: true })
545
598
 
546
599
 
547
- </script>
600
+ </script>