[imp]
bzr revid: nicolas.vanhoren@openerp.com-20120120145812-stii3u8jd2gmwe83
This commit is contained in:
parent
1a1a77afef
commit
6348133f5a
|
@ -12,7 +12,7 @@
|
||||||
'static/lib/dhtmlxGantt/sources/dhtmlxgantt.js',
|
'static/lib/dhtmlxGantt/sources/dhtmlxgantt.js',
|
||||||
'static/src/js/gantt.js'
|
'static/src/js/gantt.js'
|
||||||
],
|
],
|
||||||
"css": ['static/lib/dhtmlxGantt/codebase/dhtmlxgantt.css'],
|
"css": ['static/src/css/gantt.css', 'static/lib/dhtmlxGantt/codebase/dhtmlxgantt.css'],
|
||||||
'qweb' : [
|
'qweb' : [
|
||||||
"static/src/xml/*.xml",
|
"static/src/xml/*.xml",
|
||||||
],
|
],
|
||||||
|
|
|
@ -10,37 +10,84 @@ openerp.web.views.add('gantt', 'openerp.web_gantt.GanttView');
|
||||||
openerp.web_gantt.GanttView = openerp.web.View.extend({
|
openerp.web_gantt.GanttView = openerp.web.View.extend({
|
||||||
display_name: _lt('Gantt'),
|
display_name: _lt('Gantt'),
|
||||||
template: "GanttView",
|
template: "GanttView",
|
||||||
|
init: function() {
|
||||||
|
this._super.apply(this, arguments);
|
||||||
|
this.has_been_loaded = $.Deferred();
|
||||||
|
this.chart_id = _.uniqueId();
|
||||||
|
},
|
||||||
start: function() {
|
start: function() {
|
||||||
return this.rpc("/web/view/load", {"model": this.dataset.model, "view_id": this.view_id, "view_type": "gantt"}, this.on_loaded);
|
return $.when(this.rpc("/web/view/load", {"model": this.dataset.model, "view_id": this.view_id, "view_type": "gantt"}),
|
||||||
|
this.rpc("/web/searchview/fields_get", {"model": this.model})).pipe(this.on_loaded);
|
||||||
},
|
},
|
||||||
on_loaded: function(data) {
|
on_loaded: function(fields_view, fields_get) {
|
||||||
this.fields_view = data;
|
this.fields_view = fields_view;
|
||||||
|
this.fields = fields_get.fields;
|
||||||
|
this.has_been_loaded.resolve();
|
||||||
},
|
},
|
||||||
do_search: function (domains, contexts, groupbys) {
|
do_search: function (domains, contexts, group_bys) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var group_by = [];
|
// select the group by
|
||||||
|
var n_group_bys = [];
|
||||||
if (this.fields_view.arch.attrs.default_group_by) {
|
if (this.fields_view.arch.attrs.default_group_by) {
|
||||||
group_by = this.fields_view.arch.attrs.default_group_by.split(',');
|
n_group_bys = this.fields_view.arch.attrs.default_group_by.split(',');
|
||||||
|
}
|
||||||
|
if (group_bys.length) {
|
||||||
|
n_group_bys = groupbys;
|
||||||
|
}
|
||||||
|
// gather the fields to get
|
||||||
|
var fields = _.compact(_.map(["date_start", "date_delay", "date_stop", "color", "colors"], function(key) {
|
||||||
|
return self.fields_view.arch.attrs[key] || '';
|
||||||
|
}));
|
||||||
|
fields = _.uniq(fields.concat(["name"], n_group_bys));
|
||||||
|
|
||||||
|
return $.when(this.has_been_loaded).pipe(function() {
|
||||||
|
return self.dataset.read_slice(fields, {
|
||||||
|
domain: domains,
|
||||||
|
context: contexts
|
||||||
|
}).pipe(function(data) {
|
||||||
|
return self.on_data_loaded(data, n_group_bys);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
on_data_loaded: function(tasks, group_bys) {
|
||||||
|
var self = this;
|
||||||
|
$(".oe-gantt-view-view", this.$element).html("");
|
||||||
|
|
||||||
|
//prevent more that 1 group by
|
||||||
|
if (group_bys.length > 0) {
|
||||||
|
group_bys = [group_bys[0]];
|
||||||
|
}
|
||||||
|
// if there is no group by, simulate it
|
||||||
|
if (group_bys.length == 0) {
|
||||||
|
group_bys = ["_pseudo_group_by"];
|
||||||
|
_.each(tasks, function(el) {
|
||||||
|
el._pseudo_group_by = "Gantt View";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (groupbys.length) {
|
// get the groups
|
||||||
group_by = groupbys;
|
var groups = [];
|
||||||
}
|
_.each(tasks, function(task) {
|
||||||
// make something better
|
var group_name = task[group_bys[0]];
|
||||||
var fields = _.compact(_.map(this.fields_view.arch.attrs,function(value,key) {
|
var group = _.find(groups, function(group) { return _.isEqual(group.name, group_name); });
|
||||||
if (key != 'string' && key != 'default_group_by') {
|
if (group === undefined) {
|
||||||
return value || '';
|
group = {name:group_name, tasks: []};
|
||||||
|
groups.push(group);
|
||||||
}
|
}
|
||||||
}));
|
group.tasks.push(task);
|
||||||
fields = _.uniq(fields.concat(_.keys(this.fields), this.text, this.group_by));
|
|
||||||
$.when(this.has_been_loaded).then(function() {
|
|
||||||
self.dataset.read_slice(fields, {
|
|
||||||
domain: domains,
|
|
||||||
context: contexts
|
|
||||||
}).done(function(projects) {
|
|
||||||
self.on_project_loaded(projects);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// creation of the chart
|
||||||
|
debugger;
|
||||||
|
var gantt = new GanttChart();
|
||||||
|
_.each(groups, function(group) {
|
||||||
|
var project_1 = new GanttProjectInfo(1, "Yopla", new Date(2006, 5, 11));
|
||||||
|
var task_1 = new GanttTaskInfo(1, "Old code review", new Date(2006, 5, 11), 208, 50, "");
|
||||||
|
project_1.addTask(task_1);
|
||||||
|
gantt.addProject(project_1);
|
||||||
|
})
|
||||||
|
|
||||||
|
gantt.create(this.chart_id);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
<t t-name="GanttView">
|
<t t-name="GanttView">
|
||||||
<div>
|
<div>
|
||||||
<button class="oe_button oe-gantt-view-create">Create</button>
|
<button class="oe_button oe-gantt-view-create">Create</button>
|
||||||
<div class="oe-gantt-view-view"/>
|
<div t-att-id="widget.chart_id" class="oe-gantt-view-view"/>
|
||||||
</div>
|
</div>
|
||||||
</t>
|
</t>
|
||||||
<t t-name="GanttViewOld">
|
<t t-name="GanttViewOld">
|
||||||
|
|
Loading…
Reference in New Issue