diff --git a/src/components/OrderMessage.vue b/src/components/OrderMessage.vue index ea58056..808268a 100644 --- a/src/components/OrderMessage.vue +++ b/src/components/OrderMessage.vue @@ -249,6 +249,12 @@ function verifyOrderFields() { return true; } +function hasHeaderFieldsComplete() { + return Object.values(store.orderData.header).every((v) => { + return v.trim().length != 0; + }); +} + // TODO function incrementOrderNo() { // store.orderData. = (Number(order.header.orderNo) + 1).toString(); @@ -270,12 +276,8 @@ function copyMessage() { } function saveOrder() { - const noHeaderInfo = Object.values(store.orderData.header).some((v) => { - return v.trim().length == 0; - }); - - if (noHeaderInfo) { - showActionMonit(`${t('order-message.warning-fill-top')}`, 'warning'); + if (!hasHeaderFieldsComplete()) { + showActionMonit(`${t('order-message.warning-fill-top-save')}`, 'warning'); return; } @@ -322,15 +324,19 @@ function saveOrder() { function updateOrder() { if (!store.chosenLocalOrderId) { - showActionMonit(`${t('order-message.warning-no-order-selected')}`, 'warning'); + showActionMonit(t('order-message.warning-no-order-selected'), 'warning'); + return; + } + if (!hasHeaderFieldsComplete()) { + showActionMonit(t('order-message.warning-fill-top-update'), 'warning'); return; } const localOrder = window.localStorage.getItem(store.chosenLocalOrderId); if (!localOrder) { - showActionMonit(`${t('order-message.error-update')}`, 'warning'); + showActionMonit(t('order-message.error-update'), 'warning'); return; } diff --git a/src/locales/en.json b/src/locales/en.json index addc3a8..09b20fe 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -28,7 +28,8 @@ "warning-fill-inputs": "Fill all the empty fields before copying the order!", "warning-add-instruction": "Add at least one order instruction before copying the order!", "warning-fill-missing": "Fill rows in the order's header and footer before copying it!", - "warning-fill-top": "Fill at least fields A, B, C and D in the order's header before saving it!", + "warning-fill-top-save": "Fill at least fields A, B, C and D in the order's header before saving it!", + "warning-fill-top-update": "Fill at least fields A, B, C and D in the order's header before updating it!", "warning-order-identical": "Last saved order is identical as the current one!", "warning-no-order-selected": "Choose the already saved order first!", "error-update": "An error occurred while saving this order! :/", diff --git a/src/locales/pl.json b/src/locales/pl.json index 42369d4..55eb40b 100644 --- a/src/locales/pl.json +++ b/src/locales/pl.json @@ -28,7 +28,8 @@ "warning-fill-inputs": "Wypełnij puste rubryki rozkazu przed jego skopiowaniem!", "warning-add-instruction": "Dodaj co najmniej jedną instrukcję rozkazu przed jego skopiowaniem!", "warning-fill-missing": "Uzupełnij rubryki w nagłówku i stopce rozkazu przed jego skopiowaniem!", - "warning-fill-top": "Wypełnij co najmniej rubryki A, B, C i D w nagłówku rozkazu przed jego zapisaniem!", + "warning-fill-top-save": "Wypełnij co najmniej rubryki A, B, C i D w nagłówku rozkazu przed jego zapisaniem!", + "warning-fill-top-update": "Wypełnij co najmniej rubryki A, B, C i D w nagłówku rozkazu przed jego zaktualizowaniem!", "warning-order-identical": "Ostatni zapisany rozkaz jest identyczny z obecnym!", "warning-no-order-selected": "Wybierz rozkaz, który chcesz zaktualizować!", "error-update": "Wystąpił błąd podczas aktualizowania tego rozkazu! :/",