pgo-ui 1.0.21 → 1.0.23
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.
- package/dist/index.es.js +5386 -5331
- package/dist/index.umd.js +38 -38
- package/dist/pgo-ui.css +1 -1
- package/package.json +1 -1
- package/src/components/pgo/Card.vue +2 -2
- package/src/components/pgo/DataTable.vue +5 -5
- package/src/components/pgo/SearchBox.vue +14 -13
- package/src/components/pgo/base/Base.vue +1 -0
- package/src/components/pgo/forms/DynamicForm.vue +25 -16
- package/src/components/pgo/forms/Form.vue +2 -1
- package/src/main.js +0 -1
- package/src/pgo-components/lib/componentConfig.js +1 -1
- package/src/pgo-components/pages/ComponentRenderer.vue +2 -1
- package/src/pgo-components/pages/ListView copy.vue +385 -0
- package/src/pgo-components/pages/ListView.vue +214 -117
- package/src/pgo-components/pages/customSlot.vue +3 -0
|
@@ -1,24 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="mx-auto m-4">
|
|
3
3
|
<template v-if="items">
|
|
4
|
-
|
|
5
|
-
<SearchBox
|
|
6
|
-
v-model="search"
|
|
7
|
-
label="Find Users"
|
|
8
|
-
/>
|
|
9
|
-
</Card> -->
|
|
10
|
-
<DynamicForm
|
|
11
|
-
v-if="showDynamicForm && items.componentSettings?.form"
|
|
12
|
-
:form="items.componentSettings?.form"
|
|
13
|
-
rounded="sm"
|
|
14
|
-
:title="useLanguageSelected(formMode == 'edit' ? items.componentSettings?.form?.editTitle : items.componentSettings?.form?.createTitle) || ''"
|
|
15
|
-
@close="showDynamicForm = false"
|
|
16
|
-
@submit:success="handleFormSubmit"
|
|
17
|
-
:lang="lang"
|
|
18
|
-
:crud-link="props.items?.componentSettings?.meta?.crudLink"
|
|
19
|
-
:edit-item-id="editItemId"
|
|
20
|
-
:mode="formMode"
|
|
21
|
-
/>
|
|
4
|
+
<slot name="topSlot" :items="items" />
|
|
22
5
|
|
|
23
6
|
<!-- <hr class="border-input-border my-2" /> -->
|
|
24
7
|
<Card
|
|
@@ -28,22 +11,24 @@
|
|
|
28
11
|
margin="mb-4"
|
|
29
12
|
shadow="shadow-lg"
|
|
30
13
|
>
|
|
31
|
-
<
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
14
|
+
<slot name="toolbar" :toolbar="LToolbar" :filterSection="LFilterSection">
|
|
15
|
+
<Toolbar
|
|
16
|
+
v-if="items.componentSettings?.toolbar"
|
|
17
|
+
:elevation="false"
|
|
18
|
+
color="none"
|
|
19
|
+
variant="contained"
|
|
20
|
+
:title="useLanguageSelected(LToolbar.title)"
|
|
21
|
+
:quick-filters="LToolbar?.filters"
|
|
22
|
+
:filter-section="LFilterSection ? true : false"
|
|
23
|
+
:filter-values="quickFilterValues"
|
|
24
|
+
:filter-section-values="filterSectionValues"
|
|
25
|
+
@update:filter-values="quickFilterValues = $event"
|
|
26
|
+
@show-filter-section="handleShowFilterSection"
|
|
27
|
+
@search="handleSearch"
|
|
28
|
+
@refresh="handleRefresh"
|
|
29
|
+
@create-button="handleCreateButton"
|
|
30
|
+
/>
|
|
31
|
+
</slot>
|
|
47
32
|
<Transition
|
|
48
33
|
enter-active-class="transition-all duration-300 ease-out"
|
|
49
34
|
enter-from-class="transform -translate-y-4 opacity-0"
|
|
@@ -54,52 +39,54 @@
|
|
|
54
39
|
>
|
|
55
40
|
|
|
56
41
|
<Card
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
42
|
+
v-if="LFilterSection && showFilters"
|
|
43
|
+
card-class="border-dashed"
|
|
44
|
+
rounded="lg"
|
|
45
|
+
bg=""
|
|
46
|
+
margin="mt-2"
|
|
62
47
|
>
|
|
63
|
-
<
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
48
|
+
<slot name="filterSection">
|
|
49
|
+
<FilterSection
|
|
50
|
+
dir=""
|
|
51
|
+
grid
|
|
52
|
+
:grid-columns="2"
|
|
53
|
+
v-model="filterSectionValues"
|
|
54
|
+
rounded=""
|
|
55
|
+
:filters="LFilterSection?.filters"
|
|
56
|
+
:buttons="LFilterSection?.buttons"
|
|
57
|
+
@search="handleSearch"
|
|
58
|
+
@submit="handleSearch"
|
|
59
|
+
@close="showFilters = false"
|
|
60
|
+
/>
|
|
61
|
+
</slot>
|
|
76
62
|
</Card>
|
|
77
63
|
</Transition>
|
|
78
64
|
</Card>
|
|
79
|
-
<
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
65
|
+
<slot name="table" :table="LTable">
|
|
66
|
+
<DataTable
|
|
67
|
+
v-if="items.componentSettings?.table"
|
|
68
|
+
dir=""
|
|
69
|
+
:items="tableData?.data"
|
|
70
|
+
:settings="LTable"
|
|
71
|
+
:server-side-options="options"
|
|
72
|
+
:loading="tableLoading"
|
|
73
|
+
title=""
|
|
74
|
+
:lang="lang"
|
|
75
|
+
@update:options="handleOptionsUpdate"
|
|
76
|
+
:show-actions="LTable?.showActions ?? true"
|
|
77
|
+
:show-view="LTable?.actions?.showView ?? true"
|
|
78
|
+
:show-edit="LTable?.actions?.showEdit ?? true"
|
|
79
|
+
:show-delete="LTable?.actions?.showDelete ?? true"
|
|
80
|
+
:inline-edit="LTable?.showInlineEdit ?? true"
|
|
81
|
+
@inline-update="handleInlineUpdate"
|
|
82
|
+
@view="handleView"
|
|
83
|
+
@edit="handleEdit"
|
|
84
|
+
@delete="handleDelete"
|
|
85
|
+
/>
|
|
86
|
+
<div v-else class="p-8">
|
|
87
|
+
<p>No headers found</p>
|
|
88
|
+
</div>
|
|
89
|
+
</slot>
|
|
103
90
|
|
|
104
91
|
|
|
105
92
|
</template>
|
|
@@ -107,24 +94,42 @@
|
|
|
107
94
|
<p>No data</p>
|
|
108
95
|
</div>
|
|
109
96
|
|
|
97
|
+
<!-- FORM -->
|
|
98
|
+
<slot name="form" :form="LForm">
|
|
99
|
+
<DynamicForm
|
|
100
|
+
v-if="showDynamicForm && items.componentSettings?.form"
|
|
101
|
+
:form="LForm"
|
|
102
|
+
rounded="sm"
|
|
103
|
+
:title="useLanguageSelected(formMode == 'edit' ? LForm?.editTitle : LForm?.createTitle) || ''"
|
|
104
|
+
@close="showDynamicForm = false"
|
|
105
|
+
@submit:success="handleFormSubmit"
|
|
106
|
+
:lang="lang"
|
|
107
|
+
:crud-link="LForm?.crudLink"
|
|
108
|
+
:edit-item-id="editItemId"
|
|
109
|
+
:mode="formMode"
|
|
110
|
+
/>
|
|
111
|
+
</slot>
|
|
110
112
|
<!-- Delete Confirmation Modal -->
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
<div
|
|
121
|
-
v-if="items.componentSettings?.table?.delete?.message"
|
|
122
|
-
v-for="(message, key) in items.componentSettings?.table?.delete?.message"
|
|
123
|
-
:key="key"
|
|
113
|
+
<slot name="delete" :delete="LDelete">
|
|
114
|
+
<ConfirmationModal
|
|
115
|
+
v-model="showConfirmation"
|
|
116
|
+
:item="DeleteItem"
|
|
117
|
+
:title="LDelete?.title || 'Delete Confirmation'"
|
|
118
|
+
:subtitle="LDelete?.subtitle || 'Are you sure you want to delete this item?'"
|
|
119
|
+
type="warning"
|
|
120
|
+
@confirm="handleDeleteConfirm"
|
|
121
|
+
@cancel="showConfirmation = false; DeleteItem = null"
|
|
124
122
|
>
|
|
125
|
-
<
|
|
126
|
-
|
|
127
|
-
|
|
123
|
+
<div
|
|
124
|
+
v-if="LDelete?.message"
|
|
125
|
+
v-for="(message, key) in LDelete?.message"
|
|
126
|
+
:key="key"
|
|
127
|
+
>
|
|
128
|
+
<p><b>{{ useLanguageSelected(message) }}:</b> {{ DeleteItem[key] }}</p>
|
|
129
|
+
</div>
|
|
130
|
+
</ConfirmationModal>
|
|
131
|
+
</slot>
|
|
132
|
+
<slot name="bottomSlot" :items="items" />
|
|
128
133
|
</div>
|
|
129
134
|
</template>
|
|
130
135
|
|
|
@@ -154,7 +159,7 @@ const props = defineProps({
|
|
|
154
159
|
|
|
155
160
|
const tableLoading = ref(props.loading)
|
|
156
161
|
|
|
157
|
-
const emit = defineEmits(['update:queryParams'])
|
|
162
|
+
const emit = defineEmits(['update:queryParams', 'items'])
|
|
158
163
|
|
|
159
164
|
const showFilters = ref(false)
|
|
160
165
|
// const searchbar = ref({})
|
|
@@ -167,6 +172,17 @@ const showDynamicForm = ref(false)
|
|
|
167
172
|
const formMode = ref('')
|
|
168
173
|
const editItemId = ref(null)
|
|
169
174
|
|
|
175
|
+
const LTable =ref({})
|
|
176
|
+
const LFilterSection = ref({})
|
|
177
|
+
const LToolbar = ref({})
|
|
178
|
+
const LForm = ref({})
|
|
179
|
+
const LDelete = ref({})
|
|
180
|
+
|
|
181
|
+
// Computed properties use injected values
|
|
182
|
+
const computedBaseUrl = computed(() => {
|
|
183
|
+
return baseUrl; // Use baseUrl, don't inject
|
|
184
|
+
});
|
|
185
|
+
|
|
170
186
|
// Manage options internally
|
|
171
187
|
const options = ref({
|
|
172
188
|
page: 1,
|
|
@@ -176,6 +192,85 @@ const options = ref({
|
|
|
176
192
|
itemsLength: 0
|
|
177
193
|
})
|
|
178
194
|
|
|
195
|
+
const tableFetch = async (tableurl) => {
|
|
196
|
+
try {
|
|
197
|
+
tableLoading.value = true
|
|
198
|
+
|
|
199
|
+
const isFullUrl = /^https?:\/\//i.test(tableurl)
|
|
200
|
+
const url = isFullUrl ? tableurl : computedBaseUrl.value + '/ccs/' + tableurl
|
|
201
|
+
|
|
202
|
+
const response = await api.get(url)
|
|
203
|
+
LTable.value = response
|
|
204
|
+
|
|
205
|
+
// Only fetch if componentSettings and table.datalink exist
|
|
206
|
+
if (LTable.value?.datalink) {
|
|
207
|
+
fetchData()
|
|
208
|
+
if (LTable.value?.pagination) {
|
|
209
|
+
options.value = {
|
|
210
|
+
...options.value,
|
|
211
|
+
page: LTable.value?.pagination.current_page,
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
console.log('Table settings fetched:', LTable.value)
|
|
217
|
+
} catch (error) {
|
|
218
|
+
const errormsg = error.response?.data?.error || 'Error fetching data'
|
|
219
|
+
snackbar.show({ message: errormsg, variant: 'error' })
|
|
220
|
+
} finally {
|
|
221
|
+
tableLoading.value = false
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const filterSectionFetch = async (filterSectionUrl) => {
|
|
227
|
+
try {
|
|
228
|
+
const isFullUrl = /^https?:\/\//i.test(filterSectionUrl)
|
|
229
|
+
const url = isFullUrl ? filterSectionUrl : computedBaseUrl.value + '/ccs/' + filterSectionUrl
|
|
230
|
+
|
|
231
|
+
const response = await api.get(url)
|
|
232
|
+
LFilterSection.value = response
|
|
233
|
+
} catch (error) {
|
|
234
|
+
const errormsg = error.response?.data?.error || 'Error fetching filter section data'
|
|
235
|
+
snackbar.show({ message: errormsg, variant: 'error' })
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
const toolbarFetch = async (toolbarUrl) => {
|
|
239
|
+
try {
|
|
240
|
+
const isFullUrl = /^https?:\/\//i.test(toolbarUrl)
|
|
241
|
+
const url = isFullUrl ? toolbarUrl : computedBaseUrl.value + '/ccs/' + toolbarUrl
|
|
242
|
+
|
|
243
|
+
const response = await api.get(url)
|
|
244
|
+
LToolbar.value = response
|
|
245
|
+
console.log('Toolbar settings fetched:', LToolbar.value)
|
|
246
|
+
} catch (error) {
|
|
247
|
+
const errormsg = error.response?.data?.error || 'Error fetching toolbar data'
|
|
248
|
+
snackbar.show({ message: errormsg, variant: 'error' })
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const formFetch = async (formUrl) => {
|
|
252
|
+
try {
|
|
253
|
+
const isFullUrl = /^https?:\/\//i.test(formUrl)
|
|
254
|
+
const url = isFullUrl ? formUrl : computedBaseUrl.value + '/ccs/' + formUrl
|
|
255
|
+
const response = await api.get(url)
|
|
256
|
+
LForm.value = response
|
|
257
|
+
console.log('Form settings fetched:', LForm.value)
|
|
258
|
+
} catch (error) {
|
|
259
|
+
const errormsg = error.response?.data?.error || 'Error fetching form data'
|
|
260
|
+
snackbar.show({ message: errormsg, variant: 'error' })
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
const deleteFetch = async (deleteUrl) => {
|
|
264
|
+
try { const isFullUrl = /^https?:\/\//i.test(deleteUrl)
|
|
265
|
+
const url = isFullUrl ? deleteUrl : computedBaseUrl.value + '/ccs/' + deleteUrl
|
|
266
|
+
const response = await api.get(url)
|
|
267
|
+
LDelete.value = response
|
|
268
|
+
} catch (error) {
|
|
269
|
+
const errormsg = error.response?.data?.error || 'Error fetching delete confirmation data'
|
|
270
|
+
snackbar.show({ message: errormsg, variant: 'error' })
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
179
274
|
const fetchData = async (queryParams = {}) => {
|
|
180
275
|
try {
|
|
181
276
|
tableLoading.value = true
|
|
@@ -185,12 +280,14 @@ const fetchData = async (queryParams = {}) => {
|
|
|
185
280
|
...queryParams
|
|
186
281
|
})
|
|
187
282
|
|
|
283
|
+
// console.log('Fetching with params:', params.toString())
|
|
284
|
+
|
|
188
285
|
// Get the datalink from props
|
|
189
|
-
const datalink =
|
|
286
|
+
const datalink = LTable.value?.datalink || ''
|
|
190
287
|
|
|
191
288
|
// Check if datalink is a full URL
|
|
192
289
|
const isFullUrl = /^https?:\/\//i.test(datalink)
|
|
193
|
-
const url = isFullUrl ? datalink :
|
|
290
|
+
const url = isFullUrl ? datalink : computedBaseUrl.value + '/' + datalink
|
|
194
291
|
|
|
195
292
|
const response = await api.get(url + (params.toString() ? '&' + params.toString() : ''))
|
|
196
293
|
// const response = await api.get(`${props.items.componentSettings?.table.datalink}` + (params.toString() ? '&' + params.toString() : '')) // uncomment this line to use real API)
|
|
@@ -215,26 +312,6 @@ const fetchData = async (queryParams = {}) => {
|
|
|
215
312
|
}
|
|
216
313
|
}
|
|
217
314
|
|
|
218
|
-
// Update options from server response
|
|
219
|
-
watch(() => props.items, (newItems) => {
|
|
220
|
-
// Only fetch if componentSettings and table.datalink exist
|
|
221
|
-
if (newItems?.componentSettings?.table?.datalink) {
|
|
222
|
-
fetchData()
|
|
223
|
-
if (newItems?.componentSettings?.table?.pagination) {
|
|
224
|
-
options.value = {
|
|
225
|
-
...options.value,
|
|
226
|
-
page: newItems.componentSettings.table.pagination.current_page,
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
}, { immediate: true, deep: true })
|
|
231
|
-
|
|
232
|
-
// const headers = computed(() => {
|
|
233
|
-
// const headersFromTable = props.items?.componentSettings?.table?.headers
|
|
234
|
-
// const headersFromSettings = props.items?.componentSettings?.headers
|
|
235
|
-
|
|
236
|
-
// return headersFromTable || headersFromSettings || []
|
|
237
|
-
// })
|
|
238
315
|
|
|
239
316
|
// Handle options update from DataTable
|
|
240
317
|
const handleOptionsUpdate = (newOptions) => {
|
|
@@ -298,6 +375,11 @@ const handleSearch = (filters) => {
|
|
|
298
375
|
fetchData(queryParams)
|
|
299
376
|
// emit('update:queryParams', queryParams)
|
|
300
377
|
}
|
|
378
|
+
|
|
379
|
+
const handleShowFilterSection = () => {
|
|
380
|
+
filterSectionFetch(props.items?.componentSettings?.filterSection)
|
|
381
|
+
showFilters.value = !showFilters.value
|
|
382
|
+
}
|
|
301
383
|
const handleFormSubmit = (msg) => {
|
|
302
384
|
snackbar.show({ message: msg, variant: 'success' })
|
|
303
385
|
showDynamicForm.value = false;
|
|
@@ -327,6 +409,7 @@ const handleQuickSearch = (filters) => {
|
|
|
327
409
|
fetchData(newOptions)
|
|
328
410
|
}
|
|
329
411
|
const handleCreateButton = () => {
|
|
412
|
+
formFetch(props.items?.componentSettings?.form)
|
|
330
413
|
editItemId.value = null
|
|
331
414
|
showDynamicForm.value = true
|
|
332
415
|
formMode.value = 'create'
|
|
@@ -337,15 +420,17 @@ const handleView = (item) => {
|
|
|
337
420
|
// Navigate to detail view or open modal
|
|
338
421
|
}
|
|
339
422
|
const handleEdit = (item) => {
|
|
423
|
+
formFetch(props.items?.componentSettings?.form)
|
|
340
424
|
showDynamicForm.value = true
|
|
341
425
|
editItemId.value = item.id
|
|
342
426
|
formMode.value = 'edit'
|
|
343
427
|
// Navigate to detail view or open modal
|
|
344
428
|
}
|
|
345
429
|
const handleDelete = (item) => {
|
|
430
|
+
deleteFetch(props.items?.componentSettings?.form)
|
|
346
431
|
DeleteItem.value = item
|
|
347
|
-
|
|
348
|
-
|
|
432
|
+
showConfirmation.value = true
|
|
433
|
+
console.log('Delete item:', item)
|
|
349
434
|
// Navigate to detail view or open modal
|
|
350
435
|
}
|
|
351
436
|
|
|
@@ -381,4 +466,16 @@ const deleteItemRequest = async (id) => {
|
|
|
381
466
|
}
|
|
382
467
|
// Perform delete action, e.g. call API to delete item
|
|
383
468
|
}
|
|
469
|
+
|
|
470
|
+
// Update options from server response
|
|
471
|
+
watch(() => props.items, (newItems) => {
|
|
472
|
+
tableFetch(newItems?.componentSettings?.table)
|
|
473
|
+
toolbarFetch(newItems?.componentSettings?.toolbar)
|
|
474
|
+
console.log('Watching items change:', LTable.value)
|
|
475
|
+
|
|
476
|
+
|
|
477
|
+
emit('items', newItems)
|
|
478
|
+
}, { immediate: true, deep: true })
|
|
479
|
+
|
|
480
|
+
|
|
384
481
|
</script>
|