Merge lp:~openerp-dev/openerp-web/trunk-improve-calendar-dragdrop-bth into lp:openerp-web

Proposed by Thibault Delavallée (OpenERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openerp-web/trunk-improve-calendar-dragdrop-bth
Merge into: lp:openerp-web
Diff against target: 322 lines (+120/-20)
5 files modified
addons/web/static/src/css/base.css (+5/-0)
addons/web/static/src/css/base.sass (+4/-0)
addons/web_calendar/static/src/js/calendar.js (+109/-20)
addons/web_kanban/static/src/css/kanban.css (+1/-0)
addons/web_kanban/static/src/css/kanban.sass (+1/-0)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/trunk-improve-calendar-dragdrop-bth
Reviewer Review Type Date Requested Status
OpenERP R&D Web Team Pending
Review via email: mp+169200@code.launchpad.net
To post a comment you must log in.
3758. By Jignesh Rathod(OpenERP)

Merge with latest web.

3759. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3760. By Amit Bhavsar (Open ERP)

[MERGE] merge with latest trunk

3761. By Bhumi Thakkar (Open ERP)

[IMP]Get readonly modifiers from py file of date_start field of calendar view and set value of true or false to date_start field.

3762. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3763. By Bhumi Thakkar (Open ERP)

[IMP]Get attrs of start_date field from calendar view.

3764. By Bhumi Thakkar (Open ERP)

[IMP]ON date_start field drag & drop will work and improved code.

3765. By Bhumi Thakkar (Open ERP)

[IMP]Improved code to remove exist data from object.

3766. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3767. By Bhumi Thakkar (Open ERP)

[MERGE]Fixed issue of traceback on calendar view.

3768. By Bhumi Thakkar (Open ERP)

[IMP]Improved code for resize stop_date based on attribute of stop_date.

3769. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3770. By Bhumi Thakkar (Open ERP)

[IMP]Improved code to pop up existing value and push updated value.

3771. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3772. By Bhumi Thakkar (Open ERP)

[IMP]Improved code for reload dataset when create or update record.

3773. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3774. By Bhumi Thakkar (Open ERP)

[IMP]Code Optimization.

3775. By Bhumi Thakkar (Open ERP)

[IMP]Code Optimization.

3776. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3777. By Bhumi Thakkar (Open ERP)

[MERGE]Merge trunk.

3778. By Bhumi Thakkar (Open ERP)

[MERGE]Merge trunk.

Unmerged revisions

3778. By Bhumi Thakkar (Open ERP)

[MERGE]Merge trunk.

3777. By Bhumi Thakkar (Open ERP)

[MERGE]Merge trunk.

3776. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3775. By Bhumi Thakkar (Open ERP)

[IMP]Code Optimization.

3774. By Bhumi Thakkar (Open ERP)

[IMP]Code Optimization.

3773. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3772. By Bhumi Thakkar (Open ERP)

[IMP]Improved code for reload dataset when create or update record.

3771. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3770. By Bhumi Thakkar (Open ERP)

[IMP]Improved code to pop up existing value and push updated value.

3769. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'addons/web/static/src/css/base.css'
--- addons/web/static/src/css/base.css 2013-10-18 12:32:53 +0000
+++ addons/web/static/src/css/base.css 2013-11-08 10:26:02 +0000
@@ -1440,6 +1440,11 @@
1440 white-space: nowrap;1440 white-space: nowrap;
1441 text-overflow: ellipsis;1441 text-overflow: ellipsis;
1442}1442}
1443.openerp .oe_application .oe_breadcrumb_item:last-child {
1444 max-width: 17em;
1445 white-space: nowrap;
1446 text-overflow: ellipsis;
1447}
1443.openerp .oe_application .oe_breadcrumb_title > * {1448.openerp .oe_application .oe_breadcrumb_title > * {
1444 display: inline-block;1449 display: inline-block;
1445 overflow: hidden;1450 overflow: hidden;
14461451
=== modified file 'addons/web/static/src/css/base.sass'
--- addons/web/static/src/css/base.sass 2013-10-18 12:32:53 +0000
+++ addons/web/static/src/css/base.sass 2013-11-08 10:26:02 +0000
@@ -1157,6 +1157,10 @@
1157 max-width: 7em1157 max-width: 7em
1158 white-space: nowrap1158 white-space: nowrap
1159 text-overflow: ellipsis1159 text-overflow: ellipsis
1160 .oe_breadcrumb_item:last-child
1161 max-width: 17em
1162 white-space: nowrap
1163 text-overflow: ellipsis
1160 .oe_breadcrumb_title > *1164 .oe_breadcrumb_title > *
1161 display: inline-block1165 display: inline-block
1162 overflow: hidden1166 overflow: hidden
11631167
=== modified file 'addons/web_calendar/static/src/js/calendar.js'
--- addons/web_calendar/static/src/js/calendar.js 2013-08-28 16:58:15 +0000
+++ addons/web_calendar/static/src/js/calendar.js 2013-11-08 10:26:02 +0000
@@ -66,12 +66,15 @@
66 this._super();66 this._super();
67 },67 },
68 load_calendar: function(data) {68 load_calendar: function(data) {
69 var self = this;
69 this.fields_view = data;70 this.fields_view = data;
70 this.$el.addClass(this.fields_view.arch.attrs['class']);71 this.$el.addClass(this.fields_view.arch.attrs['class']);
71 this.calendar_fields = {};72 this.calendar_fields = {};
73 this.res_event = [];
72 this.ids = this.dataset.ids;74 this.ids = this.dataset.ids;
73 this.color_values = [];75 this.color_values = [];
74 this.info_fields = [];76 this.info_fields = [];
77 this.field_modifiers = [];
7578
76 this.name = this.fields_view.name || this.fields_view.arch.attrs.string;79 this.name = this.fields_view.name || this.fields_view.arch.attrs.string;
77 this.view_id = this.fields_view.view_id;80 this.view_id = this.fields_view.view_id;
@@ -83,7 +86,7 @@
83 this.date_start = this.fields_view.arch.attrs.date_start;86 this.date_start = this.fields_view.arch.attrs.date_start;
84 this.date_delay = this.fields_view.arch.attrs.date_delay;87 this.date_delay = this.fields_view.arch.attrs.date_delay;
85 this.date_stop = this.fields_view.arch.attrs.date_stop;88 this.date_stop = this.fields_view.arch.attrs.date_stop;
8689
87 this.day_length = this.fields_view.arch.attrs.day_length || 8;90 this.day_length = this.fields_view.arch.attrs.day_length || 8;
88 this.color_field = this.fields_view.arch.attrs.color;91 this.color_field = this.fields_view.arch.attrs.color;
89 this.color_string = this.fields_view.fields[this.color_field] ?92 this.color_string = this.fields_view.fields[this.color_field] ?
@@ -96,7 +99,6 @@
96 }99 }
97 }100 }
98 this.fields = this.fields_view.fields;101 this.fields = this.fields_view.fields;
99
100 if (!this.date_start) {102 if (!this.date_start) {
101 throw new Error(_t("Calendar view has not defined 'date_start' attribute."));103 throw new Error(_t("Calendar view has not defined 'date_start' attribute."));
102 }104 }
@@ -117,7 +119,17 @@
117 for (var fld = 0; fld < this.fields_view.arch.children.length; fld++) {119 for (var fld = 0; fld < this.fields_view.arch.children.length; fld++) {
118 this.info_fields.push(this.fields_view.arch.children[fld].attrs.name);120 this.info_fields.push(this.fields_view.arch.children[fld].attrs.name);
119 }121 }
120122 var modifiers = [], modifiers_stop = [];
123 this.field_attrs_modifiers = [];
124 _.each(this.fields_view.arch.children, function(r) {
125 if (r.attrs.attrs) {
126 modifier = JSON.parse(r.attrs.modifiers || '{}')
127 if (r.attrs.name == self.date_start)
128 self.field_attrs_modifiers = modifier['readonly'];
129 if (r.attrs.name == self.date_stop)
130 self.field_stop_modifiers = modifier['readonly'];
131 }
132 });
121 this.init_scheduler();133 this.init_scheduler();
122134
123 if (!this.sidebar && this.options.$sidebar) {135 if (!this.sidebar && this.options.$sidebar) {
@@ -125,6 +137,7 @@
125 this.has_been_loaded.then(this.sidebar.appendTo(this.$el.find('.oe_calendar_sidebar_container')));137 this.has_been_loaded.then(this.sidebar.appendTo(this.$el.find('.oe_calendar_sidebar_container')));
126 }138 }
127 this.trigger('calendar_view_loaded', data);139 this.trigger('calendar_view_loaded', data);
140
128 return this.has_been_loaded.resolve();141 return this.has_been_loaded.resolve();
129 },142 },
130 init_scheduler: function() {143 init_scheduler: function() {
@@ -231,7 +244,30 @@
231 }244 }
232 return false;245 return false;
233 });246 });
234247 scheduler.attachEvent('onBeforeDrag', function(event_id,mode,event) {
248 if (mode == "create") {
249 e = event || window.event; //e ||
250 scheduler.callEvent("onEmptyClick",[scheduler.getActionData(e).date, e]);
251 }
252 else{
253 for (i=0; i < self.res_event.length; i++) {
254 if (self.res_event[i].id == event_id) {
255 if (mode == "move") {
256 result = (self.res_event[i].readonly==true || self.res_event[i].readonly==1) ? false : true;
257 return result;
258 } else if (mode == "resize") {
259 var compute_domain = instance.web.form.compute_domain;
260 var res = [];
261 _.each(self.dataset_events[i], function(d, k){
262 res[k] = {'value': d};
263 });
264 result = (compute_domain(self.field_stop_modifiers, res) == true) ? false : true;
265 return result;
266 }
267 }
268 }
269 }
270 });
235 this.refresh_scheduler();271 this.refresh_scheduler();
236272
237 // Remove hard coded style attributes from dhtmlx scheduler273 // Remove hard coded style attributes from dhtmlx scheduler
@@ -256,7 +292,12 @@
256 scheduler.setCurrentView(scheduler._date);292 scheduler.setCurrentView(scheduler._date);
257 },293 },
258 reload_event: function(id) {294 reload_event: function(id) {
259 this.dataset.read_ids([id], _.keys(this.fields)).done(this.proxy('events_loaded'));295 var self = this;
296 this.id = id;
297 this.dataset.read_ids([id], _.keys(this.fields)).done(function(events) {
298 _.each(events, function(event){self.dataset_events.push(event);});
299 self.events_loaded(events, false, true);
300 });
260 },301 },
261 get_color: function(key) {302 get_color: function(key) {
262 if (this.color_map[key]) {303 if (this.color_map[key]) {
@@ -280,6 +321,16 @@
280 selection_label[value[0]] = value[1];321 selection_label[value[0]] = value[1];
281 });322 });
282 }323 }
324 if (this.fields[this.date_start].states) {
325 var states = [];
326 var res = "";
327 _.each (this.fields[this.date_start].states, function(modifier, state) {
328 if (modifier[0][0] == "readonly")
329 states.push(state);
330 res = (modifier[0][1] == false) ? ['state', 'not in', states] : ['state', 'in', states];
331 });
332 this.field_modifiers.push(res);
333 }
283 for (var e = 0; e < events.length; e++) {334 for (var e = 0; e < events.length; e++) {
284 var evt = events[e];335 var evt = events[e];
285 if (!evt[this.date_start]) {336 if (!evt[this.date_start]) {
@@ -313,14 +364,28 @@
313 evt.textColor = '#000000';364 evt.textColor = '#000000';
314 }365 }
315 }366 }
316367 if (this.fields[this.date_start]['type'] == 'date' || this.fields[this.date_start]['type'] == 'datetime') {
317 if (this.fields[this.date_start]['type'] == 'date') {
318 evt[this.date_start] = instance.web.auto_str_to_date(evt[this.date_start]).set({hour: 9}).toString('yyyy-MM-dd HH:mm:ss');368 evt[this.date_start] = instance.web.auto_str_to_date(evt[this.date_start]).set({hour: 9}).toString('yyyy-MM-dd HH:mm:ss');
319 }369 }
320 if (this.date_stop && evt[this.date_stop] && this.fields[this.date_stop]['type'] == 'date') {370 if (this.date_stop && evt[this.date_stop] && this.fields[this.date_stop]['type'] == 'date') {
321 evt[this.date_stop] = instance.web.auto_str_to_date(evt[this.date_stop]).set({hour: 17}).toString('yyyy-MM-dd HH:mm:ss');371 evt[this.date_stop] = instance.web.auto_str_to_date(evt[this.date_stop]).set({hour: 17}).toString('yyyy-MM-dd HH:mm:ss');
322 }372 }
323 res_events.push(this.convert_event(evt));373 var converted_data = this.convert_event(evt);
374 res_events.push(converted_data);
375
376 if (events.length == 1) {
377 for (i=0; i<this.res_event.length; i++) {
378 if (this.res_event[i].id == evt.id) {
379 this.res_event.pop(this.res_event[i].id);
380 }
381 }
382 }
383 if (events.length != this.res_event.length) {
384 this.res_event.push(converted_data);
385 }
386 }
387 if(events.length == this.res_event.length) {
388 this.res_event = res_events;
324 }389 }
325 scheduler.parse(res_events, 'json');390 scheduler.parse(res_events, 'json');
326 this.refresh_scheduler();391 this.refresh_scheduler();
@@ -332,8 +397,8 @@
332 var date_start = instance.web.str_to_datetime(evt[this.date_start]),397 var date_start = instance.web.str_to_datetime(evt[this.date_start]),
333 date_stop = this.date_stop ? instance.web.str_to_datetime(evt[this.date_stop]) : null,398 date_stop = this.date_stop ? instance.web.str_to_datetime(evt[this.date_stop]) : null,
334 date_delay = evt[this.date_delay] || 1.0,399 date_delay = evt[this.date_delay] || 1.0,
400 readonly = this.process_modifiers(evt),
335 res_text = '';401 res_text = '';
336
337 if (this.info_fields) {402 if (this.info_fields) {
338 res_text = _.map(this.info_fields, function(fld) {403 res_text = _.map(this.info_fields, function(fld) {
339 if(evt[fld] instanceof Array)404 if(evt[fld] instanceof Array)
@@ -348,7 +413,8 @@
348 'start_date': date_start.toString('yyyy-MM-dd HH:mm:ss'),413 'start_date': date_start.toString('yyyy-MM-dd HH:mm:ss'),
349 'end_date': date_stop.toString('yyyy-MM-dd HH:mm:ss'),414 'end_date': date_stop.toString('yyyy-MM-dd HH:mm:ss'),
350 'text': res_text.join(', '),415 'text': res_text.join(', '),
351 'id': evt.id416 'id': evt.id,
417 'readonly': readonly
352 };418 };
353 if (evt.color) {419 if (evt.color) {
354 r.color = evt.color;420 r.color = evt.color;
@@ -424,7 +490,6 @@
424 current_mode: function() {490 current_mode: function() {
425 return scheduler.getState().mode;491 return scheduler.getState().mode;
426 },492 },
427
428 quick_save: function(event_id, event_obj) {493 quick_save: function(event_id, event_obj) {
429 var self = this;494 var self = this;
430 var data = this.get_event_data(event_obj);495 var data = this.get_event_data(event_obj);
@@ -464,6 +529,7 @@
464 },529 },
465 slow_create: function(event_id, event_obj) {530 slow_create: function(event_id, event_obj) {
466 var self = this;531 var self = this;
532 var def = $.Deferred();
467 if (this.current_mode() === 'month') {533 if (this.current_mode() === 'month') {
468 event_obj['start_date'].addHours(8);534 event_obj['start_date'].addHours(8);
469 if (event_obj._length === 1) {535 if (event_obj._length === 1) {
@@ -477,7 +543,7 @@
477 _.each(this.get_event_data(event_obj), function(val, field_name) {543 _.each(this.get_event_data(event_obj), function(val, field_name) {
478 defaults['default_' + field_name] = val;544 defaults['default_' + field_name] = val;
479 });545 });
480 var something_saved = false;546 var something_saved = false, reload = false, created_id = null;
481 var pop = new instance.web.form.FormOpenPopup(this);547 var pop = new instance.web.form.FormOpenPopup(this);
482 var pop_infos = this.get_form_popup_infos();548 var pop_infos = this.get_form_popup_infos();
483 pop.show_element(this.dataset.model, null, this.dataset.get_context(defaults), {549 pop.show_element(this.dataset.model, null, this.dataset.get_context(defaults), {
@@ -485,16 +551,24 @@
485 disable_multiple_selection: true,551 disable_multiple_selection: true,
486 view_id: pop_infos.view_id,552 view_id: pop_infos.view_id,
487 });553 });
488 pop.on('closed', self, function() {
489 if (!something_saved) {
490 scheduler.deleteEvent(event_id);
491 }
492 });
493 pop.on('create_completed', self, function(id) {554 pop.on('create_completed', self, function(id) {
494 something_saved = true;555 something_saved = true;
556 def.resolve(id).promise();
495 self.dataset.ids.push(id);557 self.dataset.ids.push(id);
558 created_id = id;
496 scheduler.changeEventId(event_id, id);559 scheduler.changeEventId(event_id, id);
497 self.reload_event(id);560 });
561 pop.on('closed', self, function(id) {
562 $.when(def).then(function(id) {
563 if (something_saved) {
564 reload = true;
565 something_saved = false;
566 }
567 });
568 if (reload) {
569 self.reload_event(created_id);
570 reload = false;
571 }
498 });572 });
499 },573 },
500 open_event: function(event_id) {574 open_event: function(event_id) {
@@ -521,8 +595,12 @@
521 title: _.str.sprintf(_t("Edit: %s"), pop_infos.title),595 title: _.str.sprintf(_t("Edit: %s"), pop_infos.title),
522 view_id: pop_infos.view_id,596 view_id: pop_infos.view_id,
523 });597 });
524 pop.on('write_completed', self, function(){598 var reload = false;
525 self.reload_event(id_from_dataset);599 pop.on('closed', self, function() {
600 if(!reload){
601 self.reload_event(id_from_dataset);
602 reload = true;
603 }
526 });604 });
527 }605 }
528 },606 },
@@ -535,6 +613,17 @@
535 this.dataset.unlink(this.dataset.ids[index]);613 this.dataset.unlink(this.dataset.ids[index]);
536 }614 }
537 },615 },
616 process_modifiers: function(field){
617 var compute_domain = instance.web.form.compute_domain;
618 var res = [];
619 _.each(field, function(d, k){
620 res[k] = {'value': d};
621 });
622 var result = false;
623 if (this.field_attrs_modifiers.length) result = compute_domain(this.field_attrs_modifiers, res);
624 else if (this.field_modifiers.length) result = compute_domain(this.field_modifiers, res);
625 return result;
626 },
538});627});
539628
540instance.web_calendar.Sidebar = instance.web.Widget.extend({629instance.web_calendar.Sidebar = instance.web.Widget.extend({
541630
=== modified file 'addons/web_kanban/static/src/css/kanban.css'
--- addons/web_kanban/static/src/css/kanban.css 2013-10-02 09:37:30 +0000
+++ addons/web_kanban/static/src/css/kanban.css 2013-11-08 10:26:02 +0000
@@ -198,6 +198,7 @@
198}198}
199.openerp .oe_kanban_view .oe_kanban_add {199.openerp .oe_kanban_view .oe_kanban_add {
200 top: -8px;200 top: -8px;
201 z-index: 1;
201}202}
202.openerp .oe_kanban_view .oe_kanban_header .oe_dropdown_toggle {203.openerp .oe_kanban_view .oe_kanban_header .oe_dropdown_toggle {
203 top: -2px;204 top: -2px;
204205
=== modified file 'addons/web_kanban/static/src/css/kanban.sass'
--- addons/web_kanban/static/src/css/kanban.sass 2013-10-02 09:37:30 +0000
+++ addons/web_kanban/static/src/css/kanban.sass 2013-11-08 10:26:02 +0000
@@ -213,6 +213,7 @@
213 position: relative213 position: relative
214 .oe_kanban_add214 .oe_kanban_add
215 top: -8px215 top: -8px
216 z-index: 1
216 .oe_kanban_header .oe_dropdown_toggle217 .oe_kanban_header .oe_dropdown_toggle
217 top: -2px218 top: -2px
218 height: 14px219 height: 14px