mirror of
https://github.com/Spythere/genera-tor.git
synced 2026-05-03 13:38:12 +00:00
Rozszerzono walidację rozkazu
This commit is contained in:
@@ -12,7 +12,9 @@
|
|||||||
<button class="g-button action" @click="copyMessage">Kopiuj treść rozkazu</button>
|
<button class="g-button action" @click="copyMessage">Kopiuj treść rozkazu</button>
|
||||||
<button class="g-button action" :data-disabled="!store.chosenLocalOrderId" @click="updateOrder">
|
<button class="g-button action" :data-disabled="!store.chosenLocalOrderId" @click="updateOrder">
|
||||||
Zaktualizuj rozkaz
|
Zaktualizuj rozkaz
|
||||||
<span class="text--accent">{{ store.chosenLocalOrderId && `#${store.chosenLocalOrderId.split('-')[1]}` }} </span>
|
<span class="text--accent"
|
||||||
|
>{{ store.chosenLocalOrderId && `#${store.chosenLocalOrderId.split('-')[1]}` }}
|
||||||
|
</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -85,12 +87,17 @@ export default defineComponent({
|
|||||||
'Ups! Twoja przeglądarka musi być dosyć przestarzała, ponieważ nie obsługuje zapisu do schowka! :/'
|
'Ups! Twoja przeglądarka musi być dosyć przestarzała, ponieważ nie obsługuje zapisu do schowka! :/'
|
||||||
);
|
);
|
||||||
|
|
||||||
// const isOrderValid = this.verifyOrder();
|
const hasAtLeastOneRow = /(\[ \d \])/g.test(this.fullOrderMessage);
|
||||||
|
const hasAllInputsFilled = !/_/g.test(this.fullOrderMessage);
|
||||||
|
|
||||||
|
if (!hasAllInputsFilled) return this.showActionMonit(`<span class="text--warn">Wypełnij puste rubryki rozkazu przed jego skopiowaniem!</span>`);
|
||||||
|
if (!hasAtLeastOneRow) return this.showActionMonit(`<span class="text--warn">Dodaj co najmniej jedną działkę rozkazu przed jego skopiowaniem!</span>`);
|
||||||
|
|
||||||
const fieldsToCorrect = this.verifyOrderFields();
|
const fieldsToCorrect = this.verifyOrderFields();
|
||||||
|
|
||||||
if (fieldsToCorrect.length > 0)
|
if (fieldsToCorrect.length > 0)
|
||||||
return this.showActionMonit(
|
return this.showActionMonit(
|
||||||
`<span class="text--warn">Przed skopiowaniem wiadomości uzupełnij rubryki: ${fieldsToCorrect.join(
|
`<span class="text--warn">Uzupełnij następujące rubryki na dole rozkazu przed jego skopiowaniem: ${fieldsToCorrect.join(
|
||||||
', '
|
', '
|
||||||
)}</span>`
|
)}</span>`
|
||||||
);
|
);
|
||||||
@@ -98,7 +105,7 @@ export default defineComponent({
|
|||||||
navigator.clipboard.writeText(this.fullOrderMessage);
|
navigator.clipboard.writeText(this.fullOrderMessage);
|
||||||
|
|
||||||
this.showActionMonit(
|
this.showActionMonit(
|
||||||
'Skopiowano do <b class="text--accent">schowka</b>! Możesz teraz wkleić treść rozkazu na czacie symulatora!'
|
'<b class="text--accent">Skopiowano!</b> Możesz teraz wkleić treść rozkazu na czacie symulatora!'
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -9,21 +9,15 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
verifyOrder() {
|
|
||||||
const orderMessage = this.store.orderMessage;
|
|
||||||
|
|
||||||
return !/<b>/g.test(orderMessage);
|
|
||||||
},
|
|
||||||
|
|
||||||
verifyOrderFields() {
|
verifyOrderFields() {
|
||||||
const header = this.store[this.store.chosenOrderType].header;
|
// const header = this.store[this.store.chosenOrderType].header;
|
||||||
const footer = this.store.orderFooter;
|
const footer = this.store.orderFooter;
|
||||||
|
|
||||||
const fieldsToCorrect = [];
|
const fieldsToCorrect = [];
|
||||||
|
|
||||||
if (!header.orderNo) fieldsToCorrect.push('numer rozkazu');
|
// if (!header.orderNo) fieldsToCorrect.push('numer rozkazu');
|
||||||
if (!header.trainNo) fieldsToCorrect.push('numer pociągu / manewru');
|
// if (!header.trainNo) fieldsToCorrect.push('numer pociągu / manewru');
|
||||||
if (!header.date) fieldsToCorrect.push('data');
|
// if (!header.date) fieldsToCorrect.push('data');
|
||||||
|
|
||||||
if (!footer.stationName) fieldsToCorrect.push('stacja');
|
if (!footer.stationName) fieldsToCorrect.push('stacja');
|
||||||
if (!footer.checkpointName) fieldsToCorrect.push('posterunek');
|
if (!footer.checkpointName) fieldsToCorrect.push('posterunek');
|
||||||
@@ -37,3 +31,5 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user