<commit_before>openerp_staff_management_calendar_booking = function(instance) {
	var _t = instance.web._t; // For text translations
	
	instance.web.views.add('calendar_booking', 'instance.staff_management.BookingCalendar');
	
	instance.staff_management.BookingCalendar = instance.staff_management.Calendar.extend({
	
		template: "PersonalScheduleView",
		
		init:function(){
			this._super.apply(this,arguments);
		},
		
		// destroy, restore scheduler fonctions
		destroy:function(){
			this._super();
		},
		
		get_fc_init_options: function () {
			//Documentation here : http://arshaw.com/fullcalendar/docs/
			var self = this;
			return  $.extend({}, this._super(), {
				
				eventClick: function(event){
					self.open_event_staff(event.id,event.title);
				},
				select: function (start_date, end_date, all_day, _js_event, _view) {
					var data_template = self.get_event_data({
						start: start_date,
						end: end_date,
						allDay: all_day,
					});
					self.slow_create(data_template);
				},
				eventRender: function(event, element) {		
					
					element.text(self.format_hour(event.hour_from)+' '+event.booking_name);
					element.mouseenter(event, function(evt){
						instance.staff_management.tooltip.show($(this), self.get_tooltip_content(evt.data));
					}).mouseleave(instance.staff_management.tooltip.hide);
				},
			});
		},
	
		get_tooltip_content: function(event){
			var div = $('<div>');
			div.append($('<div>').text(this.format_hour(event.hour_from)+' - '+this.format_hour(event.hour_to)));
			div.append($('<div>').text(event.booking_name));
			div.append($('<div>').text(event.nbr_adult+' '+_t('adults')));
			div.append($('<div>').text(event.nbr_child+' '+_t('children')));
			if(event.meal_included){
				div.append($('<div>').text(_t('Meal included')));
			}
			if(event.observation){
				div.append($('<div>').text(event.observation));
			}
			return div;
		},
		
		event_data_transform: function(evt) {
			var r = this._super.apply(this,arguments);
			r.booking_name = evt.booking_name;
			r.hour_from = evt.hour_from;
			r.hour_to = evt.hour_to;
			r.observation = evt.observation;
			r.nbr_adult = evt.nbr_adult;
			r.nbr_child = evt.nbr_child;
			r.meal_included = evt.meal_included;
			return r;
		},

		get_title: function () {
			var title = (_.isUndefined(this.field_widget)) ?
					(this.string || this.name) :
					this.field_widget.string || this.field_widget.name || '';
			return _t("Create: ") + title;
		},
		get_form_popup_infos: function() {
			var infos = {
				view_id: false,
				title: this.name,
			};
			if (!(_.isUndefined(this.ViewManager))) {
				infos.view_id = this.ViewManager.get_view_id('form');
			}
			return infos;
		},
		slow_create: function(data){
			
			var self = this;
			var defaults = {};
			
			_.each(data, function(val, field_name) {
				defaults['default_' + field_name] = val;
			});
			
			var pop_infos = self.get_form_popup_infos();
			var pop = new instance.web.form.FormOpenPopup(this);
			var context = new instance.web.CompoundContext(this.dataset.context, defaults);
			pop.show_element(this.dataset.model, null, this.dataset.get_context(defaults), {
				title: this.get_title(),
				disable_multiple_selection: true,
				view_id: pop_infos.view_id,
				// Ensuring we use ``self.dataset`` and DO NOT create a new one.
				create_function: function(data, options) {<commit_msg>Modify event titles in booking view<commit_after>openerp_staff_management_calendar_booking = function(instance) {
	var _t = instance.web._t; // For text translations
	
	instance.web.views.add('calendar_booking', 'instance.staff_management.BookingCalendar');
	
	instance.staff_management.BookingCalendar = instance.staff_management.Calendar.extend({
	
		template: "PersonalScheduleView",
		
		init:function(){
			this._super.apply(this,arguments);
		},
		
		// destroy, restore scheduler fonctions
		destroy:function(){
			this._super();
		},
		
		get_fc_init_options: function () {
			//Documentation here : http://arshaw.com/fullcalendar/docs/
			var self = this;
			return  $.extend({}, this._super(), {
				
				eventClick: function(event){
					self.open_event_staff(event.id,event.booking_name);
				},
				select: function (start_date, end_date, all_day, _js_event, _view) {
					var data_template = self.get_event_data({
						start: start_date,
						end: end_date,
						allDay: all_day,
					});
					self.slow_create(data_template);
				},
				eventRender: function(event, element) {		
					
					element.text(self.format_hour(event.hour_from)+' '+event.booking_name);
					element.mouseenter(event, function(evt){
						instance.staff_management.tooltip.show($(this), self.get_tooltip_content(evt.data));
					}).mouseleave(instance.staff_management.tooltip.hide);
				},
			});
		},
	
		get_tooltip_content: function(event){
			var div = $('<div>');
			div.append($('<div>').text(this.format_hour(event.hour_from)+' - '+this.format_hour(event.hour_to)));
			div.append($('<div>').text(event.booking_name));
			div.append($('<div>').text(event.nbr_adult+' '+_t('adults')));
			div.append($('<div>').text(event.nbr_child+' '+_t('children')));
			if(event.meal_included){
				div.append($('<div>').text(_t('Meal included')));
			}
			if(event.observation){
				div.append($('<div>').text(event.observation));
			}
			return div;
		},
		
		event_data_transform: function(evt) {
			var r = this._super.apply(this,arguments);
			r.booking_name = evt.booking_name;
			r.hour_from = evt.hour_from;
			r.hour_to = evt.hour_to;
			r.observation = evt.observation;
			r.nbr_adult = evt.nbr_adult;
			r.nbr_child = evt.nbr_child;
			r.meal_included = evt.meal_included;
			return r;
		},

		get_title: function () {
			return _t("Create booking");
		},
		get_form_popup_infos: function() {
			var infos = {
				view_id: false,
				title: this.name,
			};
			if (!(_.isUndefined(this.ViewManager))) {
				infos.view_id = this.ViewManager.get_view_id('form');
			}
			return infos;
		},
		slow_create: function(data){
			
			var self = this;
			var defaults = {};
			
			_.each(data, function(val, field_name) {
				defaults['default_' + field_name] = val;
			});
			
			var pop_infos = self.get_form_popup_infos();
			var pop = new instance.web.form.FormOpenPopup(this);
			var context = new instance.web.CompoundContext(this.dataset.context, defaults);
			pop.show_element(this.dataset.model, null, this.dataset.get_context(defaults), {
				title: this.get_title(),
				disable_multiple_selection: true,
				view_id: pop_infos.view_id,
				// Ensuring we use ``self.dataset`` and DO NOT create a new one.
				create_function: function(data, options) {
{'fraction_non_alphanumeric': 0.15605191669182011, 'fraction_numerical': 0.0, 'mean_word_length': 3.784837545126354, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7053415', 'n_tokens_mistral': 2746, 'n_tokens_neox': 2257, 'n_words': 352}