clear lot value

deepsource-autofix-76c6eb20
Dan Gowans 2022-09-01 14:20:00 -04:00
parent 2cb0bf3697
commit d10cc97417
4 changed files with 78 additions and 37 deletions

View File

@ -147,7 +147,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
} }
}); });
} }
document.querySelector("#lotOccupancy--lotName").addEventListener("click", (clickEvent) => { const lotNameElement = document.querySelector("#lotOccupancy--lotName");
lotNameElement.addEventListener("click", (clickEvent) => {
const currentLotName = clickEvent.currentTarget.value; const currentLotName = clickEvent.currentTarget.value;
let lotSelectCloseModalFunction; let lotSelectCloseModalFunction;
let lotSelectFormElement; let lotSelectFormElement;
@ -210,7 +211,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
bulmaJS.toggleHtmlClipped(); bulmaJS.toggleHtmlClipped();
lotSelectCloseModalFunction = closeModalFunction; lotSelectCloseModalFunction = closeModalFunction;
const lotNameFilterElement = modalElement.querySelector("#lotSelect--lotName"); const lotNameFilterElement = modalElement.querySelector("#lotSelect--lotName");
lotNameFilterElement.value = currentLotName; if (document.querySelector("#lotOccupancy--lotId").value !== "") {
lotNameFilterElement.value = currentLotName;
}
lotNameFilterElement.focus(); lotNameFilterElement.focus();
lotNameFilterElement.addEventListener("change", searchLots); lotNameFilterElement.addEventListener("change", searchLots);
const occupancyStatusFilterElement = modalElement.querySelector("#lotSelect--occupancyStatus"); const occupancyStatusFilterElement = modalElement.querySelector("#lotSelect--occupancyStatus");
@ -242,6 +245,19 @@ Object.defineProperty(exports, "__esModule", { value: true });
}); });
} }
}); });
document.querySelector(".is-clear-lot-button").addEventListener("click", () => {
if (lotNameElement.disabled) {
bulmaJS.alert({
message: "You need to unlock the field before clearing it.",
contextualColorName: "info"
});
}
else {
lotNameElement.value = "(No " + exports.aliases.lot + ")";
document.querySelector("#lotOccupancy--lotId").value = "";
setUnsavedChanges();
}
});
document.querySelector("#lotOccupancy--occupancyStartDateString").addEventListener("change", () => { document.querySelector("#lotOccupancy--occupancyStartDateString").addEventListener("change", () => {
document.querySelector("#lotOccupancy--occupancyEndDateString").min = document.querySelector("#lotOccupancy--occupancyEndDateString").min =
document.querySelector("#lotOccupancy--occupancyStartDateString").value; document.querySelector("#lotOccupancy--occupancyStartDateString").value;

View File

@ -224,7 +224,9 @@ declare const bulmaJS: BulmaJS;
// Lot Selector // Lot Selector
document.querySelector("#lotOccupancy--lotName").addEventListener("click", (clickEvent) => { const lotNameElement = document.querySelector("#lotOccupancy--lotName") as HTMLInputElement;
lotNameElement.addEventListener("click", (clickEvent) => {
const currentLotName = (clickEvent.currentTarget as HTMLInputElement).value; const currentLotName = (clickEvent.currentTarget as HTMLInputElement).value;
@ -302,7 +304,7 @@ declare const bulmaJS: BulmaJS;
lotSelectResultsElement.innerHTML = ""; lotSelectResultsElement.innerHTML = "";
lotSelectResultsElement.append(panelElement); lotSelectResultsElement.append(panelElement);
}); });
} };
cityssm.openHtmlModal("lotOccupancy-selectLot", { cityssm.openHtmlModal("lotOccupancy-selectLot", {
onshow: (modalElement) => { onshow: (modalElement) => {
@ -315,7 +317,11 @@ declare const bulmaJS: BulmaJS;
lotSelectCloseModalFunction = closeModalFunction; lotSelectCloseModalFunction = closeModalFunction;
const lotNameFilterElement = modalElement.querySelector("#lotSelect--lotName") as HTMLInputElement; const lotNameFilterElement = modalElement.querySelector("#lotSelect--lotName") as HTMLInputElement;
lotNameFilterElement.value = currentLotName;
if ((document.querySelector("#lotOccupancy--lotId") as HTMLInputElement).value !== "") {
lotNameFilterElement.value = currentLotName;
}
lotNameFilterElement.focus(); lotNameFilterElement.focus();
lotNameFilterElement.addEventListener("change", searchLots); lotNameFilterElement.addEventListener("change", searchLots);
@ -355,6 +361,20 @@ declare const bulmaJS: BulmaJS;
} }
}); });
document.querySelector(".is-clear-lot-button").addEventListener("click", () => {
if (lotNameElement.disabled) {
bulmaJS.alert({
message: "You need to unlock the field before clearing it.",
contextualColorName: "info"
});
} else {
lotNameElement.value = "(No " + exports.aliases.lot + ")";
(document.querySelector("#lotOccupancy--lotId") as HTMLInputElement).value = "";
setUnsavedChanges();
}
});
// Start Date // Start Date
document.querySelector("#lotOccupancy--occupancyStartDateString").addEventListener("change", () => { document.querySelector("#lotOccupancy--occupancyStartDateString").addEventListener("change", () => {

File diff suppressed because one or more lines are too long

View File

@ -1,36 +1,36 @@
<%- include('_header'); -%> <%- include('_header'); -%>
<nav class="breadcrumb"> <nav class="breadcrumb">
<ul> <ul>
<li><a href="<%= urlPrefix %>/dashboard">Home</a></li> <li><a href="<%= urlPrefix %>/dashboard">Home</a></li>
<li> <li>
<a href="<%= urlPrefix %>/lotOccupancies"> <a href="<%= urlPrefix %>/lotOccupancies">
<span class="icon is-small"> <span class="icon is-small">
<span class="fa-layers fa-fw" aria-hidden="true"> <span class="fa-layers fa-fw" aria-hidden="true">
<i class="fas fa-vector-square"></i> <i class="fas fa-vector-square"></i>
<i class="fas fa-user" data-fa-transform="shrink-10"></i> <i class="fas fa-user" data-fa-transform="shrink-10"></i>
</span>
</span> </span>
</span> <span><%= configFunctions.getProperty("aliases.lots") %> <%= configFunctions.getProperty("aliases.occupancies") %></span>
<span><%= configFunctions.getProperty("aliases.lots") %> <%= configFunctions.getProperty("aliases.occupancies") %></span> </a>
</a> </li>
</li> <% if (!isCreate) { %>
<% if (!isCreate) { %> <li>
<li> <a href="<%= urlPrefix %>/lotOccupancies/<%= lotOccupancy.lotOccupancyId %>">
<a href="<%= urlPrefix %>/lotOccupancies/<%= lotOccupancy.lotOccupancyId %>"> <%= configFunctions.getProperty("aliases.occupancy") %>: <%= lotOccupancy.lotName || ("(No " + configFunctions.getProperty("aliases.lot") + ")") %>
<%= configFunctions.getProperty("aliases.occupancy") %>: <%= lotOccupancy.lotName || ("(No " + configFunctions.getProperty("aliases.lot") + ")") %> </a>
</a> </li>
</li> <% } %>
<% } %> <li class="is-active">
<li class="is-active"> <a href="#" aria-current="page">
<a href="#" aria-current="page"> <% if (isCreate) { %>
<% if (isCreate) { %> Create a New <%= configFunctions.getProperty("aliases.occupancy") %> Record
Create a New <%= configFunctions.getProperty("aliases.occupancy") %> Record <% } else { %>
<% } else { %> Update <%= configFunctions.getProperty("aliases.occupancy") %>
Update <%= configFunctions.getProperty("aliases.occupancy") %> <% } %>
<% } %> </a>
</a> </li>
</li> </ul>
</ul>
</nav> </nav>
<% if (isCreate) { %> <% if (isCreate) { %>
@ -109,10 +109,15 @@
</label> </label>
<div class="field has-addons"> <div class="field has-addons">
<div class="control is-expanded"> <div class="control is-expanded">
<input class="input has-text-left" id="lotOccupancy--lotName" type="button" value="<%= lotOccupancy.lotName %>" <input class="input is-clickable has-text-left" id="lotOccupancy--lotName" type="button" value="<%= lotOccupancy.lotName || "(No " + configFunctions.getProperty("aliases.lot") + ")" %>"
<%= (configFunctions.getProperty("settings.lotOccupancy.lotIdIsRequired") ? " required" : "") %> <%= (configFunctions.getProperty("settings.lotOccupancy.lotIdIsRequired") ? " required" : "") %>
<%= (isCreate ? "" : " disabled") %> /> <%= (isCreate ? "" : " disabled") %> />
</div> </div>
<div class="control is-hidden-print">
<button class="button is-clear-lot-button" data-tooltip="Clear" type="button" aria-label="Clear <%= configFunctions.getProperty("aliases.lot") %></button> Field">
<i class="fas fa-eraser" aria-hidden="true"></i>
</button>
</div>
<div class="control is-hidden-print"> <div class="control is-hidden-print">
<button class="button is-unlock-field-button" data-tooltip="Unlock Field" type="button" aria-label="Unlock <%= configFunctions.getProperty("aliases.lot") %></button> Field"> <button class="button is-unlock-field-button" data-tooltip="Unlock Field" type="button" aria-label="Unlock <%= configFunctions.getProperty("aliases.lot") %></button> Field">
<i class="fas fa-unlock" aria-hidden="true"></i> <i class="fas fa-unlock" aria-hidden="true"></i>
@ -125,7 +130,7 @@
</div> </div>
</div> </div>
</div> </div>
<div class="column"> <div class="column is-3">
<div class="field"> <div class="field">
<label class="label" for="lotOccupancy--occupancyStartDateString">Start Date</label> <label class="label" for="lotOccupancy--occupancyStartDateString">Start Date</label>
<div class="control"> <div class="control">