Merge lp:~openerp-dev/openerp-web/7.0-bug-1072709-fme into lp:openerp-web/7.0

Proposed by Fabien Meghazi (OpenERP)
Status: Rejected
Rejected by: Fabien Meghazi (OpenERP)
Proposed branch: lp:~openerp-dev/openerp-web/7.0-bug-1072709-fme
Merge into: lp:openerp-web/7.0
Diff against target: 62 lines (+16/-14)
1 file modified
addons/web_calendar/static/src/js/calendar.js (+16/-14)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/7.0-bug-1072709-fme
Reviewer Review Type Date Requested Status
Olivier Dony (Odoo) Pending
Review via email: mp+155976@code.launchpad.net

Description of the change

As I couldn't think of the best behavior for this very strange calendar feature ( day_length ), I used a very simple and naive algorithm.

To post a comment you must log in.
3871. By Fabien Meghazi (OpenERP)

[REM] Removed useless variable

Revision history for this message
Fabien Meghazi (OpenERP) (fme) wrote :

This feature will/shall not be re-implemented :
https://bugs.launchpad.net/openerp-web/+bug/1072709/comments/2

Unmerged revisions

3872. By Fabien Meghazi (OpenERP)

[MERGE] 7.0

3871. By Fabien Meghazi (OpenERP)

[REM] Removed useless variable

3870. By Fabien Meghazi (OpenERP)

[IMP] Improved day_length a bit

3869. By Fabien Meghazi (OpenERP)

[WIP] Start support for day_length

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/calendar.js'
2--- addons/web_calendar/static/src/js/calendar.js 2013-03-21 22:54:02 +0000
3+++ addons/web_calendar/static/src/js/calendar.js 2013-03-28 16:56:21 +0000
4@@ -60,7 +60,6 @@
5 load_calendar: function(data) {
6 this.fields_view = data;
7 this.$el.addClass(this.fields_view.arch.attrs['class']);
8- this.calendar_fields = {};
9 this.ids = this.dataset.ids;
10 this.color_values = [];
11 this.info_fields = [];
12@@ -75,8 +74,8 @@
13 this.date_start = this.fields_view.arch.attrs.date_start;
14 this.date_delay = this.fields_view.arch.attrs.date_delay;
15 this.date_stop = this.fields_view.arch.attrs.date_stop;
16+ this.day_length = parseInt(this.fields_view.arch.attrs.day_length, 10) || 8;
17
18- this.day_length = this.fields_view.arch.attrs.day_length || 8;
19 this.color_field = this.fields_view.arch.attrs.color;
20 this.color_string = this.fields_view.fields[this.color_field] ?
21 this.fields_view.fields[this.color_field].string : _t("Filter");
22@@ -93,17 +92,8 @@
23 throw new Error(_t("Calendar view has not defined 'date_start' attribute."));
24 }
25
26- //* Calendar Fields *
27- this.calendar_fields.date_start = {'name': this.date_start, 'kind': this.fields[this.date_start].type};
28-
29- if (this.date_delay) {
30- if (this.fields[this.date_delay].type != 'float') {
31- throw new Error(_t("Calendar view has a 'date_delay' type != float"));
32- }
33- this.calendar_fields.date_delay = {'name': this.date_delay, 'kind': this.fields[this.date_delay].type};
34- }
35- if (this.date_stop) {
36- this.calendar_fields.date_stop = {'name': this.date_stop, 'kind': this.fields[this.date_stop].type};
37+ if (this.date_delay && this.fields[this.date_delay].type != 'float') {
38+ throw new Error(_t("Calendar view has a 'date_delay' type != float"));
39 }
40
41 for (var fld = 0; fld < this.fields_view.arch.children.length; fld++) {
42@@ -321,7 +311,19 @@
43 });
44 }
45 if (!date_stop && date_delay) {
46- date_stop = date_start.clone().addHours(date_delay);
47+ // `day_length` is a strange feature considering we have no concept
48+ // of working day timerange. Besides, there's no support for such
49+ // a thing in dhtmlxscheduler.
50+ var days = Math.floor(date_delay / this.day_length);
51+ var remaining_seconds = (date_delay % this.day_length) * 3600;
52+ if (!remaining_seconds) {
53+ // On rounded number of days, remove one second in order to
54+ // avoid spaning on one more day. Not exact but this is
55+ // what people expect.
56+ days -= 1;
57+ remaining_seconds = this.day_length * 3600 - 1;
58+ }
59+ date_stop = date_start.clone().addDays(days).addSeconds(remaining_seconds);
60 }
61 var r = {
62 'start_date': date_start.toString('yyyy-MM-dd HH:mm:ss'),