arreglar ultimos coletazos
This commit is contained in:
parent
b95fc6642a
commit
1672123ebf
|
@ -10,17 +10,16 @@ import IconCalendar from "../icons/IconCalendar.vue";
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "calendar-input",
|
name: "calendar-input",
|
||||||
components: { IconCalendar },
|
components: { IconCalendar },
|
||||||
props: ["modelValue", "bindValue", "setValues"],
|
props: ["modelValue", "bindValue", "setValues", "dateCookies"],
|
||||||
setup({ setValues }, { emit }) {
|
setup({ setValues, dateCookies, modelValue }, { emit }) {
|
||||||
const formStore = useFormStore();
|
const formStore = useFormStore();
|
||||||
const { availability, postalCodeValid } = storeToRefs(formStore);
|
const { availability, postalCodeValid } = storeToRefs(formStore);
|
||||||
|
|
||||||
const [year, month, day] = fullCurrentDate.replaceAll("/", "-").split("-");
|
const [year, month, day] = fullCurrentDate.replaceAll("/", "-").split("-");
|
||||||
const currentDate = `${day}-${month}-${year}`;
|
const currentDate = `${day}-${month}-${year}`;
|
||||||
const proxyDate = ref(invertDate(currentDate));
|
const proxyDate = ref(invertDate(modelValue));
|
||||||
|
|
||||||
function updateProxy() {
|
function updateProxy() {
|
||||||
proxyDate.value = invertDate(currentDate);
|
proxyDate.value = invertDate(proxyDate.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
function optionsValidDates(date) {
|
function optionsValidDates(date) {
|
||||||
|
@ -37,6 +36,8 @@ export default defineComponent({
|
||||||
|
|
||||||
watch(proxyDate, (newProxy) => {
|
watch(proxyDate, (newProxy) => {
|
||||||
setValues({ date: invertDate(newProxy) });
|
setValues({ date: invertDate(newProxy) });
|
||||||
|
const btn = document.querySelector(".buttons-close-modal button")
|
||||||
|
if(btn) btn.click()
|
||||||
});
|
});
|
||||||
|
|
||||||
const LOCALE = {
|
const LOCALE = {
|
||||||
|
@ -71,7 +72,6 @@ export default defineComponent({
|
||||||
<IconCalendar />
|
<IconCalendar />
|
||||||
|
|
||||||
<q-popup-proxy
|
<q-popup-proxy
|
||||||
@before-show="updateProxy"
|
|
||||||
cover
|
cover
|
||||||
transition-show="scale"
|
transition-show="scale"
|
||||||
transition-hide="scale"
|
transition-hide="scale"
|
||||||
|
@ -83,9 +83,9 @@ export default defineComponent({
|
||||||
:readonly="!postalCodeValid.isValid"
|
:readonly="!postalCodeValid.isValid"
|
||||||
mask="YYYY-MM-DD"
|
mask="YYYY-MM-DD"
|
||||||
>
|
>
|
||||||
<div class="row items-center justify-end q-gutter-sm">
|
<div class="row items-center justify-end q-gutter-sm buttons-close-modal">
|
||||||
<q-btn label="Cancel" color="primary" flat v-close-popup />
|
<q-btn label="Cancel" color="primary" flat v-close-popup />
|
||||||
<q-btn label="OK" color="primary" flat v-close-popup />
|
<q-btn label="OK" color="primary" flat v-close-popup class="modal-close"/>
|
||||||
</div>
|
</div>
|
||||||
</q-date>
|
</q-date>
|
||||||
</q-popup-proxy>
|
</q-popup-proxy>
|
||||||
|
@ -108,4 +108,4 @@ export default defineComponent({
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
|
@ -9,6 +9,7 @@ import { usePostalCalendar } from "src/hooks/usePostalCalendar";
|
||||||
import { useVerticalCarouselImgs } from "src/hooks/useVerticalCarouselImgs";
|
import { useVerticalCarouselImgs } from "src/hooks/useVerticalCarouselImgs";
|
||||||
import { useFormStore } from "src/stores/forms";
|
import { useFormStore } from "src/stores/forms";
|
||||||
import { onMounted } from "vue";
|
import { onMounted } from "vue";
|
||||||
|
import { useLocalStorage } from "../../../hooks/useLocalStorage";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "vertical-carousel-imgs",
|
name: "vertical-carousel-imgs",
|
||||||
|
@ -30,14 +31,19 @@ export default defineComponent({
|
||||||
const { navPos, screenWidth, slide, target } = useVerticalCarouselImgs();
|
const { navPos, screenWidth, slide, target } = useVerticalCarouselImgs();
|
||||||
|
|
||||||
const formStore = useFormStore();
|
const formStore = useFormStore();
|
||||||
const {postalCodeValid } = storeToRefs(formStore);
|
const { getItem } = useLocalStorage();
|
||||||
|
const localValues = getItem("availability")
|
||||||
|
|
||||||
|
const { postalCodeValid } = storeToRefs(formStore);
|
||||||
|
let isEventKeyActive = false
|
||||||
|
|
||||||
function handleFormKeyPress() {
|
function handleFormKeyPress() {
|
||||||
const postalCodeField = document.querySelector("#carousel-form .postal-code-control input")
|
const postalCodeField = document.querySelector("#carousel-form .postal-code-control input")
|
||||||
const modalDate = document.querySelector("#carousel-form .calendar .custom-date-btn")
|
const modalDate = document.querySelector("#carousel-form .calendar .custom-date-btn")
|
||||||
let isEventKeyActive = false
|
|
||||||
postalCodeField.addEventListener('input', (e) =>{
|
postalCodeField.addEventListener('input', (e) =>{
|
||||||
isEventKeyActive = true
|
if (e.target.value.length === 5) {
|
||||||
|
isEventKeyActive = true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
postalCodeField.addEventListener('keypress', e => {
|
postalCodeField.addEventListener('keypress', e => {
|
||||||
if (e.target.value.length === 5 && isEventKeyActive) {
|
if (e.target.value.length === 5 && isEventKeyActive) {
|
||||||
|
@ -66,6 +72,7 @@ export default defineComponent({
|
||||||
postalCodeAttrs,
|
postalCodeAttrs,
|
||||||
calendar,
|
calendar,
|
||||||
calendarAttrs,
|
calendarAttrs,
|
||||||
|
localValues
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -75,7 +82,7 @@ export default defineComponent({
|
||||||
<div ref="target" class="vertical-carousel-container" style="min-height: 100dvh">
|
<div ref="target" class="vertical-carousel-container" style="min-height: 100dvh">
|
||||||
<q-carousel navigation-position="right" style="min-height: 100dvh" v-model="slide" navigation autoplay infinite
|
<q-carousel navigation-position="right" style="min-height: 100dvh" v-model="slide" navigation autoplay infinite
|
||||||
animated v-if="!!banners.length" class="custom-carousel">
|
animated v-if="!!banners.length" class="custom-carousel">
|
||||||
<q-carousel-slide v-for="(item, i) in banners[0]" :key="i" :name="item.longName" :img-src="item.url">
|
<q-carousel-slide v-for="(item, i) in banners" :key="i" :name="item.longName" :img-src="item.url">
|
||||||
<div class="vertical-carousel-content">
|
<div class="vertical-carousel-content">
|
||||||
<header class="carousel-content-header">
|
<header class="carousel-content-header">
|
||||||
<h1 class="carousel-header-title">
|
<h1 class="carousel-header-title">
|
||||||
|
@ -93,7 +100,7 @@ export default defineComponent({
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="carousel-content-item date-expired-control">
|
<div class="carousel-content-item date-expired-control">
|
||||||
<Calendar v-model="calendar" v-bind:bindValue="calendarAttrs" :setValues="setValues" />
|
<Calendar v-model="calendar" v-bind:bindValue="calendarAttrs" :setValues="setValues" :dateCookies="localValues.dateExpired"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<q-btn type="submit" class="btn carousel-content-item">
|
<q-btn type="submit" class="btn carousel-content-item">
|
||||||
|
|
|
@ -74,9 +74,17 @@ export function usePostalCalendar({ modalItem = "", type = "home" }) {
|
||||||
|
|
||||||
return isAvailabilityEmpty.value;
|
return isAvailabilityEmpty.value;
|
||||||
});
|
});
|
||||||
|
let DATE_INITIAL
|
||||||
const [YEAR, MONTH, DAY] = fullCurrentDate.replaceAll("/", "-").split("-");
|
const [YEAR, MONTH, DAY] = fullCurrentDate.replaceAll("/", "-").split("-");
|
||||||
const CURRENT_DATE = `${DAY}-${MONTH}-${YEAR}`;
|
const CURRENT_DATE = `${DAY}-${MONTH}-${YEAR}`;
|
||||||
|
DATE_INITIAL = CURRENT_DATE
|
||||||
|
if (availability.value.dateExpired) {
|
||||||
|
const [yearStorage, monthStorage, dayStorage] = availability.value.dateExpired.replaceAll("/", "-").split("-");
|
||||||
|
const STORAGE_DATE = `${dayStorage}-${monthStorage}-${yearStorage}`;
|
||||||
|
DATE_INITIAL = STORAGE_DATE
|
||||||
|
}
|
||||||
|
const POSTAL_CODE_INITIAL = availability.value.postalCode ? availability.value.postalCode : ""
|
||||||
|
|
||||||
const {
|
const {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
handleReset,
|
handleReset,
|
||||||
|
@ -94,11 +102,11 @@ export function usePostalCalendar({ modalItem = "", type = "home" }) {
|
||||||
min,
|
min,
|
||||||
max,
|
max,
|
||||||
},
|
},
|
||||||
postalCode: "",
|
postalCode: POSTAL_CODE_INITIAL,
|
||||||
date: CURRENT_DATE,
|
date: DATE_INITIAL,
|
||||||
},
|
},
|
||||||
initialTouched: {
|
initialTouched: {
|
||||||
date: false,
|
date: availability.value.dateExpired ? true : false,
|
||||||
postalCode: true,
|
postalCode: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue