Commit 5cb8c254 authored by Sebastien Robin's avatar Sebastien Robin

officejs task app: add parameter to allow grouping in planning

parent 100bde26
...@@ -131,6 +131,7 @@ ...@@ -131,6 +131,7 @@
gadget.property_dict.planning_widget = planning_widget; gadget.property_dict.planning_widget = planning_widget;
return planning_widget.render({ return planning_widget.render({
search_page: 'planning', search_page: 'planning',
//grouping_property: 'description',
mapping: {title: 'title', mapping: {title: 'title',
start: 'start_date', start: 'start_date',
stop: 'stop_date'}, stop: 'stop_date'},
......
...@@ -119,8 +119,11 @@ ...@@ -119,8 +119,11 @@
link, link,
container, container,
item_dict = {}, item_dict = {},
group_set = new Set(),
timeline, timeline,
group_value,
task, task,
group_data,
items = new vis.DataSet({ items = new vis.DataSet({
//type: { start: 'ISODate', end: 'ISODate' } //type: { start: 'ISODate', end: 'ISODate' }
}); });
...@@ -148,7 +151,7 @@ ...@@ -148,7 +151,7 @@
var options = { var options = {
//start: '2016-09-10', //start: '2016-09-10',
//end: '2016-09-30', //end: '2016-09-30',
height: '500px', //height: '500px',
// allow selecting multiple items using ctrl+click, shift+click, or hold. // allow selecting multiple items using ctrl+click, shift+click, or hold.
multiselect: true, multiselect: true,
...@@ -172,6 +175,11 @@ ...@@ -172,6 +175,11 @@
task = all_docs_result.data.rows[j].value; task = all_docs_result.data.rows[j].value;
item_id = all_docs_result.data.rows[j].id; item_id = all_docs_result.data.rows[j].id;
item.id = item_id; item.id = item_id;
if (option_dict.grouping_property !== undefined) {
group_value = task[option_dict.grouping_property];
group_set.add(group_value);
item.group = group_value;
}
item.content = task[option_dict.mapping.title]; item.content = task[option_dict.mapping.title];
item.start = task[option_dict.mapping.start]; item.start = task[option_dict.mapping.start];
item.end = task[option_dict.mapping.stop]; item.end = task[option_dict.mapping.stop];
...@@ -184,7 +192,18 @@ ...@@ -184,7 +192,18 @@
translated_column_list.push(gadget.translate(option_dict.column_list[i].title)); translated_column_list.push(gadget.translate(option_dict.column_list[i].title));
} }
items.add(item_list); items.add(item_list);
timeline = new vis.Timeline(container, items, options); timeline = new vis.Timeline(container);
timeline.setOptions(options);
timeline.setItems(items);
if (group_set.size !== 0) {
group_data = new vis.DataSet();
i = 0;
group_set.forEach(function (group_value) {
group_data.add({id: group_value, content: group_value});
i += 1;
});
timeline.setGroups(group_data);
}
}); });
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment