mirror of
https://github.com/Spythere/genera-tor.git
synced 2026-05-03 21:48:13 +00:00
chore: added order fields verification for copying
This commit is contained in:
@@ -196,23 +196,39 @@ function copyMessage() {
|
|||||||
if (!navigator.clipboard)
|
if (!navigator.clipboard)
|
||||||
return showActionMonit(t('order-message.warning-outdated-clipboard'), 'warning');
|
return showActionMonit(t('order-message.warning-outdated-clipboard'), 'warning');
|
||||||
|
|
||||||
// const hasAtLeastOneRow = /(\[ \d \])/g.test(orderMessagePreview.value);
|
|
||||||
// const hasAllInputsFilled = !/_/g.test(store.orderMessage);
|
|
||||||
|
|
||||||
// if (!hasAllInputsFilled)
|
|
||||||
// return showActionMonit(
|
|
||||||
// `${t('order-message.warning-fill-inputs')}`
|
|
||||||
// );
|
|
||||||
// if (!hasAtLeastOneRow)
|
|
||||||
// return showActionMonit(
|
|
||||||
// `${t('order-message.warning-add-rows')}`
|
|
||||||
// );
|
|
||||||
|
|
||||||
const fieldsToCorrect = verifyOrderFields();
|
const fieldsToCorrect = verifyOrderFields();
|
||||||
|
|
||||||
if (fieldsToCorrect.length > 0)
|
if (fieldsToCorrect.length > 0)
|
||||||
return showActionMonit(t('order-message.warning-fill-missing'), 'warning');
|
return showActionMonit(t('order-message.warning-fill-missing'), 'warning');
|
||||||
|
|
||||||
|
const activeInstructions = store.orderData.instructions.filter((v) => v.active);
|
||||||
|
|
||||||
|
if (activeInstructions.length == 0) {
|
||||||
|
return showActionMonit(t('order-message.warning-add-instruction'), 'warning');
|
||||||
|
}
|
||||||
|
|
||||||
|
const hasAllInputsFilled = activeInstructions.every((v) => {
|
||||||
|
let isInstructionFilled = false;
|
||||||
|
|
||||||
|
isInstructionFilled = Object.values(v.inputFields).every((field) => field.trim().length != 0);
|
||||||
|
|
||||||
|
if (v.listFields) {
|
||||||
|
if (!v.listFields.some((field) => field.active)) return false;
|
||||||
|
|
||||||
|
isInstructionFilled = v.listFields
|
||||||
|
.filter((field) => field.active)
|
||||||
|
.every((field) =>
|
||||||
|
Object.values(field.values).every((fieldValue) => fieldValue.trim().length != 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return isInstructionFilled;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!hasAllInputsFilled) {
|
||||||
|
return showActionMonit(t('order-message.warning-fill-inputs'), 'warning');
|
||||||
|
}
|
||||||
|
|
||||||
navigator.clipboard.writeText(orderMessagePreview.value);
|
navigator.clipboard.writeText(orderMessagePreview.value);
|
||||||
|
|
||||||
if (incrementOnCopy) incrementOrderNo();
|
if (incrementOnCopy) incrementOrderNo();
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@
|
|||||||
"button-reset": "Reset the order",
|
"button-reset": "Reset the order",
|
||||||
"warning-outdated-clipboard": "Oops! Your browser may be a little bit depraceted since it's not supporting saving data to the clipboard! :/",
|
"warning-outdated-clipboard": "Oops! Your browser may be a little bit depraceted since it's not supporting saving data to the clipboard! :/",
|
||||||
"warning-fill-inputs": "Fill all the empty fields before copying the order!",
|
"warning-fill-inputs": "Fill all the empty fields before copying the order!",
|
||||||
"warning-add-rows": "Add at least one row 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-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": "Fill at least fields A, B, C and D in the order's header before saving it!",
|
||||||
"warning-order-identical": "Last saved order is identical as the current one!",
|
"warning-order-identical": "Last saved order is identical as the current one!",
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@
|
|||||||
"button-reset": "Wyczyść rozkaz",
|
"button-reset": "Wyczyść rozkaz",
|
||||||
"warning-outdated-clipboard": "Ups! Twoja przeglądarka musi być dosyć przestarzała, ponieważ nie obsługuje zapisu do schowka! :/",
|
"warning-outdated-clipboard": "Ups! Twoja przeglądarka musi być dosyć przestarzała, ponieważ nie obsługuje zapisu do schowka! :/",
|
||||||
"warning-fill-inputs": "Wypełnij puste rubryki rozkazu przed jego skopiowaniem!",
|
"warning-fill-inputs": "Wypełnij puste rubryki rozkazu przed jego skopiowaniem!",
|
||||||
"warning-add-rows": "Dodaj co najmniej jedną działkę 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-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": "Wypełnij co najmniej rubryki A, B, C i D w nagłówku rozkazu przed jego zapisaniem!",
|
||||||
"warning-order-identical": "Ostatni zapisany rozkaz jest identyczny z obecnym!",
|
"warning-order-identical": "Ostatni zapisany rozkaz jest identyczny z obecnym!",
|
||||||
|
|||||||
Reference in New Issue
Block a user