Додан пошук територій за назвою вулиці
This commit is contained in:
@@ -39,6 +39,24 @@ const Territory_list = {
|
||||
Territory_list.homestead.setHTML();
|
||||
},
|
||||
|
||||
// Пошук
|
||||
search: {
|
||||
open: () => {
|
||||
const sheepSearchForm = document.getElementById("page-territory-search");
|
||||
const current = sheepSearchForm.dataset.state;
|
||||
sheepSearchForm.dataset.state = current === 'open' ? 'closed' : 'open';
|
||||
},
|
||||
input: (value) => {
|
||||
console.log(value);
|
||||
|
||||
search_value = value?.trim()?.toLowerCase() || "";
|
||||
// Sheeps.sheeps_list.setHTML(search_value);
|
||||
|
||||
Territory_list.house.setHTML(search_value);
|
||||
Territory_list.homestead.setHTML(search_value);
|
||||
}
|
||||
},
|
||||
|
||||
house: {
|
||||
url: null,
|
||||
list: [],
|
||||
@@ -54,7 +72,7 @@ const Territory_list = {
|
||||
Territory_list.house.list = await response.json();
|
||||
return Territory_list.house.list;
|
||||
},
|
||||
setHTML: async function () {
|
||||
setHTML: async function (search_value = null) {
|
||||
const block = document.getElementById('list-house');
|
||||
const territory_entrances = localStorage.getItem('territory_list_entrances') === 'true';
|
||||
const sort_mode = localStorage.getItem('territory_list_sort') ?? "1";
|
||||
@@ -88,6 +106,11 @@ const Territory_list = {
|
||||
(territory_list_filter === 2 && qty !== work && !territory_entrances) ||
|
||||
(territory_list_filter === 2 && element.working === false);
|
||||
|
||||
|
||||
if (search_value && !element.house.title.toLowerCase().includes(search_value)) {
|
||||
continue; // пропустити, якщо ім'я не містить рядок пошуку
|
||||
}
|
||||
|
||||
if (statusMatch) {
|
||||
const card = document.createElement('app-territory-card');
|
||||
|
||||
@@ -161,7 +184,7 @@ const Territory_list = {
|
||||
Territory_list.homestead.list = await response.json();
|
||||
return Territory_list.homestead.list;
|
||||
},
|
||||
setHTML: async function () {
|
||||
setHTML: async function (search_value = null) {
|
||||
const block = document.getElementById('list-homestead');
|
||||
const sortMode = localStorage.getItem('territory_list_sort') ?? "1";
|
||||
const territory_list_filter = Number(localStorage.getItem("territory_list_filter") ?? 0);
|
||||
@@ -184,6 +207,10 @@ const Territory_list = {
|
||||
(territory_list_filter === 1 && element.working) ||
|
||||
(territory_list_filter === 2 && !element.working);
|
||||
|
||||
if (search_value && !element.title.toLowerCase().includes(search_value)) {
|
||||
continue; // пропустити, якщо ім'я не містить рядок пошуку
|
||||
}
|
||||
|
||||
if (statusMatch) {
|
||||
const working = element.working;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user