From bac23e1df8446e634e1bfcacffacbffd2ed11bbd Mon Sep 17 00:00:00 2001 From: robonen Date: Wed, 1 Jun 2022 20:47:42 +0700 Subject: [PATCH] Catalog filters --- frontend/src/assets/css/catalog.css | 12 +++-- frontend/src/views/CatalogView.vue | 78 +++++++++++++++++++++++------ frontend/src/views/OfferView.vue | 10 +++- 3 files changed, 80 insertions(+), 20 deletions(-) diff --git a/frontend/src/assets/css/catalog.css b/frontend/src/assets/css/catalog.css index 8110559..f46575a 100644 --- a/frontend/src/assets/css/catalog.css +++ b/frontend/src/assets/css/catalog.css @@ -212,10 +212,12 @@ h1, h2, h3, h4, h5, h6 { } .sugg__img { - flex-basis: 30%; - height: 460px; + width: 100%; + height: 100%; margin: 4% 0 1% auto; - background: linear-gradient(to top, rgba(1, 80, 140, 1), rgba(37, 45, 45, 0.6)); + /*background: linear-gradient(to top, rgba(1, 80, 140, 1), rgba(37, 45, 45, 0.6));*/ + background-repeat: no-repeat; + background-size: cover; transition: transform .2s linear; } @@ -255,6 +257,7 @@ h1, h2, h3, h4, h5, h6 { .podlozhka { position: relative; width: 369px; + height: 460px; } .podlozhka:hover .sugg__img { @@ -426,8 +429,7 @@ h1, h2, h3, h4, h5, h6 { } /* изменяем цвет фона при наведении курсора */ -.parametrs__block a:hover { - +.parametrs__block a:hover, .parametrs__block__selected { background-color: #000000; } diff --git a/frontend/src/views/CatalogView.vue b/frontend/src/views/CatalogView.vue index fbcf57a..f76308f 100644 --- a/frontend/src/views/CatalogView.vue +++ b/frontend/src/views/CatalogView.vue @@ -36,31 +36,45 @@ @@ -92,12 +106,48 @@ export default { data () { return { offers: [], - componentForm: '' + sortParams: [], + spaceParams: { + min: null, + max: null, + }, + priceParams: { + min: null, + max: null, + }, } }, methods: { url(path) { return `url(${getURL(path)})`; + }, + isSelected(name, value) { + return this.sortParams.some((e) => e.name === name && e.value === value) ? 'parametrs__block__selected' : ''; + }, + addSortParam(name, value, isRange = false) { + const element = this.sortParams.findIndex((e) => e.name === name && e.value === value); + + if (~element && !isRange) { + this.sortParams.splice(element, 1); + return; + } + + this.sortParams = this.sortParams.filter((e) => e.name !== name); + this.sortParams.push({ name, value }); + }, + addRangeSortParam(range, paramName) { + const min = this[range].min; + const max = this[range].max; + + if (min) + this.addSortParam('start' + paramName, min, true); + else + this.addSortParam('start' + paramName, min); + + if (max) + this.addSortParam('end' + paramName, max, true); + else + this.addSortParam('end' + paramName, max); } }, async mounted() { diff --git a/frontend/src/views/OfferView.vue b/frontend/src/views/OfferView.vue index 2e94bd3..47171f3 100644 --- a/frontend/src/views/OfferView.vue +++ b/frontend/src/views/OfferView.vue @@ -58,7 +58,7 @@

Адрес: {{ offer.location }}

-

Кол-во комнат: {{ offer.rooms }}

+

Кол-во комнат: {{ roomType }}

Общая площадь: {{ offer.space }} м²

@@ -127,6 +127,14 @@ export default { 'House': 'Дом', 'Land': 'Участок', }[this.offer.type]; + }, + roomType() { + return { + 'Studio': 'Студия', + 'Room1': '1 комната', + 'Room2': '2 комнаты', + 'Room3More': '3 комнаты и больше', + }[this.offer.rooms] } }, async mounted() {