Commit cc4b1072 authored by Kazuhiko Shiozaki's avatar Kazuhiko Shiozaki

store spreadsheet data in the same JSON as graph one.

parent bf763ba9
...@@ -271,8 +271,7 @@ ...@@ -271,8 +271,7 @@
$.ajax( $.ajax(
'/runSimulation', { '/runSimulation', {
data: JSON.stringify({ data: JSON.stringify({
json: model, json: model
spreadsheet: $.sheet.instance[0].exportSheet.json()
}), }),
contentType: 'application/json', contentType: 'application/json',
type: 'POST', type: 'POST',
......
...@@ -294,8 +294,37 @@ ...@@ -294,8 +294,37 @@
} else { } else {
dream_instance.redraw(); dream_instance.redraw();
} }
var spreadsheet = data.spreadsheet;
if (spreadsheet !== undefined) {
$.sheet.makeTable.json(JSON.parse(response.data));
}
}; };
// spreadsheet
var default_config = {
id: "jquerysheet-div",
style: '',
jquerySheet: true,
jquerySheetCss: true,
parser: true,
jqueryUiCss: true,
scrollTo: false,
jQueryUI: false,
raphaelJs: false,
gRaphaelJs: false,
colorPicker: false,
colorPickerCss: false,
elastic: false,
advancedMath: false,
finance: false,
editable: true,
autoFiller: true,
urlGet: 'lib/jquery.sheet-2.0.0/new_spreadsheet.html'
};
var sheet = $('.jQuerySheet').sheet(default_config);
// Check if there is already data when we first load the page, if yes, then build graph from it // Check if there is already data when we first load the page, if yes, then build graph from it
jio.get({ jio.get({
_id: "dream_demo" _id: "dream_demo"
...@@ -310,12 +339,6 @@ ...@@ -310,12 +339,6 @@
_id: "dream_demo", _id: "dream_demo",
data: data data: data
}, function (err, response) {}); }, function (err, response) {});
jio.put({
_id: "dream_demo.spreadsheet",
data: JSON.stringify($.sheet.instance[0].exportSheet.json(), undefined, " ")
}, function (err, response) {});
}); });
}); });
...@@ -486,46 +509,5 @@ ...@@ -486,46 +509,5 @@
$("#graph_zone").hide(); $("#graph_zone").hide();
// spreadsheet
var default_config = {
id: "jquerysheet-div",
style: '',
jquerySheet: true,
jquerySheetCss: true,
parser: true,
jqueryUiCss: true,
scrollTo: false,
jQueryUI: false,
raphaelJs: false,
gRaphaelJs: false,
colorPicker: false,
colorPickerCss: false,
elastic: false,
advancedMath: false,
finance: false,
editable: true,
autoFiller: true,
urlGet: 'lib/jquery.sheet-2.0.0/new_spreadsheet.html'
};
var sheet = $('.jQuerySheet').sheet(default_config);
// reread spreadsheet from jio
jio.get({
_id: "dream_demo.spreadsheet"
}, function (err, response) {
if (response !== undefined && response.data !== undefined) {
var config = $.extend({
buildSheet: $.sheet.makeTable.json(JSON.parse(response.data))
});
sheet.sheet(config);
}
});
sheet.bind('sheetCellEdited', function() {
// TODO
});
}); });
})(jQuery); })(jQuery);
...@@ -257,12 +257,16 @@ ...@@ -257,12 +257,16 @@
}; };
priv.getData = function () { priv.getData = function () {
return { var data = {
"nodes": priv.node_container, "nodes": priv.node_container,
"edges": priv.edge_container, "edges": priv.edge_container,
"preference": priv.preference_container, "preference": priv.preference_container,
"general": priv.general_container "general": priv.general_container
}; };
if ($.sheet.instance !== undefined) {
data['spreadsheet'] = $.sheet.instance[0].exportSheet.json();
}
return data;
}; };
priv.removeElement = function (element_id) { priv.removeElement = function (element_id) {
......
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