From ed642b299efd2cbccf110d472799fe664616992c Mon Sep 17 00:00:00 2001 From: jorgep <jorgep@verdnatura.es> Date: Thu, 27 Jun 2024 12:27:04 +0200 Subject: [PATCH 1/2] feat: refs #7436 show checkbox --- src/components/ui/CardSummary.vue | 5 -- src/components/ui/VnLv.vue | 96 ++++++++++++++++++------------- 2 files changed, 56 insertions(+), 45 deletions(-) diff --git a/src/components/ui/CardSummary.vue b/src/components/ui/CardSummary.vue index 253683889..11dcbee3b 100644 --- a/src/components/ui/CardSummary.vue +++ b/src/components/ui/CardSummary.vue @@ -187,15 +187,10 @@ function existSummary(routes) { color: lighten($primary, 20%); } .q-checkbox { - display: flex; - margin-bottom: 9px; & .q-checkbox__label { - margin-left: 31px; color: var(--vn-text-color); } & .q-checkbox__inner { - position: absolute; - left: 0; color: var(--vn-label-color); } } diff --git a/src/components/ui/VnLv.vue b/src/components/ui/VnLv.vue index 3220bce6a..ff65f759b 100644 --- a/src/components/ui/VnLv.vue +++ b/src/components/ui/VnLv.vue @@ -2,6 +2,7 @@ import { dashIfEmpty } from 'src/filters'; import { useI18n } from 'vue-i18n'; import { useClipboard } from 'src/composables/useClipboard'; +import { computed } from 'vue'; const $props = defineProps({ label: { type: String, default: null }, @@ -24,52 +25,67 @@ function copyValueText() { }, }); } +const val = computed(() => $props.value); </script> -<style scoped> -.label, -.value { - white-space: pre-line; - word-wrap: break-word; -} -</style> <template> <div class="vn-label-value"> - <div v-if="$props.label || $slots.label" class="label"> - <slot name="label"> - <span>{{ $props.label }}</span> - </slot> - </div> - <div class="value"> - <slot name="value"> - <span :title="$props.value"> - {{ $props.dash ? dashIfEmpty($props.value) : $props.value }} - </span> - </slot> - </div> - <div class="info" v-if="$props.info"> - <QIcon name="info" class="cursor-pointer" size="xs" color="grey"> - <QTooltip class="bg-dark text-white shadow-4" :offset="[10, 10]"> - {{ $props.info }} - </QTooltip> - </QIcon> - </div> - <div class="copy" v-if="$props.copy && $props.value" @click="copyValueText()"> - <QIcon name="Content_Copy" color="primary"> - <QTooltip>{{ t('globals.copyClipboard') }}</QTooltip> - </QIcon> - </div> + <QCheckbox + v-if="typeof value === 'boolean'" + v-model="val" + :label="label" + disable + dense + /> + <template v-else> + <div v-if="label || $slots.label" class="label"> + <slot name="label"> + <span>{{ label }}</span> + </slot> + </div> + <div class="value"> + <slot name="value"> + <span :title="value"> + {{ dash ? dashIfEmpty(value) : value }} + </span> + </slot> + </div> + <div class="info" v-if="info"> + <QIcon name="info" class="cursor-pointer" size="xs" color="grey"> + <QTooltip class="bg-dark text-white shadow-4" :offset="[10, 10]"> + {{ info }} + </QTooltip> + </QIcon> + </div> + <div class="copy" v-if="copy && value" @click="copyValueText()"> + <QIcon name="Content_Copy" color="primary"> + <QTooltip>{{ t('globals.copyClipboard') }}</QTooltip> + </QIcon> + </div> + </template> </div> </template> - <style lang="scss" scoped> -.vn-label-value:hover .copy { - visibility: visible; - cursor: pointer; +.vn-label-value { + &:hover .copy { + visibility: visible; + cursor: pointer; + } + + .label, + .value { + white-space: pre-line; + word-wrap: break-word; + } + .copy { + visibility: hidden; + } + + .info { + margin-left: 5px; + } } -.copy { - visibility: hidden; -} -.info { - margin-left: 5px; + +:deep(.q-checkbox.disabled) { + opacity: 1 !important; } </style> From 63a05130e3df039c9b243da9068619682ca4c1e3 Mon Sep 17 00:00:00 2001 From: jorgep <jorgep@verdnatura.es> Date: Fri, 28 Jun 2024 12:46:14 +0200 Subject: [PATCH 2/2] chore: refs #7436 fix e2e --- .../integration/invoiceIn/invoiceInDescriptor.spec.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js b/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js index ca0b309e9..a2e9998bb 100644 --- a/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js +++ b/test/cypress/integration/invoiceIn/invoiceInDescriptor.spec.js @@ -1,8 +1,7 @@ describe('InvoiceInDescriptor', () => { const dialogBtns = '.q-card__actions button'; const firstDescritorOpt = '.q-menu > .q-list > :nth-child(1) > .q-item__section'; - const isBookedField = - '.q-card:nth-child(3) .vn-label-value:nth-child(5) > .value > span'; + const isBookedField = '.q-card:nth-child(3) .vn-label-value:nth-child(5) .q-checkbox'; it('should booking and unbooking the invoice properly', () => { cy.viewport(1280, 720); @@ -12,10 +11,10 @@ describe('InvoiceInDescriptor', () => { cy.openActionsDescriptor(); cy.get(firstDescritorOpt).click(); cy.get(dialogBtns).eq(1).click(); - cy.get(isBookedField).should('have.attr', 'title', 'true'); + cy.get(isBookedField).should('have.attr', 'aria-checked', 'true'); cy.get(firstDescritorOpt).click(); cy.get(dialogBtns).eq(1).click(); - cy.get(isBookedField).should('have.attr', 'title', 'false'); + cy.get(isBookedField).should('have.attr', 'aria-checked', 'false'); }); });