From 48f10707400afd1ddedb843f236dd6fc28d5b8bd Mon Sep 17 00:00:00 2001 From: alexm Date: Tue, 5 Nov 2024 12:52:53 +0100 Subject: [PATCH 01/12] feat(VnLog): add descriptors --- src/components/common/VnJsonValue.vue | 63 ++++++++++++++++++--------- src/components/common/VnLog.vue | 59 +++++++++++-------------- src/stores/useDescriptorStore.js | 29 ++++++++++++ 3 files changed, 98 insertions(+), 53 deletions(-) create mode 100644 src/stores/useDescriptorStore.js diff --git a/src/components/common/VnJsonValue.vue b/src/components/common/VnJsonValue.vue index a2e858d0d..408d16d1a 100644 --- a/src/components/common/VnJsonValue.vue +++ b/src/components/common/VnJsonValue.vue @@ -1,67 +1,86 @@ @@ -85,4 +104,8 @@ updateValue(); color: #cd7c7c; font-style: italic; } +.json-link { + text-decoration: underline; + cursor: pointer; +} diff --git a/src/components/common/VnLog.vue b/src/components/common/VnLog.vue index 8c71c0997..7b65a8a88 100644 --- a/src/components/common/VnLog.vue +++ b/src/components/common/VnLog.vue @@ -598,33 +598,17 @@ watch( /> - - - {{ prop.nameI18n }}: - - - ,  - - - -
+ - {{ prop.nameI18n }}: + v-if=" + prop2Index < log.props.length + " + class="q-mr-xs" + >, - #{{ prop.val.id }} - + { + const descriptors = ref({}); + const loaded = ref(false); + + function set() { + const files = import.meta.glob(`src/**/*DescriptorProxy.vue`); + for (const file in files) { + descriptors.value[file.split('/').at(-1).slice(0, -19).toLowerCase() + 'Fk'] = + defineAsyncComponent(() => import(file)); + } + loaded.value = true; + } + + function get() { + if (!loaded.value) set(); + } + + function has(name) { + get(); + return descriptors.value[name]; + } + + return { + has, + }; +}); From 0e7a8e61d3e8dc134943d1e271c58f8cf65341f2 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 24 Feb 2025 14:50:57 +0100 Subject: [PATCH 02/12] refactor: refs #6994 update VnJsonValue component props and improve descriptor handling --- src/components/common/VnJsonValue.vue | 32 ++++++++------------------- src/components/common/VnLog.vue | 24 +++++++++++++------- src/stores/useDescriptorStore.js | 18 ++++++++++----- 3 files changed, 38 insertions(+), 36 deletions(-) diff --git a/src/components/common/VnJsonValue.vue b/src/components/common/VnJsonValue.vue index 408d16d1a..11588e710 100644 --- a/src/components/common/VnJsonValue.vue +++ b/src/components/common/VnJsonValue.vue @@ -1,11 +1,11 @@ @@ -104,8 +94,4 @@ updateValue(); color: #cd7c7c; font-style: italic; } -.json-link { - text-decoration: underline; - cursor: pointer; -} diff --git a/src/components/common/VnLog.vue b/src/components/common/VnLog.vue index 1d56b3ae4..28c9206a6 100644 --- a/src/components/common/VnLog.vue +++ b/src/components/common/VnLog.vue @@ -561,9 +561,8 @@ watch( }}: @@ -619,19 +618,27 @@ watch( :key="prop2Index" class="q-pa-none text-grey" > + + {{ prop.nameI18n }}: + , #{{ prop.val.id }} @@ -644,7 +651,8 @@ watch( > ← { const descriptors = ref({}); - const loaded = ref(false); function set() { const files = import.meta.glob(`src/**/*DescriptorProxy.vue`); + const moduleParser = { + user: 'account', + client: 'customer', + }; for (const file in files) { - descriptors.value[file.split('/').at(-1).slice(0, -19).toLowerCase() + 'Fk'] = - defineAsyncComponent(() => import(file)); + console.log('fasd', file.split('/').at(-1).slice(0, -19).toLowerCase()); + const name = file.split('/').at(-1).slice(0, -19).toLowerCase(); + const descriptor = moduleParser[name] ?? name; + //Ver pq no funciona account//user + descriptors.value[descriptor + 'Fk'] = defineAsyncComponent(() => + import(file) + ); } - loaded.value = true; } function get() { - if (!loaded.value) set(); + if (!Object.keys(descriptors.value).length) set(); } function has(name) { get(); + console.log('descriptors.value: ', descriptors.value); return descriptors.value[name]; } From 80eebef931030b06355cb3e9ccd628165f39c015 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 7 Mar 2025 14:01:36 +0100 Subject: [PATCH 03/12] feat(VnLog): refs #6994 add descriptors --- src/components/common/VnJsonValue.vue | 13 +++-- src/components/common/VnLog.vue | 76 +++++++++++++-------------- src/stores/useDescriptorStore.js | 32 +++++------ src/stores/useStateStore.js | 7 +++ 4 files changed, 69 insertions(+), 59 deletions(-) diff --git a/src/components/common/VnJsonValue.vue b/src/components/common/VnJsonValue.vue index 11588e710..331c72d0a 100644 --- a/src/components/common/VnJsonValue.vue +++ b/src/components/common/VnJsonValue.vue @@ -66,11 +66,15 @@ updateValue(); :title="type === 'string' && value.length > maxStrLen ? value : ''" :class="{ [cssClass]: t !== '', - 'json-link': descriptorStore.has(name), + 'link json-link': descriptorStore.has(name), }" > - {{ name }} - + {{ t }} + @@ -94,4 +98,7 @@ updateValue(); color: #cd7c7c; font-style: italic; } +.json-link { + text-decoration: underline; +} diff --git a/src/components/common/VnLog.vue b/src/components/common/VnLog.vue index 1d73e4689..f4d6c5bca 100644 --- a/src/components/common/VnLog.vue +++ b/src/components/common/VnLog.vue @@ -561,7 +561,7 @@ watch( }}: @@ -599,17 +599,36 @@ watch( /> + + + {{ prop.nameI18n }}: + + + ,  + + + +
- , - - - #{{ prop.val.id }} - - - ← + { - const descriptors = ref({}); + function get() { + if (Object.keys(descriptors).length) return descriptors; - function set() { - const files = import.meta.glob(`src/**/*DescriptorProxy.vue`); + const currentDescriptors = {}; + const files = import.meta.glob(`/src/**/*DescriptorProxy.vue`); const moduleParser = { - user: 'account', + account: 'user', client: 'customer', }; for (const file in files) { - console.log('fasd', file.split('/').at(-1).slice(0, -19).toLowerCase()); const name = file.split('/').at(-1).slice(0, -19).toLowerCase(); const descriptor = moduleParser[name] ?? name; - //Ver pq no funciona account//user - descriptors.value[descriptor + 'Fk'] = defineAsyncComponent(() => - import(file) + currentDescriptors[descriptor + 'Fk'] = defineAsyncComponent( + () => import(/* @vite-ignore */ file), ); } - } - - function get() { - if (!Object.keys(descriptors.value).length) set(); + setDescriptors(currentDescriptors); + return currentDescriptors; } function has(name) { - get(); - console.log('descriptors.value: ', descriptors.value); - return descriptors.value[name]; + console.log('get(): ', get()); + return get()[name]; } return { has, + get, }; }); diff --git a/src/stores/useStateStore.js b/src/stores/useStateStore.js index ca447bc11..44fa133d0 100644 --- a/src/stores/useStateStore.js +++ b/src/stores/useStateStore.js @@ -8,6 +8,7 @@ export const useStateStore = defineStore('stateStore', () => { const rightAdvancedDrawer = ref(false); const subToolbar = ref(false); const cardDescriptor = ref(null); + const descriptors = ref({}); function cardDescriptorChangeValue(descriptor) { cardDescriptor.value = descriptor; @@ -52,6 +53,10 @@ export const useStateStore = defineStore('stateStore', () => { return subToolbar.value; } + function setDescriptors(value) { + descriptors.value = value; + } + return { cardDescriptor, cardDescriptorChangeValue, @@ -68,5 +73,7 @@ export const useStateStore = defineStore('stateStore', () => { isSubToolbarShown, toggleSubToolbar, rightDrawerChangeValue, + descriptors, + setDescriptors, }; }); From a4dfb549be90b00722b4d8173da1818e9b72b202 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 7 Mar 2025 14:02:03 +0100 Subject: [PATCH 04/12] test: refs #6994 add e2e VnLog descriptors --- src/components/ui/CardDescriptor.vue | 2 +- src/pages/Claim/Card/ClaimDescriptorProxy.vue | 14 ++++++++++++++ test/cypress/integration/vnComponent/VnLog.spec.js | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 src/pages/Claim/Card/ClaimDescriptorProxy.vue diff --git a/src/components/ui/CardDescriptor.vue b/src/components/ui/CardDescriptor.vue index a29d1d429..ad344082d 100644 --- a/src/components/ui/CardDescriptor.vue +++ b/src/components/ui/CardDescriptor.vue @@ -200,7 +200,7 @@ const toModule = computed(() =>
- + #{{ getValueFromPath(subtitle) ?? entity.id }} +import ClaimDescriptor from './ClaimDescriptor.vue'; +import ClaimSummary from './ClaimSummary.vue'; + + diff --git a/test/cypress/integration/vnComponent/VnLog.spec.js b/test/cypress/integration/vnComponent/VnLog.spec.js index 80b9d07df..0baab21c9 100644 --- a/test/cypress/integration/vnComponent/VnLog.spec.js +++ b/test/cypress/integration/vnComponent/VnLog.spec.js @@ -22,4 +22,11 @@ describe('VnLog', () => { cy.get('.q-page').click(); cy.validateContent(chips[0], 'Claim'); }); + + it('should show claimDescriptor', () => { + cy.get('.json-link').first().contains('1'); + cy.get('.json-link').first().click(); + cy.dataCy('descriptor_id').contains('1'); + cy.get('.json-link').first().click(); + }); }); From 564877a73c767ee3064dde534373964ebdfb59a5 Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 7 Mar 2025 14:02:21 +0100 Subject: [PATCH 05/12] test: refs #6994 add front test descriptors --- .../Account/Card/AccountDescriptorProxy.vue | 14 ++++++++++ .../__tests__/useDescriptorStore.spec.js | 28 +++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 src/pages/Account/Card/AccountDescriptorProxy.vue create mode 100644 src/stores/__tests__/useDescriptorStore.spec.js diff --git a/src/pages/Account/Card/AccountDescriptorProxy.vue b/src/pages/Account/Card/AccountDescriptorProxy.vue new file mode 100644 index 000000000..de3220fea --- /dev/null +++ b/src/pages/Account/Card/AccountDescriptorProxy.vue @@ -0,0 +1,14 @@ + + diff --git a/src/stores/__tests__/useDescriptorStore.spec.js b/src/stores/__tests__/useDescriptorStore.spec.js new file mode 100644 index 000000000..61aab8d14 --- /dev/null +++ b/src/stores/__tests__/useDescriptorStore.spec.js @@ -0,0 +1,28 @@ +import { describe, expect, it, beforeEach } from 'vitest'; +import 'app/test/vitest/helper'; + +import { useDescriptorStore } from 'src/stores/useDescriptorStore'; +import { useStateStore } from 'stores/useStateStore'; + +describe('useDescriptorStore', () => { + const { get, has } = useDescriptorStore(); + const stateStore = useStateStore(); + + beforeEach(() => { + stateStore.setDescriptors({}); + }); + + function getDescriptors() { + return stateStore.descriptors; + } + + it('should get descriptors in stateStore', async () => { + expect(Object.keys(getDescriptors()).length).toBe(0); + get(); + expect(Object.keys(getDescriptors()).length).toBeGreaterThan(0); + }); + + it('should find ticketDescriptor if search ticketFk', async () => { + expect(has('ticketFk')).toBeDefined(); + }); +}); From bb6082026b6ea6d27b62d0250b17fb2b3efaa24d Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 7 Mar 2025 14:59:29 +0100 Subject: [PATCH 06/12] refactor(descriptorStore): refs #6994 remove debug log from has function --- src/stores/useDescriptorStore.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/stores/useDescriptorStore.js b/src/stores/useDescriptorStore.js index 7ffbdda7a..150db7fbd 100644 --- a/src/stores/useDescriptorStore.js +++ b/src/stores/useDescriptorStore.js @@ -26,7 +26,6 @@ export const useDescriptorStore = defineStore('descriptorStore', () => { } function has(name) { - console.log('get(): ', get()); return get()[name]; } From 9f498c83df1520ae45ef9b48a73de786f3adba11 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 10 Mar 2025 08:47:46 +0100 Subject: [PATCH 07/12] test: refs #6994 add json-link front test --- src/components/common/VnJsonValue.vue | 14 +++++--- .../common/__tests__/VnJsonValue.spec.js | 34 ++++++++++++------- 2 files changed, 31 insertions(+), 17 deletions(-) diff --git a/src/components/common/VnJsonValue.vue b/src/components/common/VnJsonValue.vue index 331c72d0a..f89918d2c 100644 --- a/src/components/common/VnJsonValue.vue +++ b/src/components/common/VnJsonValue.vue @@ -4,7 +4,7 @@ import { toDateString } from 'src/filters'; import { useDescriptorStore } from 'src/stores/useDescriptorStore'; const props = defineProps({ - value: { type: [String, Number, Boolean, Object], default: undefined }, + value: { type: Object, default: undefined }, name: { type: String, default: undefined }, }); @@ -32,6 +32,7 @@ const updateValue = () => { Math.round((propsValue.value + Number.EPSILON) * 1000) / 1000 ).toString(); } + cssClass = isLink(cssClass); break; case 'boolean': t = propsValue.value ? '✓' : '✗'; @@ -40,8 +41,9 @@ const updateValue = () => { case 'string': t = propsValue.value.length <= maxStrLen - ? propsValue + ? propsValue.value : propsValue.value.substring(0, maxStrLen) + '...'; + cssClass = isLink(cssClass); break; case 'object': if (propsValue.value instanceof Date) { @@ -56,6 +58,11 @@ const updateValue = () => { } }; +function isLink(cssClass) { + if (!descriptorStore.has(props.name)) return cssClass; + return 'link json-link'; +} + watch(() => props.value, updateValue); updateValue(); @@ -63,10 +70,9 @@ updateValue();