mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP] Multi-Calendar
This commit is contained in:
@@ -10,6 +10,7 @@ var Core = require('web.core'),
|
||||
Session = require('web.session'),
|
||||
AbstractRenderer = require('web.AbstractRenderer'),
|
||||
HotelConstants = require('hotel_calendar.Constants'),
|
||||
MultiCalendar = require('hotel_calendar.MultiCalendar'),
|
||||
//Formats = require('web.formats'),
|
||||
|
||||
_t = Core._t,
|
||||
@@ -30,33 +31,29 @@ var HotelCalendarView = AbstractRenderer.extend({
|
||||
_reserv_tooltips: {},
|
||||
_days_tooltips: [],
|
||||
_last_dates: [false, false],
|
||||
_hcalendars: [],
|
||||
_multi_calendar: null,
|
||||
|
||||
|
||||
/** VIEW METHODS **/
|
||||
init: function(parent, state, params) {
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
this._multi_calendar = new MultiCalendar(this);
|
||||
},
|
||||
|
||||
start: function () {
|
||||
return this._super().then(function() {
|
||||
this.init_calendar_view();
|
||||
}.bind(this));
|
||||
this._multi_calendar.setElement(this.$el.find('#hcal_widget'));
|
||||
this._multi_calendar.start();
|
||||
this.init_calendar_view();
|
||||
return this._super();
|
||||
},
|
||||
|
||||
on_attach_callback: function() {
|
||||
this._super();
|
||||
|
||||
if (this._hcalendar && !this._is_visible) {
|
||||
if (!this._is_visible) {
|
||||
// FIXME: Workaround for restore "lost" reservations (Drawn when the view is hidden)
|
||||
setTimeout(function(){
|
||||
for (var reserv of this._hcalendar._reservations) {
|
||||
var style = window.getComputedStyle(reserv._html, null);
|
||||
if (parseInt(style.width, 10) < 15 || parseInt(style.height, 10) < 15 || parseInt(style.top, 10) === 0) {
|
||||
this._hcalendar._updateReservation(reserv);
|
||||
}
|
||||
}
|
||||
}.bind(this), 300);
|
||||
this._multi_calendar.recalculate_reservation_positions();
|
||||
}
|
||||
},
|
||||
|
||||
@@ -130,8 +127,8 @@ var HotelCalendarView = AbstractRenderer.extend({
|
||||
endOfWeekOffset: this._view_options['eday_week_offset'] || 0
|
||||
};
|
||||
|
||||
this._hcalendar = new HotelCalendar(containerSelector, options, pricelist, restrictions, this.$el[0]);
|
||||
this._assign_hcalendar_events();
|
||||
//this._hcalendar = new HotelCalendar(containerSelector, options, pricelist, restrictions, this.$el[0]);
|
||||
//this._assign_hcalendar_events();
|
||||
},
|
||||
|
||||
_assign_hcalendar_events: function() {
|
||||
|
||||
@@ -162,7 +162,7 @@ var CalendarMenu = Widget.extend({
|
||||
var PMSCalendarView = AbstractView.extend({
|
||||
display_name: _lt('Calendar PMS'),
|
||||
icon: 'fa-calendar',
|
||||
jsLibs: ['/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js'],
|
||||
//jsLibs: [],
|
||||
cssLibs: ['/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css'],
|
||||
config: {
|
||||
Model: PMSCalendarModel,
|
||||
|
||||
45
hotel_calendar/static/src/js/widgets/MultiCalendar.js
Normal file
45
hotel_calendar/static/src/js/widgets/MultiCalendar.js
Normal file
@@ -0,0 +1,45 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.MultiCalendar', function(require) {
|
||||
'use strict';
|
||||
|
||||
var core = require('web.core');
|
||||
var session = require('web.session');
|
||||
var Widget = require('web.Widget');
|
||||
|
||||
var MultiCalendar = Widget.extend({
|
||||
_calendars: null,
|
||||
_active_calendar: -1,
|
||||
|
||||
init: function(parent) {
|
||||
this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
start: function() {
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
this.$el.html("<p>NO CALENDAR DEFINED!</p>");
|
||||
},
|
||||
|
||||
get_active_calendar: function() {
|
||||
return this._calendars[this._active_calendar];
|
||||
}
|
||||
|
||||
recalculate_reservation_positions: function() {
|
||||
setTimeout(function(){
|
||||
for (var reserv of this._hcalendar._reservations) {
|
||||
var style = window.getComputedStyle(reserv._html, null);
|
||||
if (parseInt(style.width, 10) < 15 || parseInt(style.height, 10) < 15 || parseInt(style.top, 10) === 0) {
|
||||
this.get_active_calendar()._updateReservation(reserv);
|
||||
}
|
||||
}
|
||||
}.bind(this), 200);
|
||||
},
|
||||
|
||||
create_calendar: function() {
|
||||
|
||||
},
|
||||
});
|
||||
|
||||
return MultiCalendar;
|
||||
});
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
<!-- Hotel Calendar (Internal) -->
|
||||
<link rel="stylesheet" href="/hotel_calendar/static/src/css/view.css" />
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/widgets/MultiCalendar.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/constants.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_model.js"></script>
|
||||
|
||||
Reference in New Issue
Block a user