reduce move duplication
parent
abf8f6df37
commit
aabaf299f9
|
|
@ -1,7 +1,7 @@
|
||||||
import { moveOccupancyTypeDown, moveOccupancyTypeDownToBottom } from "../../helpers/lotOccupancyDB/moveOccupancyTypeDown.js";
|
import { moveOccupancyTypeDown, moveOccupancyTypeDownToBottom } from "../../helpers/lotOccupancyDB/moveOccupancyTypeDown.js";
|
||||||
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
||||||
export const handler = async (request, response) => {
|
export const handler = async (request, response) => {
|
||||||
const success = request.body.moveToBottom === "1"
|
const success = request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypeDownToBottom(request.body.occupancyTypeId)
|
? moveOccupancyTypeDownToBottom(request.body.occupancyTypeId)
|
||||||
: moveOccupancyTypeDown(request.body.occupancyTypeId);
|
: moveOccupancyTypeDown(request.body.occupancyTypeId);
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/func
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
const success =
|
const success =
|
||||||
request.body.moveToBottom === "1"
|
request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypeDownToBottom(request.body.occupancyTypeId)
|
? moveOccupancyTypeDownToBottom(request.body.occupancyTypeId)
|
||||||
: moveOccupancyTypeDown(request.body.occupancyTypeId);
|
: moveOccupancyTypeDown(request.body.occupancyTypeId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { moveOccupancyTypeFieldDown, moveOccupancyTypeFieldDownToBottom } from "../../helpers/lotOccupancyDB/moveOccupancyTypeFieldDown.js";
|
import { moveOccupancyTypeFieldDown, moveOccupancyTypeFieldDownToBottom } from "../../helpers/lotOccupancyDB/moveOccupancyTypeFieldDown.js";
|
||||||
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
||||||
export const handler = async (request, response) => {
|
export const handler = async (request, response) => {
|
||||||
const success = request.body.moveToBottom === "1"
|
const success = request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypeFieldDownToBottom(request.body.occupancyTypeFieldId)
|
? moveOccupancyTypeFieldDownToBottom(request.body.occupancyTypeFieldId)
|
||||||
: moveOccupancyTypeFieldDown(request.body.occupancyTypeFieldId);
|
: moveOccupancyTypeFieldDown(request.body.occupancyTypeFieldId);
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/func
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
const success =
|
const success =
|
||||||
request.body.moveToBottom === "1"
|
request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypeFieldDownToBottom(request.body.occupancyTypeFieldId)
|
? moveOccupancyTypeFieldDownToBottom(request.body.occupancyTypeFieldId)
|
||||||
: moveOccupancyTypeFieldDown(request.body.occupancyTypeFieldId);
|
: moveOccupancyTypeFieldDown(request.body.occupancyTypeFieldId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { moveOccupancyTypeFieldUp, moveOccupancyTypeFieldUpToTop } from "../../helpers/lotOccupancyDB/moveOccupancyTypeFieldUp.js";
|
import { moveOccupancyTypeFieldUp, moveOccupancyTypeFieldUpToTop } from "../../helpers/lotOccupancyDB/moveOccupancyTypeFieldUp.js";
|
||||||
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
||||||
export const handler = async (request, response) => {
|
export const handler = async (request, response) => {
|
||||||
const success = request.body.moveToTop === "1"
|
const success = request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypeFieldUpToTop(request.body.occupancyTypeFieldId)
|
? moveOccupancyTypeFieldUpToTop(request.body.occupancyTypeFieldId)
|
||||||
: moveOccupancyTypeFieldUp(request.body.occupancyTypeFieldId);
|
: moveOccupancyTypeFieldUp(request.body.occupancyTypeFieldId);
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/func
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
const success =
|
const success =
|
||||||
request.body.moveToTop === "1"
|
request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypeFieldUpToTop(request.body.occupancyTypeFieldId)
|
? moveOccupancyTypeFieldUpToTop(request.body.occupancyTypeFieldId)
|
||||||
: moveOccupancyTypeFieldUp(request.body.occupancyTypeFieldId);
|
: moveOccupancyTypeFieldUp(request.body.occupancyTypeFieldId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { moveOccupancyTypePrintDown, moveOccupancyTypePrintDownToBottom } from "../../helpers/lotOccupancyDB/moveOccupancyTypePrintDown.js";
|
import { moveOccupancyTypePrintDown, moveOccupancyTypePrintDownToBottom } from "../../helpers/lotOccupancyDB/moveOccupancyTypePrintDown.js";
|
||||||
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
||||||
export const handler = async (request, response) => {
|
export const handler = async (request, response) => {
|
||||||
const success = request.body.moveToBottom === "1"
|
const success = request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypePrintDownToBottom(request.body.occupancyTypeId, request.body.printEJS)
|
? moveOccupancyTypePrintDownToBottom(request.body.occupancyTypeId, request.body.printEJS)
|
||||||
: moveOccupancyTypePrintDown(request.body.occupancyTypeId, request.body.printEJS);
|
: moveOccupancyTypePrintDown(request.body.occupancyTypeId, request.body.printEJS);
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/func
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
const success =
|
const success =
|
||||||
request.body.moveToBottom === "1"
|
request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypePrintDownToBottom(request.body.occupancyTypeId, request.body.printEJS)
|
? moveOccupancyTypePrintDownToBottom(request.body.occupancyTypeId, request.body.printEJS)
|
||||||
: moveOccupancyTypePrintDown(request.body.occupancyTypeId, request.body.printEJS);
|
: moveOccupancyTypePrintDown(request.body.occupancyTypeId, request.body.printEJS);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { moveOccupancyTypePrintUp, moveOccupancyTypePrintUpToTop } from "../../helpers/lotOccupancyDB/moveOccupancyTypePrintUp.js";
|
import { moveOccupancyTypePrintUp, moveOccupancyTypePrintUpToTop } from "../../helpers/lotOccupancyDB/moveOccupancyTypePrintUp.js";
|
||||||
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
||||||
export const handler = async (request, response) => {
|
export const handler = async (request, response) => {
|
||||||
const success = request.body.moveToTop === "1"
|
const success = request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypePrintUpToTop(request.body.occupancyTypeId, request.body.printEJS)
|
? moveOccupancyTypePrintUpToTop(request.body.occupancyTypeId, request.body.printEJS)
|
||||||
: moveOccupancyTypePrintUp(request.body.occupancyTypeId, request.body.printEJS);
|
: moveOccupancyTypePrintUp(request.body.occupancyTypeId, request.body.printEJS);
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/func
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
const success =
|
const success =
|
||||||
request.body.moveToTop === "1"
|
request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypePrintUpToTop(request.body.occupancyTypeId, request.body.printEJS)
|
? moveOccupancyTypePrintUpToTop(request.body.occupancyTypeId, request.body.printEJS)
|
||||||
: moveOccupancyTypePrintUp(request.body.occupancyTypeId, request.body.printEJS);
|
: moveOccupancyTypePrintUp(request.body.occupancyTypeId, request.body.printEJS);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { moveOccupancyTypeUp, moveOccupancyTypeUpToTop } from "../../helpers/lotOccupancyDB/moveOccupancyTypeUp.js";
|
import { moveOccupancyTypeUp, moveOccupancyTypeUpToTop } from "../../helpers/lotOccupancyDB/moveOccupancyTypeUp.js";
|
||||||
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/functions.cache.js";
|
||||||
export const handler = async (request, response) => {
|
export const handler = async (request, response) => {
|
||||||
const success = request.body.moveToTop === "1"
|
const success = request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypeUpToTop(request.body.occupancyTypeId)
|
? moveOccupancyTypeUpToTop(request.body.occupancyTypeId)
|
||||||
: moveOccupancyTypeUp(request.body.occupancyTypeId);
|
: moveOccupancyTypeUp(request.body.occupancyTypeId);
|
||||||
const occupancyTypes = getOccupancyTypes();
|
const occupancyTypes = getOccupancyTypes();
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import { getAllOccupancyTypeFields, getOccupancyTypes } from "../../helpers/func
|
||||||
|
|
||||||
export const handler: RequestHandler = async (request, response) => {
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
const success =
|
const success =
|
||||||
request.body.moveToTop === "1"
|
request.body.moveToEnd === "1"
|
||||||
? moveOccupancyTypeUpToTop(request.body.occupancyTypeId)
|
? moveOccupancyTypeUpToTop(request.body.occupancyTypeId)
|
||||||
: moveOccupancyTypeUp(request.body.occupancyTypeId);
|
: moveOccupancyTypeUp(request.body.occupancyTypeId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -123,20 +123,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function moveOccupancyTypeUp(clickEvent) {
|
function moveOccupancyType(clickEvent) {
|
||||||
clickEvent.preventDefault();
|
const buttonElement = clickEvent.currentTarget;
|
||||||
const occupancyTypeId = clickEvent.currentTarget.closest(".container--occupancyType").dataset.occupancyTypeId;
|
const occupancyTypeId = clickEvent.currentTarget.closest(".container--occupancyType").dataset.occupancyTypeId;
|
||||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveOccupancyTypeUp", {
|
cityssm.postJSON(los.urlPrefix +
|
||||||
|
"/admin/" +
|
||||||
|
(buttonElement.dataset.direction === "up"
|
||||||
|
? "doMoveOccupancyTypeUp"
|
||||||
|
: "doMoveOccupancyTypeDown"), {
|
||||||
occupancyTypeId,
|
occupancyTypeId,
|
||||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||||
}, occupancyTypeResponseHandler);
|
|
||||||
}
|
|
||||||
function moveOccupancyTypeDown(clickEvent) {
|
|
||||||
clickEvent.preventDefault();
|
|
||||||
const occupancyTypeId = clickEvent.currentTarget.closest(".container--occupancyType").dataset.occupancyTypeId;
|
|
||||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveOccupancyTypeDown", {
|
|
||||||
occupancyTypeId,
|
|
||||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
|
||||||
}, occupancyTypeResponseHandler);
|
}, occupancyTypeResponseHandler);
|
||||||
}
|
}
|
||||||
function openEditOccupancyTypeField(occupancyTypeId, occupancyTypeFieldId) {
|
function openEditOccupancyTypeField(occupancyTypeId, occupancyTypeFieldId) {
|
||||||
|
|
@ -241,20 +237,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
const occupancyTypeId = Number.parseInt(clickEvent.currentTarget.closest(".container--occupancyType").dataset.occupancyTypeId, 10);
|
const occupancyTypeId = Number.parseInt(clickEvent.currentTarget.closest(".container--occupancyType").dataset.occupancyTypeId, 10);
|
||||||
openEditOccupancyTypeField(occupancyTypeId, occupancyTypeFieldId);
|
openEditOccupancyTypeField(occupancyTypeId, occupancyTypeFieldId);
|
||||||
}
|
}
|
||||||
function moveOccupancyTypeFieldUp(clickEvent) {
|
function moveOccupancyTypeField(clickEvent) {
|
||||||
clickEvent.preventDefault();
|
const buttonElement = clickEvent.currentTarget;
|
||||||
const occupancyTypeFieldId = clickEvent.currentTarget.closest(".container--occupancyTypeField").dataset.occupancyTypeFieldId;
|
const occupancyTypeFieldId = clickEvent.currentTarget.closest(".container--occupancyTypeField").dataset.occupancyTypeFieldId;
|
||||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveOccupancyTypeFieldUp", {
|
cityssm.postJSON(los.urlPrefix +
|
||||||
|
"/admin/" +
|
||||||
|
(buttonElement.dataset.direction === "up"
|
||||||
|
? "doMoveOccupancyTypeFieldUp"
|
||||||
|
: "doMoveOccupancyTypeFieldDown"), {
|
||||||
occupancyTypeFieldId,
|
occupancyTypeFieldId,
|
||||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||||
}, occupancyTypeResponseHandler);
|
|
||||||
}
|
|
||||||
function moveOccupancyTypeFieldDown(clickEvent) {
|
|
||||||
clickEvent.preventDefault();
|
|
||||||
const occupancyTypeFieldId = clickEvent.currentTarget.closest(".container--occupancyTypeField").dataset.occupancyTypeFieldId;
|
|
||||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveOccupancyTypeFieldDown", {
|
|
||||||
occupancyTypeFieldId,
|
|
||||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
|
||||||
}, occupancyTypeResponseHandler);
|
}, occupancyTypeResponseHandler);
|
||||||
}
|
}
|
||||||
function renderOccupancyTypeFields(panelElement, occupancyTypeId, occupancyTypeFields) {
|
function renderOccupancyTypeFields(panelElement, occupancyTypeId, occupancyTypeFields) {
|
||||||
|
|
@ -296,8 +288,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
panelBlockElement
|
panelBlockElement
|
||||||
.querySelector(".button--editOccupancyTypeField")
|
.querySelector(".button--editOccupancyTypeField")
|
||||||
.addEventListener("click", openEditOccupancyTypeFieldByClick);
|
.addEventListener("click", openEditOccupancyTypeFieldByClick);
|
||||||
panelBlockElement.querySelector(".button--moveOccupancyTypeFieldUp").addEventListener("click", moveOccupancyTypeFieldUp);
|
panelBlockElement.querySelector(".button--moveOccupancyTypeFieldUp").addEventListener("click", moveOccupancyTypeField);
|
||||||
panelBlockElement.querySelector(".button--moveOccupancyTypeFieldDown").addEventListener("click", moveOccupancyTypeFieldDown);
|
panelBlockElement.querySelector(".button--moveOccupancyTypeFieldDown").addEventListener("click", moveOccupancyTypeField);
|
||||||
panelElement.append(panelBlockElement);
|
panelElement.append(panelBlockElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -333,24 +325,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function moveOccupancyTypePrintUp(clickEvent) {
|
function moveOccupancyTypePrint(clickEvent) {
|
||||||
clickEvent.preventDefault();
|
const buttonElement = clickEvent.currentTarget;
|
||||||
const printEJS = clickEvent.currentTarget.closest(".container--occupancyTypePrint").dataset.printEJS;
|
const printEJS = buttonElement.closest(".container--occupancyTypePrint")
|
||||||
const occupancyTypeId = clickEvent.currentTarget.closest(".container--occupancyTypePrintList").dataset.occupancyTypeId;
|
.dataset.printEJS;
|
||||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveOccupancyTypePrintUp", {
|
const occupancyTypeId = buttonElement.closest(".container--occupancyTypePrintList").dataset.occupancyTypeId;
|
||||||
|
cityssm.postJSON(los.urlPrefix +
|
||||||
|
"/admin/" +
|
||||||
|
(buttonElement.dataset.direction === "up"
|
||||||
|
? "doMoveOccupancyTypePrintUp"
|
||||||
|
: "doMoveOccupancyTypePrintDown"), {
|
||||||
occupancyTypeId,
|
occupancyTypeId,
|
||||||
printEJS,
|
printEJS,
|
||||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||||
}, occupancyTypeResponseHandler);
|
|
||||||
}
|
|
||||||
function moveOccupancyTypePrintDown(clickEvent) {
|
|
||||||
clickEvent.preventDefault();
|
|
||||||
const printEJS = clickEvent.currentTarget.closest(".container--occupancyTypePrint").dataset.printEJS;
|
|
||||||
const occupancyTypeId = clickEvent.currentTarget.closest(".container--occupancyTypePrintList").dataset.occupancyTypeId;
|
|
||||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveOccupancyTypePrintDown", {
|
|
||||||
occupancyTypeId,
|
|
||||||
printEJS,
|
|
||||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
|
||||||
}, occupancyTypeResponseHandler);
|
}, occupancyTypeResponseHandler);
|
||||||
}
|
}
|
||||||
function deleteOccupancyTypePrint(clickEvent) {
|
function deleteOccupancyTypePrint(clickEvent) {
|
||||||
|
|
@ -420,8 +407,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
"</div>") +
|
"</div>") +
|
||||||
"</div>" +
|
"</div>" +
|
||||||
"</div>";
|
"</div>";
|
||||||
panelBlockElement.querySelector(".button--moveOccupancyTypePrintUp").addEventListener("click", moveOccupancyTypePrintUp);
|
panelBlockElement.querySelector(".button--moveOccupancyTypePrintUp").addEventListener("click", moveOccupancyTypePrint);
|
||||||
panelBlockElement.querySelector(".button--moveOccupancyTypePrintDown").addEventListener("click", moveOccupancyTypePrintDown);
|
panelBlockElement.querySelector(".button--moveOccupancyTypePrintDown").addEventListener("click", moveOccupancyTypePrint);
|
||||||
panelBlockElement
|
panelBlockElement
|
||||||
.querySelector(".button--deleteOccupancyTypePrint")
|
.querySelector(".button--deleteOccupancyTypePrint")
|
||||||
.addEventListener("click", deleteOccupancyTypePrint);
|
.addEventListener("click", deleteOccupancyTypePrint);
|
||||||
|
|
@ -530,8 +517,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
occupancyTypeContainer
|
occupancyTypeContainer
|
||||||
.querySelector(".button--addOccupancyTypeField")
|
.querySelector(".button--addOccupancyTypeField")
|
||||||
.addEventListener("click", openAddOccupancyTypeField);
|
.addEventListener("click", openAddOccupancyTypeField);
|
||||||
occupancyTypeContainer.querySelector(".button--moveOccupancyTypeUp").addEventListener("click", moveOccupancyTypeUp);
|
occupancyTypeContainer.querySelector(".button--moveOccupancyTypeUp").addEventListener("click", moveOccupancyType);
|
||||||
occupancyTypeContainer.querySelector(".button--moveOccupancyTypeDown").addEventListener("click", moveOccupancyTypeDown);
|
occupancyTypeContainer.querySelector(".button--moveOccupancyTypeDown").addEventListener("click", moveOccupancyType);
|
||||||
occupancyTypesContainerElement.append(occupancyTypeContainer);
|
occupancyTypesContainerElement.append(occupancyTypeContainer);
|
||||||
}
|
}
|
||||||
// Prints
|
// Prints
|
||||||
|
|
|
||||||
|
|
@ -246,8 +246,8 @@ declare const bulmaJS: BulmaJS;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveOccupancyTypeUp(clickEvent: MouseEvent) {
|
function moveOccupancyType(clickEvent: MouseEvent) {
|
||||||
clickEvent.preventDefault();
|
const buttonElement = clickEvent.currentTarget as HTMLButtonElement;
|
||||||
|
|
||||||
const occupancyTypeId = (
|
const occupancyTypeId = (
|
||||||
(clickEvent.currentTarget as HTMLElement).closest(
|
(clickEvent.currentTarget as HTMLElement).closest(
|
||||||
|
|
@ -256,29 +256,14 @@ declare const bulmaJS: BulmaJS;
|
||||||
).dataset.occupancyTypeId;
|
).dataset.occupancyTypeId;
|
||||||
|
|
||||||
cityssm.postJSON(
|
cityssm.postJSON(
|
||||||
los.urlPrefix + "/admin/doMoveOccupancyTypeUp",
|
los.urlPrefix +
|
||||||
|
"/admin/" +
|
||||||
|
(buttonElement.dataset.direction === "up"
|
||||||
|
? "doMoveOccupancyTypeUp"
|
||||||
|
: "doMoveOccupancyTypeDown"),
|
||||||
{
|
{
|
||||||
occupancyTypeId,
|
occupancyTypeId,
|
||||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||||
},
|
|
||||||
occupancyTypeResponseHandler
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function moveOccupancyTypeDown(clickEvent: MouseEvent) {
|
|
||||||
clickEvent.preventDefault();
|
|
||||||
|
|
||||||
const occupancyTypeId = (
|
|
||||||
(clickEvent.currentTarget as HTMLElement).closest(
|
|
||||||
".container--occupancyType"
|
|
||||||
) as HTMLElement
|
|
||||||
).dataset.occupancyTypeId;
|
|
||||||
|
|
||||||
cityssm.postJSON(
|
|
||||||
los.urlPrefix + "/admin/doMoveOccupancyTypeDown",
|
|
||||||
{
|
|
||||||
occupancyTypeId,
|
|
||||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
|
||||||
},
|
},
|
||||||
occupancyTypeResponseHandler
|
occupancyTypeResponseHandler
|
||||||
);
|
);
|
||||||
|
|
@ -471,8 +456,8 @@ declare const bulmaJS: BulmaJS;
|
||||||
openEditOccupancyTypeField(occupancyTypeId, occupancyTypeFieldId);
|
openEditOccupancyTypeField(occupancyTypeId, occupancyTypeFieldId);
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveOccupancyTypeFieldUp(clickEvent: MouseEvent) {
|
function moveOccupancyTypeField(clickEvent: MouseEvent) {
|
||||||
clickEvent.preventDefault();
|
const buttonElement = clickEvent.currentTarget as HTMLButtonElement;
|
||||||
|
|
||||||
const occupancyTypeFieldId = (
|
const occupancyTypeFieldId = (
|
||||||
(clickEvent.currentTarget as HTMLElement).closest(
|
(clickEvent.currentTarget as HTMLElement).closest(
|
||||||
|
|
@ -481,29 +466,14 @@ declare const bulmaJS: BulmaJS;
|
||||||
).dataset.occupancyTypeFieldId;
|
).dataset.occupancyTypeFieldId;
|
||||||
|
|
||||||
cityssm.postJSON(
|
cityssm.postJSON(
|
||||||
los.urlPrefix + "/admin/doMoveOccupancyTypeFieldUp",
|
los.urlPrefix +
|
||||||
|
"/admin/" +
|
||||||
|
(buttonElement.dataset.direction === "up"
|
||||||
|
? "doMoveOccupancyTypeFieldUp"
|
||||||
|
: "doMoveOccupancyTypeFieldDown"),
|
||||||
{
|
{
|
||||||
occupancyTypeFieldId,
|
occupancyTypeFieldId,
|
||||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||||
},
|
|
||||||
occupancyTypeResponseHandler
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function moveOccupancyTypeFieldDown(clickEvent: MouseEvent) {
|
|
||||||
clickEvent.preventDefault();
|
|
||||||
|
|
||||||
const occupancyTypeFieldId = (
|
|
||||||
(clickEvent.currentTarget as HTMLElement).closest(
|
|
||||||
".container--occupancyTypeField"
|
|
||||||
) as HTMLElement
|
|
||||||
).dataset.occupancyTypeFieldId;
|
|
||||||
|
|
||||||
cityssm.postJSON(
|
|
||||||
los.urlPrefix + "/admin/doMoveOccupancyTypeFieldDown",
|
|
||||||
{
|
|
||||||
occupancyTypeFieldId,
|
|
||||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
|
||||||
},
|
},
|
||||||
occupancyTypeResponseHandler
|
occupancyTypeResponseHandler
|
||||||
);
|
);
|
||||||
|
|
@ -566,13 +536,13 @@ declare const bulmaJS: BulmaJS;
|
||||||
panelBlockElement.querySelector(
|
panelBlockElement.querySelector(
|
||||||
".button--moveOccupancyTypeFieldUp"
|
".button--moveOccupancyTypeFieldUp"
|
||||||
) as HTMLButtonElement
|
) as HTMLButtonElement
|
||||||
).addEventListener("click", moveOccupancyTypeFieldUp);
|
).addEventListener("click", moveOccupancyTypeField);
|
||||||
|
|
||||||
(
|
(
|
||||||
panelBlockElement.querySelector(
|
panelBlockElement.querySelector(
|
||||||
".button--moveOccupancyTypeFieldDown"
|
".button--moveOccupancyTypeFieldDown"
|
||||||
) as HTMLButtonElement
|
) as HTMLButtonElement
|
||||||
).addEventListener("click", moveOccupancyTypeFieldDown);
|
).addEventListener("click", moveOccupancyTypeField);
|
||||||
|
|
||||||
panelElement.append(panelBlockElement);
|
panelElement.append(panelBlockElement);
|
||||||
}
|
}
|
||||||
|
|
@ -640,53 +610,26 @@ declare const bulmaJS: BulmaJS;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function moveOccupancyTypePrintUp(clickEvent: MouseEvent): void {
|
function moveOccupancyTypePrint(clickEvent: MouseEvent): void {
|
||||||
clickEvent.preventDefault();
|
const buttonElement = clickEvent.currentTarget as HTMLButtonElement;
|
||||||
|
|
||||||
const printEJS = (
|
const printEJS = (buttonElement.closest(".container--occupancyTypePrint") as HTMLElement)
|
||||||
(clickEvent.currentTarget as HTMLElement).closest(
|
.dataset.printEJS;
|
||||||
".container--occupancyTypePrint"
|
|
||||||
) as HTMLElement
|
|
||||||
).dataset.printEJS;
|
|
||||||
|
|
||||||
const occupancyTypeId = (
|
const occupancyTypeId = (
|
||||||
(clickEvent.currentTarget as HTMLElement).closest(
|
buttonElement.closest(".container--occupancyTypePrintList") as HTMLElement
|
||||||
".container--occupancyTypePrintList"
|
|
||||||
) as HTMLElement
|
|
||||||
).dataset.occupancyTypeId;
|
).dataset.occupancyTypeId;
|
||||||
|
|
||||||
cityssm.postJSON(
|
cityssm.postJSON(
|
||||||
los.urlPrefix + "/admin/doMoveOccupancyTypePrintUp",
|
los.urlPrefix +
|
||||||
|
"/admin/" +
|
||||||
|
(buttonElement.dataset.direction === "up"
|
||||||
|
? "doMoveOccupancyTypePrintUp"
|
||||||
|
: "doMoveOccupancyTypePrintDown"),
|
||||||
{
|
{
|
||||||
occupancyTypeId,
|
occupancyTypeId,
|
||||||
printEJS,
|
printEJS,
|
||||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||||
},
|
|
||||||
occupancyTypeResponseHandler
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function moveOccupancyTypePrintDown(clickEvent: MouseEvent): void {
|
|
||||||
clickEvent.preventDefault();
|
|
||||||
|
|
||||||
const printEJS = (
|
|
||||||
(clickEvent.currentTarget as HTMLElement).closest(
|
|
||||||
".container--occupancyTypePrint"
|
|
||||||
) as HTMLElement
|
|
||||||
).dataset.printEJS;
|
|
||||||
|
|
||||||
const occupancyTypeId = (
|
|
||||||
(clickEvent.currentTarget as HTMLElement).closest(
|
|
||||||
".container--occupancyTypePrintList"
|
|
||||||
) as HTMLElement
|
|
||||||
).dataset.occupancyTypeId;
|
|
||||||
|
|
||||||
cityssm.postJSON(
|
|
||||||
los.urlPrefix + "/admin/doMoveOccupancyTypePrintDown",
|
|
||||||
{
|
|
||||||
occupancyTypeId,
|
|
||||||
printEJS,
|
|
||||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
|
||||||
},
|
},
|
||||||
occupancyTypeResponseHandler
|
occupancyTypeResponseHandler
|
||||||
);
|
);
|
||||||
|
|
@ -795,13 +738,13 @@ declare const bulmaJS: BulmaJS;
|
||||||
panelBlockElement.querySelector(
|
panelBlockElement.querySelector(
|
||||||
".button--moveOccupancyTypePrintUp"
|
".button--moveOccupancyTypePrintUp"
|
||||||
) as HTMLButtonElement
|
) as HTMLButtonElement
|
||||||
).addEventListener("click", moveOccupancyTypePrintUp);
|
).addEventListener("click", moveOccupancyTypePrint);
|
||||||
|
|
||||||
(
|
(
|
||||||
panelBlockElement.querySelector(
|
panelBlockElement.querySelector(
|
||||||
".button--moveOccupancyTypePrintDown"
|
".button--moveOccupancyTypePrintDown"
|
||||||
) as HTMLButtonElement
|
) as HTMLButtonElement
|
||||||
).addEventListener("click", moveOccupancyTypePrintDown);
|
).addEventListener("click", moveOccupancyTypePrint);
|
||||||
|
|
||||||
panelBlockElement
|
panelBlockElement
|
||||||
.querySelector(".button--deleteOccupancyTypePrint")!
|
.querySelector(".button--deleteOccupancyTypePrint")!
|
||||||
|
|
@ -952,13 +895,13 @@ declare const bulmaJS: BulmaJS;
|
||||||
occupancyTypeContainer.querySelector(
|
occupancyTypeContainer.querySelector(
|
||||||
".button--moveOccupancyTypeUp"
|
".button--moveOccupancyTypeUp"
|
||||||
) as HTMLButtonElement
|
) as HTMLButtonElement
|
||||||
).addEventListener("click", moveOccupancyTypeUp);
|
).addEventListener("click", moveOccupancyType);
|
||||||
|
|
||||||
(
|
(
|
||||||
occupancyTypeContainer.querySelector(
|
occupancyTypeContainer.querySelector(
|
||||||
".button--moveOccupancyTypeDown"
|
".button--moveOccupancyTypeDown"
|
||||||
) as HTMLButtonElement
|
) as HTMLButtonElement
|
||||||
).addEventListener("click", moveOccupancyTypeDown);
|
).addEventListener("click", moveOccupancyType);
|
||||||
|
|
||||||
occupancyTypesContainerElement.append(occupancyTypeContainer);
|
occupancyTypesContainerElement.append(occupancyTypeContainer);
|
||||||
}
|
}
|
||||||
|
|
@ -1008,60 +951,57 @@ declare const bulmaJS: BulmaJS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
document.querySelector("#button--addOccupancyType")!.addEventListener(
|
document.querySelector("#button--addOccupancyType")!.addEventListener("click", () => {
|
||||||
"click",
|
let addCloseModalFunction: () => void;
|
||||||
() => {
|
|
||||||
let addCloseModalFunction: () => void;
|
|
||||||
|
|
||||||
const doAdd = (submitEvent: SubmitEvent) => {
|
const doAdd = (submitEvent: SubmitEvent) => {
|
||||||
submitEvent.preventDefault();
|
submitEvent.preventDefault();
|
||||||
|
|
||||||
cityssm.postJSON(
|
cityssm.postJSON(
|
||||||
los.urlPrefix + "/admin/doAddOccupancyType",
|
los.urlPrefix + "/admin/doAddOccupancyType",
|
||||||
submitEvent.currentTarget,
|
submitEvent.currentTarget,
|
||||||
(responseJSON: {
|
(responseJSON: {
|
||||||
success: boolean;
|
success: boolean;
|
||||||
errorMessage?: string;
|
errorMessage?: string;
|
||||||
occupancyTypes?: recordTypes.OccupancyType[];
|
occupancyTypes?: recordTypes.OccupancyType[];
|
||||||
}) => {
|
}) => {
|
||||||
if (responseJSON.success) {
|
if (responseJSON.success) {
|
||||||
addCloseModalFunction();
|
addCloseModalFunction();
|
||||||
occupancyTypes = responseJSON.occupancyTypes!;
|
occupancyTypes = responseJSON.occupancyTypes!;
|
||||||
renderOccupancyTypes();
|
renderOccupancyTypes();
|
||||||
} else {
|
} else {
|
||||||
bulmaJS.alert({
|
bulmaJS.alert({
|
||||||
title: "Error Adding " + exports.aliases.occupancy + " Type",
|
title: "Error Adding " + exports.aliases.occupancy + " Type",
|
||||||
message: responseJSON.errorMessage || "",
|
message: responseJSON.errorMessage || "",
|
||||||
contextualColorName: "danger"
|
contextualColorName: "danger"
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
cityssm.openHtmlModal("adminOccupancyTypes-addOccupancyType", {
|
|
||||||
onshow: (modalElement) => {
|
|
||||||
los.populateAliases(modalElement);
|
|
||||||
},
|
|
||||||
onshown: (modalElement, closeModalFunction) => {
|
|
||||||
addCloseModalFunction = closeModalFunction;
|
|
||||||
|
|
||||||
(
|
|
||||||
modalElement.querySelector(
|
|
||||||
"#occupancyTypeAdd--occupancyType"
|
|
||||||
) as HTMLInputElement
|
|
||||||
).focus();
|
|
||||||
|
|
||||||
modalElement.querySelector("form")!.addEventListener("submit", doAdd);
|
|
||||||
|
|
||||||
bulmaJS.toggleHtmlClipped();
|
|
||||||
},
|
|
||||||
onremoved: () => {
|
|
||||||
bulmaJS.toggleHtmlClipped();
|
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
}
|
};
|
||||||
);
|
|
||||||
|
cityssm.openHtmlModal("adminOccupancyTypes-addOccupancyType", {
|
||||||
|
onshow: (modalElement) => {
|
||||||
|
los.populateAliases(modalElement);
|
||||||
|
},
|
||||||
|
onshown: (modalElement, closeModalFunction) => {
|
||||||
|
addCloseModalFunction = closeModalFunction;
|
||||||
|
|
||||||
|
(
|
||||||
|
modalElement.querySelector(
|
||||||
|
"#occupancyTypeAdd--occupancyType"
|
||||||
|
) as HTMLInputElement
|
||||||
|
).focus();
|
||||||
|
|
||||||
|
modalElement.querySelector("form")!.addEventListener("submit", doAdd);
|
||||||
|
|
||||||
|
bulmaJS.toggleHtmlClipped();
|
||||||
|
},
|
||||||
|
onremoved: () => {
|
||||||
|
bulmaJS.toggleHtmlClipped();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
renderOccupancyTypes();
|
renderOccupancyTypes();
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue