Checkboxy i numeracja rozkazów

This commit is contained in:
2022-11-17 15:34:05 +01:00
parent 94235df38d
commit df25fb0b36
5 changed files with 79 additions and 7 deletions
+61 -2
View File
@@ -18,6 +18,30 @@
</button>
</div>
<div class="message_checkboxes">
<label for="copy-increment">
<input
type="checkbox"
name="copy-increment"
id="copy-increment"
v-model="incrementOnCopy"
@change="onCheckboxChange"
/>
Aktualizuj numer rozkazu po skopiowaniu
</label>
<br />
<label for="save-increment">
<input
type="checkbox"
name="save-increment"
id="save-increment"
v-model="incrementOnSave"
@change="onCheckboxChange"
/>
Aktualizuj numer rokazu po zapisaniu
</label>
</div>
<transition name="monit-anim">
<div class="action_monit" v-if="actionMonit" v-html="actionMonit"></div>
</transition>
@@ -42,6 +66,9 @@ export default defineComponent({
saveIcon,
actionMonit: '',
monitTimeout: undefined as number | undefined,
incrementOnSave: true,
incrementOnCopy: true,
};
},
@@ -51,6 +78,11 @@ export default defineComponent({
};
},
mounted() {
this.incrementOnSave = this.getOrderSetting('save-increment') === 'false' ? false : true;
this.incrementOnCopy = this.getOrderSetting('copy-increment') === 'false' ? false : true;
},
computed: {
fullOrderMessage() {
return this.store.orderMessage + this.store.footerMessage;
@@ -58,6 +90,13 @@ export default defineComponent({
},
methods: {
onCheckboxChange(e: Event) {
const checkbox = e.target as HTMLInputElement;
console.log(checkbox.id, checkbox.checked);
this.saveOrderSetting(checkbox.id, checkbox.checked);
},
showActionMonit(text: string) {
if (this.monitTimeout) {
this.actionMonit = '';
@@ -81,6 +120,12 @@ export default defineComponent({
}, 5000);
},
incrementOrderNo() {
const order = this.store[this.store.chosenOrderType];
order.header.orderNo = (Number(order.header.orderNo) + 1).toString();
},
copyMessage() {
if (!navigator.clipboard)
return this.showActionMonit(
@@ -90,8 +135,14 @@ export default defineComponent({
const hasAtLeastOneRow = /(\[ \d \])/g.test(this.fullOrderMessage);
const hasAllInputsFilled = !/_/g.test(this.store.orderMessage);
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>`);
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();
@@ -104,6 +155,8 @@ export default defineComponent({
navigator.clipboard.writeText(this.fullOrderMessage);
if (this.incrementOnCopy) this.incrementOrderNo();
this.showActionMonit(
'<b class="text--accent">Skopiowano!</b> Możesz teraz wkleić treść rozkazu na czacie symulatora!'
);
@@ -123,6 +176,8 @@ export default defineComponent({
break;
case 1:
this.showActionMonit('Zapisano treść <b class="text--accent">rozkazu</b> w pamięci przeglądarki!');
if (this.incrementOnSave) this.incrementOrderNo();
break;
default:
@@ -201,6 +256,10 @@ export default defineComponent({
}
}
.message_checkboxes {
margin-top: 1em;
}
.action_monit {
text-align: center;
padding: 1.5em;