Merge lp:~openerp-dev/openerp-web/saas-3-fix-filters-calendar-jke into lp:~openerp/openerp-web/saas-3

Proposed by jke-openerp
Status: Merged
Merged at revision: 3943
Proposed branch: lp:~openerp-dev/openerp-web/saas-3-fix-filters-calendar-jke
Merge into: lp:~openerp/openerp-web/saas-3
Diff against target: 789 lines (+169/-150)
1 file modified
addons/web_calendar/static/src/js/web_calendar.js (+169/-150)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/saas-3-fix-filters-calendar-jke
Reviewer Review Type Date Requested Status
OpenERP Core Team Pending
Review via email: mp+206901@code.launchpad.net

Description of the change

Calendar
------------
Fix bug timezones
Fix bug dashboards
Fix bug filters

To post a comment you must log in.
3941. By jke-openerp

[FIX] Fix bug with timezone, for no all_day event also ! (Eg : in hr_holidays)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web_calendar/static/src/js/web_calendar.js'
2--- addons/web_calendar/static/src/js/web_calendar.js 2014-02-17 10:28:06 +0000
3+++ addons/web_calendar/static/src/js/web_calendar.js 2014-02-18 12:31:54 +0000
4@@ -5,9 +5,9 @@
5 _.str.toBoolElse = function(str, elseValues, trueValues, falseValues) {
6 var ret = _.str.toBool(str, trueValues, falseValues);
7 if (_.isUndefined(ret)) {
8- return elseValues
9+ return elseValues;
10 }
11- return ret
12+ return ret;
13 };
14
15 openerp.web_calendar = function(instance) {
16@@ -37,7 +37,7 @@
17 }
18
19 function isNullOrUndef(value) {
20- return _.isUndefined(value) || _.isNull(value)
21+ return _.isUndefined(value) || _.isNull(value);
22 }
23
24 instance.web.views.add('calendar', 'instance.web_calendar.CalendarView');
25@@ -60,7 +60,6 @@
26 this.range_start = null;
27 this.range_stop = null;
28 this.selected_filters = [];
29-
30 },
31
32 set_default_options: function(options) {
33@@ -72,7 +71,9 @@
34
35 destroy: function() {
36 this.$calendar.fullCalendar('destroy');
37- this.$small_calendar.datepicker('destroy');
38+ if (this.$small_calendar){
39+ this.$small_calendar.datepicker('destroy');
40+ }
41 this._super.apply(this, arguments);
42 },
43
44@@ -112,21 +113,21 @@
45 this.date_start = attrs.date_start; // Field name of starting date field
46 this.date_delay = attrs.date_delay; // duration
47 this.date_stop = attrs.date_stop;
48- this.all_day = attrs.all_day;
49- this.attendee_people = attrs.attendee;
50+ this.all_day = attrs.all_day;
51 this.how_display_event = '';
52-
53+ this.attendee_people = attrs.attendee;
54+
55 if (!isNullOrUndef(attrs.quick_create_instance)) {
56- self.quick_create_instance = 'instance.' + attrs.quick_create_instance;
57+ self.quick_create_instance = 'instance.' + attrs.quick_create_instance;
58 }
59
60 //if quick_add = False, we don't allow quick_add
61 //if quick_add = not specified in view, we use the default quick_create_instance
62 //if quick_add = is NOT False and IS specified in view, we this one for quick_create_instance'
63
64- this.quick_add_pop = (isNullOrUndef(attrs.quick_add) || _.str.toBoolElse(attrs.quick_add,true) );
65+ this.quick_add_pop = (isNullOrUndef(attrs.quick_add) || _.str.toBoolElse(attrs.quick_add,true) );
66 if (this.quick_add_pop && !isNullOrUndef(attrs.quick_add)) {
67- self.quick_create_instance = 'instance.' + attrs.quick_add;
68+ self.quick_create_instance = 'instance.' + attrs.quick_add;
69 }
70 // The display format which will be used to display the event where fields are between "[" and "]"
71 if (!isNullOrUndef(attrs.display)) {
72@@ -135,18 +136,29 @@
73
74 // If this field is set ot true, we don't open the event in form view, but in a popup with the view_id passed by this parameter
75 if (isNullOrUndef(attrs.event_open_popup) || !_.str.toBoolElse(attrs.event_open_popup,true)) {
76- this.open_popup_action = false;
77+ this.open_popup_action = false;
78 }
79 else {
80 this.open_popup_action = attrs.event_open_popup;
81 }
82
83- // If this field is set to true, we will use de calendar_friends model as filter and not the color field.
84- this.useContacts = (!isNullOrUndef(attrs.use_contacts) && _.str.toBool(attrs.use_contacts));
85+
86+ // If this field is set to true, we will use the calendar_friends model as filter and not the color field.
87+ this.useContacts = (!isNullOrUndef(attrs.use_contacts) && _.str.toBool(attrs.use_contacts)) && (!isNullOrUndef(self.options.$sidebar));
88
89 // If this field is set ot true, we don't add itself as an attendee when we use attendee_people to add each attendee icon on an event
90 // The color is the color of the attendee, so don't need to show again that it will be present
91- this.colorIsAttendee = (!(isNullOrUndef(attrs.color_is_attendee) || !_.str.toBoolElse(attrs.color_is_attendee,true)));
92+ this.colorIsAttendee = (!(isNullOrUndef(attrs.color_is_attendee) || !_.str.toBoolElse(attrs.color_is_attendee, true))) && (!isNullOrUndef(self.options.$sidebar));
93+
94+
95+
96+ // if we have not sidebar, (eg: Dashboard), we don't use the filter "coworkers"
97+ if (isNullOrUndef(self.options.$sidebar)) {
98+ this.useContacts = false;
99+ this.colorIsAttendee = false;
100+ this.attendee_people = undefined;
101+ }
102+
103
104 /*
105 Will be more logic to do it in futur, but see below to stay Retro-compatible
106@@ -164,14 +176,14 @@
107 }
108 */
109 if (isNullOrUndef(attrs.avatar_model)) {
110- this.avatar_model = null;
111+ this.avatar_model = null;
112 }
113 else {
114 this.avatar_model = attrs.avatar_model;
115 }
116
117 if (isNullOrUndef(attrs.avatar_title)) {
118- this.avatar_title = this.avatar_model;
119+ this.avatar_title = this.avatar_model;
120 }
121 else {
122 this.avatar_title = attrs.avatar_title;
123@@ -195,7 +207,7 @@
124 .call("check_access_rights", ["create", false])
125 .then(function (create_right) {
126 self.create_right = create_right;
127- self.init_calendar().then(function() {
128+ self.init_calendar().then(function() {
129 self.trigger('calendar_view_loaded', fv);
130 self.ready.resolve();
131 });
132@@ -231,15 +243,15 @@
133 self.proxy('update_record')(event._id, data);
134 },
135 eventRender: function (event, element, view) {
136- element.find('.fc-event-title').html(event.title);
137+ element.find('.fc-event-title').html(event.title);
138 },
139- eventAfterRender: function (event, element, view) {
140+ eventAfterRender: function (event, element, view) {
141 if ((view.name !== 'month') && (((event.end-event.start)/60000)<=30)) {
142 //if duration is too small, we see the html code of img
143 var current_title = $(element.find('.fc-event-time')).text();
144- var new_title = current_title.substr(0,current_title.indexOf("<img")>0?current_title.indexOf("<img"):current_title.length)
145+ var new_title = current_title.substr(0,current_title.indexOf("<img")>0?current_title.indexOf("<img"):current_title.length);
146 element.find('.fc-event-time').html(new_title);
147- }
148+ }
149 },
150 eventClick: function (event) { self.open_event(event._id,event.title); },
151 select: function (start_date, end_date, all_day, _js_event, _view) {
152@@ -248,7 +260,6 @@
153 end: end_date,
154 allDay: all_day,
155 });
156-
157 self.open_quick_create(data_template);
158
159 },
160@@ -277,7 +288,7 @@
161 agenda: 'h:mm{ - h:mm}', // 5:00 - 6:30
162
163 // for all other views
164- '': 'h(:mm)tt' // 7pm
165+ '': 'h(:mm)tt' // 7pm
166 },
167 weekMode : 'liquid',
168 aspectRatio: 1.8,
169@@ -294,11 +305,11 @@
170 context.$calendar.fullCalendar('changeView','agendaDay');
171 }
172 }
173- else if (curView.name != "agendaDay" || (curView.name == "agendaDay" && curDate.compareTo(curView.start)==0)) {
174+ else if (curView.name != "agendaDay" || (curView.name == "agendaDay" && curDate.compareTo(curView.start)===0)) {
175 context.$calendar.fullCalendar('changeView','agendaWeek');
176 }
177 context.$calendar.fullCalendar('gotoDate', obj.currentYear , obj.currentMonth, obj.currentDay);
178- }
179+ };
180 },
181
182 init_calendar: function() {
183@@ -312,9 +323,10 @@
184 this.$small_calendar.datepicker({ onSelect: self.calendarMiniChanged(self) });
185
186 if (this.useContacts) {
187+ //Get my Partner ID
188 new instance.web.Model("res.users").query(["partner_id"]).filter([["id", "=",this.dataset.context.uid]]).first()
189 .done(
190- function(result) {
191+ function(result) {
192 var sidebar_items = {};
193 var filter_value = result.partner_id[0];
194 var filter_item = {
195@@ -326,12 +338,12 @@
196 sidebar_items[filter_value] = filter_item ;
197 filter_item = {
198 value: -1,
199- label: _lt("All calendars"),
200+ label: _lt("Everybody's calendars"),
201 color: self.get_color(-1),
202 avatar_model: self.avatar_model
203 };
204 sidebar_items[-1] = filter_item ;
205-
206+ //Get my coworkers/contacts
207 new instance.web.Model("calendar.contacts").query(["partner_id"]).filter([["user_id", "=",self.dataset.context.uid]]).all().then(function(result) {
208 _.each(result, function(item) {
209 filter_value = item.partner_id[0];
210@@ -347,12 +359,12 @@
211 self.allFilters = sidebar_items;
212 self.sidebar.filter.events_loaded(sidebar_items);
213 self.sidebar.filter.addUpdateButton();
214- }).done(function () {
215- self.$calendar.fullCalendar('refetchEvents');
216+ }).done(function () {
217+ self.$calendar.fullCalendar('refetchEvents');
218 });
219 }
220- );
221- };
222+ );
223+ }
224 this.extraSideBar();
225
226 }
227@@ -380,7 +392,7 @@
228 delete this.quick;
229 this.$calendar.fullCalendar('unselect');
230 });
231- this.quick.replace($(".oe_calendar_qc_placeholder"));
232+ this.quick.replace(this.$el.find('.oe_calendar_qc_placeholder'));
233 this.quick.focus();
234
235 },
236@@ -486,13 +498,20 @@
237 event_data_transform: function(evt) {
238 var self = this;
239
240- var date_start = instance.web.auto_str_to_date(evt[this.date_start]),
241- date_stop = this.date_stop ? instance.web.auto_str_to_date(evt[this.date_stop]) : null,
242- date_delay = evt[this.date_delay] || 1.0,
243+ var date_delay = evt[this.date_delay] || 1.0,
244 all_day = this.all_day ? evt[this.all_day] : false,
245 res_computed_text = '',
246 the_title = '',
247- attendees = [];
248+ attendees = [];
249+
250+ if (!all_day) {
251+ date_start = instance.web.auto_str_to_date(evt[this.date_start]);
252+ date_stop = this.date_stop ? instance.web.auto_str_to_date(evt[this.date_stop]) : null;
253+ }
254+ else {
255+ date_start = instance.web.auto_str_to_date(evt[this.date_start].split(' ')[0],'date');
256+ date_stop = this.date_stop ? instance.web.auto_str_to_date(evt[this.date_stop].split(' ')[0],'date').addMinutes(-1) : null;
257+ }
258
259 if (this.info_fields) {
260 var temp_ret = {};
261@@ -526,7 +545,7 @@
262 temp_ret[fieldname] = value;
263 }
264 res_computed_text = res_computed_text.replace("["+fieldname+"]",temp_ret[fieldname]);
265- });
266+ });
267
268
269 if (res_computed_text.length) {
270@@ -534,8 +553,8 @@
271 }
272 else {
273 var res_text= [];
274- _.each(temp_ret, function(val,key) { res_text.push(val)} );
275- the_title = res_text.join(', ');
276+ _.each(temp_ret, function(val,key) { res_text.push(val); });
277+ the_title = res_text.join(', ');
278 }
279 the_title = _.escape(the_title);
280
281@@ -547,41 +566,41 @@
282 var attendee_showed = 0;
283 var attendee_other = '';
284
285- _.each(temp_ret[this.attendee_people],
286- function (the_attendee_people) {
287+ _.each(temp_ret[this.attendee_people],
288+ function (the_attendee_people) {
289 attendees.push(the_attendee_people);
290 attendee_showed += 1;
291- if (attendee_showed<= MAX_ATTENDEES) {
292- if (self.avatar_model != null) {
293- the_title_avatar += '<img title="' + self.all_attendees[the_attendee_people] + '" class="attendee_head" src="/web/binary/image?model=' + self.avatar_model + '&field=image_small&id=' + the_attendee_people + '"></img>';
294+ if (attendee_showed<= MAX_ATTENDEES) {
295+ if (self.avatar_model !== null) {
296+ the_title_avatar += '<img title="' + self.all_attendees[the_attendee_people] + '" class="attendee_head" \
297+ src="/web/binary/image?model=' + self.avatar_model + '&field=image_small&id=' + the_attendee_people + '"></img>';
298 }
299 else {
300 if (!self.colorIsAttendee || the_attendee_people != temp_ret[self.color_field]) {
301 tempColor = (self.all_filters[the_attendee_people] != undefined)
302 ? self.all_filters[the_attendee_people].color
303 : self.all_filters[-1].color;
304-
305- the_title_avatar += '<i class="fa fa-user attendee_head color_'+tempColor+'" title="' + self.all_attendees[the_attendee_people] + '" ></i>'
306+ the_title_avatar += '<i class="fa fa-user attendee_head color_'+tempColor+'" title="' + self.all_attendees[the_attendee_people] + '" ></i>';
307 }//else don't add myself
308 }
309 }
310 else {
311 attendee_other += self.all_attendees[the_attendee_people] +", ";
312- }
313+ }
314 }
315 );
316 if (attendee_other.length>2) {
317- the_title_avatar += '<span class="attendee_head" title="' + attendee_other.slice(0, -2) + '">+</span>';
318+ the_title_avatar += '<span class="attendee_head" title="' + attendee_other.slice(0, -2) + '">+</span>';
319 }
320 the_title = the_title_avatar + the_title;
321- }
322+ }
323 }
324
325 if (!date_stop && date_delay) {
326 date_stop = date_start.clone().addHours(date_delay);
327 }
328 if (this.fields[this.date_start].type != "date" && all_day) {
329- date_stop.addDays(-1);
330+ //date_stop.addDays(-1);
331 }
332 var r = {
333 'start': date_start.toString('yyyy-MM-dd HH:mm:ss'),
334@@ -593,20 +612,19 @@
335 };
336
337
338- if (!self.useContacts || self.all_filters[evt[this.color_field]] != undefined) {
339+ if (!self.useContacts || self.all_filters[evt[this.color_field]] !== undefined) {
340 if (this.color_field && evt[this.color_field]) {
341 var color_key = evt[this.color_field];
342 if (typeof color_key === "object") {
343 color_key = color_key[0];
344 }
345- r.className = 'cal_opacity calendar_color_'+ this.get_color(color_key);
346+ r.className = 'cal_opacity calendar_color_'+ this.get_color(color_key);
347 }
348 }
349 else { // if form all, get color -1
350
351 r.className = 'cal_opacity calendar_color_'+ self.all_filters[-1].color;
352 }
353-
354 return r;
355 },
356
357@@ -623,7 +641,7 @@
358
359 var event_end = event.end;
360 //Bug when we move an all_day event from week or day view, we don't have a dateend or duration...
361- if (event_end == null) {
362+ if (event_end === null) {
363 event_end = new Date(event.start).addHours(2);
364 }
365
366@@ -633,14 +651,14 @@
367 event_end = new Date(event.start);
368 }
369 if (this.all_day) {
370- event_end = (new Date(event_end.getTime())).addDays(1);
371- date_start_day = new Date(Date.UTC(event.start.getFullYear(),event.start.getMonth(),event.start.getDate()))
372- date_stop_day = new Date(Date.UTC(event_end.getFullYear(),event_end.getMonth(),event_end.getDate()))
373+ event_end = (new Date(event_end.getTime())).addDays(1);
374+ date_start_day = new Date(event.start.getFullYear(),event.start.getMonth(),event.start.getDate());
375+ date_stop_day = new Date(event_end.getFullYear(),event_end.getMonth(),event_end.getDate());
376 }
377 else {
378- date_start_day = new Date(Date.UTC(event.start.getFullYear(),event.start.getMonth(),event.start.getDate(),7))
379- date_stop_day = new Date(Date.UTC(event_end.getFullYear(),event_end.getMonth(),event_end.getDate(),19))
380- }
381+ date_start_day = new Date(event.start.getFullYear(),event.start.getMonth(),event.start.getDate(),7);
382+ date_stop_day = new Date(event_end.getFullYear(),event_end.getMonth(),event_end.getDate(),19);
383+ }
384 data[this.date_start] = instance.web.parse_value(date_start_day, this.fields[this.date_start]);
385 if (this.date_stop) {
386 data[this.date_stop] = instance.web.parse_value(date_stop_day, this.fields[this.date_stop]);
387@@ -652,13 +670,12 @@
388 data[this.date_start] = instance.web.parse_value(event.start, this.fields[this.date_start]);
389 if (this.date_stop) {
390 data[this.date_stop] = instance.web.parse_value(event_end, this.fields[this.date_stop]);
391- }
392-
393+ }
394 }
395
396
397 if (this.all_day) {
398- data[this.all_day] = event.allDay;
399+ data[this.all_day] = event.allDay;
400 }
401
402 if (this.date_delay) {
403@@ -667,8 +684,14 @@
404 }
405 return data;
406 },
407+
408 do_search: function(domain, context, _group_by) {
409 var self = this;
410+
411+ if (self.sidebar) {
412+ self.sidebar.filter.is_loaded = false;
413+ }
414+
415 if (! _.isUndefined(this.event_source)) {
416 this.$calendar.fullCalendar('removeEventSource', this.event_source);
417 }
418@@ -680,33 +703,32 @@
419 domain: self.get_range_domain(domain, start, end),
420 context: context,
421 }).done(function(events) {
422+
423 if (self.event_source !== current_event_source) {
424 console.log("Consecutive ``do_search`` called. Cancelling.");
425 return;
426 }
427- // We should make sure that *2many used in title of event have their extended form [ID, NAME]...
428
429- events = $.map(events, function (e) {
430-
431- if (self.attendee_people != undefined) { //If we filter on contacts...
432- if (_.intersection(self.selected_filters,e[self.attendee_people]).length || (self.selected_filters.indexOf(-1) > -1)) {
433- return e;
434- }
435- else {
436- return null;
437- }
438+ if (self.attendee_people !== undefined) {
439+ //Else we filter on 'Everybody's Calendar, we don't filter events
440+ if (self.selected_filters.indexOf(-1) == -1) {
441+
442+ //If we filter on contacts... we keep only events from coworkers
443+ events = $.map(events, function (e) {
444+ if (_.intersection(self.selected_filters,e[self.attendee_people]).length ) {
445+ return e;
446+ }
447+ return null;
448+ });
449 }
450- else { //We adds all events
451- return e;
452- }
453- return null;
454- });
455+ }
456
457- if (!self.useContacts) { // If we use all peoples as filter in sidebars
458+ if (!self.useContacts) { // If we use all peoples displayed in the current month as filter in sidebars
459 var now_filters = {};
460 var filter_value;
461 var filter_item;
462
463+
464 _.each(events, function (e) {
465 filter_value = e[self.color_field][0];
466 filter_item = {
467@@ -720,31 +742,44 @@
468 }
469 });
470
471+
472 self.allFilters = now_filters;
473- self.sidebar.filter.events_loaded(now_filters);
474-
475+
476+ if (self.sidebar) {
477+ if (!self.sidebar.filter.is_loaded) {
478+ self.sidebar.filter.events_loaded(now_filters);
479+ }
480+ else {
481+ events = $.map(events, function (e) {
482+ if (_.contains(self.selected_filters,e[self.color_field][0]) ) {
483+ return e;
484+ }
485+ return null;
486+ });
487+ }
488+ }
489 return self.perform_necessary_name_gets(events).then(callback);
490 }
491 else {
492 var all_attendees = [];
493
494 _.each(events, function (e) {
495- all_attendees.push(e[self.attendee_people]);
496+ all_attendees.push(e[self.attendee_people]);
497 });
498
499- self.all_attendees = {}
500+ self.all_attendees = {};
501
502 all_attendees = _.chain(all_attendees).flatten().uniq().value();
503
504- if (self.avatar_title != null) {
505+ if (self.avatar_title !== null) {
506 new instance.web.Model(self.avatar_title).query(["name"]).filter([["id", "in",all_attendees]]).all().then(function(result) {
507 _.each(result, function(item) {
508 self.all_attendees[item.id] = item.name;
509 });
510- }).done(function() {
511+ }).done(function() {
512 return self.perform_necessary_name_gets(events).then(callback);
513 });
514- }
515+ }
516 else {
517 _.each(all_attendees,function(item){
518 self.all_attendees[item] = '';
519@@ -752,10 +787,7 @@
520 return self.perform_necessary_name_gets(events).then(callback);
521
522 }
523-
524 }
525-
526-
527 });
528 },
529 eventDataTransform: function (event) {
530@@ -776,7 +808,6 @@
531 [this.date_start, '<=', format(end.clone())]]);
532 },
533
534-
535 /**
536 * Updates record identified by ``id`` with values in object ``data``
537 */
538@@ -799,26 +830,22 @@
539 }
540 return false;
541 },
542- open_event: function(id,title) {
543+ open_event: function(id, title) {
544 var self = this;
545- if (! this.open_popup_action) {
546+ if (! this.open_popup_action) {
547 var index = this.dataset.get_id_index(id);
548 this.dataset.index = index;
549 this.do_switch_view('form', null, { mode: "edit" });
550- }
551+ }
552 else {
553-
554- var self = this;
555-
556 var pop = new instance.web.form.FormOpenPopup(this);
557- console.log(this.open_popup_action, +this.open_popup_action);
558 pop.show_element(this.dataset.model, id, this.dataset.get_context(), {
559 title: _.str.sprintf(_t("View: %s"),title),
560 view_id: +this.open_popup_action,
561 res_id: id,
562 target: 'new',
563 readonly:true
564- });
565+ });
566
567 var form_controller = pop.view_form;
568 form_controller.on("load_record", self, function(){
569@@ -826,33 +853,25 @@
570 button_edit = _.str.sprintf("<button class='oe_button oe_bold editme oe_highlight'><span> %s </span></button>",_t("Edit Event"));
571
572
573- pop.$el.closest(".ui-dialog").find(".ui-dialog-buttonpane").prepend(button_delete)
574- pop.$el.closest(".ui-dialog").find(".ui-dialog-buttonpane").prepend(button_edit)
575+ pop.$el.closest(".ui-dialog").find(".ui-dialog-buttonpane").prepend(button_delete);
576+ pop.$el.closest(".ui-dialog").find(".ui-dialog-buttonpane").prepend(button_edit);
577
578 $('.delme').click(
579- function() {
580- $('.oe_form_button_cancel').trigger('click');
581- self.remove_event(id);
582+ function() {
583+ $('.oe_form_button_cancel').trigger('click');
584+ self.remove_event(id);
585 }
586 );
587 $('.editme').click(
588- function() {
589- $('.oe_form_button_cancel').trigger('click');
590-
591- var index = self.dataset.get_id_index(id);
592- self.dataset.index = index;
593+ function() {
594+ $('.oe_form_button_cancel').trigger('click');
595+ self.dataset.index = self.dataset.get_id_index(id);
596 self.do_switch_view('form', null, { mode: "edit" });
597-
598 }
599 );
600-
601-
602 });
603-
604- }
605-
606- return false;
607-
608+ }
609+ return false;
610 },
611
612 do_show: function() {
613@@ -896,6 +915,10 @@
614 slow_created: function () {
615 // refresh all view, because maybe some recurrents item
616 var self = this;
617+ if (self.sidebar) {
618+ // force filter refresh
619+ self.sidebar.filter.is_loaded = false;
620+ }
621 self.$calendar.fullCalendar('refetchEvents');
622 },
623
624@@ -929,7 +952,7 @@
625 template: 'CalendarView.quick_create',
626
627 init: function(parent, dataset, buttons, options, data_template) {
628- this._super(parent);
629+ this._super(parent);
630 this.dataset = dataset;
631 this._buttons = buttons || false;
632 this.options = options;
633@@ -940,7 +963,7 @@
634 get_title: function () {
635 var parent = this.getParent();
636 if (_.isUndefined(parent)) {
637- return _t("Create")
638+ return _t("Create");
639 }
640 var title = (_.isUndefined(parent.field_widget)) ?
641 (parent.string || parent.name) :
642@@ -961,7 +984,7 @@
643 if(event.keyCode == 13){
644 self.$input.off('keyup', enterHandler);
645 if (!self.quick_add()){
646- self.$input.on('keyup', enterHandler);
647+ self.$input.on('keyup', enterHandler);
648 }
649 }
650 });
651@@ -970,14 +993,13 @@
652 submit.click(function clickHandler() {
653 submit.off('click', clickHandler);
654 if (!self.quick_add()){
655- submit.on('click', clickHandler);
656- }
657+ submit.on('click', clickHandler); }
658 self.focus();
659 });
660 this.$el.find(".oe_calendar_quick_create_edit").click(function () {
661 self.slow_add();
662 self.focus();
663- });
664+ });
665 this.$el.find(".oe_calendar_quick_create_close").click(function (ev) {
666 ev.preventDefault();
667 self.trigger('close');
668@@ -993,7 +1015,6 @@
669 });
670
671 self.$el.on('dialogclose', self, function() {
672- console.log("dialogclose");
673 self.trigger('close');
674 });
675
676@@ -1007,10 +1028,10 @@
677 */
678 quick_add: function() {
679 var val = this.$input.val();
680- if (/^\s*$/.test(val)) {
681- return false;
682+ if (/^\s*$/.test(val)) {
683+ return false;
684 }
685- return this.quick_create({'name': val}).always(function() { return true });
686+ return this.quick_create({'name': val}).always(function() { return true; });
687 },
688
689 slow_add: function() {
690@@ -1052,18 +1073,14 @@
691 var self = this;
692 var def = $.Deferred();
693 var defaults = {};
694+
695 _.each($.extend({}, this.data_template, data), function(val, field_name) {
696 defaults['default_' + field_name] = val;
697 });
698-
699- if (defaults['default_allday'] && (defaults['default_date_deadline'] || defaults['default_duration'])) {
700- delete defaults['default_date_deadline'];
701- delete defaults['default_duration'];
702- }
703-
704+
705 var pop_infos = self.get_form_popup_infos();
706 var pop = new instance.web.form.FormOpenPopup(this);
707- var context = new instance.web.CompoundContext(this.dataset.context, defaults)
708+ var context = new instance.web.CompoundContext(this.dataset.context, defaults);
709 pop.show_element(this.dataset.model, null, this.dataset.get_context(defaults), {
710 title: this.get_title(),
711 disable_multiple_selection: true,
712@@ -1312,7 +1329,6 @@
713 },
714
715 render_value: function() {
716- console.log("In render value");
717 var self = this;
718 this.dataset.set_ids(this.get("value"));
719 this.is_loaded = this.is_loaded.then(function() {
720@@ -1356,7 +1372,7 @@
721 },
722
723 alternative_form_view: this.field.views ? this.field.views.form : undefined,
724- parent_view: this.view, //XXXvlab: to check ! this.view is likely undefined
725+ parent_view: this.view,
726 child_name: this.name,
727 readonly: this.get("effective_readonly")
728 });
729@@ -1373,19 +1389,26 @@
730 }
731 });
732 instance.web_calendar.SidebarFilter = instance.web.Widget.extend({
733+ is_loaded:false,
734 events: {
735 'change input:checkbox': 'filter_click'
736 },
737 init: function(parent, view) {
738 this._super(parent);
739- this.view = view;
740+ this.view = view;
741 },
742+
743+
744+
745 events_loaded: function(filters) {
746 var self = this;
747+ self.is_loaded=true;
748+
749 self.selected_filters = [];
750 self.view.all_filters = filters;
751 this.$el.html(QWeb.render('CalendarView.sidebar.responsible', { filters: filters }));
752- this.filter_click(null);
753+ this.filter_click(null);
754+
755 },
756 filter_click: function(e) {
757 var self = this,
758@@ -1394,25 +1417,21 @@
759 this.$('div.oe_calendar_responsible input:checked').each(function() {
760 responsibles.push($(this).val());
761
762- if (e==null && parseInt($(this).val())<0) {
763+ if (e==null && parseInt($(this).val())<0){
764 $(this).prop('checked',false);
765 return;
766- }
767+ }
768+
769 self.view.selected_filters.push(parseInt($(this).val()));
770 });
771-
772- if (e !== null) { //First intialize
773- self.view.$calendar.fullCalendar('refetchEvents');
774- }
775-
776-
777+ self.view.$calendar.fullCalendar('refetchEvents');
778 },
779 addUpdateButton: function() {
780 var self=this;
781 this.$('div.oe_calendar_all_responsibles').append(QWeb.render('CalendarView.sidebar.button_add_contact'));
782- this.$(".add_contacts_link_btn").on('click', function() {
783- self.rpc("/web/action/load", {
784- action_id: "calendar.action_calendar_contacts"
785+ this.$(".add_contacts_link_btn").on('click', function() {
786+ self.rpc("/web/action/load", {
787+ action_id: "calendar.action_calendar_contacts"
788 }).then( function(result) { return self.do_action(result); });
789 });
790

Subscribers

People subscribed via source and target branches