clean up from comments
This commit is contained in:
@@ -38,11 +38,11 @@ const props = defineProps({
|
||||
const emit = defineEmits(["update:hour", "update:minute"]);
|
||||
const interval = ref(null);
|
||||
const timeout = ref(null);
|
||||
// Tymczasowe zmienne na input
|
||||
|
||||
const tempHour = ref(props.hour);
|
||||
const tempMinute = ref(props.minute);
|
||||
|
||||
// Nasłuchiwanie zmian propsów, aby synchronizować z ref
|
||||
|
||||
watch(() => props.hour, (newVal) => {
|
||||
tempHour.value = newVal;
|
||||
console.log("watch")
|
||||
@@ -51,13 +51,13 @@ watch(() => props.minute, (newVal) => {
|
||||
tempMinute.value = newVal;
|
||||
});
|
||||
|
||||
// Funkcje walidacyjne
|
||||
|
||||
const validateHour = () => {
|
||||
const hour = Number(tempHour.value);
|
||||
if (!isNaN(hour) && hour >= 6 && hour <= 18) {
|
||||
emit("update:hour", hour);
|
||||
} else {
|
||||
tempHour.value = props.hour; // Przywróć poprzednią wartość
|
||||
tempHour.value = props.hour;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ const validateMinute = () => {
|
||||
if (!isNaN(minute) && minute >= 0 && minute <= 59) {
|
||||
emit("update:minute", minute);
|
||||
} else {
|
||||
tempMinute.value = props.minute; // Przywróć poprzednią wartość
|
||||
tempMinute.value = props.minute;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -76,10 +76,8 @@ const incrementValue = (type) => {
|
||||
if (type == "hour") {
|
||||
let newHour = tempHour.value + 1;
|
||||
if (newHour >= 6 && newHour <= 18) {
|
||||
// tempHour.value = newHour;
|
||||
emit("update:hour", newHour);
|
||||
}
|
||||
// validateHour();
|
||||
} else if (type === "minute") {
|
||||
let newMinute = tempMinute.value + 1;
|
||||
if (newMinute >= 0 && newMinute <= 59) {
|
||||
@@ -129,10 +127,6 @@ const stopInterval = () => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
button {
|
||||
width: 2.5rem;
|
||||
}
|
||||
|
||||
.visibility-hidden {
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="container text-center">
|
||||
<div class="row align-items-center">
|
||||
<!-- Przyciski -->
|
||||
<!-- buttons -->
|
||||
<div class="col-3"></div>
|
||||
<div class="col d-flex justify-content-center align-items-center">
|
||||
<button type="button" class="btn btn-outline-primary mx-2" style="width: 150px;" data-bs-toggle="modal"
|
||||
@@ -19,22 +19,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="d-flex flex-row justify-content-center align-items-center">
|
||||
Przyciski
|
||||
<div class="d-flex">
|
||||
<button type="button" class="btn btn-outline-primary mx-2" style="width: 150px;" data-bs-toggle="modal"
|
||||
data-bs-target="#inputModal">WCZYTAJ</button>
|
||||
<button type="button" class="btn btn-outline-primary mx-2" style="width: 150px;" data-bs-toggle="modal"
|
||||
data-bs-target="#clearAllModal">USUŃ</button>
|
||||
<button type="button" class="btn btn-outline-primary mx-2" style="width: 150px;">DODAJ</button>
|
||||
</div>
|
||||
|
||||
Toggle
|
||||
<div class="form-check form-switch ms-5">
|
||||
<input class="form-check-input" type="checkbox" id="toggleSwitch">
|
||||
<label class="form-check-label" for="toggleSwitch">Toggle</label>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<div class="container-fluid ">
|
||||
<div class="text-center">
|
||||
@@ -59,46 +43,16 @@
|
||||
{{ storeWorkHours.getWeekday(index)[1] }}</span>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<!-- <div class="d-flex align-items-center justify-content-center">
|
||||
Godziny dla Enter
|
||||
<input class="form-control text-center" style="width: 4rem;" type="text"
|
||||
v-model="day.enterHour" @focus="saveOldValue(day, 'enterHour')"
|
||||
@blur="validate(day, 'enterHour', 6, 18, $event)">
|
||||
<span class="mx-1">:</span>
|
||||
Minuty dla Enter
|
||||
<input class="form-control text-center" style="width: 4rem;" type="text"
|
||||
v-model="day.enterMinute" @focus="saveOldValue(day, 'enterMinute')"
|
||||
@blur="validate(day, 'enterMinute', 0, 59, $event)">
|
||||
</div> -->
|
||||
<TimeInputComponent v-model:hour="day.enterHour" v-model:minute="day.enterMinute"
|
||||
:showButtons="showButtons" />
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<!-- <div class="d-flex align-items-center justify-content-center">
|
||||
Godziny dla Leave
|
||||
<input class="form-control text-center" style="width: 4rem;" type="text"
|
||||
v-model="day.leaveHour" @focus="saveOldValue(day, 'leaveHour')"
|
||||
@blur="validate(day, 'leaveHour', 6, 18, $event)">
|
||||
<span class="mx-1">:</span>
|
||||
Minuty dla Leave
|
||||
<input class="form-control text-center" style="width: 4rem;" type="text"
|
||||
v-model="day.leaveMinute" @focus="saveOldValue(day, 'leaveMinute')"
|
||||
@blur="validate(day, 'leaveMinute', 0, 59, $event)">
|
||||
</div> -->
|
||||
<TimeInputComponent v-model:hour="day.leaveHour" v-model:minute="day.leaveMinute"
|
||||
:showButtons="showButtons" />
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<div class="d-flex align-items-center justify-content-center">
|
||||
<!-- Godziny dla Hours -->
|
||||
<!-- <input class="form-control text-center" style="width: 4rem;" type="text"
|
||||
v-model="day.workHours" @focus="saveOldValue(day, 'workHours')"
|
||||
@blur="validate(day, 'workHours', 6, 18, $event)"> -->
|
||||
<span class="mx-1 fs-5">{{ formattedWorkTime(day) }}</span>
|
||||
<!-- Minuty dla Hours -->
|
||||
<!-- <input class="form-control text-center" style="width: 4rem;" type="text"
|
||||
v-model="day.workMinutes" @focus="saveOldValue(day, 'workMinutes')"
|
||||
@blur="validate(day, 'workMinutes', 0, 59, $event)"> -->
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -158,7 +112,7 @@
|
||||
|
||||
<script setup>
|
||||
import TimeInputComponent from "@/components/TimeInputComponent.vue";
|
||||
import { useWorkHoursStore } from "../stores/counter.js";
|
||||
import { useWorkHoursStore } from "../stores/WorkHoursStore.js";
|
||||
import { Modal } from 'bootstrap';
|
||||
import { computed, watch, ref, onMounted } from "vue";
|
||||
|
||||
@@ -172,32 +126,17 @@ onMounted(() => {
|
||||
|
||||
if (modalElement) {
|
||||
modalElement.addEventListener('hidden.bs.modal', () => {
|
||||
console.log('Modal został zamknięty kliknięciem poza oknem lub przez kliknięcie przycisku zamykania.');
|
||||
|
||||
// Tutaj możesz dodać własną logikę
|
||||
clearInput();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const formattedWorkTime = (day) => {
|
||||
const hours = String(day.workHours).padStart(2, '0'); // Dodaj wiodące zero do godzin
|
||||
const minutes = String(day.workMinutes).padStart(2, '0'); // Dodaj wiodące zero do minut
|
||||
return `${hours}:${minutes}`; // Zwróć sformatowany czas
|
||||
const hours = String(day.workHours).padStart(2, '0');
|
||||
const minutes = String(day.workMinutes).padStart(2, '0');
|
||||
return `${hours}:${minutes}`;
|
||||
};
|
||||
|
||||
// function saveOldValue(item, field) {
|
||||
// oldValue.value = item[field];
|
||||
// };
|
||||
|
||||
// const validate = (item, field, min, max, event) => {
|
||||
// const newValue = Number(event.target.value);
|
||||
// console.log("validate: " + field + ", min: " + min + ", max: " + max + ", newValue: " + newValue + ", oldValue: " + oldValue.value);
|
||||
// if (isNaN(newValue) || newValue < min || newValue > max) {
|
||||
// item[field] = oldValue.value; // Przywróć starą wartość
|
||||
// }
|
||||
// };
|
||||
|
||||
const getClassWeekday = (index) => {
|
||||
switch (storeWorkHours.getWeekday(index)[0]) {
|
||||
case 0:
|
||||
@@ -216,14 +155,5 @@ const processInputText = () => {
|
||||
const clearInput = () => {
|
||||
rawText.value = '';
|
||||
}
|
||||
// const closeModal = () => {
|
||||
// const modalElement = document.getElementById('staticBackdrop');
|
||||
// const modal = Modal.getInstance(modalElement);
|
||||
|
||||
// if (modal) {
|
||||
// modal.hide();
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user