Commit 666bc534 authored by Romain Courteaud's avatar Romain Courteaud Committed by Jérome Perrin

Display spreadsheet with handsontable.

parent 1d3ff25a
......@@ -198,13 +198,13 @@ module.exports = function (grunt) {
},
handsontablejs: {
src: 'https://raw.githubusercontent.com/warpech/' +
'jquery-handsontable/v0.10.5/dist/jquery.handsontable.js',
'jquery-handsontable/v0.10.5/dist/jquery.handsontable.full.js',
relative_dest: 'lib/handsontable.js',
dest: '<%= global_config.dest %>/<%= curl.handsontablejs.relative_dest %>'
},
handsontablecss: {
src: 'https://raw.githubusercontent.com/warpech/' +
'jquery-handsontable/v0.10.5/dist/jquery.handsontable.css',
'jquery-handsontable/v0.10.5/dist/jquery.handsontable.full.css',
relative_dest: 'lib/handsontable.css',
dest: '<%= global_config.dest %>/<%= curl.handsontablecss.relative_dest %>'
// },
......
......@@ -8,7 +8,6 @@
<link rel="stylesheet" href="css/skeleton_wide.css">
<link rel="stylesheet" href="css/layout.css">
<link rel="stylesheet" href="css/jquery-ui-1.10.3.custom.min.css">
<link rel="stylesheet" type="text/css" href="css/jquery.handsontable.full.css">
<link rel="stylesheet" type="text/css" href="lib/dhtmlxgantt/dhtmlxgantt.css">
<link rel="stylesheet" href="css/demo-new.css">
<link rel="stylesheet" href="css/font-awesome.css">
......@@ -132,9 +131,6 @@
<script type="text/javascript" src="lib/jquery.flot.js"></script>
<script type="text/javascript" src="lib/jquery.flot.stack.js"></script>
<!-- spreadsheet -->
<script type="text/javascript" src="lib/jquery.handsontable.full.js"></script>
<!-- gantt chart -->
<script type="text/javascript" src="lib/dhtmlxgantt/dhtmlxgantt.js"></script>
......
......@@ -75,12 +75,12 @@
}
try {
// spreadsheets
var shift_spreadsheet_data = data.shift_spreadsheet;
if (shift_spreadsheet_data !== undefined) {
var spreadsheet = $('#shift_spreadsheet');
spreadsheet.handsontable('populateFromArray', 0, 0, shift_spreadsheet_data);
}
// // spreadsheets
// var shift_spreadsheet_data = data.shift_spreadsheet;
// if (shift_spreadsheet_data !== undefined) {
// var spreadsheet = $('#shift_spreadsheet');
// spreadsheet.handsontable('populateFromArray', 0, 0, shift_spreadsheet_data);
// }
var wip_part_spreadsheet_data = data.wip_part_spreadsheet;
if (wip_part_spreadsheet_data !== undefined) {
var spreadsheet = $('#wip_part_spreadsheet');
......
......@@ -11,6 +11,7 @@
<script src="edit_table.js" type="text/javascript"></script>
</head>
<body>
<section class="document_list"></section>
<div data-gadget-url="../handsontable/index.html"
data-gadget-scope="tableeditor"></div>
</body>
</html>
......@@ -33,12 +33,28 @@
var jio_key = options.id,
gadget = this;
gadget.props.jio_key = jio_key;
return gadget.aq_getAttachment({
"_id": jio_key,
"_attachment": "body.json"
})
.push(function (result) {
gadget.props.element.textContent = result;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.aq_getAttachment({
"_id": jio_key,
"_attachment": "body.json"
}),
gadget.getDeclaredGadget("tableeditor")
]);
})
.push(function (result_list) {
return result_list[1].render(
JSON.stringify(JSON.parse(result_list[0]).shift_spreadsheet)
);
});
})
.declareMethod("startService", function () {
return this.getDeclaredGadget("tableeditor")
.push(function (tableeditor) {
return tableeditor.startService();
});
});
}(window, rJS, RSVP, initDocumentPageMixin));
/*global jQuery, rJS, window, JSON */
/*global jQuery, rJS, window, JSON, RSVP */
(function (window, $, rJS, JSON) {
(function (window, $, rJS, JSON, RSVP) {
"use strict";
rJS(window)
......@@ -9,7 +9,14 @@
return this.getElement()
.push(function (element) {
$(element).find('.table-container')
.handsontable({data: data});
.handsontable({
data: data,
minSpareRows: 1,
stretchH: 'all'
// afterChange: function () {
// priv.onDataChange();
// }
});
});
})
......@@ -20,5 +27,22 @@
.handsontable('getData');
return JSON.stringify(data);
});
})
.declareMethod("startService", function () {
var gadget_element;
return this.getElement()
.push(function (element) {
gadget_element = element;
$(element).find('.table-container').handsontable("render");
})
.push(function () {
// Infinite wait, until cancelled
return (new RSVP.defer()).promise;
})
.push(undefined, function (error) {
$(gadget_element).find('.table-container').handsontable("destroy");
throw error;
});
});
}(window, jQuery, rJS, JSON));
}(window, jQuery, rJS, JSON, RSVP));
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