reduce url duplication
parent
da821b1d28
commit
c33e52102e
|
|
@ -353,25 +353,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
* URLs
|
* URLs
|
||||||
*/
|
*/
|
||||||
const urlPrefix = document.querySelector("main").dataset.urlPrefix;
|
const urlPrefix = document.querySelector("main").dataset.urlPrefix;
|
||||||
|
function getRecordURL(recordTypePlural, recordId, edit, time) {
|
||||||
|
return (urlPrefix +
|
||||||
|
"/" +
|
||||||
|
recordTypePlural +
|
||||||
|
"/" +
|
||||||
|
recordId +
|
||||||
|
(edit ? "/edit" : "") +
|
||||||
|
(time ? "/?t=" + Date.now() : ""));
|
||||||
|
}
|
||||||
function getMapURL(mapId, edit = false, time = false) {
|
function getMapURL(mapId, edit = false, time = false) {
|
||||||
return urlPrefix + "/maps/" + mapId + (edit ? "/edit" : "") + (time ? "/?t=" + Date.now() : "");
|
return getRecordURL("maps", mapId, edit, time);
|
||||||
}
|
}
|
||||||
function getLotURL(lotId, edit = false, time = false) {
|
function getLotURL(lotId, edit = false, time = false) {
|
||||||
return urlPrefix + "/lots/" + lotId + (edit ? "/edit" : "") + (time ? "/?t=" + Date.now() : "");
|
return getRecordURL("lots", lotId, edit, time);
|
||||||
}
|
}
|
||||||
function getLotOccupancyURL(lotOccupancyId, edit = false, time = false) {
|
function getLotOccupancyURL(lotOccupancyId, edit = false, time = false) {
|
||||||
return (urlPrefix +
|
return getRecordURL("lotOccupancies", lotOccupancyId, edit, time);
|
||||||
"/lotOccupancies/" +
|
|
||||||
lotOccupancyId +
|
|
||||||
(edit ? "/edit" : "") +
|
|
||||||
(time ? "/?t=" + Date.now() : ""));
|
|
||||||
}
|
}
|
||||||
function getWorkOrderURL(workOrderId, edit = false, time = false) {
|
function getWorkOrderURL(workOrderId, edit = false, time = false) {
|
||||||
return (urlPrefix +
|
return getRecordURL("workOrders", workOrderId, edit, time);
|
||||||
"/workOrders/" +
|
|
||||||
workOrderId +
|
|
||||||
(edit ? "/edit" : "") +
|
|
||||||
(time ? "/?t=" + Date.now() : ""));
|
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* Declare LOS
|
* Declare LOS
|
||||||
|
|
|
||||||
|
|
@ -438,32 +438,37 @@ declare const bulmaJS: BulmaJS;
|
||||||
|
|
||||||
const urlPrefix = document.querySelector("main")!.dataset.urlPrefix!;
|
const urlPrefix = document.querySelector("main")!.dataset.urlPrefix!;
|
||||||
|
|
||||||
|
function getRecordURL(
|
||||||
|
recordTypePlural: "maps" | "lots" | "lotOccupancies" | "workOrders",
|
||||||
|
recordId: number | string,
|
||||||
|
edit: boolean,
|
||||||
|
time: boolean
|
||||||
|
): string {
|
||||||
|
return (
|
||||||
|
urlPrefix +
|
||||||
|
"/" +
|
||||||
|
recordTypePlural +
|
||||||
|
"/" +
|
||||||
|
recordId +
|
||||||
|
(edit ? "/edit" : "") +
|
||||||
|
(time ? "/?t=" + Date.now() : "")
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function getMapURL(mapId: number | string, edit = false, time = false) {
|
function getMapURL(mapId: number | string, edit = false, time = false) {
|
||||||
return urlPrefix + "/maps/" + mapId + (edit ? "/edit" : "") + (time ? "/?t=" + Date.now() : "");
|
return getRecordURL("maps", mapId, edit, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLotURL(lotId: number | string, edit = false, time = false) {
|
function getLotURL(lotId: number | string, edit = false, time = false) {
|
||||||
return urlPrefix + "/lots/" + lotId + (edit ? "/edit" : "") + (time ? "/?t=" + Date.now() : "");
|
return getRecordURL("lots", lotId, edit, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getLotOccupancyURL(lotOccupancyId: number | string, edit = false, time = false) {
|
function getLotOccupancyURL(lotOccupancyId: number | string, edit = false, time = false) {
|
||||||
return (
|
return getRecordURL("lotOccupancies", lotOccupancyId, edit, time);
|
||||||
urlPrefix +
|
|
||||||
"/lotOccupancies/" +
|
|
||||||
lotOccupancyId +
|
|
||||||
(edit ? "/edit" : "") +
|
|
||||||
(time ? "/?t=" + Date.now() : "")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getWorkOrderURL(workOrderId: number | string, edit = false, time = false) {
|
function getWorkOrderURL(workOrderId: number | string, edit = false, time = false) {
|
||||||
return (
|
return getRecordURL("workOrders", workOrderId, edit, time);
|
||||||
urlPrefix +
|
|
||||||
"/workOrders/" +
|
|
||||||
workOrderId +
|
|
||||||
(edit ? "/edit" : "") +
|
|
||||||
(time ? "/?t=" + Date.now() : "")
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -247,9 +247,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
"</td>" +
|
"</td>" +
|
||||||
("<td>" +
|
("<td>" +
|
||||||
'<a class="has-text-weight-bold" href="' +
|
'<a class="has-text-weight-bold" href="' +
|
||||||
cityssm.escapeHTML(los.urlPrefix) +
|
los.getLotOccupancyURL(lotOccupancy.lotOccupancyId) +
|
||||||
"/lotOccupancies/" +
|
|
||||||
lotOccupancy.lotOccupancyId +
|
|
||||||
'">' +
|
'">' +
|
||||||
cityssm.escapeHTML(lotOccupancy.occupancyType || "") +
|
cityssm.escapeHTML(lotOccupancy.occupancyType || "") +
|
||||||
"</a>" +
|
"</a>" +
|
||||||
|
|
@ -434,9 +432,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
rowElement.innerHTML =
|
rowElement.innerHTML =
|
||||||
"<td>" +
|
"<td>" +
|
||||||
'<a class="has-text-weight-bold" href="' +
|
'<a class="has-text-weight-bold" href="' +
|
||||||
cityssm.escapeHTML(los.urlPrefix) +
|
los.getLotURL(lot.lotId) +
|
||||||
"/lots/" +
|
|
||||||
lot.lotId +
|
|
||||||
'">' +
|
'">' +
|
||||||
cityssm.escapeHTML(lot.lotName || "") +
|
cityssm.escapeHTML(lot.lotName || "") +
|
||||||
"</a>" +
|
"</a>" +
|
||||||
|
|
|
||||||
|
|
@ -119,9 +119,7 @@ function renderRelatedOccupancies() {
|
||||||
"</td>" +
|
"</td>" +
|
||||||
("<td>" +
|
("<td>" +
|
||||||
'<a class="has-text-weight-bold" href="' +
|
'<a class="has-text-weight-bold" href="' +
|
||||||
cityssm.escapeHTML(los.urlPrefix) +
|
los.getLotOccupancyURL(lotOccupancy.lotOccupancyId) +
|
||||||
"/lotOccupancies/" +
|
|
||||||
lotOccupancy.lotOccupancyId +
|
|
||||||
'">' +
|
'">' +
|
||||||
cityssm.escapeHTML(lotOccupancy.occupancyType || "") +
|
cityssm.escapeHTML(lotOccupancy.occupancyType || "") +
|
||||||
"</a>" +
|
"</a>" +
|
||||||
|
|
@ -306,9 +304,7 @@ function renderRelatedLots() {
|
||||||
rowElement.innerHTML =
|
rowElement.innerHTML =
|
||||||
"<td>" +
|
"<td>" +
|
||||||
'<a class="has-text-weight-bold" href="' +
|
'<a class="has-text-weight-bold" href="' +
|
||||||
cityssm.escapeHTML(los.urlPrefix) +
|
los.getLotURL(lot.lotId) +
|
||||||
"/lots/" +
|
|
||||||
lot.lotId +
|
|
||||||
'">' +
|
'">' +
|
||||||
cityssm.escapeHTML(lot.lotName || "") +
|
cityssm.escapeHTML(lot.lotName || "") +
|
||||||
"</a>" +
|
"</a>" +
|
||||||
|
|
|
||||||
|
|
@ -174,9 +174,7 @@ function renderRelatedOccupancies(): void {
|
||||||
"</td>" +
|
"</td>" +
|
||||||
("<td>" +
|
("<td>" +
|
||||||
'<a class="has-text-weight-bold" href="' +
|
'<a class="has-text-weight-bold" href="' +
|
||||||
cityssm.escapeHTML(los.urlPrefix) +
|
los.getLotOccupancyURL(lotOccupancy.lotOccupancyId!) +
|
||||||
"/lotOccupancies/" +
|
|
||||||
lotOccupancy.lotOccupancyId +
|
|
||||||
'">' +
|
'">' +
|
||||||
cityssm.escapeHTML(lotOccupancy.occupancyType || "") +
|
cityssm.escapeHTML(lotOccupancy.occupancyType || "") +
|
||||||
"</a>" +
|
"</a>" +
|
||||||
|
|
@ -427,9 +425,7 @@ function renderRelatedLots(): void {
|
||||||
rowElement.innerHTML =
|
rowElement.innerHTML =
|
||||||
"<td>" +
|
"<td>" +
|
||||||
'<a class="has-text-weight-bold" href="' +
|
'<a class="has-text-weight-bold" href="' +
|
||||||
cityssm.escapeHTML(los.urlPrefix) +
|
los.getLotURL(lot.lotId) +
|
||||||
"/lots/" +
|
|
||||||
lot.lotId +
|
|
||||||
'">' +
|
'">' +
|
||||||
cityssm.escapeHTML(lot.lotName || "") +
|
cityssm.escapeHTML(lot.lotName || "") +
|
||||||
"</a>" +
|
"</a>" +
|
||||||
|
|
|
||||||
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