Skip to content

Commit

Permalink
Fixes for creating strains / plants
Browse files Browse the repository at this point in the history
  • Loading branch information
dwot committed Feb 1, 2025
1 parent d86b518 commit f31f513
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
1 change: 0 additions & 1 deletion web/templates/pages/plants.html
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,6 @@ <h5 class="modal-title" id="addPlantModalLabel">{{ .lcl.add_new_plant }}</h5>
});

addPlantModal.addEventListener("show.bs.modal", () => {
setDefaultDate();
resetZoneSelection();
resetStrainSelection();
});
Expand Down
32 changes: 30 additions & 2 deletions web/templates/pages/strains.html
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ <h5 class="modal-title" id="editStrainModalLabel">{{ .lcl.edit_strain }}</h5>
sativaLabel.textContent = `Sativa: ${sativa}%`;
});

// If no breeders exist, show the new breeder input by default
if (document.getElementById("breederSelect").length === 1) {
newBreederInput.classList.remove("d-none");
}

addStrainForm.addEventListener("submit", (e) => {
e.preventDefault();

Expand Down Expand Up @@ -422,9 +427,28 @@ <h5 class="modal-title" id="editStrainModalLabel">{{ .lcl.edit_strain }}</h5>

function renderStrainsTable(data) {
const editStrainModal = new bootstrap.Modal(document.getElementById("editStrainModal"));
const filteredData = filterStrains(data, searchInput.value);
let filteredData = filterStrains(data, searchInput.value);

strainsContainer.innerHTML = `
//If filteredData is null, reset with empty map object
if (filteredData == null) {
strainsContainer.innerHTML = `
<table class="table table-striped table-bordered table-hover">
<thead class="table-dark">
<tr>
<th scope="col" data-key="name" data-type="text" class="sortable ${currentSort.key === "name" ? (currentSort.isAscending ? "asc" : "desc") : ""}">{{ .lcl.title_strain }} <i class="fa-solid fa-sort"></i></th>
<th scope="col" data-key="breeder" data-type="text" class="sortable ${currentSort.key === "breeder" ? (currentSort.isAscending ? "asc" : "desc") : ""}">{{ .lcl.breeder }} <i class="fa-solid fa-sort"></i></th>
<th scope="col" data-key="indica" data-type="numeric" class="sortable ${currentSort.key === "indica" ? (currentSort.isAscending ? "asc" : "desc") : ""}">{{ .lcl.title_is }} <i class="fa-solid fa-sort"></i></th>
<th scope="col" data-key="autoflower" data-type="text" class="sortable ${currentSort.key === "autoflower" ? (currentSort.isAscending ? "asc" : "desc") : ""}">{{ .lcl.title_auto }} <i class="fa-solid fa-sort"></i></th>
<th scope="col" data-key="seed_count" data-type="numeric" class="sortable ${currentSort.key === "seed_count" ? (currentSort.isAscending ? "asc" : "desc") : ""}">{{ .lcl.seed_count }} <i class="fa-solid fa-sort"></i></th>
<th scope="col">Edit </th>
</tr>
</thead>
<tbody>
</tbody>
</table>
`;
} else {
strainsContainer.innerHTML = `
<table class="table table-striped table-bordered table-hover">
<thead class="table-dark">
<tr>
Expand Down Expand Up @@ -454,6 +478,10 @@ <h5 class="modal-title" id="editStrainModalLabel">{{ .lcl.edit_strain }}</h5>
</tbody>
</table>
`;
}




// Add click listeners for sorting
document.querySelectorAll(".sortable").forEach(header => {
Expand Down

0 comments on commit f31f513

Please sign in to comment.