bug fix; feature: autouzupełnianie godz.

This commit is contained in:
2023-05-16 02:08:13 +02:00
parent 189720c206
commit 1783ae1fce
2 changed files with 17 additions and 5 deletions
+14 -4
View File
@@ -39,6 +39,10 @@
/> />
<span>Aktualizuj numer rozkazu po zapisaniu</span> <span>Aktualizuj numer rozkazu po zapisaniu</span>
</label> </label>
<label for="update-date" class="g-checkbox">
<input type="checkbox" name="update-date" id="update-date" v-model="updateDate" @change="onCheckboxChange" />
<span>Aktualizuj godziny przy edycji</span>
</label>
</div> </div>
<transition name="monit-anim"> <transition name="monit-anim">
@@ -54,6 +58,7 @@ import { useStore } from '../store/store';
import saveIcon from '../assets/icon-save.svg'; import saveIcon from '../assets/icon-save.svg';
import orderStorageMixin from '../mixins/orderStorageMixin'; import orderStorageMixin from '../mixins/orderStorageMixin';
import orderValidationMixin from '../mixins/orderValidationMixin'; import orderValidationMixin from '../mixins/orderValidationMixin';
import { currentFormattedHours, currentFormattedMinutes } from '../utils/dateUtils';
export default defineComponent({ export default defineComponent({
name: 'OrderMessage', name: 'OrderMessage',
@@ -68,6 +73,7 @@ export default defineComponent({
incrementOnSave: true, incrementOnSave: true,
incrementOnCopy: true, incrementOnCopy: true,
updateDate: true,
}; };
}, },
@@ -78,12 +84,18 @@ export default defineComponent({
}, },
mounted() { mounted() {
this.incrementOnSave = this.getOrderSetting('save-increment') === 'false' ? false : true; this.incrementOnSave = this.getOrderSetting('save-increment') === 'true';
this.incrementOnCopy = this.getOrderSetting('copy-increment') === 'false' ? false : true; this.incrementOnCopy = this.getOrderSetting('copy-increment') === 'true';
this.updateDate = this.getOrderSetting('update-date') === 'true';
}, },
computed: { computed: {
fullOrderMessage() { fullOrderMessage() {
if(this.updateDate) {
this.store.orderFooter['hour'] = currentFormattedHours();
this.store.orderFooter['minutes'] = currentFormattedMinutes();
}
return this.store.orderMessage + this.store.footerMessage; return this.store.orderMessage + this.store.footerMessage;
}, },
}, },
@@ -91,8 +103,6 @@ export default defineComponent({
methods: { methods: {
onCheckboxChange(e: Event) { onCheckboxChange(e: Event) {
const checkbox = e.target as HTMLInputElement; const checkbox = e.target as HTMLInputElement;
console.log(checkbox.id, checkbox.checked);
this.saveOrderSetting(checkbox.id, checkbox.checked); this.saveOrderSetting(checkbox.id, checkbox.checked);
}, },
+3 -1
View File
@@ -3,9 +3,11 @@ export function currentFormattedDate() {
} }
export function currentFormattedMinutes() { export function currentFormattedMinutes() {
return new Date().toLocaleTimeString('pl-PL', { minute: '2-digit' }); const date = new Date();
return (date.getMinutes() < 10 ? '0' : '') + date.getMinutes();
} }
export function currentFormattedHours() { export function currentFormattedHours() {
return new Date().toLocaleTimeString('pl-PL', { hour: '2-digit' }); return new Date().toLocaleTimeString('pl-PL', { hour: '2-digit' });
} }