From ee7c2389b58d2831e33338741129160bd8d2307e Mon Sep 17 00:00:00 2001 From: jorgep Date: Wed, 16 Aug 2023 09:03:41 +0200 Subject: [PATCH 1/8] refs 6105 claimNotes and VnNotes created --- src/components/ui/AvatarPicture.vue | 36 +++++ src/components/ui/VnNotes.vue | 156 ++++++++++++++++++++ src/filters/index.js | 2 + src/filters/toDateHour.js | 12 ++ src/pages/Claim/Card/ClaimCard.vue | 36 +++-- src/pages/Claim/Card/ClaimNotes.vue | 86 +++++++++++ src/router/modules/claim.js | 9 ++ test/cypress/integration/ClaimNotes.spec.js | 16 ++ 8 files changed, 342 insertions(+), 11 deletions(-) create mode 100644 src/components/ui/AvatarPicture.vue create mode 100644 src/components/ui/VnNotes.vue create mode 100644 src/filters/toDateHour.js create mode 100644 src/pages/Claim/Card/ClaimNotes.vue create mode 100644 test/cypress/integration/ClaimNotes.spec.js diff --git a/src/components/ui/AvatarPicture.vue b/src/components/ui/AvatarPicture.vue new file mode 100644 index 000000000..a28a660c2 --- /dev/null +++ b/src/components/ui/AvatarPicture.vue @@ -0,0 +1,36 @@ + + + diff --git a/src/components/ui/VnNotes.vue b/src/components/ui/VnNotes.vue new file mode 100644 index 000000000..21c56b0b3 --- /dev/null +++ b/src/components/ui/VnNotes.vue @@ -0,0 +1,156 @@ + + + + + es: + Add note here...: Añadir nota aquí... + Add note: Añadir nota + diff --git a/src/filters/index.js b/src/filters/index.js index 4d24d9f67..158ce1009 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -1,6 +1,7 @@ import toLowerCase from './toLowerCase'; import toDate from './toDate'; import toDateString from './toDateString'; +import toDateHour from './toDateHour'; import toCurrency from './toCurrency'; import toPercentage from './toPercentage'; import toLowerCamel from './toLowerCamel'; @@ -11,6 +12,7 @@ export { toLowerCamel, toDate, toDateString, + toDateHour, toCurrency, toPercentage, dashIfEmpty, diff --git a/src/filters/toDateHour.js b/src/filters/toDateHour.js new file mode 100644 index 000000000..939352404 --- /dev/null +++ b/src/filters/toDateHour.js @@ -0,0 +1,12 @@ +export default function toDateHour(date) { + const dateHour = new Date(date).toLocaleDateString('es-ES', { + timeZone: 'Europe/Madrid', + year: 'numeric', + month: '2-digit', + day: '2-digit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit', + }); + return dateHour; +} diff --git a/src/pages/Claim/Card/ClaimCard.vue b/src/pages/Claim/Card/ClaimCard.vue index 2691bbc51..cfc06444f 100644 --- a/src/pages/Claim/Card/ClaimCard.vue +++ b/src/pages/Claim/Card/ClaimCard.vue @@ -3,11 +3,12 @@ import LeftMenu from 'components/LeftMenu.vue'; import { getUrl } from 'composables/getUrl'; import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; import { useStateStore } from 'stores/useStateStore'; -import { computed, onMounted } from 'vue'; +import { computed } from 'vue'; import { useI18n } from 'vue-i18n'; import { useRoute } from 'vue-router'; import ClaimDescriptor from './ClaimDescriptor.vue'; +import { onMounted } from 'vue'; const stateStore = useStateStore(); const { t } = useI18n(); const route = useRoute(); @@ -21,11 +22,6 @@ const $props = defineProps({ const entityId = computed(() => { return $props.id || route.params.id; }); -const claimSections = [ - { name: 'Notes', url: '/note/index', icon: 'draft' }, - { name: 'Development', url: '/development', icon: 'vn:traceability' }, - { name: 'Action', url: '/action', icon: 'vn:actions' }, -]; let salixUrl; onMounted(async () => { @@ -49,17 +45,35 @@ onMounted(async () => { - + - {{ t(section.name) }} + {{ t('Notes') }} + + + + + + {{ t('Development') }} + + + + {{ t('Action') }} diff --git a/src/pages/Claim/Card/ClaimNotes.vue b/src/pages/Claim/Card/ClaimNotes.vue new file mode 100644 index 000000000..c79c9e486 --- /dev/null +++ b/src/pages/Claim/Card/ClaimNotes.vue @@ -0,0 +1,86 @@ + + + diff --git a/src/router/modules/claim.js b/src/router/modules/claim.js index c43ed5012..9f16f9569 100644 --- a/src/router/modules/claim.js +++ b/src/router/modules/claim.js @@ -103,6 +103,15 @@ export default { }, component: () => import('src/pages/Claim/Card/ClaimLog.vue'), }, + { + name: 'ClaimNotes', + path: 'notes', + meta: { + title: 'notes', + icon: 'vn:details', + }, + component: () => import('src/pages/Claim/Card/ClaimNotes.vue'), + }, ], }, ], diff --git a/test/cypress/integration/ClaimNotes.spec.js b/test/cypress/integration/ClaimNotes.spec.js new file mode 100644 index 000000000..9370c7a9e --- /dev/null +++ b/test/cypress/integration/ClaimNotes.spec.js @@ -0,0 +1,16 @@ +/// +describe('ClaimNotes', () => { + beforeEach(() => { + const claimId = 2; + cy.login('developer'); + cy.visit(`/#/claim/${claimId}/notes`); + }); + + it('should add a new note', () => { + const message = 'This is a new message.'; + cy.get('.add-btn').click(); + cy.get('.note-dialog__content').type(message); + cy.get('.note-dialog__actions .q-btn:nth-child(2)').click(); + cy.get('.notes > :nth-child(1) > .text').should('have.text', message); + }); +}); From 4bac67de38d2ac416536f90e7f211d414862e41c Mon Sep 17 00:00:00 2001 From: jorgep Date: Fri, 18 Aug 2023 12:12:53 +0200 Subject: [PATCH 2/8] refs 6105 VnNotes and ClaimNotes refactored --- src/components/ui/AvatarPicture.vue | 12 +- src/components/ui/VnNotes.vue | 136 +++++++++----------- src/components/ui/VnPaginate.vue | 2 +- src/pages/Claim/Card/ClaimNotes.vue | 42 +++--- test/cypress/integration/ClaimNotes.spec.js | 2 +- 5 files changed, 87 insertions(+), 107 deletions(-) diff --git a/src/components/ui/AvatarPicture.vue b/src/components/ui/AvatarPicture.vue index a28a660c2..127bc8970 100644 --- a/src/components/ui/AvatarPicture.vue +++ b/src/components/ui/AvatarPicture.vue @@ -8,7 +8,7 @@ const session = useSession(); const token = session.getToken(); - diff --git a/src/components/ui/VnNotes.vue b/src/components/ui/VnNotes.vue index 21c56b0b3..c05ecdecf 100644 --- a/src/components/ui/VnNotes.vue +++ b/src/components/ui/VnNotes.vue @@ -4,8 +4,8 @@ import AvatarPicture from 'src/components/ui/AvatarPicture.vue'; import { toDateHour } from 'src/filters'; import { ref } from 'vue'; import axios from 'axios'; -import FetchData from 'components/FetchData.vue'; import { useI18n } from 'vue-i18n'; +import VnPaginate from './VnPaginate.vue'; const $props = defineProps({ id: { type: String, required: true }, @@ -15,36 +15,75 @@ const $props = defineProps({ addNote: { type: Boolean, default: false }, }); const { t } = useI18n(); -const notes = ref([]); const noteModal = ref(false); const newNote = ref(''); -const claimObservationRef = ref(); - -function setNotes(data) { - notes.value = data; -} +const vnPaginateRef = ref(); async function fetch() { const body = $props.body; Object.assign(body, { text: newNote.value }); await axios.post($props.url, body); - claimObservationRef.value.fetch(); + vnPaginateRef.value.fetch(); } diff --git a/src/components/ui/VnPaginate.vue b/src/components/ui/VnPaginate.vue index 2a5b878f5..434ebf232 100644 --- a/src/components/ui/VnPaginate.vue +++ b/src/components/ui/VnPaginate.vue @@ -49,6 +49,7 @@ const props = defineProps({ }); const emit = defineEmits(['onFetch', 'onPaginate']); +defineExpose({ fetch }); const isLoading = ref(false); const pagination = ref({ sortBy: props.order, @@ -82,7 +83,6 @@ async function fetch() { if (!arrayData.hasMoreData.value) { isLoading.value = false; } - emit('onFetch', store.data); } diff --git a/src/pages/Claim/Card/ClaimNotes.vue b/src/pages/Claim/Card/ClaimNotes.vue index c79c9e486..6c8361fde 100644 --- a/src/pages/Claim/Card/ClaimNotes.vue +++ b/src/pages/Claim/Card/ClaimNotes.vue @@ -9,7 +9,6 @@ const user = state.getUser(); const id = route.params.id; const claimFilter = { - order: 'created DESC', where: { claimFk: id }, fields: ['created', 'workerFk', 'text'], include: { @@ -38,7 +37,6 @@ const body = { diff --git a/src/pages/Claim/Card/ClaimNotes.vue b/src/pages/Claim/Card/ClaimNotes.vue index 6c8361fde..9e587533a 100644 --- a/src/pages/Claim/Card/ClaimNotes.vue +++ b/src/pages/Claim/Card/ClaimNotes.vue @@ -25,7 +25,7 @@ const body = { }; - From 330db88cccae077df31bc0d852d2df9f364009f9 Mon Sep 17 00:00:00 2001 From: jorgep Date: Thu, 24 Aug 2023 14:56:26 +0200 Subject: [PATCH 6/8] refs #6105 replaced css by QuasarComponents --- src/components/ui/VnNotes.vue | 86 +++++++-------------- src/i18n/en/index.js | 1 + src/i18n/es/index.js | 1 + src/pages/Claim/Card/ClaimCard.vue | 11 --- src/pages/Claim/Card/ClaimNotes.vue | 2 +- src/router/modules/claim.js | 11 ++- test/cypress/integration/ClaimNotes.spec.js | 13 ++-- 7 files changed, 47 insertions(+), 78 deletions(-) diff --git a/src/components/ui/VnNotes.vue b/src/components/ui/VnNotes.vue index 12d93073a..dbc30ae74 100644 --- a/src/components/ui/VnNotes.vue +++ b/src/components/ui/VnNotes.vue @@ -27,7 +27,7 @@ async function insert() { }