update static

parent f5363e77
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit Shift Spreadsheet</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/jquery.js" type="text/javascript"></script>
<script src="../lib/jquerymobile.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="Input_viewShiftSpreadsheet.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url="../handsontable/index.html"
data-gadget-scope="tableeditor"></div>
<form class="save_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right">Save</button>
</form>
</body>
</html>
/*global rJS, RSVP, initGadgetMixin, loopEventListener */
(function(window, rJS, RSVP, initGadgetMixin, loopEventListener) {
"use strict";
function saveSpreadsheet(evt) {
var gadget = this, editor_data, editor_gadget;
return new RSVP.Queue().push(function() {
// Prevent double click
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
}
return gadget.getDeclaredGadget("tableeditor");
}).push(function(tablegadget) {
editor_gadget = tablegadget;
return editor_gadget.getData();
}).push(function(data) {
editor_data = data;
// Always get a fresh version, to prevent deleting spreadsheet & co
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
});
}).push(function(body) {
var data = JSON.parse(body);
data.shift_spreadsheet = JSON.parse(editor_data);
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json",
_data: JSON.stringify(data, null, 2),
_mimetype: "application/json"
});
}).push(function() {
if (evt) {
evt.target.getElementsByClassName("ui-btn")[0].disabled = false;
}
});
}
function waitForSave(gadget) {
return loopEventListener(gadget.props.element.getElementsByClassName("save_form")[0], "submit", false, saveSpreadsheet.bind(gadget));
}
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareMethod("render", function(options) {
var jio_key = options.id, gadget = this;
gadget.props.jio_key = jio_key;
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), {
minSpareRows: 1,
onChange: function() {
if (gadget.timeout) {
window.clearTimeout(gadget.timeout);
}
gadget.timeout = window.setTimeout(saveSpreadsheet.bind(gadget), 100);
}
});
});
}).declareMethod("startService", function() {
var gadget = this;
return this.getDeclaredGadget("tableeditor").push(function(tableeditor) {
return RSVP.all([ tableeditor.startService(), waitForSave(gadget) ]);
});
});
})(window, rJS, RSVP, initGadgetMixin, loopEventListener);
\ No newline at end of file
......@@ -100,6 +100,7 @@
});
return queue;
}).declareMethod("getContent", function() {
console.log("GET CONTENT SIMPLE FIELDSET");
var i, promise_list = [], gadget = this;
for (i = 0; i < this.props.field_gadget_list.length; i += 1) {
promise_list.push(this.props.field_gadget_list[i].getContent());
......@@ -118,7 +119,19 @@
}
}
}
console.log("GET CONTENT SIMPLE FIELDSET 2");
console.log(result);
return result;
});
}).declareMethod("startService", function() {
console.log("startservice FIElDSET 1");
var gadget = this, i, promise_list = [];
for (i = 0; i < gadget.props.field_gadget_list.length; i += 1) {
if (gadget.props.field_gadget_list[i].startService) {
promise_list.push(gadget.props.field_gadget_list[i].startService());
}
}
console.log("there are " + promise_list.length + " subgadget promises");
return RSVP.all(promise_list);
});
})(window, rJS, RSVP, Handlebars, initGadgetMixin);
\ No newline at end of file
......@@ -470,19 +470,24 @@
property_definition: schema
}, node_id) ]);
}).push(function(fieldset_gadget) {
node_edit_popup.enhanceWithin();
node_edit_popup.popup("open");
return fieldset_gadget[0];
console.log(fieldset_gadget[0]);
return RSVP.Queue().push(function() {
console.log(fieldset_gadget[0]);
fieldset_gadget[0].startService();
}).push(function() {
console.log(":::::::::::::::::::::::::::");
console.log(fieldset_gadget);
console.log(":::::::::::::::::::::::::::");
node_edit_popup.enhanceWithin();
node_edit_popup.popup("open");
return fieldset_gadget[0];
});
}).push(function(fieldset_gadget) {
// Expose the dialog handling promise so that we can wait for it in
// test.
console.log(":::::::::::::::::::2");
console.log(":::::::::::::::::::2");
console.log(":::::::::::::::::::2");
console.log("=======:::::::::::::::::::=======");
console.log(fieldset_gadget);
console.log(":::::::::::::::::::2");
console.log(":::::::::::::::::::2");
console.log(":::::::::::::::::::2");
console.log("=======:::::::::::::::::::=======");
gadget.props.dialog_promise = RSVP.any([ save_promise(fieldset_gadget, node_id), delete_promise ]);
return gadget.props.dialog_promise;
}).push(function() {
......
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