Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.

Commit 212ab01

Browse files
feat(#8): add visibility information on the website
1 parent 7f20a66 commit 212ab01

File tree

11 files changed

+91
-10
lines changed

11 files changed

+91
-10
lines changed

src/app/app.component.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ import {faSadCry} from '@fortawesome/pro-light-svg-icons/faSadCry';
5151
import {faLightbulbOn} from '@fortawesome/pro-light-svg-icons/faLightbulbOn';
5252
import {faHourglassEnd} from '@fortawesome/pro-light-svg-icons/faHourglassEnd';
5353
import {faGift as faGiftLight} from '@fortawesome/pro-light-svg-icons/faGift';
54+
import {faFemale} from '@fortawesome/pro-light-svg-icons/faFemale';
55+
import {faMale} from '@fortawesome/pro-light-svg-icons/faMale';
5456

5557
@Component({
5658
selector: 'app-root',
@@ -178,7 +180,7 @@ export class AppComponent implements OnInit, OnDestroy {
178180
// We only set the following meta tags if we are not displaying an item or a blog post
179181
// For these new meta tags will be interpreted inside their routes
180182
if (Comparator.isStringEmpty(this.req.originalUrl) ||
181-
(this.req.originalUrl.indexOf('/item/') === -1 && (this.req.originalUrl.indexOf('/blog/post/') == -1))) {
183+
(this.req.originalUrl.indexOf('/item/') === -1 && (this.req.originalUrl.indexOf('/blog/post/') === -1))) {
182184
const description = this.translateService.instant('META.DESCRIPTION');
183185

184186
this.meta.updateTag({name: 'description', content: description});
@@ -249,6 +251,8 @@ export class AppComponent implements OnInit, OnDestroy {
249251
library.add(faLightbulbOn);
250252
library.add(faHourglassEnd);
251253
library.add(faGiftLight);
254+
library.add(faFemale);
255+
library.add(faMale);
252256
}
253257

254258
private initCookieConsent() {

src/assets/i18n/de.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
},
4747
"ITEM_DETAILS": {
4848
"CONTENT": {
49-
"PRICE_GROSS": "Miete/Monat"
49+
"PRICE_GROSS": "Miete/Monat",
50+
"VISIBILITY": {
51+
"LOOKING_FOR": "Mitbewohner gesucht",
52+
"YEARS_OLD": "Jahre alt"
53+
}
5054
}
5155
},
5256
"TEXT": {

src/assets/i18n/en.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
},
4747
"ITEM_DETAILS": {
4848
"CONTENT": {
49-
"PRICE_GROSS": "Rental fee/month"
49+
"PRICE_GROSS": "Rental fee/month",
50+
"VISIBILITY": {
51+
"LOOKING_FOR": "Roommates wanted",
52+
"YEARS_OLD": "years old"
53+
}
5054
}
5155
},
5256
"TEXT": {

src/assets/i18n/fr.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
},
4747
"ITEM_DETAILS": {
4848
"CONTENT": {
49-
"PRICE_GROSS": "Loyer mensuel"
49+
"PRICE_GROSS": "Loyer mensuel",
50+
"VISIBILITY": {
51+
"LOOKING_FOR": "Colocataires recherchés",
52+
"YEARS_OLD": "ans"
53+
}
5054
}
5155
},
5256
"TEXT": {

src/assets/i18n/it.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@
4646
},
4747
"ITEM_DETAILS": {
4848
"CONTENT": {
49-
"PRICE_GROSS": "Affitto/mese"
49+
"PRICE_GROSS": "Affitto/mese",
50+
"VISIBILITY": {
51+
"LOOKING_FOR": "Cercasi compagni di stanza",
52+
"YEARS_OLD": "anni"
53+
}
5054
}
5155
},
5256
"TEXT": {

src/components/core/item-summary/item-summary.component.html

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,10 @@ <h1>
1313
<div class="row" *ngIf="isItemFlat()">
1414
<div class="col-md-12 mb-2">
1515
<h1>
16-
<span *ngIf="item.attributes.rooms > 1">{{item.attributes.rooms}} {{'SELECT_ATTRIBUTES.ROOMS'| translate}}</span>
17-
<span *ngIf="item.attributes.rooms == 1">{{item.attributes.rooms}} {{'SELECT_ATTRIBUTES.ROOM'| translate}}</span>
16+
<span
17+
*ngIf="item.attributes.rooms > 1">{{item.attributes.rooms}} {{'SELECT_ATTRIBUTES.ROOMS'| translate}}</span>
18+
<span
19+
*ngIf="item.attributes.rooms == 1">{{item.attributes.rooms}} {{'SELECT_ATTRIBUTES.ROOM'| translate}}</span>
1820
<span *ngIf="item.attributes.size > 0">{{item.attributes.size}} {{'CORE.SQUARE_METER'| translate}}</span>
1921
</h1>
2022
</div>
@@ -46,6 +48,20 @@ <h1>
4648
</div>
4749
</div>
4850

51+
<!-- Visibility -->
52+
<div class="row" *ngIf="isItemShare() && hasUserLimitations()">
53+
<div class="col-md-12">
54+
<p>
55+
<span>{{'ITEM_DETAILS.CONTENT.VISIBILITY.LOOKING_FOR'| translate}}&nbsp;</span>
56+
<fa-icon [icon]="['fal', 'male']" *ngIf="hasVisibilityMale()"></fa-icon>
57+
<fa-icon [icon]="['fal', 'female']" *ngIf="hasVisibilityFemale()"></fa-icon>
58+
<span>&nbsp;</span>
59+
{{item.userLimitations.age?.min}}<span>-</span>{{item.userLimitations.age?.max}}
60+
<span>{{'ITEM_DETAILS.CONTENT.VISIBILITY.YEARS_OLD'| translate}}</span>
61+
</p>
62+
</div>
63+
</div>
64+
4965
<!-- Price -->
5066
<div class="row">
5167
<div class="col-md-12">
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fa-icon {
2+
margin-left: .25rem;
3+
}

src/components/core/item-summary/item-summary.component.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@ import {Item} from '../../../providers/model/item/item';
66
// Utils
77
import {ItemsComparator} from '../../../providers/core/utils/items-utils';
88
import {Comparator} from '../../../providers/core/utils/utils';
9+
import {Resources} from '../../../providers/core/utils/resources';
910

1011
// Services
1112
import {CurrencyService} from '../../../providers/core/currency/currency.service';
1213

1314
@Component({
1415
selector: 'app-item-summary',
15-
templateUrl: './item-summary.component.html'
16+
templateUrl: './item-summary.component.html',
17+
styleUrls: ['./item-summary.component.scss']
1618
})
1719
export class ItemSummaryComponent implements OnInit {
1820

21+
RESOURCES: any = Resources.Constants;
22+
1923
@Input() item: Item;
2024

2125
@Output() notifyPrice: EventEmitter<string> = new EventEmitter<string>();
@@ -65,4 +69,21 @@ export class ItemSummaryComponent implements OnInit {
6569
return ItemsComparator.getItemFormattedDate(input);
6670
}
6771

72+
hasUserLimitations(): boolean {
73+
return !Comparator.isEmpty(this.item) && !Comparator.isEmpty(this.item.userLimitations);
74+
}
75+
76+
hasVisibilityMale(): boolean {
77+
return this.hasVisibility(this.RESOURCES.ITEM.USER_RESTRICTIONS.GENDER.MALE);
78+
}
79+
80+
hasVisibilityFemale(): boolean {
81+
return this.hasVisibility(this.RESOURCES.ITEM.USER_RESTRICTIONS.GENDER.FEMALE);
82+
}
83+
84+
private hasVisibility(gender: string): boolean {
85+
return this.item.userLimitations.gender && (
86+
this.item.userLimitations.gender === this.RESOURCES.ITEM.USER_RESTRICTIONS.GENDER.IRRELEVANT ||
87+
this.item.userLimitations.gender === gender);
88+
}
6889
}

src/components/core/item-summary/item-summary.module.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {CommonModule} from '@angular/common';
33

44
import {TranslateModule} from '@ngx-translate/core';
55

6+
import {FontAwesomeModule} from '@fortawesome/angular-fontawesome';
7+
68
import {ItemSummaryComponent} from './item-summary.component';
79

810
const CORE_COMPONENTS = [
@@ -15,7 +17,8 @@ const CORE_COMPONENTS = [
1517
],
1618
imports: [
1719
CommonModule,
18-
TranslateModule.forChild()
20+
TranslateModule.forChild(),
21+
FontAwesomeModule
1922
],
2023
exports: [
2124
CORE_COMPONENTS

src/providers/core/utils/resources.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ export class Resources {
8686
TYPE: {
8787
TAKEOVER: 'takeover',
8888
SHARE: 'share'
89+
},
90+
USER_RESTRICTIONS: {
91+
GENDER: {
92+
MALE: 'male',
93+
FEMALE: 'female',
94+
IRRELEVANT: 'irrelevant'
95+
}
8996
}
9097
},
9198

0 commit comments

Comments
 (0)