From c95adf2c8a8530ad433d0de27781b22af093cfa3 Mon Sep 17 00:00:00 2001 From: "Vaibhav (OpenERP)" Date: Mon, 21 Nov 2011 14:45:12 +0530 Subject: [PATCH] [FIX] Reload and update record on Resize. bzr revid: vda@tinyerp.com-20111121091512-8o5wxtid0cky2on8 --- addons/web_gantt/static/src/js/gantt.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/addons/web_gantt/static/src/js/gantt.js b/addons/web_gantt/static/src/js/gantt.js index ec212c7007d..77170d103ff 100644 --- a/addons/web_gantt/static/src/js/gantt.js +++ b/addons/web_gantt/static/src/js/gantt.js @@ -87,13 +87,17 @@ init: function(parent, dataset, view_id) { projects = this.database_projects; if (!this.group_by.length) return def.resolve().promise(); - this.data_groups = _.groupBy(projects, function(project, index) { - return _.map(self.group_by, function(group, index) { + this.data_groups = _.groupBy(projects, function(project) { + return _.map(self.group_by, function(group) { if(!project[group]) project[group] = 'Undefined'; else if(project[group] instanceof Array) project[group] = project[group][1]; return project[group]; }); }); + + this.group_keys = _.map(this.group_by, function(group, index) { + return _.map(projects, function(project){return project[group]}); + }); return def.resolve().promise(); }, generate_projects : function() { @@ -102,6 +106,7 @@ init: function(parent, dataset, view_id) { this.GanttTasks = []; if(this.group_by.length) { + } else { this.GanttTasks.push(new GanttTaskInfo(0, self.name, self.project_start_date, self.total_duration, 100, "")); } @@ -198,10 +203,9 @@ init: function(parent, dataset, view_id) { var self = this; if (this.group_by.length) { - } else { - _.each(this.GanttTasks, function(tsk, index){ + _.each(this.GanttTasks, function(tsk, index) { self.GanttProjects.addTask(tsk); }); } @@ -238,7 +242,6 @@ init: function(parent, dataset, view_id) { ganttChartControl.attachEvent("onTaskEndResize", function(task) {return self.ResizeTask(task);}); ganttChartControl.attachEvent("onTaskEndDrag", function(task) {return self.ResizeTask(task);}); - ganttChartControl.attachEvent("onTaskClick", function(task) { return self.editTask(task);}); }, format_date : function(date) { @@ -257,7 +260,6 @@ init: function(parent, dataset, view_id) { }, ResizeTask: function(task) { - var self = this, event_id = task.getId(); @@ -277,6 +279,8 @@ init: function(parent, dataset, view_id) { this.dataset .write(event_id, data, {}) .done(function() { + var get_project = _.find(self.database_projects, function(project){ return project.id == event_id}); + _.extend(get_project,data); self.reloadView(); }); }, @@ -350,7 +354,7 @@ init: function(parent, dataset, view_id) { }).done(function(projects){ self.on_project_loaded(projects); }); - }) + }); } });