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

officejs: continue app handling task

parent a053bedc
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<meta charset="utf-8"> <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1"> <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="rsvp.js"></script>
<script src="renderjs.js"></script> <script src="renderjs.js"></script>
...@@ -14,6 +14,8 @@ ...@@ -14,6 +14,8 @@
</head> </head>
<body> <body>
<div data-gadget-url="gadget_officejs_widget_planning.html" data-gadget-scope="planning"></div> <div class='document-content'></div>
</body> </body>
</html> </html>
/*globals window, RSVP, rJS*/ /*globals window, RSVP, rJS, console*/
/*jslint indent: 2, nomen: true, maxlen: 80*/ /*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, RSVP, rJS) { (function (window, RSVP, rJS) {
"use strict"; "use strict";
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
return g.getElement() return g.getElement()
.push(function (element) { .push(function (element) {
g.props.element = element; g.props.element = element;
g.props.deferred = RSVP.defer();
}); });
}) })
.ready(function (g) { .ready(function (g) {
...@@ -78,12 +79,40 @@ ...@@ -78,12 +79,40 @@
}); });
}) })
.push(function () { .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) { .push(function (planning_gadget) {
return planning.render({ 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_page: 'planning',
search: options.search,
column_list: [{ column_list: [{
select: 'title', select: 'title',
title: 'Title' title: 'Title'
...@@ -111,7 +140,13 @@ ...@@ -111,7 +140,13 @@
sort_on: [["modification_date", "descending"]] sort_on: [["modification_date", "descending"]]
} }
}); });
})
.push(function () {
return text_gadget.getElement();
}); });
}); });
}(window, RSVP, rJS)); }(window, RSVP, rJS));
\ No newline at end of file
...@@ -26,3 +26,4 @@ ...@@ -26,3 +26,4 @@
</div> </div>
</body> </body>
</html> </html>
/*global window, rJS, RSVP, Handlebars, loopEventListener, vis, console */ /*global window, rJS, RSVP, Handlebars, vis, console */
/*jslint nomen: true, indent: 2 */ /*jslint nomen: true, indent: 2 */
(function (window, rJS, RSVP, vis, loopEventListener) { (function (window, rJS, RSVP, vis) {
"use strict"; "use strict";
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
// ready // ready
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
.ready(function (gadget) { .ready(function (gadget) {
console.log("widget_planning, ready");
gadget.property_dict = { gadget.property_dict = {
render_deferred: RSVP.defer() render_deferred: RSVP.defer()
}; };
...@@ -54,7 +53,6 @@ ...@@ -54,7 +53,6 @@
search_list = [], search_list = [],
translated_column_list = [], translated_column_list = [],
all_docs_result; all_docs_result;
console.log("widget_planning, render");
// store initial configuration // store initial configuration
gadget.property_dict.option_dict = option_dict; gadget.property_dict.option_dict = option_dict;
...@@ -76,7 +74,7 @@ ...@@ -76,7 +74,7 @@
} }
return RSVP.all(promise_list); return RSVP.all(promise_list);
}) })
.push(function (link_list) { .push(function (link_list) {
var row_list = [], var row_list = [],
cell_list, cell_list,
...@@ -94,15 +92,6 @@ ...@@ -94,15 +92,6 @@
type: { start: 'ISODate', end: 'ISODate' } 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 // log changes to the console
items.on('*', function (event, properties) { items.on('*', function (event, properties) {
...@@ -113,9 +102,9 @@ ...@@ -113,9 +102,9 @@
container = gadget.property_dict.element.querySelector(".planning-widget"); container = gadget.property_dict.element.querySelector(".planning-widget");
var options = { var options = {
start: '2016-09-10', //start: '2016-09-10',
end: '2016-09-30', //end: '2016-09-30',
height: '300px', 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,
...@@ -131,7 +120,8 @@ ...@@ -131,7 +120,8 @@
showCurrentTime: true 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) { for (j = 0, j_len = all_docs_result.data.total_rows; j < j_len; j += 1) {
item = {}; item = {};
link = link_list[j]; link = link_list[j];
...@@ -139,8 +129,7 @@ ...@@ -139,8 +129,7 @@
item.id = j; item.id = j;
item.content = task.title; item.content = task.title;
item.start = task.start_date; item.start = task.start_date;
//item.end = task.end_date; item.end = task.stop_date;
console.log("adding item", item);
item_list.push(item); item_list.push(item);
} }
console.log("item_list", item_list); console.log("item_list", item_list);
...@@ -151,31 +140,12 @@ ...@@ -151,31 +140,12 @@
items.add(item_list); items.add(item_list);
timeline = new vis.Timeline(container, items, options); 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