Adding garage.

Adding missing house type.
This commit is contained in:
Jorge Bolois Guerrero 2022-08-21 14:48:50 +02:00
parent 453af167f0
commit fa25e3c983
2 changed files with 29 additions and 1 deletions

View File

@ -4,6 +4,7 @@ export default class Item {
static NAME_SELECTOR = '.item-link';
static PRICE_SELECTOR = '.item-price';
static GARAGE_SELECTOR = '.item-parking';
static ROOM_SELECTOR = '.item-detail-char .item-detail:nth-child(1)';
static METERS_SELECTOR = '.item-detail-char .item-detail:nth-child(2)';
@ -18,6 +19,7 @@ export default class Item {
this.priceMeter = this._extractPriceMeter();
this.additionalInfo = this._extractAdditionalInfo();
this.hasGarage = this._extractGarage();
this.hasLift = this._extractLift();
this.isExterior = this._extractExterior();
this.isInterior = this._extractInterior();
@ -61,9 +63,11 @@ export default class Item {
isHouse() {
return this._nameIncludes('Casa')
|| this._nameIncludes('Chalet');
|| this._nameIncludes('Chalet')
|| this._nameIncludes('Finca');
}
// TODO: This may be included in isFlat.
isGround() {
return this._nameIncludes('Bajo');
}
@ -116,4 +120,8 @@ export default class Item {
return this.additionalInfo.includes('interior');
}
_extractGarage() {
return this._node.querySelector(Item.GARAGE_SELECTOR) !== null;
}
}

View File

@ -27,6 +27,10 @@ export default class ItemHTML {
return this.ERROR_CLASS_NAME;
}
if (this._shouldCheckGarage() && !item.hasGarage) {
return this.ERROR_CLASS_NAME;
}
if (this._shouldCheckLift(item) && !item.hasLift) {
return this.ERROR_CLASS_NAME;
}
@ -43,6 +47,7 @@ export default class ItemHTML {
${this._createPercentagePriceHTML(item)}
${this._createPriceHTML(item)}
${this._createPriceMeterHTML(item)}
${this._createGarageHTML(item)}
${this._createLiftHTML(item)}
${this._createExteriorHTML(item)}
</div>`
@ -90,6 +95,21 @@ export default class ItemHTML {
return this._createTextError('m²', item.priceMeter)
}
static _createGarageHTML(item) {
if (!this._shouldCheckGarage()) {
return ``;
}
if (item.hasGarage) {
return this._createSuccess('Garaje');
}
return this._createError('Garaje');
}
static _shouldCheckGarage() {
return Preferences.get('garage');
}
static _createLiftHTML(item) {
if (!this._shouldCheckLift(item)) {
return ``;