feat: #7449 added new button on claimLines, prevented claimAction to import lines with 0 quantity #1550

Open
provira wants to merge 13 commits from 7449-claimBeginningQuantity into dev
5 changed files with 60 additions and 4 deletions
Showing only changes of commit d4fe1e6a6d - Show all commits

View File

@ -1,10 +1,11 @@
<script setup>
import axios from 'axios';
import { ref, reactive, useAttrs, computed } from 'vue';
import { onBeforeRouteLeave } from 'vue-router';
import { ref, reactive, useAttrs, computed, onMounted, nextTick, } from 'vue';
import { onBeforeRouteLeave , useRouter, useRoute} from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
import { useStateStore } from 'stores/useStateStore';
import { tMobile } from 'src/composables/tMobile';
import { toDateHourMin } from 'src/filters';
import VnPaginate from 'components/ui/VnPaginate.vue';
@ -38,13 +39,19 @@ const $props = defineProps({
addNote: { type: Boolean, default: false },
selectType: { type: Boolean, default: false },
justInput: { type: Boolean, default: false },
goTo: { type: String, default: '', },
});
const { t } = useI18n();
const quasar = useQuasar();
const stateStore = useStateStore();
const router = useRouter();
const route = useRoute();
const componentIsRendered = ref(false);
const newNote = reactive({ text: null, observationTypeFk: null });
const observationTypes = ref([]);
const vnPaginateRef = ref();
let savedNote = false;
let originalText;
function handleClick(e) {
@ -63,6 +70,7 @@ async function insert() {
};
await axios.post($props.url, newBody);
await vnPaginateRef.value.fetch();
savedNote = true;
}
function confirmAndUpdate() {
@ -116,8 +124,29 @@ function fetchData([data]) {
originalText = data?.notes;
emit('onFetch', data);
}
onMounted(() => {
nextTick(() => (componentIsRendered.value = true));
});
async function saveAndGo() {
savedNote = false;
await insert();
await savedNote;
router.push({ path: $props.goTo });
}
</script>
<template>
<Teleport to="#st-actions" v-if="stateStore?.isSubToolbarShown() && componentIsRendered && $props.goTo && !route.path.includes('summary')">
<QBtn
:label="tMobile('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
:title="t('globals.saveAndContinue') + ' ' + t('globals.' + $props.goTo.split('/').pop())"
color="primary"
icon="save"
@click="saveAndGo"
data-cy="save-continue-note-button"
/>
</Teleport>
<FetchData
v-if="selectType"
url="ObservationTypes"
@ -163,7 +192,7 @@ function fetchData([data]) {
:required="isRequired"
clearable
>
<template #append>
<template #append v-if="!$props.goTo">
<QBtn
:title="t('Save (Enter)')"
icon="save"

View File

@ -22,6 +22,7 @@ globals:
dataDeleted: Data deleted
delete: Delete
search: Search
lines: Lines
changes: Changes
dataCreated: Data created
add: Add

View File

@ -22,6 +22,7 @@ globals:
dataDeleted: Datos eliminados
delete: Eliminar
search: Buscar
lines: Lineas
changes: Cambios
dataCreated: Datos creados
add: Añadir

View File

@ -35,9 +35,11 @@ const body = {
workerFk: user.value.id,
};
</script>
<template>
<VnNotes
url="claimObservations"
:go-to="`/claim/${route.params.id}/lines`"
:add-note="$props.addNote"
:user-filter="claimFilter"
:filter="{ where: { claimFk: claimId } }"

View File

@ -0,0 +1,23 @@
/// <reference types="cypress" />
describe('ClaimLines', () => {
const claimId = 1;
beforeEach(() => {
cy.viewport(1920, 1080);
cy.login('developer');
cy.visit(`/#/claim/${claimId}/lines`);
});
it('should add new line', () => {
cy.get('.q-page-sticky > div > .q-btn').click();
cy.get('.q-card > .q-table__container > .q-table__middle > .q-table > thead > tr > .q-table--col-auto-width > .q-checkbox > .q-checkbox__inner > .q-checkbox__bg').click();
cy.get('.q-card__actions > .q-btn--unelevated').click();
cy.get('.q-notification__message').should('have.text', 'Lines added to claim');
})
it.only('should autofill claimed quantity if 0 or null', () => {
cy.get('thead > tr > .q-table--col-auto-width > .q-checkbox > .q-checkbox__inner > .q-checkbox__bg').click();
cy.get('.q-btn--unelevated').click();
cy.get('tbody > :nth-child(1) > .text-primary').should('have.text', 5);
})
});