Skip to content

Commit

Permalink
исправлена фильтрация домов
Browse files Browse the repository at this point in the history
  • Loading branch information
ardnaxelas committed Dec 9, 2024
1 parent 763caa3 commit 7cd55dd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
10 changes: 9 additions & 1 deletion citywalls2/controllers/streetController.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,18 @@ exports.houseDetails = asyncHandler(async (req, res) => {
exports.filterPage = asyncHandler(async (req, res) => {
const districtsCursor = await db.query('FOR house IN houses RETURN DISTINCT house.district');
const districts = await districtsCursor.all();


const managementCompaniesCursor = await db.query('FOR house IN houses RETURN DISTINCT house.management_company');
const managementCompanies = await managementCompaniesCursor.all();

const conditionsCursor = await db.query('FOR house IN houses RETURN DISTINCT house.condition');
const conditions = await conditionsCursor.all();

res.render('houses_filter', {
title: 'Дома Санкт-Петербурга',
districts,
managementCompanies,
conditions,
});
});

Expand Down
4 changes: 2 additions & 2 deletions citywalls2/data/houses.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
"floors": 27,
"apartments": 803,
"condition": "Исправный",
"management_company": "Комендантский, 13",
"management_company": "нет",
"series": "индивидуальный",
"district": "Приморский"
},
Expand Down Expand Up @@ -138,7 +138,7 @@
"floors": 9,
"apartments": 367,
"condition": "Исправный",
"management_company": "Сиреневый 7-1",
"management_company": "нет",
"series": "504",
"district": "Выборгский"
},
Expand Down
23 changes: 20 additions & 3 deletions citywalls2/views/houses_filter.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<h1><%= title %></h1>

<form action="/main/houses/filter" method="GET">
<!-- Фильтр по году постройки -->
<div>
<label for="year">Введите год постройки:</label>
<select id="year" name="year">
Expand All @@ -21,6 +22,7 @@
</select>
</div>

<!-- Фильтр по району -->
<div>
<label for="district">Введите район:</label>
<select id="district" name="district">
Expand All @@ -31,26 +33,41 @@
</select>
</div>

<!-- Фильтр по количеству этажей -->
<div>
<label for="floors">Введите количество этажей:</label>
<input type="number" id="floors" name="floors" placeholder="Value">
</div>

<!-- Фильтр по количеству квартир -->
<div>
<label for="apartments">Введите количество квартир:</label>
<input type="number" id="apartments" name="apartments" placeholder="Value">
</div>

<!-- Фильтр по состоянию дома -->
<div>
<label for="condition">Введите состояние дома:</label>
<input type="text" id="condition" name="condition" placeholder="Value">
<select id="condition" name="condition">
<option value="">Все</option>
<% conditions.forEach(function(condition) { %>
<option value="<%= condition %>"><%= condition %></option>
<% }); %>
</select>
</div>

<!-- Фильтр по управляющей компании -->
<div>
<label for="management_company">Введите УК:</label>
<input type="text" id="management_company" name="management_company" placeholder="Value">
<select id="management_company" name="management_company">
<option value="">Все</option>
<% managementCompanies.forEach(function(company) { %>
<option value="<%= company %>"><%= company %></option>
<% }); %>
</select>
</div>

<!-- Фильтр по улице -->
<div>
<label for="street">Введите улицу:</label>
<input type="text" id="street" name="street" placeholder="Value">
Expand All @@ -61,4 +78,4 @@

<a href="/main">На главную</a>
</body>
</html>
</html>

0 comments on commit 7cd55dd

Please sign in to comment.