@dracul/audit-frontend 1.35.6 → 1.35.7

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dracul/audit-frontend",
3
- "version": "1.35.6",
3
+ "version": "1.35.7",
4
4
  "description": "Audit frontend",
5
5
  "author": "Cristian Incarnato <cristian.cdi@gmail.com>",
6
6
  "publishConfig": {
@@ -38,5 +38,5 @@
38
38
  "type": "git",
39
39
  "url": "git+https://github.com/draculjs/modular-framework.git"
40
40
  },
41
- "gitHead": "b866b70b275902cba82da8e6b7f490a3543b82bc"
41
+ "gitHead": "b9c5be39959452b94d59742d37b0a391ccef62b5"
42
42
  }
@@ -87,7 +87,6 @@
87
87
  class="rounded-0"
88
88
  >
89
89
 
90
- <!-- MAKE THIS STICKY -->
91
90
  <div class="sticky-header">
92
91
 
93
92
  <v-toolbar
@@ -134,9 +133,6 @@
134
133
  </v-card>
135
134
  </div>
136
135
 
137
- <!-- MAKE THIS STICKY -->
138
-
139
-
140
136
  <v-spacer></v-spacer>
141
137
 
142
138
  <div class="scrollable-content">
@@ -162,7 +158,7 @@
162
158
  </template>
163
159
  </v-data-table>
164
160
 
165
- <v-treeview
161
+ <v-treeview v-if="item.dialogVisible"
166
162
  :items="getAuditDataChanges(item)"
167
163
  item-text="name"
168
164
  item-children="children"
@@ -288,28 +284,31 @@ export default {
288
284
  this.fetch()
289
285
  },
290
286
  async fetch() {
291
- this.loading = true;
292
- try {
293
- const response = await AuditProvider.paginateAudit(
294
- this.pageNumber,
295
- this.itemsPerPage,
296
- this.search,
297
- this.filters,
298
- this.getOrderBy,
299
- this.getOrderDesc
300
- );
301
- this.items = response.data.paginateAudit.items.map(item => ({
302
- ...item,
303
- changes: item.changes.length === 0 ? [{ length: 1 }] : item.changes,
304
- dialogVisible: false,
305
- }));
306
- this.totalItems = response.data.paginateAudit.totalItems;
307
- } catch (err) {
308
- console.error(err);
309
- } finally {
310
- this.loading = false;
311
- }
312
- },
287
+ this.loading = true
288
+
289
+ try {
290
+ const response = await AuditProvider.paginateAudit(
291
+ this.pageNumber,
292
+ this.itemsPerPage,
293
+ this.search,
294
+ this.filters,
295
+ this.getOrderBy,
296
+ this.getOrderDesc
297
+ )
298
+
299
+ this.items = response.data.paginateAudit.items.map(item => ({
300
+ ...item,
301
+ changes: item.changes.length === 0 ? [{ length: 1 }] : item.changes,
302
+ dialogVisible: false,
303
+ }))
304
+
305
+ this.totalItems = response.data.paginateAudit.totalItems
306
+ } catch (err) {
307
+ console.error(err)
308
+ } finally {
309
+ this.loading = false
310
+ }
311
+ },
313
312
  setFilters(auditFilters) {
314
313
  console.log('auditFilters', auditFilters)
315
314
  this.filters = auditFilters
@@ -322,14 +321,32 @@ export default {
322
321
  this.fetch()
323
322
  },
324
323
  getAuditDataChanges(audit) {
325
- if (!audit || typeof audit.resourceData !== 'object' || !audit.resourceData) return [];
326
-
327
- return Object.entries(audit.resourceData).map(([key, value]) => ({
328
- name: key,
329
- children: Array.isArray(value) || typeof value === 'object'
330
- ? Object.entries(value).map(([subKey, subValue]) => ({ name: `${subKey}: ${subValue}` }))
331
- : [{ name: `${value}` }]
332
- }))
324
+ if (audit && typeof audit.resourceData === 'string') {
325
+ try {
326
+ audit.resourceData = JSON.parse(audit.resourceData)
327
+ } catch {
328
+ console.error('Invalid JSON format in resourceData')
329
+ return []
330
+ }
331
+ }
332
+
333
+ if (!audit || typeof audit.resourceData !== 'object') return []
334
+
335
+ const buildTree = (data) => {
336
+ return Object.entries(data).map(([key, value]) => {
337
+ if (typeof value === 'object' && value !== null) {
338
+ return {
339
+ name: key,
340
+ children: buildTree(value) // Recursión para niveles anidados
341
+ }
342
+ }
343
+ return {
344
+ name: `${key}: ${String(value)}`
345
+ }
346
+ })
347
+ }
348
+
349
+ return buildTree(audit.resourceData)
333
350
  }
334
351
  }
335
352
 
@@ -1,83 +0,0 @@
1
- <template>
2
- <v-dialog
3
- :content-class=" audit.action == 'UPDATE' ? 'rounded-sm' : 'rounded-0'"
4
- >
5
- <template v-slot:activator="{ on, attrs }">
6
- <v-btn
7
- text
8
- color="secondary"
9
- outlined
10
- tile
11
-
12
- v-bind="attrs"
13
- v-on="on"
14
- >
15
- {{ audit.changes.length }}
16
- </v-btn>
17
- </template>
18
-
19
- <v-data-table v-if="audit.action == 'UPDATE'"
20
- :headers=changeHeaders
21
- :items="audit.changes"
22
- :hide-default-footer="true"
23
-
24
- class="rounded-0"
25
- >
26
- <template v-slot:[`item.oldValue`]="{ item }">
27
- {{ item.oldValue }}
28
- </template>
29
-
30
- <template v-slot:[`item.newValue`]="{ item }">
31
- {{ item.newValue }}
32
- </template>
33
- </v-data-table>
34
-
35
- <v-card>
36
- <v-treeview
37
- :items="getAuditDataChanges(item)"
38
- item-text="name"
39
- item-children="children"
40
- open-on-click
41
- class="rounded-0"
42
- >
43
- </v-treeview>
44
- </v-card>
45
-
46
- </v-dialog>
47
- </template>
48
-
49
-
50
-
51
- <script>
52
- export default {
53
- name:"AuditChanges",
54
- props:{
55
- audit: {type: Object, required: true}
56
- },
57
- methods: {
58
- getAuditDataChanges(audit) {
59
- if (!audit || typeof audit.resourceData !== 'object' || !audit.resourceData) return [];
60
-
61
- return Object.entries(audit.resourceData).map(([key, value]) => ({
62
- name: key,
63
- children: Array.isArray(value) || typeof value === 'object'
64
- ? Object.entries(value).map(([subKey, subValue]) => ({ name: `${subKey}: ${subValue}` }))
65
- : [{ name: `${value}` }]
66
- }))
67
- }
68
- },
69
- computed: {
70
- changeHeaders() {
71
- return [
72
- { text: this.$t('audit.actions.changes.field'), value: 'field' },
73
- { text: this.$t('audit.actions.changes.oldValue'), value: 'oldValue' },
74
- { text: this.$t('audit.actions.changes.newValue'), value: 'newValue' },
75
- ]
76
- },
77
- }
78
- }
79
- </script>
80
-
81
- <style lang="scss" scoped>
82
-
83
- </style>