mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Task 985 - filter room classes and room types
This commit is contained in:
@@ -47,6 +47,8 @@ function HotelCalendar(/*String*/querySelector, /*Dictionary*/options, /*List*/p
|
|||||||
startDate: now_utc,
|
startDate: now_utc,
|
||||||
days: now_utc.daysInMonth(),
|
days: now_utc.daysInMonth(),
|
||||||
rooms: [],
|
rooms: [],
|
||||||
|
room_types: [],
|
||||||
|
room_classes: [],
|
||||||
allowInvalidActions: false,
|
allowInvalidActions: false,
|
||||||
assistedMovement: false,
|
assistedMovement: false,
|
||||||
endOfWeek: 6,
|
endOfWeek: 6,
|
||||||
@@ -67,7 +69,6 @@ function HotelCalendar(/*String*/querySelector, /*Dictionary*/options, /*List*/p
|
|||||||
this.options.orig_days = this.options.days;
|
this.options.orig_days = this.options.days;
|
||||||
this.options.days = this.parseDays(this.options.days) + 1;
|
this.options.days = this.parseDays(this.options.days) + 1;
|
||||||
this.options.rooms = _.map(this.options.rooms, function(item){ return item.clone(); });
|
this.options.rooms = _.map(this.options.rooms, function(item){ return item.clone(); });
|
||||||
|
|
||||||
// Check correct values
|
// Check correct values
|
||||||
if (this.options.rooms.length > 0 && !(this.options.rooms[0] instanceof HRoom)) {
|
if (this.options.rooms.length > 0 && !(this.options.rooms[0] instanceof HRoom)) {
|
||||||
this.options.rooms = [];
|
this.options.rooms = [];
|
||||||
@@ -599,15 +600,29 @@ HotelCalendar.prototype = {
|
|||||||
//==== ROOMS
|
//==== ROOMS
|
||||||
_filterRooms: function() {
|
_filterRooms: function() {
|
||||||
// Two-Step filter: Scrollbar mistake
|
// Two-Step filter: Scrollbar mistake
|
||||||
// 1. Filter rooms
|
this.options.room_classes = [];
|
||||||
|
this.options.room_types = [];
|
||||||
|
// 1.1 Filter rooms
|
||||||
for (var r of this.options.rooms) {
|
for (var r of this.options.rooms) {
|
||||||
r._active = this._in_domain(r, this._domains[HotelCalendar.DOMAIN.ROOMS]);
|
r._active = this._in_domain(r, this._domains[HotelCalendar.DOMAIN.ROOMS]);
|
||||||
if (r._active) {
|
if (r._active) {
|
||||||
r._html.classList.remove('hcal-hidden');
|
r._html.classList.remove('hcal-hidden');
|
||||||
|
// 1.2 Filter room classes used in occupation rows
|
||||||
|
if (this.options.room_classes.indexOf(r.type) === -1) {
|
||||||
|
this.options.room_classes.push(r.type);
|
||||||
|
}
|
||||||
|
// 1.3 Filter room types used in pricelist rows
|
||||||
|
if (this.options.room_types.indexOf(r._userData.room_type_id) === -1) {
|
||||||
|
this.options.room_types.push(r._userData.room_type_id);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
r._html.classList.add('hcal-hidden');
|
r._html.classList.add('hcal-hidden');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Hide all the rows corresponding to occupation and prices
|
||||||
|
$("[id^=ROW_DETAIL_FREE_TYPE]").addClass('hcal-hidden');
|
||||||
|
$("[id^=ROW_DETAIL_PRICE_ROOM]").addClass('hcal-hidden');
|
||||||
|
// TODO: update OCCUPATION
|
||||||
|
|
||||||
this._calcViewHeight();
|
this._calcViewHeight();
|
||||||
|
|
||||||
@@ -621,6 +636,20 @@ HotelCalendar.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 2.2 Update room classes
|
||||||
|
for (var room_class of self.options.room_classes)
|
||||||
|
{
|
||||||
|
var tr_name = self._sanitizeId(`ROW_DETAIL_FREE_TYPE_${room_class}`);
|
||||||
|
var x = _.findWhere(self.edtable.rows, {id: tr_name});
|
||||||
|
x.classList.remove('hcal-hidden');
|
||||||
|
}
|
||||||
|
// 2.3 Update room types
|
||||||
|
for (var room_type of self.options.room_types)
|
||||||
|
{
|
||||||
|
var tr_name = self._sanitizeId(`ROW_DETAIL_PRICE_ROOM_${self._pricelist_id}_${room_type}`);
|
||||||
|
var x = _.findWhere(self.edtable.rows, {id: tr_name});
|
||||||
|
x.classList.remove('hcal-hidden');
|
||||||
|
}
|
||||||
}, this);
|
}, this);
|
||||||
//_.defer(function(){ this._updateReservationOccupation() }.bind(this));
|
//_.defer(function(){ this._updateReservationOccupation() }.bind(this));
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user