reduce move duplication
parent
aabaf299f9
commit
1edb2e3e88
|
|
@ -1,7 +1,7 @@
|
|||
import { moveLotTypeDown, moveLotTypeDownToBottom } from "../../helpers/lotOccupancyDB/moveLotTypeDown.js";
|
||||
import { getLotTypes } from "../../helpers/functions.cache.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = request.body.moveToBottom === "1"
|
||||
const success = request.body.moveToEnd === "1"
|
||||
? moveLotTypeDownToBottom(request.body.lotTypeId)
|
||||
: moveLotTypeDown(request.body.lotTypeId);
|
||||
const lotTypes = getLotTypes();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { getLotTypes } from "../../helpers/functions.cache.js";
|
|||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
const success =
|
||||
request.body.moveToBottom === "1"
|
||||
request.body.moveToEnd === "1"
|
||||
? moveLotTypeDownToBottom(request.body.lotTypeId)
|
||||
: moveLotTypeDown(request.body.lotTypeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { moveLotTypeFieldDown, moveLotTypeFieldDownToBottom } from "../../helpers/lotOccupancyDB/moveLotTypeFieldDown.js";
|
||||
import { getLotTypes } from "../../helpers/functions.cache.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = request.body.moveToBottom === "1"
|
||||
const success = request.body.moveToEnd === "1"
|
||||
? moveLotTypeFieldDownToBottom(request.body.lotTypeFieldId)
|
||||
: moveLotTypeFieldDown(request.body.lotTypeFieldId);
|
||||
const lotTypes = getLotTypes();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { getLotTypes } from "../../helpers/functions.cache.js";
|
|||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
const success =
|
||||
request.body.moveToBottom === "1"
|
||||
request.body.moveToEnd === "1"
|
||||
? moveLotTypeFieldDownToBottom(request.body.lotTypeFieldId)
|
||||
: moveLotTypeFieldDown(request.body.lotTypeFieldId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { moveLotTypeFieldUp, moveLotTypeFieldUpToTop } from "../../helpers/lotOccupancyDB/moveLotTypeFieldUp.js";
|
||||
import { getLotTypes } from "../../helpers/functions.cache.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = request.body.moveToTop === "1"
|
||||
const success = request.body.moveToEnd === "1"
|
||||
? moveLotTypeFieldUpToTop(request.body.lotTypeFieldId)
|
||||
: moveLotTypeFieldUp(request.body.lotTypeFieldId);
|
||||
const lotTypes = getLotTypes();
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { getLotTypes } from "../../helpers/functions.cache.js";
|
|||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
const success =
|
||||
request.body.moveToTop === "1"
|
||||
request.body.moveToEnd === "1"
|
||||
? moveLotTypeFieldUpToTop(request.body.lotTypeFieldId)
|
||||
: moveLotTypeFieldUp(request.body.lotTypeFieldId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { moveLotTypeUp, moveLotTypeUpToTop } from "../../helpers/lotOccupancyDB/moveLotTypeUp.js";
|
||||
import { getLotTypes } from "../../helpers/functions.cache.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = request.body.moveToTop === "1"
|
||||
const success = request.body.moveToEnd === "1"
|
||||
? moveLotTypeUpToTop(request.body.lotTypeId)
|
||||
: moveLotTypeUp(request.body.lotTypeId);
|
||||
const lotTypes = getLotTypes();
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { getLotTypes } from "../../helpers/functions.cache.js";
|
|||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
const success =
|
||||
request.body.moveToTop === "1"
|
||||
request.body.moveToEnd === "1"
|
||||
? moveLotTypeUpToTop(request.body.lotTypeId)
|
||||
: moveLotTypeUp(request.body.lotTypeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -121,20 +121,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
}
|
||||
});
|
||||
}
|
||||
function moveLotTypeUp(clickEvent) {
|
||||
clickEvent.preventDefault();
|
||||
const lotTypeId = clickEvent.currentTarget.closest(".container--lotType").dataset.lotTypeId;
|
||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveLotTypeUp", {
|
||||
function moveLotType(clickEvent) {
|
||||
const buttonElement = clickEvent.currentTarget;
|
||||
const lotTypeId = buttonElement.closest(".container--lotType").dataset
|
||||
.lotTypeId;
|
||||
cityssm.postJSON(los.urlPrefix +
|
||||
"/admin/" +
|
||||
(buttonElement.dataset.direction === "up"
|
||||
? "doMoveLotTypeUp"
|
||||
: "doMoveLotTypeDown"), {
|
||||
lotTypeId,
|
||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
||||
}, lotTypeResponseHandler);
|
||||
}
|
||||
function moveLotTypeDown(clickEvent) {
|
||||
clickEvent.preventDefault();
|
||||
const lotTypeId = clickEvent.currentTarget.closest(".container--lotType").dataset.lotTypeId;
|
||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveLotTypeDown", {
|
||||
lotTypeId,
|
||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
||||
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||
}, lotTypeResponseHandler);
|
||||
}
|
||||
function openEditLotTypeField(lotTypeId, lotTypeFieldId) {
|
||||
|
|
@ -235,20 +232,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
const lotTypeId = Number.parseInt(clickEvent.currentTarget.closest(".container--lotType").dataset.lotTypeId, 10);
|
||||
openEditLotTypeField(lotTypeId, lotTypeFieldId);
|
||||
}
|
||||
function moveLotTypeFieldUp(clickEvent) {
|
||||
clickEvent.preventDefault();
|
||||
const lotTypeFieldId = clickEvent.currentTarget.closest(".container--lotTypeField").dataset.lotTypeFieldId;
|
||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveLotTypeFieldUp", {
|
||||
function moveLotTypeField(clickEvent) {
|
||||
const buttonElement = clickEvent.currentTarget;
|
||||
const lotTypeFieldId = buttonElement.closest(".container--lotTypeField")
|
||||
.dataset.lotTypeFieldId;
|
||||
cityssm.postJSON(los.urlPrefix +
|
||||
"/admin/" +
|
||||
(buttonElement.dataset.direction === "up"
|
||||
? "doMoveLotTypeFieldUp"
|
||||
: "doMoveLotTypeFieldDown"), {
|
||||
lotTypeFieldId,
|
||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
||||
}, lotTypeResponseHandler);
|
||||
}
|
||||
function moveLotTypeFieldDown(clickEvent) {
|
||||
clickEvent.preventDefault();
|
||||
const lotTypeFieldId = clickEvent.currentTarget.closest(".container--lotTypeField").dataset.lotTypeFieldId;
|
||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveLotTypeFieldDown", {
|
||||
lotTypeFieldId,
|
||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
||||
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||
}, lotTypeResponseHandler);
|
||||
}
|
||||
function renderLotTypeFields(panelElement, lotTypeId, lotTypeFields) {
|
||||
|
|
@ -287,8 +281,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
panelBlockElement
|
||||
.querySelector(".button--editLotTypeField")
|
||||
.addEventListener("click", openEditLotTypeFieldByClick);
|
||||
panelBlockElement.querySelector(".button--moveLotTypeFieldUp").addEventListener("click", moveLotTypeFieldUp);
|
||||
panelBlockElement.querySelector(".button--moveLotTypeFieldDown").addEventListener("click", moveLotTypeFieldDown);
|
||||
panelBlockElement.querySelector(".button--moveLotTypeFieldUp").addEventListener("click", moveLotTypeField);
|
||||
panelBlockElement.querySelector(".button--moveLotTypeFieldDown").addEventListener("click", moveLotTypeField);
|
||||
panelElement.append(panelBlockElement);
|
||||
}
|
||||
}
|
||||
|
|
@ -362,8 +356,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
lotTypeContainer
|
||||
.querySelector(".button--addLotTypeField")
|
||||
.addEventListener("click", openAddLotTypeField);
|
||||
lotTypeContainer.querySelector(".button--moveLotTypeUp").addEventListener("click", moveLotTypeUp);
|
||||
lotTypeContainer.querySelector(".button--moveLotTypeDown").addEventListener("click", moveLotTypeDown);
|
||||
lotTypeContainer.querySelector(".button--moveLotTypeUp").addEventListener("click", moveLotType);
|
||||
lotTypeContainer.querySelector(".button--moveLotTypeDown").addEventListener("click", moveLotType);
|
||||
containerElement.append(lotTypeContainer);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,35 +216,21 @@ declare const bulmaJS: BulmaJS;
|
|||
});
|
||||
}
|
||||
|
||||
function moveLotTypeUp(clickEvent: MouseEvent) {
|
||||
clickEvent.preventDefault();
|
||||
function moveLotType(clickEvent: MouseEvent) {
|
||||
const buttonElement = clickEvent.currentTarget as HTMLButtonElement;
|
||||
|
||||
const lotTypeId = (
|
||||
(clickEvent.currentTarget as HTMLElement).closest(".container--lotType") as HTMLElement
|
||||
).dataset.lotTypeId;
|
||||
const lotTypeId = (buttonElement.closest(".container--lotType") as HTMLElement).dataset
|
||||
.lotTypeId;
|
||||
|
||||
cityssm.postJSON(
|
||||
los.urlPrefix + "/admin/doMoveLotTypeUp",
|
||||
los.urlPrefix +
|
||||
"/admin/" +
|
||||
(buttonElement.dataset.direction === "up"
|
||||
? "doMoveLotTypeUp"
|
||||
: "doMoveLotTypeDown"),
|
||||
{
|
||||
lotTypeId,
|
||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
||||
},
|
||||
lotTypeResponseHandler
|
||||
);
|
||||
}
|
||||
|
||||
function moveLotTypeDown(clickEvent: MouseEvent) {
|
||||
clickEvent.preventDefault();
|
||||
|
||||
const lotTypeId = (
|
||||
(clickEvent.currentTarget as HTMLElement).closest(".container--lotType") as HTMLElement
|
||||
).dataset.lotTypeId;
|
||||
|
||||
cityssm.postJSON(
|
||||
los.urlPrefix + "/admin/doMoveLotTypeDown",
|
||||
{
|
||||
lotTypeId,
|
||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
||||
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||
},
|
||||
lotTypeResponseHandler
|
||||
);
|
||||
|
|
@ -428,39 +414,21 @@ declare const bulmaJS: BulmaJS;
|
|||
openEditLotTypeField(lotTypeId, lotTypeFieldId);
|
||||
}
|
||||
|
||||
function moveLotTypeFieldUp(clickEvent: MouseEvent) {
|
||||
clickEvent.preventDefault();
|
||||
function moveLotTypeField(clickEvent: MouseEvent) {
|
||||
const buttonElement = clickEvent.currentTarget as HTMLButtonElement;
|
||||
|
||||
const lotTypeFieldId = (
|
||||
(clickEvent.currentTarget as HTMLElement).closest(
|
||||
".container--lotTypeField"
|
||||
) as HTMLElement
|
||||
).dataset.lotTypeFieldId;
|
||||
const lotTypeFieldId = (buttonElement.closest(".container--lotTypeField") as HTMLElement)
|
||||
.dataset.lotTypeFieldId;
|
||||
|
||||
cityssm.postJSON(
|
||||
los.urlPrefix + "/admin/doMoveLotTypeFieldUp",
|
||||
los.urlPrefix +
|
||||
"/admin/" +
|
||||
(buttonElement.dataset.direction === "up"
|
||||
? "doMoveLotTypeFieldUp"
|
||||
: "doMoveLotTypeFieldDown"),
|
||||
{
|
||||
lotTypeFieldId,
|
||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
||||
},
|
||||
lotTypeResponseHandler
|
||||
);
|
||||
}
|
||||
|
||||
function moveLotTypeFieldDown(clickEvent: MouseEvent) {
|
||||
clickEvent.preventDefault();
|
||||
|
||||
const lotTypeFieldId = (
|
||||
(clickEvent.currentTarget as HTMLElement).closest(
|
||||
".container--lotTypeField"
|
||||
) as HTMLElement
|
||||
).dataset.lotTypeFieldId;
|
||||
|
||||
cityssm.postJSON(
|
||||
los.urlPrefix + "/admin/doMoveLotTypeFieldDown",
|
||||
{
|
||||
lotTypeFieldId,
|
||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
||||
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||
},
|
||||
lotTypeResponseHandler
|
||||
);
|
||||
|
|
@ -520,13 +488,13 @@ declare const bulmaJS: BulmaJS;
|
|||
panelBlockElement.querySelector(
|
||||
".button--moveLotTypeFieldUp"
|
||||
) as HTMLButtonElement
|
||||
).addEventListener("click", moveLotTypeFieldUp);
|
||||
).addEventListener("click", moveLotTypeField);
|
||||
|
||||
(
|
||||
panelBlockElement.querySelector(
|
||||
".button--moveLotTypeFieldDown"
|
||||
) as HTMLButtonElement
|
||||
).addEventListener("click", moveLotTypeFieldDown);
|
||||
).addEventListener("click", moveLotTypeField);
|
||||
|
||||
panelElement.append(panelBlockElement);
|
||||
}
|
||||
|
|
@ -622,19 +590,17 @@ declare const bulmaJS: BulmaJS;
|
|||
|
||||
(
|
||||
lotTypeContainer.querySelector(".button--moveLotTypeUp") as HTMLButtonElement
|
||||
).addEventListener("click", moveLotTypeUp);
|
||||
).addEventListener("click", moveLotType);
|
||||
|
||||
(
|
||||
lotTypeContainer.querySelector(".button--moveLotTypeDown") as HTMLButtonElement
|
||||
).addEventListener("click", moveLotTypeDown);
|
||||
).addEventListener("click", moveLotType);
|
||||
|
||||
containerElement.append(lotTypeContainer);
|
||||
}
|
||||
}
|
||||
|
||||
document.querySelector("#button--addLotType")!.addEventListener(
|
||||
"click",
|
||||
() => {
|
||||
document.querySelector("#button--addLotType")!.addEventListener("click", () => {
|
||||
let addCloseModalFunction: () => void;
|
||||
|
||||
function doAdd(submitEvent: SubmitEvent): void {
|
||||
|
|
@ -670,9 +636,7 @@ declare const bulmaJS: BulmaJS;
|
|||
onshown(modalElement, closeModalFunction) {
|
||||
addCloseModalFunction = closeModalFunction;
|
||||
|
||||
(
|
||||
modalElement.querySelector("#lotTypeAdd--lotType") as HTMLInputElement
|
||||
).focus();
|
||||
(modalElement.querySelector("#lotTypeAdd--lotType") as HTMLInputElement).focus();
|
||||
|
||||
modalElement.querySelector("form")!.addEventListener("submit", doAdd);
|
||||
|
||||
|
|
@ -682,8 +646,7 @@ declare const bulmaJS: BulmaJS;
|
|||
bulmaJS.toggleHtmlClipped();
|
||||
}
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
renderLotTypes();
|
||||
})();
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue