Commit 31b87a7c authored by Sebastien Robin's avatar Sebastien Robin

officejs: continue app handling task

parent a053bedc
......@@ -5,7 +5,7 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Text Editor List</title>
<title>OfficeJS Planning</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
......@@ -14,6 +14,8 @@
</head>
<body>
<div data-gadget-url="gadget_officejs_widget_planning.html" data-gadget-scope="planning"></div>
<div class='document-content'></div>
</body>
</html>
/*globals window, RSVP, rJS*/
/*globals window, RSVP, rJS, console*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, RSVP, rJS) {
"use strict";
......@@ -9,6 +9,7 @@
return g.getElement()
.push(function (element) {
g.props.element = element;
g.props.deferred = RSVP.defer();
});
})
.ready(function (g) {
......@@ -78,12 +79,40 @@
});
})
.push(function () {
return gadget.getDeclaredGadget("planning");
return gadget.props.deferred.resolve();
});
})
/////////////////////////////////////////
// Render text content gadget
/////////////////////////////////////////
.declareService(function () {
var gadget = this,
text_gadget = null;
return new RSVP.Queue()
.push(function () {
return gadget.props.deferred.promise;
})
.push(function () {
return gadget.declareGadget(
"gadget_officejs_widget_planning.html",
{
scope: "planning",
sandbox: "iframe",
element: gadget.props.element.querySelector(".document-content")
}
);
})
.push(function (planning) {
return planning.render({
.push(function (planning_gadget) {
var iframe = gadget.props.element.querySelector('iframe');
iframe.setAttribute(
'style',
'width:100%; border: 0 none; height: 600px'
);
text_gadget = planning_gadget;
return planning_gadget.render({
search_page: 'planning',
search: options.search,
column_list: [{
select: 'title',
title: 'Title'
......@@ -111,7 +140,13 @@
sort_on: [["modification_date", "descending"]]
}
});
})
.push(function () {
return text_gadget.getElement();
});
});
}(window, RSVP, rJS));
\ No newline at end of file
}(window, RSVP, rJS));
/*global window, rJS, RSVP, Handlebars, loopEventListener, vis, console */
/*global window, rJS, RSVP, Handlebars, vis, console */
/*jslint nomen: true, indent: 2 */
(function (window, rJS, RSVP, vis, loopEventListener) {
(function (window, rJS, RSVP, vis) {
"use strict";
/////////////////////////////////////////////////////////////////
......@@ -18,7 +18,6 @@
// ready
/////////////////////////////////////////////////////////////////
.ready(function (gadget) {
console.log("widget_planning, ready");
gadget.property_dict = {
render_deferred: RSVP.defer()
};
......@@ -54,7 +53,6 @@
search_list = [],
translated_column_list = [],
all_docs_result;
console.log("widget_planning, render");
// store initial configuration
gadget.property_dict.option_dict = option_dict;
......@@ -76,7 +74,7 @@
}
return RSVP.all(promise_list);
})
})
.push(function (link_list) {
var row_list = [],
cell_list,
......@@ -94,15 +92,6 @@
type: { start: 'ISODate', end: 'ISODate' }
});
// add items to the DataSet
/*items.add([
{id: 1, content: 'item 1<br>start', start: '2014-01-23'},
{id: 2, content: 'item 2', start: '2014-01-18'},
{id: 3, content: 'item 3', start: '2014-01-21'},
{id: 4, content: 'item 4', start: '2014-01-19', end: '2014-01-24'},
{id: 5, content: 'item 5', start: '2014-01-28', type: 'point'},
{id: 6, content: 'item 6', start: '2014-01-26'}
]);*/
// log changes to the console
items.on('*', function (event, properties) {
......@@ -113,9 +102,9 @@
container = gadget.property_dict.element.querySelector(".planning-widget");
var options = {
start: '2016-09-10',
end: '2016-09-30',
height: '300px',
//start: '2016-09-10',
//end: '2016-09-30',
height: '500px',
// allow selecting multiple items using ctrl+click, shift+click, or hold.
multiselect: true,
......@@ -131,7 +120,8 @@
showCurrentTime: true
};
// XXX We must not hardcode what is used for start and end, it must be
// parameters of this render method
for (j = 0, j_len = all_docs_result.data.total_rows; j < j_len; j += 1) {
item = {};
link = link_list[j];
......@@ -139,8 +129,7 @@
item.id = j;
item.content = task.title;
item.start = task.start_date;
//item.end = task.end_date;
console.log("adding item", item);
item.end = task.stop_date;
item_list.push(item);
}
console.log("item_list", item_list);
......@@ -151,31 +140,12 @@
items.add(item_list);
timeline = new vis.Timeline(container, items, options);
});
})
/////////////////////////////////////////////////////////////////
// declared service
/////////////////////////////////////////////////////////////////
.declareService(function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.property_dict.render_deferred.promise;
})
.push(function () {
return loopEventListener(
gadget.property_dict.element.querySelector('form'),
'submit',
false,
function (evt) {
return gadget.redirect({
jio_key: gadget.property_dict.option_dict.jio_key || '',
page: gadget.property_dict.option_dict.search_page || '',
search: evt.target[0].value
});
}
);
});
});
}(window, rJS, RSVP, vis, loopEventListener));
}(window, rJS, RSVP, vis));
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