[IMP] Too Fast, Too Furious

This commit is contained in:
Alexandre Díaz
2019-01-14 04:31:52 +01:00
parent 0ab1c2faa0
commit aee74efa54
3 changed files with 85 additions and 57 deletions

View File

@@ -288,7 +288,6 @@ var PMSCalendarController = AbstractController.extend({
this.renderer.$el.find('#pms-menu #btn_action_overbooking button').on('click', function(ev){
var active_calendar = self._multi_calendar.get_active_calendar();
active_calendar.toggleOverbookingsVisibility();
active_calendar.addReservations(self._multi_calendar._dataset['reservations']);
if (active_calendar.options.showOverbookings) {
$(this).find('.led').removeClass('led-disabled');
$(this).find('.led').addClass('led-enabled');
@@ -296,12 +295,13 @@ var PMSCalendarController = AbstractController.extend({
$(this).find('.led').addClass('led-disabled');
$(this).find('.led').removeClass('led-enabled');
}
active_calendar.addReservations(_.reject(self._multi_calendar._dataset['reservations'], {overbooking:false}));
_.defer(function(){ active_calendar._updateReservations(false); }); // Fix Possible Rows Displacements
});
this.renderer.$el.find('#pms-menu #btn_action_cancelled button').on('click', function(ev){
var active_calendar = self._multi_calendar.get_active_calendar();
active_calendar.toggleCancelledVisibility();
active_calendar.addReservations(self._multi_calendar._dataset['reservations']);
if (active_calendar.options.showCancelled) {
$(this).find('.led').removeClass('led-disabled');
$(this).find('.led').addClass('led-enabled');
@@ -309,6 +309,8 @@ var PMSCalendarController = AbstractController.extend({
$(this).find('.led').addClass('led-disabled');
$(this).find('.led').removeClass('led-enabled');
}
active_calendar.addReservations(_.reject(self._multi_calendar._dataset['reservations'], {cancelled:false}));
_.defer(function(){ active_calendar._updateReservations(false); }); // Fix Possible Rows Displacements
});
this.renderer.$el.find('#pms-menu #btn_action_divide button').on('click', function(ev){

View File

@@ -354,6 +354,9 @@ HotelCalendar.prototype = {
// Create & Render New Reservations
_.defer(function(reservs){
// Update offsets (New Rooms change positions?)
this._updateOffsets();
var unusedZones = this._createUnusedZones(reservs);
// Add Unused Zones
this._reservations = this._reservations.concat(unusedZones);
@@ -666,10 +669,21 @@ HotelCalendar.prototype = {
var exRoomRow = this.getExtraRoomRow(ex_reserv);
if (exRoomRow) {
// Update Reservations Position
var bounds = this.loopedOffsetOptimized(exRoomRow);
var start_index = _.indexOf(this.options.rooms, ex_reserv.room) + 1;
for (var i=start_index; i<this.options.rooms.length; i++) {
var reservs = this.getReservationsByRoom(this.options.rooms[i], true);
for (var reserv of reservs) {
if (reserv && reserv._html) {
var top = parseInt(reserv._html.style.top, 10);
reserv._html.style.top = `${top - bounds.height}px`;
}
}
}
exRoomRow.parentNode.removeChild(exRoomRow);
this.options.rooms = _.reject(this.options.rooms, function(item){ return item.id === ex_reserv.room.id; });
this._updateOffsets();
this._updateReservations(false);
this.options.rooms = _.reject(this.options.rooms, {id: ex_reserv.room.id});
}
},
@@ -776,7 +790,6 @@ HotelCalendar.prototype = {
}
// Update Reservations Position
this._updateOffsets();
var bounds = this.loopedOffsetOptimized(row);
var cheight = bounds.height;
var start_index = _.indexOf(this.options.rooms, ex_room) + 1;