copy lot occupancy as new
parent
055aa8db59
commit
4888bd2294
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
export declare const handler: RequestHandler;
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
import { copyLotOccupancy } from "../../helpers/lotOccupancyDB/copyLotOccupancy.js";
|
||||||
|
export const handler = async (request, response) => {
|
||||||
|
const lotOccupancyId = copyLotOccupancy(request.body.lotOccupancyId, request.session);
|
||||||
|
response.json({
|
||||||
|
success: true,
|
||||||
|
lotOccupancyId
|
||||||
|
});
|
||||||
|
};
|
||||||
|
export default handler;
|
||||||
|
|
@ -0,0 +1,14 @@
|
||||||
|
import type { RequestHandler } from "express";
|
||||||
|
|
||||||
|
import { copyLotOccupancy } from "../../helpers/lotOccupancyDB/copyLotOccupancy.js";
|
||||||
|
|
||||||
|
export const handler: RequestHandler = async (request, response) => {
|
||||||
|
const lotOccupancyId = copyLotOccupancy(request.body.lotOccupancyId, request.session);
|
||||||
|
|
||||||
|
response.json({
|
||||||
|
success: true,
|
||||||
|
lotOccupancyId
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
export default handler;
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
interface AddLotOccupancyForm {
|
interface AddLotOccupancyForm {
|
||||||
occupancyTypeId: string | number;
|
occupancyTypeId: string | number;
|
||||||
|
|
@ -7,5 +8,5 @@ interface AddLotOccupancyForm {
|
||||||
occupancyTypeFieldIds?: string;
|
occupancyTypeFieldIds?: string;
|
||||||
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
|
[lotOccupancyFieldValue_occupancyTypeFieldId: string]: unknown;
|
||||||
}
|
}
|
||||||
export declare const addLotOccupancy: (lotOccupancyForm: AddLotOccupancyForm, requestSession: recordTypes.PartialSession) => number;
|
export declare const addLotOccupancy: (lotOccupancyForm: AddLotOccupancyForm, requestSession: recordTypes.PartialSession, connectedDatabase?: sqlite.Database) => number;
|
||||||
export default addLotOccupancy;
|
export default addLotOccupancy;
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,8 @@ import sqlite from "better-sqlite3";
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
import * as dateTimeFunctions from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||||
import { addOrUpdateLotOccupancyField } from "./addOrUpdateLotOccupancyField.js";
|
import { addOrUpdateLotOccupancyField } from "./addOrUpdateLotOccupancyField.js";
|
||||||
export const addLotOccupancy = (lotOccupancyForm, requestSession) => {
|
export const addLotOccupancy = (lotOccupancyForm, requestSession, connectedDatabase) => {
|
||||||
const database = sqlite(databasePath);
|
const database = connectedDatabase || sqlite(databasePath);
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
const occupancyStartDate = dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyStartDateString);
|
const occupancyStartDate = dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyStartDateString);
|
||||||
if (occupancyStartDate <= 0) {
|
if (occupancyStartDate <= 0) {
|
||||||
|
|
@ -31,7 +31,9 @@ export const addLotOccupancy = (lotOccupancyForm, requestSession) => {
|
||||||
}, requestSession, database);
|
}, requestSession, database);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
database.close();
|
if (!connectedDatabase) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
return lotOccupancyId;
|
return lotOccupancyId;
|
||||||
};
|
};
|
||||||
export default addLotOccupancy;
|
export default addLotOccupancy;
|
||||||
|
|
|
||||||
|
|
@ -21,9 +21,10 @@ interface AddLotOccupancyForm {
|
||||||
|
|
||||||
export const addLotOccupancy = (
|
export const addLotOccupancy = (
|
||||||
lotOccupancyForm: AddLotOccupancyForm,
|
lotOccupancyForm: AddLotOccupancyForm,
|
||||||
requestSession: recordTypes.PartialSession
|
requestSession: recordTypes.PartialSession,
|
||||||
|
connectedDatabase?: sqlite.Database
|
||||||
): number => {
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = connectedDatabase || sqlite(databasePath);
|
||||||
|
|
||||||
const rightNowMillis = Date.now();
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
|
|
@ -50,9 +51,7 @@ export const addLotOccupancy = (
|
||||||
occupancyStartDate,
|
occupancyStartDate,
|
||||||
lotOccupancyForm.occupancyEndDateString === ""
|
lotOccupancyForm.occupancyEndDateString === ""
|
||||||
? undefined
|
? undefined
|
||||||
: dateTimeFunctions.dateStringToInteger(
|
: dateTimeFunctions.dateStringToInteger(lotOccupancyForm.occupancyEndDateString),
|
||||||
lotOccupancyForm.occupancyEndDateString
|
|
||||||
),
|
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
rightNowMillis,
|
rightNowMillis,
|
||||||
requestSession.user.userName,
|
requestSession.user.userName,
|
||||||
|
|
@ -61,9 +60,7 @@ export const addLotOccupancy = (
|
||||||
|
|
||||||
const lotOccupancyId = result.lastInsertRowid as number;
|
const lotOccupancyId = result.lastInsertRowid as number;
|
||||||
|
|
||||||
const occupancyTypeFieldIds = (
|
const occupancyTypeFieldIds = (lotOccupancyForm.occupancyTypeFieldIds || "").split(",");
|
||||||
lotOccupancyForm.occupancyTypeFieldIds || ""
|
|
||||||
).split(",");
|
|
||||||
|
|
||||||
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
for (const occupancyTypeFieldId of occupancyTypeFieldIds) {
|
||||||
const lotOccupancyFieldValue = lotOccupancyForm[
|
const lotOccupancyFieldValue = lotOccupancyForm[
|
||||||
|
|
@ -83,7 +80,9 @@ export const addLotOccupancy = (
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close();
|
if (!connectedDatabase) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
|
||||||
return lotOccupancyId;
|
return lotOccupancyId;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
interface AddLotOccupancyOccupantForm {
|
interface AddLotOccupancyOccupantForm {
|
||||||
lotOccupancyId: string | number;
|
lotOccupancyId: string | number;
|
||||||
|
|
@ -11,5 +12,5 @@ interface AddLotOccupancyOccupantForm {
|
||||||
occupantPhoneNumber: string;
|
occupantPhoneNumber: string;
|
||||||
occupantEmailAddress: string;
|
occupantEmailAddress: string;
|
||||||
}
|
}
|
||||||
export declare const addLotOccupancyOccupant: (lotOccupancyOccupantForm: AddLotOccupancyOccupantForm, requestSession: recordTypes.PartialSession) => number;
|
export declare const addLotOccupancyOccupant: (lotOccupancyOccupantForm: AddLotOccupancyOccupantForm, requestSession: recordTypes.PartialSession, connectedDatabase?: sqlite.Database) => number;
|
||||||
export default addLotOccupancyOccupant;
|
export default addLotOccupancyOccupant;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import sqlite from "better-sqlite3";
|
import sqlite from "better-sqlite3";
|
||||||
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
export const addLotOccupancyOccupant = (lotOccupancyOccupantForm, requestSession) => {
|
export const addLotOccupancyOccupant = (lotOccupancyOccupantForm, requestSession, connectedDatabase) => {
|
||||||
const database = sqlite(databasePath);
|
const database = connectedDatabase || sqlite(databasePath);
|
||||||
let lotOccupantIndex = 0;
|
let lotOccupantIndex = 0;
|
||||||
const maxIndexResult = database
|
const maxIndexResult = database
|
||||||
.prepare("select lotOccupantIndex" +
|
.prepare("select lotOccupantIndex" +
|
||||||
|
|
@ -26,7 +26,9 @@ export const addLotOccupancyOccupant = (lotOccupancyOccupantForm, requestSession
|
||||||
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
" recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
" values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)")
|
||||||
.run(lotOccupancyOccupantForm.lotOccupancyId, lotOccupantIndex, lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.lotOccupantTypeId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
.run(lotOccupancyOccupantForm.lotOccupancyId, lotOccupantIndex, lotOccupancyOccupantForm.occupantName, lotOccupancyOccupantForm.occupantAddress1, lotOccupancyOccupantForm.occupantAddress2, lotOccupancyOccupantForm.occupantCity, lotOccupancyOccupantForm.occupantProvince, lotOccupancyOccupantForm.occupantPostalCode, lotOccupancyOccupantForm.occupantPhoneNumber, lotOccupancyOccupantForm.occupantEmailAddress, lotOccupancyOccupantForm.lotOccupantTypeId, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
database.close();
|
if (!connectedDatabase) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
return lotOccupantIndex;
|
return lotOccupantIndex;
|
||||||
};
|
};
|
||||||
export default addLotOccupancyOccupant;
|
export default addLotOccupancyOccupant;
|
||||||
|
|
|
||||||
|
|
@ -19,9 +19,10 @@ interface AddLotOccupancyOccupantForm {
|
||||||
|
|
||||||
export const addLotOccupancyOccupant = (
|
export const addLotOccupancyOccupant = (
|
||||||
lotOccupancyOccupantForm: AddLotOccupancyOccupantForm,
|
lotOccupancyOccupantForm: AddLotOccupancyOccupantForm,
|
||||||
requestSession: recordTypes.PartialSession
|
requestSession: recordTypes.PartialSession,
|
||||||
|
connectedDatabase?: sqlite.Database
|
||||||
): number => {
|
): number => {
|
||||||
const database = sqlite(databasePath);
|
const database = connectedDatabase || sqlite(databasePath);
|
||||||
|
|
||||||
let lotOccupantIndex = 0;
|
let lotOccupantIndex = 0;
|
||||||
|
|
||||||
|
|
@ -72,7 +73,9 @@ export const addLotOccupancyOccupant = (
|
||||||
rightNowMillis
|
rightNowMillis
|
||||||
);
|
);
|
||||||
|
|
||||||
database.close();
|
if (!connectedDatabase) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
|
||||||
return lotOccupantIndex;
|
return lotOccupantIndex;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
export declare const copyLotOccupancy: (oldLotOccupancyId: number | string, requestSession: recordTypes.PartialSession) => number;
|
||||||
|
export default copyLotOccupancy;
|
||||||
|
|
@ -0,0 +1,42 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
|
import { getLotOccupancy } from "./getLotOccupancy.js";
|
||||||
|
import { addLotOccupancy } from "./addLotOccupancy.js";
|
||||||
|
import { addLotOccupancyOccupant } from "./addLotOccupancyOccupant.js";
|
||||||
|
import { dateToString } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||||
|
export const copyLotOccupancy = (oldLotOccupancyId, requestSession) => {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
const oldLotOccupancy = getLotOccupancy(oldLotOccupancyId, database);
|
||||||
|
const newLotOccupancyId = addLotOccupancy({
|
||||||
|
lotId: oldLotOccupancy.lotId || "",
|
||||||
|
occupancyTypeId: oldLotOccupancy.occupancyTypeId,
|
||||||
|
occupancyStartDateString: dateToString(new Date()),
|
||||||
|
occupancyEndDateString: ""
|
||||||
|
}, requestSession, database);
|
||||||
|
const rightNowMillis = Date.now();
|
||||||
|
for (const occupancyField of oldLotOccupancy.lotOccupancyFields) {
|
||||||
|
database
|
||||||
|
.prepare("insert into LotOccupancyFields" +
|
||||||
|
" (lotOccupancyId, occupancyTypeFieldId, lotOccupancyFieldValue," +
|
||||||
|
" recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
|
" values (?, ?, ?, ?, ?, ?, ?)")
|
||||||
|
.run(newLotOccupancyId, occupancyField.occupancyTypeFieldId, occupancyField.lotOccupancyFieldValue, requestSession.user.userName, rightNowMillis, requestSession.user.userName, rightNowMillis);
|
||||||
|
}
|
||||||
|
for (const occupant of oldLotOccupancy.lotOccupancyOccupants) {
|
||||||
|
addLotOccupancyOccupant({
|
||||||
|
lotOccupancyId: newLotOccupancyId,
|
||||||
|
lotOccupantTypeId: occupant.lotOccupantTypeId,
|
||||||
|
occupantName: occupant.occupantName,
|
||||||
|
occupantAddress1: occupant.occupantAddress1,
|
||||||
|
occupantAddress2: occupant.occupantAddress2,
|
||||||
|
occupantCity: occupant.occupantCity,
|
||||||
|
occupantProvince: occupant.occupantProvince,
|
||||||
|
occupantPostalCode: occupant.occupantPostalCode,
|
||||||
|
occupantPhoneNumber: occupant.occupantPhoneNumber,
|
||||||
|
occupantEmailAddress: occupant.occupantEmailAddress
|
||||||
|
}, requestSession, database);
|
||||||
|
}
|
||||||
|
database.close();
|
||||||
|
return newLotOccupancyId;
|
||||||
|
};
|
||||||
|
export default copyLotOccupancy;
|
||||||
|
|
@ -0,0 +1,81 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
|
|
||||||
|
import { lotOccupancyDB as databasePath } from "../../data/databasePaths.js";
|
||||||
|
|
||||||
|
import { getLotOccupancy } from "./getLotOccupancy.js";
|
||||||
|
import { addLotOccupancy } from "./addLotOccupancy.js";
|
||||||
|
import { addLotOccupancyOccupant } from "./addLotOccupancyOccupant.js";
|
||||||
|
|
||||||
|
import { dateToString } from "@cityssm/expressjs-server-js/dateTimeFns.js";
|
||||||
|
|
||||||
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
|
export const copyLotOccupancy = (
|
||||||
|
oldLotOccupancyId: number | string,
|
||||||
|
requestSession: recordTypes.PartialSession
|
||||||
|
): number => {
|
||||||
|
const database = sqlite(databasePath);
|
||||||
|
|
||||||
|
const oldLotOccupancy = getLotOccupancy(oldLotOccupancyId, database);
|
||||||
|
|
||||||
|
const newLotOccupancyId = addLotOccupancy(
|
||||||
|
{
|
||||||
|
lotId: oldLotOccupancy.lotId || "",
|
||||||
|
occupancyTypeId: oldLotOccupancy.occupancyTypeId,
|
||||||
|
occupancyStartDateString: dateToString(new Date()),
|
||||||
|
occupancyEndDateString: ""
|
||||||
|
},
|
||||||
|
requestSession,
|
||||||
|
database
|
||||||
|
);
|
||||||
|
|
||||||
|
// Copy Fields
|
||||||
|
|
||||||
|
const rightNowMillis = Date.now();
|
||||||
|
|
||||||
|
for (const occupancyField of oldLotOccupancy.lotOccupancyFields) {
|
||||||
|
database
|
||||||
|
.prepare(
|
||||||
|
"insert into LotOccupancyFields" +
|
||||||
|
" (lotOccupancyId, occupancyTypeFieldId, lotOccupancyFieldValue," +
|
||||||
|
" recordCreate_userName, recordCreate_timeMillis, recordUpdate_userName, recordUpdate_timeMillis)" +
|
||||||
|
" values (?, ?, ?, ?, ?, ?, ?)"
|
||||||
|
)
|
||||||
|
.run(
|
||||||
|
newLotOccupancyId,
|
||||||
|
occupancyField.occupancyTypeFieldId,
|
||||||
|
occupancyField.lotOccupancyFieldValue,
|
||||||
|
requestSession.user.userName,
|
||||||
|
rightNowMillis,
|
||||||
|
requestSession.user.userName,
|
||||||
|
rightNowMillis
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy Occupants
|
||||||
|
|
||||||
|
for (const occupant of oldLotOccupancy.lotOccupancyOccupants) {
|
||||||
|
addLotOccupancyOccupant(
|
||||||
|
{
|
||||||
|
lotOccupancyId: newLotOccupancyId,
|
||||||
|
lotOccupantTypeId: occupant.lotOccupantTypeId,
|
||||||
|
occupantName: occupant.occupantName,
|
||||||
|
occupantAddress1: occupant.occupantAddress1,
|
||||||
|
occupantAddress2: occupant.occupantAddress2,
|
||||||
|
occupantCity: occupant.occupantCity,
|
||||||
|
occupantProvince: occupant.occupantProvince,
|
||||||
|
occupantPostalCode: occupant.occupantPostalCode,
|
||||||
|
occupantPhoneNumber: occupant.occupantPhoneNumber,
|
||||||
|
occupantEmailAddress: occupant.occupantEmailAddress
|
||||||
|
},
|
||||||
|
requestSession,
|
||||||
|
database
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
database.close();
|
||||||
|
|
||||||
|
return newLotOccupancyId;
|
||||||
|
};
|
||||||
|
|
||||||
|
export default copyLotOccupancy;
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
import sqlite from "better-sqlite3";
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
export declare const getLotOccupancy: (lotOccupancyId: number | string) => recordTypes.LotOccupancy;
|
export declare const getLotOccupancy: (lotOccupancyId: number | string, connectedDatabase?: sqlite.Database) => recordTypes.LotOccupancy;
|
||||||
export default getLotOccupancy;
|
export default getLotOccupancy;
|
||||||
|
|
|
||||||
|
|
@ -6,10 +6,11 @@ import { getLotOccupancyComments } from "./getLotOccupancyComments.js";
|
||||||
import { getLotOccupancyFields } from "./getLotOccupancyFields.js";
|
import { getLotOccupancyFields } from "./getLotOccupancyFields.js";
|
||||||
import { getLotOccupancyFees } from "./getLotOccupancyFees.js";
|
import { getLotOccupancyFees } from "./getLotOccupancyFees.js";
|
||||||
import { getLotOccupancyTransactions } from "./getLotOccupancyTransactions.js";
|
import { getLotOccupancyTransactions } from "./getLotOccupancyTransactions.js";
|
||||||
export const getLotOccupancy = (lotOccupancyId) => {
|
export const getLotOccupancy = (lotOccupancyId, connectedDatabase) => {
|
||||||
const database = sqlite(databasePath, {
|
const database = connectedDatabase ||
|
||||||
readonly: true
|
sqlite(databasePath, {
|
||||||
});
|
readonly: true
|
||||||
|
});
|
||||||
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
||||||
const lotOccupancy = database
|
const lotOccupancy = database
|
||||||
.prepare("select o.lotOccupancyId," +
|
.prepare("select o.lotOccupancyId," +
|
||||||
|
|
@ -33,7 +34,9 @@ export const getLotOccupancy = (lotOccupancyId) => {
|
||||||
lotOccupancy.lotOccupancyFees = getLotOccupancyFees(lotOccupancyId, database);
|
lotOccupancy.lotOccupancyFees = getLotOccupancyFees(lotOccupancyId, database);
|
||||||
lotOccupancy.lotOccupancyTransactions = getLotOccupancyTransactions(lotOccupancyId, database);
|
lotOccupancy.lotOccupancyTransactions = getLotOccupancyTransactions(lotOccupancyId, database);
|
||||||
}
|
}
|
||||||
database.close();
|
if (!connectedDatabase) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
return lotOccupancy;
|
return lotOccupancy;
|
||||||
};
|
};
|
||||||
export default getLotOccupancy;
|
export default getLotOccupancy;
|
||||||
|
|
|
||||||
|
|
@ -17,11 +17,14 @@ import { getLotOccupancyTransactions } from "./getLotOccupancyTransactions.js";
|
||||||
import type * as recordTypes from "../../types/recordTypes";
|
import type * as recordTypes from "../../types/recordTypes";
|
||||||
|
|
||||||
export const getLotOccupancy = (
|
export const getLotOccupancy = (
|
||||||
lotOccupancyId: number | string
|
lotOccupancyId: number | string,
|
||||||
|
connectedDatabase?: sqlite.Database
|
||||||
): recordTypes.LotOccupancy => {
|
): recordTypes.LotOccupancy => {
|
||||||
const database = sqlite(databasePath, {
|
const database =
|
||||||
readonly: true
|
connectedDatabase ||
|
||||||
});
|
sqlite(databasePath, {
|
||||||
|
readonly: true
|
||||||
|
});
|
||||||
|
|
||||||
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
database.function("userFn_dateIntegerToString", dateIntegerToString);
|
||||||
|
|
||||||
|
|
@ -44,29 +47,19 @@ export const getLotOccupancy = (
|
||||||
.get(lotOccupancyId);
|
.get(lotOccupancyId);
|
||||||
|
|
||||||
if (lotOccupancy) {
|
if (lotOccupancy) {
|
||||||
lotOccupancy.lotOccupancyFields = getLotOccupancyFields(
|
lotOccupancy.lotOccupancyFields = getLotOccupancyFields(lotOccupancyId, database);
|
||||||
lotOccupancyId,
|
lotOccupancy.lotOccupancyOccupants = getLotOccupancyOccupants(lotOccupancyId, database);
|
||||||
database
|
lotOccupancy.lotOccupancyComments = getLotOccupancyComments(lotOccupancyId, database);
|
||||||
);
|
lotOccupancy.lotOccupancyFees = getLotOccupancyFees(lotOccupancyId, database);
|
||||||
lotOccupancy.lotOccupancyOccupants = getLotOccupancyOccupants(
|
|
||||||
lotOccupancyId,
|
|
||||||
database
|
|
||||||
);
|
|
||||||
lotOccupancy.lotOccupancyComments = getLotOccupancyComments(
|
|
||||||
lotOccupancyId,
|
|
||||||
database
|
|
||||||
);
|
|
||||||
lotOccupancy.lotOccupancyFees = getLotOccupancyFees(
|
|
||||||
lotOccupancyId,
|
|
||||||
database
|
|
||||||
);
|
|
||||||
lotOccupancy.lotOccupancyTransactions = getLotOccupancyTransactions(
|
lotOccupancy.lotOccupancyTransactions = getLotOccupancyTransactions(
|
||||||
lotOccupancyId,
|
lotOccupancyId,
|
||||||
database
|
database
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
database.close();
|
if (!connectedDatabase) {
|
||||||
|
database.close();
|
||||||
|
}
|
||||||
|
|
||||||
return lotOccupancy;
|
return lotOccupancy;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,49 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
formInputElement.addEventListener("change", setUnsavedChanges);
|
formInputElement.addEventListener("change", setUnsavedChanges);
|
||||||
}
|
}
|
||||||
if (!isCreate) {
|
if (!isCreate) {
|
||||||
|
const doCopy = () => {
|
||||||
|
cityssm.postJSON(los.urlPrefix + "/lotOccupancies/doCopyLotOccupancy", {
|
||||||
|
lotOccupancyId
|
||||||
|
}, (responseJSON) => {
|
||||||
|
var _a;
|
||||||
|
if (responseJSON.success) {
|
||||||
|
cityssm.disableNavBlocker();
|
||||||
|
window.location.href =
|
||||||
|
los.urlPrefix +
|
||||||
|
"/lotOccupancies/" +
|
||||||
|
((_a = responseJSON.lotOccupancyId) === null || _a === void 0 ? void 0 : _a.toString()) +
|
||||||
|
"/edit";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Copying Record",
|
||||||
|
message: responseJSON.errorMessage || "",
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
document.querySelector("#button--copyLotOccupancy").addEventListener("click", (clickEvent) => {
|
||||||
|
clickEvent.preventDefault();
|
||||||
|
if (hasUnsavedChanges) {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Unsaved Changes",
|
||||||
|
message: "Please save all unsaved changes before continuing.",
|
||||||
|
contextualColorName: "warning"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bulmaJS.confirm({
|
||||||
|
title: "Copy " + exports.aliases.occupancy + " Record as New",
|
||||||
|
message: "Are you sure you want to copy this record to a new record?",
|
||||||
|
contextualColorName: "info",
|
||||||
|
okButton: {
|
||||||
|
text: "Yes, Copy",
|
||||||
|
callbackFunction: doCopy
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
document.querySelector("#button--deleteLotOccupancy").addEventListener("click", (clickEvent) => {
|
document.querySelector("#button--deleteLotOccupancy").addEventListener("click", (clickEvent) => {
|
||||||
clickEvent.preventDefault();
|
clickEvent.preventDefault();
|
||||||
const doDelete = () => {
|
const doDelete = () => {
|
||||||
|
|
@ -1104,7 +1147,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
cityssm.escapeHTML(fee.feeName || "") +
|
cityssm.escapeHTML(fee.feeName || "") +
|
||||||
"</strong><br />" +
|
"</strong><br />" +
|
||||||
"<small>" +
|
"<small>" +
|
||||||
cityssm.escapeHTML(fee.feeDescription || "").replace(/\n/g, "<br />") +
|
cityssm
|
||||||
|
.escapeHTML(fee.feeDescription || "")
|
||||||
|
.replace(/\n/g, "<br />") +
|
||||||
"</small>";
|
"</small>";
|
||||||
panelBlockElement.addEventListener("click", tryAddFee);
|
panelBlockElement.addEventListener("click", tryAddFee);
|
||||||
categoryContainerElement.querySelector(".panel").append(panelBlockElement);
|
categoryContainerElement.querySelector(".panel").append(panelBlockElement);
|
||||||
|
|
|
||||||
|
|
@ -86,8 +86,64 @@ declare const bulmaJS: BulmaJS;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isCreate) {
|
if (!isCreate) {
|
||||||
|
|
||||||
|
const doCopy = () => {
|
||||||
|
cityssm.postJSON(
|
||||||
|
los.urlPrefix + "/lotOccupancies/doCopyLotOccupancy",
|
||||||
|
{
|
||||||
|
lotOccupancyId
|
||||||
|
},
|
||||||
|
(responseJSON: {
|
||||||
|
success: boolean;
|
||||||
|
errorMessage?: string;
|
||||||
|
lotOccupancyId?: number;
|
||||||
|
}) => {
|
||||||
|
if (responseJSON.success) {
|
||||||
|
cityssm.disableNavBlocker();
|
||||||
|
window.location.href =
|
||||||
|
los.urlPrefix +
|
||||||
|
"/lotOccupancies/" +
|
||||||
|
responseJSON.lotOccupancyId?.toString() +
|
||||||
|
"/edit";
|
||||||
|
} else {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Error Copying Record",
|
||||||
|
message: responseJSON.errorMessage || "",
|
||||||
|
contextualColorName: "danger"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
(document.querySelector("#button--copyLotOccupancy") as HTMLAnchorElement).addEventListener(
|
||||||
|
"click",
|
||||||
|
(clickEvent) => {
|
||||||
|
clickEvent.preventDefault();
|
||||||
|
|
||||||
|
|
||||||
|
if (hasUnsavedChanges) {
|
||||||
|
bulmaJS.alert({
|
||||||
|
title: "Unsaved Changes",
|
||||||
|
message: "Please save all unsaved changes before continuing.",
|
||||||
|
contextualColorName: "warning"
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
bulmaJS.confirm({
|
||||||
|
title: "Copy " + exports.aliases.occupancy + " Record as New",
|
||||||
|
message: "Are you sure you want to copy this record to a new record?",
|
||||||
|
contextualColorName: "info",
|
||||||
|
okButton: {
|
||||||
|
text: "Yes, Copy",
|
||||||
|
callbackFunction: doCopy
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
(
|
(
|
||||||
document.querySelector("#button--deleteLotOccupancy") as HTMLButtonElement
|
document.querySelector("#button--deleteLotOccupancy") as HTMLAnchorElement
|
||||||
).addEventListener("click", (clickEvent) => {
|
).addEventListener("click", (clickEvent) => {
|
||||||
clickEvent.preventDefault();
|
clickEvent.preventDefault();
|
||||||
|
|
||||||
|
|
@ -1717,7 +1773,9 @@ declare const bulmaJS: BulmaJS;
|
||||||
cityssm.escapeHTML(fee.feeName || "") +
|
cityssm.escapeHTML(fee.feeName || "") +
|
||||||
"</strong><br />" +
|
"</strong><br />" +
|
||||||
"<small>" +
|
"<small>" +
|
||||||
cityssm.escapeHTML(fee.feeDescription || "").replace(/\n/g, "<br />") +
|
cityssm
|
||||||
|
.escapeHTML(fee.feeDescription || "")
|
||||||
|
.replace(/\n/g, "<br />") +
|
||||||
"</small>";
|
"</small>";
|
||||||
|
|
||||||
panelBlockElement.addEventListener("click", tryAddFee);
|
panelBlockElement.addEventListener("click", tryAddFee);
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -7,6 +7,7 @@ import handler_doGetOccupancyTypeFields from "../handlers/lotOccupancies-post/do
|
||||||
import handler_doCreateLotOccupancy from "../handlers/lotOccupancies-post/doCreateLotOccupancy.js";
|
import handler_doCreateLotOccupancy from "../handlers/lotOccupancies-post/doCreateLotOccupancy.js";
|
||||||
import handler_edit from "../handlers/lotOccupancies-get/edit.js";
|
import handler_edit from "../handlers/lotOccupancies-get/edit.js";
|
||||||
import handler_doUpdateLotOccupancy from "../handlers/lotOccupancies-post/doUpdateLotOccupancy.js";
|
import handler_doUpdateLotOccupancy from "../handlers/lotOccupancies-post/doUpdateLotOccupancy.js";
|
||||||
|
import handler_doCopyLotOccupancy from "../handlers/lotOccupancies-post/doCopyLotOccupancy.js";
|
||||||
import handler_doDeleteLotOccupancy from "../handlers/lotOccupancies-post/doDeleteLotOccupancy.js";
|
import handler_doDeleteLotOccupancy from "../handlers/lotOccupancies-post/doDeleteLotOccupancy.js";
|
||||||
import handler_doSearchPastOccupants from "../handlers/lotOccupancies-post/doSearchPastOccupants.js";
|
import handler_doSearchPastOccupants from "../handlers/lotOccupancies-post/doSearchPastOccupants.js";
|
||||||
import handler_doAddLotOccupancyOccupant from "../handlers/lotOccupancies-post/doAddLotOccupancyOccupant.js";
|
import handler_doAddLotOccupancyOccupant from "../handlers/lotOccupancies-post/doAddLotOccupancyOccupant.js";
|
||||||
|
|
@ -30,6 +31,7 @@ router.post("/doCreateLotOccupancy", permissionHandlers.updatePostHandler, handl
|
||||||
router.get("/:lotOccupancyId", handler_view);
|
router.get("/:lotOccupancyId", handler_view);
|
||||||
router.get("/:lotOccupancyId/edit", permissionHandlers.updateGetHandler, handler_edit);
|
router.get("/:lotOccupancyId/edit", permissionHandlers.updateGetHandler, handler_edit);
|
||||||
router.post("/doUpdateLotOccupancy", permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancy);
|
router.post("/doUpdateLotOccupancy", permissionHandlers.updatePostHandler, handler_doUpdateLotOccupancy);
|
||||||
|
router.post("/doCopyLotOccupancy", permissionHandlers.updatePostHandler, handler_doCopyLotOccupancy);
|
||||||
router.post("/doDeleteLotOccupancy", permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancy);
|
router.post("/doDeleteLotOccupancy", permissionHandlers.updatePostHandler, handler_doDeleteLotOccupancy);
|
||||||
router.post("/doSearchPastOccupants", permissionHandlers.updatePostHandler, handler_doSearchPastOccupants);
|
router.post("/doSearchPastOccupants", permissionHandlers.updatePostHandler, handler_doSearchPastOccupants);
|
||||||
router.post("/doAddLotOccupancyOccupant", permissionHandlers.updatePostHandler, handler_doAddLotOccupancyOccupant);
|
router.post("/doAddLotOccupancyOccupant", permissionHandlers.updatePostHandler, handler_doAddLotOccupancyOccupant);
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import handler_doCreateLotOccupancy from "../handlers/lotOccupancies-post/doCrea
|
||||||
|
|
||||||
import handler_edit from "../handlers/lotOccupancies-get/edit.js";
|
import handler_edit from "../handlers/lotOccupancies-get/edit.js";
|
||||||
import handler_doUpdateLotOccupancy from "../handlers/lotOccupancies-post/doUpdateLotOccupancy.js";
|
import handler_doUpdateLotOccupancy from "../handlers/lotOccupancies-post/doUpdateLotOccupancy.js";
|
||||||
|
import handler_doCopyLotOccupancy from "../handlers/lotOccupancies-post/doCopyLotOccupancy.js";
|
||||||
import handler_doDeleteLotOccupancy from "../handlers/lotOccupancies-post/doDeleteLotOccupancy.js";
|
import handler_doDeleteLotOccupancy from "../handlers/lotOccupancies-post/doDeleteLotOccupancy.js";
|
||||||
|
|
||||||
import handler_doSearchPastOccupants from "../handlers/lotOccupancies-post/doSearchPastOccupants.js";
|
import handler_doSearchPastOccupants from "../handlers/lotOccupancies-post/doSearchPastOccupants.js";
|
||||||
|
|
@ -73,6 +74,12 @@ router.post(
|
||||||
handler_doUpdateLotOccupancy
|
handler_doUpdateLotOccupancy
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router.post(
|
||||||
|
"/doCopyLotOccupancy",
|
||||||
|
permissionHandlers.updatePostHandler,
|
||||||
|
handler_doCopyLotOccupancy
|
||||||
|
);
|
||||||
|
|
||||||
router.post(
|
router.post(
|
||||||
"/doDeleteLotOccupancy",
|
"/doDeleteLotOccupancy",
|
||||||
permissionHandlers.updatePostHandler,
|
permissionHandlers.updatePostHandler,
|
||||||
|
|
|
||||||
|
|
@ -282,6 +282,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="dropdown-menu">
|
<div class="dropdown-menu">
|
||||||
<div class="dropdown-content">
|
<div class="dropdown-content">
|
||||||
|
<a class="dropdown-item" id="button--copyLotOccupancy" href="#">
|
||||||
|
<span class="icon is-small"><i class="far fa-copy" aria-hidden="true"></i></span>
|
||||||
|
<span>Copy <%= configFunctions.getProperty("aliases.occupancy") %> Record as New</span>
|
||||||
|
</a>
|
||||||
<a class="dropdown-item" id="button--deleteLotOccupancy" href="#">
|
<a class="dropdown-item" id="button--deleteLotOccupancy" href="#">
|
||||||
<span class="icon is-small"><i class="fas fa-trash has-text-danger" aria-hidden="true"></i></span>
|
<span class="icon is-small"><i class="fas fa-trash has-text-danger" aria-hidden="true"></i></span>
|
||||||
<span>Delete <%= configFunctions.getProperty("aliases.occupancy") %> Record</span>
|
<span>Delete <%= configFunctions.getProperty("aliases.occupancy") %> Record</span>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue