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
=== modified file 'addons/web_calendar/static/src/js/calendar.js'
--- addons/web_calendar/static/src/js/calendar.js 2013-03-21 22:54:02 +0000
+++ addons/web_calendar/static/src/js/calendar.js 2013-03-28 16:56:21 +0000
@@ -60,7 +60,6 @@
60 load_calendar: function(data) {60 load_calendar: function(data) {
61 this.fields_view = data;61 this.fields_view = data;
62 this.$el.addClass(this.fields_view.arch.attrs['class']);62 this.$el.addClass(this.fields_view.arch.attrs['class']);
63 this.calendar_fields = {};
64 this.ids = this.dataset.ids;63 this.ids = this.dataset.ids;
65 this.color_values = [];64 this.color_values = [];
66 this.info_fields = [];65 this.info_fields = [];
@@ -75,8 +74,8 @@
75 this.date_start = this.fields_view.arch.attrs.date_start;74 this.date_start = this.fields_view.arch.attrs.date_start;
76 this.date_delay = this.fields_view.arch.attrs.date_delay;75 this.date_delay = this.fields_view.arch.attrs.date_delay;
77 this.date_stop = this.fields_view.arch.attrs.date_stop;76 this.date_stop = this.fields_view.arch.attrs.date_stop;
77 this.day_length = parseInt(this.fields_view.arch.attrs.day_length, 10) || 8;
7878
79 this.day_length = this.fields_view.arch.attrs.day_length || 8;
80 this.color_field = this.fields_view.arch.attrs.color;79 this.color_field = this.fields_view.arch.attrs.color;
81 this.color_string = this.fields_view.fields[this.color_field] ?80 this.color_string = this.fields_view.fields[this.color_field] ?
82 this.fields_view.fields[this.color_field].string : _t("Filter");81 this.fields_view.fields[this.color_field].string : _t("Filter");
@@ -93,17 +92,8 @@
93 throw new Error(_t("Calendar view has not defined 'date_start' attribute."));92 throw new Error(_t("Calendar view has not defined 'date_start' attribute."));
94 }93 }
9594
96 //* Calendar Fields *95 if (this.date_delay && this.fields[this.date_delay].type != 'float') {
97 this.calendar_fields.date_start = {'name': this.date_start, 'kind': this.fields[this.date_start].type};96 throw new Error(_t("Calendar view has a 'date_delay' type != float"));
98
99 if (this.date_delay) {
100 if (this.fields[this.date_delay].type != 'float') {
101 throw new Error(_t("Calendar view has a 'date_delay' type != float"));
102 }
103 this.calendar_fields.date_delay = {'name': this.date_delay, 'kind': this.fields[this.date_delay].type};
104 }
105 if (this.date_stop) {
106 this.calendar_fields.date_stop = {'name': this.date_stop, 'kind': this.fields[this.date_stop].type};
107 }97 }
10898
109 for (var fld = 0; fld < this.fields_view.arch.children.length; fld++) {99 for (var fld = 0; fld < this.fields_view.arch.children.length; fld++) {
@@ -321,7 +311,19 @@
321 });311 });
322 }312 }
323 if (!date_stop && date_delay) {313 if (!date_stop && date_delay) {
324 date_stop = date_start.clone().addHours(date_delay);314 // `day_length` is a strange feature considering we have no concept
315 // of working day timerange. Besides, there's no support for such
316 // a thing in dhtmlxscheduler.
317 var days = Math.floor(date_delay / this.day_length);
318 var remaining_seconds = (date_delay % this.day_length) * 3600;
319 if (!remaining_seconds) {
320 // On rounded number of days, remove one second in order to
321 // avoid spaning on one more day. Not exact but this is
322 // what people expect.
323 days -= 1;
324 remaining_seconds = this.day_length * 3600 - 1;
325 }
326 date_stop = date_start.clone().addDays(days).addSeconds(remaining_seconds);
325 }327 }
326 var r = {328 var r = {
327 'start_date': date_start.toString('yyyy-MM-dd HH:mm:ss'),329 'start_date': date_start.toString('yyyy-MM-dd HH:mm:ss'),