Moved number input validation to before upload.
This commit is contained in:
@@ -2,8 +2,8 @@ import { apiHttp } from "../services/http";
|
||||
import Alpine from "alpinejs";
|
||||
import clone from "just-clone";
|
||||
|
||||
const uploadDelay = 500;
|
||||
const startingSlide = "#quick-picks-slide";
|
||||
const UPLOAD_DELAY = 1500;
|
||||
const START_SLIDE = "#quick-picks-slide";
|
||||
|
||||
function initInteractiveElements() {
|
||||
let configurationToggle = document.getElementById("configuration-toggle");
|
||||
@@ -54,6 +54,7 @@ function initConfigData() {
|
||||
bestPrice: null,
|
||||
},
|
||||
searchOutlineChangeTimeout: null,
|
||||
timeoutInProgress: false,
|
||||
hasResults() {
|
||||
return this.resultsQuery !== null;
|
||||
},
|
||||
@@ -67,7 +68,7 @@ function initConfigData() {
|
||||
this.changeSearchOutlineName(this.serverSearchOutlineName, this.searchOutlines[this.selectedSearchOutline]);
|
||||
}
|
||||
},
|
||||
validateNumericalInputs() {
|
||||
validateAllNumericalInputs() {
|
||||
if (!this.searchOutline.filters.lowerPrice) this.searchOutline.filters.lowerPrice = 0;
|
||||
if (!this.searchOutline.filters.upperPrice) this.searchOutline.filters.upperPrice = 0;
|
||||
if (!this.searchOutline.filters.maxShippingFee) this.searchOutline.filters.maxShippingFee = 0;
|
||||
@@ -89,9 +90,11 @@ function initConfigData() {
|
||||
if (this.searchOutlineChangeTimeout != null) {
|
||||
clearTimeout(this.searchOutlineChangeTimeout);
|
||||
}
|
||||
this.timeoutInProgress = true;
|
||||
this.searchOutlineChangeTimeout = setTimeout(() => {
|
||||
this.uploadAll();
|
||||
}, uploadDelay);
|
||||
this.timeoutInProgress = false;
|
||||
}, UPLOAD_DELAY);
|
||||
},
|
||||
uploadAll() {
|
||||
let name = this.searchOutlines[this.selectedSearchOutline];
|
||||
@@ -100,6 +103,7 @@ function initConfigData() {
|
||||
},
|
||||
async uploadFilters(name, filters) {
|
||||
if (!this.loggedIn) return;
|
||||
this.validateAllNumericalInputs();
|
||||
this.updatingFilters = true;
|
||||
let uploadFilterResponse = await apiHttp.put(`SearchOutline/${name}/Filters`, filters);
|
||||
this.updatingFilters = false;
|
||||
@@ -273,7 +277,7 @@ function initSlides() {
|
||||
});
|
||||
const goTo = () => {
|
||||
const match = location.href.match("(#[\\w-]+)");
|
||||
const idAnchor = match && match[1] ? match[1] : startingSlide;
|
||||
const idAnchor = match && match[1] ? match[1] : START_SLIDE;
|
||||
document.querySelector("#content-pages > .selectors > .nav-item > .active")?.classList.remove("active");
|
||||
document.querySelector("#content-pages > .multipage-slides > .active.show")?.classList.remove("active", "show");
|
||||
document.querySelector(`#content-pages > .selectors > .nav-item > [data-bs-target="${idAnchor}"]`).classList.add("active");
|
||||
|
Reference in New Issue
Block a user