reduce move duplication
parent
32b32cf43a
commit
35dbc09d82
|
|
@ -1,7 +1,7 @@
|
|||
import { moveFeeCategoryDown, moveFeeCategoryDownToBottom } from "../../helpers/lotOccupancyDB/moveFeeCategoryDown.js";
|
||||
import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = request.body.moveToBottom === "1"
|
||||
const success = request.body.moveToEnd === "1"
|
||||
? moveFeeCategoryDownToBottom(request.body.feeCategoryId)
|
||||
: moveFeeCategoryDown(request.body.feeCategoryId);
|
||||
const feeCategories = getFeeCategories({}, {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.
|
|||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
const success =
|
||||
request.body.moveToBottom === "1"
|
||||
request.body.moveToEnd === "1"
|
||||
? moveFeeCategoryDownToBottom(request.body.feeCategoryId)
|
||||
: moveFeeCategoryDown(request.body.feeCategoryId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { moveFeeCategoryUp, moveFeeCategoryUpToTop } from "../../helpers/lotOccupancyDB/moveFeeCategoryUp.js";
|
||||
import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = request.body.moveToTop === "1"
|
||||
const success = request.body.moveToEnd === "1"
|
||||
? moveFeeCategoryUpToTop(request.body.feeCategoryId)
|
||||
: moveFeeCategoryUp(request.body.feeCategoryId);
|
||||
const feeCategories = getFeeCategories({}, {
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.
|
|||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
const success =
|
||||
request.body.moveToTop === "1"
|
||||
request.body.moveToEnd === "1"
|
||||
? moveFeeCategoryUpToTop(request.body.feeCategoryId)
|
||||
: moveFeeCategoryUp(request.body.feeCategoryId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { moveFeeDown, moveFeeDownToBottom } from "../../helpers/lotOccupancyDB/moveFeeDown.js";
|
||||
import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = request.body.moveToBottom === "1"
|
||||
const success = request.body.moveToEnd === "1"
|
||||
? moveFeeDownToBottom(request.body.feeId)
|
||||
: moveFeeDown(request.body.feeId);
|
||||
const feeCategories = getFeeCategories({}, {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.
|
|||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
const success =
|
||||
request.body.moveToBottom === "1"
|
||||
request.body.moveToEnd === "1"
|
||||
? moveFeeDownToBottom(request.body.feeId)
|
||||
: moveFeeDown(request.body.feeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { moveFeeUp, moveFeeUpToTop } from "../../helpers/lotOccupancyDB/moveFeeUp.js";
|
||||
import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.js";
|
||||
export const handler = async (request, response) => {
|
||||
const success = request.body.moveToTop === "1"
|
||||
const success = request.body.moveToEnd === "1"
|
||||
? moveFeeUpToTop(request.body.feeId)
|
||||
: moveFeeUp(request.body.feeId);
|
||||
const feeCategories = getFeeCategories({}, {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { getFeeCategories } from "../../helpers/lotOccupancyDB/getFeeCategories.
|
|||
|
||||
export const handler: RequestHandler = async (request, response) => {
|
||||
const success =
|
||||
request.body.moveToTop === "1"
|
||||
request.body.moveToEnd === "1"
|
||||
? moveFeeUpToTop(request.body.feeId)
|
||||
: moveFeeUp(request.body.feeId);
|
||||
|
||||
|
|
|
|||
|
|
@ -142,8 +142,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
"</div>") +
|
||||
"</div>";
|
||||
panelBlockElement.querySelector("a").addEventListener("click", openEditFee);
|
||||
panelBlockElement.querySelector(".button--moveFeeUp").addEventListener("click", moveFeeUp);
|
||||
panelBlockElement.querySelector(".button--moveFeeDown").addEventListener("click", moveFeeDown);
|
||||
panelBlockElement.querySelector(".button--moveFeeUp").addEventListener("click", moveFee);
|
||||
panelBlockElement.querySelector(".button--moveFeeDown").addEventListener("click", moveFee);
|
||||
feeCategoryContainerElement.append(panelBlockElement);
|
||||
}
|
||||
}
|
||||
|
|
@ -153,8 +153,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
feeCategoryContainerElement
|
||||
.querySelector(".button--addFee")
|
||||
.addEventListener("click", openAddFee);
|
||||
feeCategoryContainerElement.querySelector(".button--moveFeeCategoryUp").addEventListener("click", moveFeeCategoryUp);
|
||||
feeCategoryContainerElement.querySelector(".button--moveFeeCategoryDown").addEventListener("click", moveFeeCategoryDown);
|
||||
feeCategoryContainerElement.querySelector(".button--moveFeeCategoryUp").addEventListener("click", moveFeeCategory);
|
||||
feeCategoryContainerElement.querySelector(".button--moveFeeCategoryDown").addEventListener("click", moveFeeCategory);
|
||||
feeCategoriesContainerElement.append(feeCategoryContainerElement);
|
||||
}
|
||||
}
|
||||
|
|
@ -260,30 +260,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
}
|
||||
});
|
||||
}
|
||||
function moveFeeCategoryUp(clickEvent) {
|
||||
const feeCategoryId = Number.parseInt(clickEvent.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId, 10);
|
||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveFeeCategoryUp", {
|
||||
function moveFeeCategory(clickEvent) {
|
||||
const buttonElement = clickEvent.currentTarget;
|
||||
const feeCategoryId = Number.parseInt(buttonElement.closest(".container--feeCategory").dataset
|
||||
.feeCategoryId, 10);
|
||||
cityssm.postJSON(los.urlPrefix +
|
||||
"/admin/" +
|
||||
(buttonElement.dataset.direction === "up"
|
||||
? "doMoveFeeCategoryUp"
|
||||
: "doMoveFeeCategoryDown"), {
|
||||
feeCategoryId,
|
||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
||||
}, (responseJSON) => {
|
||||
if (responseJSON.success) {
|
||||
feeCategories = responseJSON.feeCategories;
|
||||
renderFeeCategories();
|
||||
}
|
||||
else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Moving Fee Category",
|
||||
message: responseJSON.errorMessage || "",
|
||||
contextualColorName: "danger"
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function moveFeeCategoryDown(clickEvent) {
|
||||
const feeCategoryId = Number.parseInt(clickEvent.currentTarget.closest(".container--feeCategory").dataset.feeCategoryId, 10);
|
||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveFeeCategoryDown", {
|
||||
feeCategoryId,
|
||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
||||
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||
}, (responseJSON) => {
|
||||
if (responseJSON.success) {
|
||||
feeCategories = responseJSON.feeCategories;
|
||||
|
|
@ -562,32 +549,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
}
|
||||
});
|
||||
}
|
||||
function moveFeeUp(clickEvent) {
|
||||
const feeContainerElement = clickEvent.currentTarget.closest(".container--fee");
|
||||
function moveFee(clickEvent) {
|
||||
const buttonElement = clickEvent.currentTarget;
|
||||
const feeContainerElement = buttonElement.closest(".container--fee");
|
||||
const feeId = Number.parseInt(feeContainerElement.dataset.feeId, 10);
|
||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveFeeUp", {
|
||||
cityssm.postJSON(los.urlPrefix +
|
||||
"/admin/" +
|
||||
(buttonElement.dataset.direction === "up" ? "doMoveFeeUp" : "doMoveFeeDown"), {
|
||||
feeId,
|
||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
||||
}, (responseJSON) => {
|
||||
if (responseJSON.success) {
|
||||
feeCategories = responseJSON.feeCategories;
|
||||
renderFeeCategories();
|
||||
}
|
||||
else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Moving Fee",
|
||||
message: responseJSON.errorMessage || "",
|
||||
contextualColorName: "danger"
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
function moveFeeDown(clickEvent) {
|
||||
const feeContainerElement = clickEvent.currentTarget.closest(".container--fee");
|
||||
const feeId = Number.parseInt(feeContainerElement.dataset.feeId, 10);
|
||||
cityssm.postJSON(los.urlPrefix + "/admin/doMoveFeeDown", {
|
||||
feeId,
|
||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
||||
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||
}, (responseJSON) => {
|
||||
if (responseJSON.success) {
|
||||
feeCategories = responseJSON.feeCategories;
|
||||
|
|
|
|||
|
|
@ -179,11 +179,11 @@ declare const bulmaJS: BulmaJS;
|
|||
|
||||
(
|
||||
panelBlockElement.querySelector(".button--moveFeeUp") as HTMLButtonElement
|
||||
).addEventListener("click", moveFeeUp);
|
||||
).addEventListener("click", moveFee);
|
||||
|
||||
(
|
||||
panelBlockElement.querySelector(".button--moveFeeDown") as HTMLButtonElement
|
||||
).addEventListener("click", moveFeeDown);
|
||||
).addEventListener("click", moveFee);
|
||||
|
||||
feeCategoryContainerElement.append(panelBlockElement);
|
||||
}
|
||||
|
|
@ -201,13 +201,13 @@ declare const bulmaJS: BulmaJS;
|
|||
feeCategoryContainerElement.querySelector(
|
||||
".button--moveFeeCategoryUp"
|
||||
) as HTMLButtonElement
|
||||
).addEventListener("click", moveFeeCategoryUp);
|
||||
).addEventListener("click", moveFeeCategory);
|
||||
|
||||
(
|
||||
feeCategoryContainerElement.querySelector(
|
||||
".button--moveFeeCategoryDown"
|
||||
) as HTMLButtonElement
|
||||
).addEventListener("click", moveFeeCategoryDown);
|
||||
).addEventListener("click", moveFeeCategory);
|
||||
|
||||
feeCategoriesContainerElement.append(feeCategoryContainerElement);
|
||||
}
|
||||
|
|
@ -378,56 +378,24 @@ declare const bulmaJS: BulmaJS;
|
|||
});
|
||||
}
|
||||
|
||||
function moveFeeCategoryUp(clickEvent: MouseEvent): void {
|
||||
function moveFeeCategory(clickEvent: MouseEvent): void {
|
||||
const buttonElement = clickEvent.currentTarget as HTMLButtonElement;
|
||||
|
||||
const feeCategoryId = Number.parseInt(
|
||||
(
|
||||
(clickEvent.currentTarget as HTMLElement).closest(
|
||||
".container--feeCategory"
|
||||
) as HTMLElement
|
||||
).dataset.feeCategoryId!,
|
||||
(buttonElement.closest(".container--feeCategory") as HTMLElement).dataset
|
||||
.feeCategoryId!,
|
||||
10
|
||||
);
|
||||
|
||||
cityssm.postJSON(
|
||||
los.urlPrefix + "/admin/doMoveFeeCategoryUp",
|
||||
los.urlPrefix +
|
||||
"/admin/" +
|
||||
(buttonElement.dataset.direction === "up"
|
||||
? "doMoveFeeCategoryUp"
|
||||
: "doMoveFeeCategoryDown"),
|
||||
{
|
||||
feeCategoryId,
|
||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
||||
},
|
||||
(responseJSON: {
|
||||
success: boolean;
|
||||
errorMessage?: string;
|
||||
feeCategories?: recordTypes.FeeCategory[];
|
||||
}) => {
|
||||
if (responseJSON.success) {
|
||||
feeCategories = responseJSON.feeCategories!;
|
||||
renderFeeCategories();
|
||||
} else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Moving Fee Category",
|
||||
message: responseJSON.errorMessage || "",
|
||||
contextualColorName: "danger"
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function moveFeeCategoryDown(clickEvent: MouseEvent): void {
|
||||
const feeCategoryId = Number.parseInt(
|
||||
(
|
||||
(clickEvent.currentTarget as HTMLElement).closest(
|
||||
".container--feeCategory"
|
||||
) as HTMLElement
|
||||
).dataset.feeCategoryId!,
|
||||
10
|
||||
);
|
||||
|
||||
cityssm.postJSON(
|
||||
los.urlPrefix + "/admin/doMoveFeeCategoryDown",
|
||||
{
|
||||
feeCategoryId,
|
||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
||||
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||
},
|
||||
(responseJSON: {
|
||||
success: boolean;
|
||||
|
|
@ -874,50 +842,20 @@ declare const bulmaJS: BulmaJS;
|
|||
});
|
||||
}
|
||||
|
||||
function moveFeeUp(clickEvent: MouseEvent): void {
|
||||
const feeContainerElement = (clickEvent.currentTarget as HTMLElement).closest(
|
||||
".container--fee"
|
||||
) as HTMLElement;
|
||||
function moveFee(clickEvent: MouseEvent): void {
|
||||
const buttonElement = clickEvent.currentTarget as HTMLButtonElement;
|
||||
|
||||
const feeContainerElement = buttonElement.closest(".container--fee") as HTMLElement;
|
||||
|
||||
const feeId = Number.parseInt(feeContainerElement.dataset.feeId!, 10);
|
||||
|
||||
cityssm.postJSON(
|
||||
los.urlPrefix + "/admin/doMoveFeeUp",
|
||||
los.urlPrefix +
|
||||
"/admin/" +
|
||||
(buttonElement.dataset.direction === "up" ? "doMoveFeeUp" : "doMoveFeeDown"),
|
||||
{
|
||||
feeId,
|
||||
moveToTop: clickEvent.shiftKey ? "1" : "0"
|
||||
},
|
||||
(responseJSON: {
|
||||
success: boolean;
|
||||
errorMessage?: string;
|
||||
feeCategories?: recordTypes.FeeCategory[];
|
||||
}) => {
|
||||
if (responseJSON.success) {
|
||||
feeCategories = responseJSON.feeCategories!;
|
||||
renderFeeCategories();
|
||||
} else {
|
||||
bulmaJS.alert({
|
||||
title: "Error Moving Fee",
|
||||
message: responseJSON.errorMessage || "",
|
||||
contextualColorName: "danger"
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
function moveFeeDown(clickEvent: MouseEvent): void {
|
||||
const feeContainerElement = (clickEvent.currentTarget as HTMLElement).closest(
|
||||
".container--fee"
|
||||
) as HTMLElement;
|
||||
|
||||
const feeId = Number.parseInt(feeContainerElement.dataset.feeId!, 10);
|
||||
|
||||
cityssm.postJSON(
|
||||
los.urlPrefix + "/admin/doMoveFeeDown",
|
||||
{
|
||||
feeId,
|
||||
moveToBottom: clickEvent.shiftKey ? "1" : "0"
|
||||
moveToEnd: clickEvent.shiftKey ? "1" : "0"
|
||||
},
|
||||
(responseJSON: {
|
||||
success: boolean;
|
||||
|
|
|
|||
|
|
@ -293,14 +293,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
<div class="control">
|
||||
<button
|
||||
class="button ${isSmall ? "is-small" : ""} ${upButtonClassNames}"
|
||||
data-tooltip="Move Up" type="button" aria-label="Move Up">
|
||||
data-tooltip="Move Up" data-direction="up" type="button" aria-label="Move Up">
|
||||
<i class="fas fa-arrow-up" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button
|
||||
class="button ${isSmall ? "is-small" : ""} ${downButtonClassNames}"
|
||||
data-tooltip="Move Down" type="button" aria-label="Move Down">
|
||||
data-tooltip="Move Down" data-direction="down" type="button" aria-label="Move Down">
|
||||
<i class="fas fa-arrow-down" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -376,14 +376,14 @@ declare const bulmaJS: BulmaJS;
|
|||
<div class="control">
|
||||
<button
|
||||
class="button ${isSmall ? "is-small" : ""} ${upButtonClassNames}"
|
||||
data-tooltip="Move Up" type="button" aria-label="Move Up">
|
||||
data-tooltip="Move Up" data-direction="up" type="button" aria-label="Move Up">
|
||||
<i class="fas fa-arrow-up" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="control">
|
||||
<button
|
||||
class="button ${isSmall ? "is-small" : ""} ${downButtonClassNames}"
|
||||
data-tooltip="Move Down" type="button" aria-label="Move Down">
|
||||
data-tooltip="Move Down" data-direction="down" type="button" aria-label="Move Down">
|
||||
<i class="fas fa-arrow-down" aria-hidden="true"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue