Commit 8fd30c47 authored by Jérome Perrin's avatar Jérome Perrin

GUI: update static version

parent ad68662d
......@@ -16,5 +16,8 @@
name="dream_import">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline ui-icon-plus ui-btn-icon-right">Import</button>
</form>
<form class="create_new_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline ui-icon-plus ui-btn-icon-right">Create New Empty</button>
</form>
</body>
</html>
\ No newline at end of file
/*global rJS, RSVP, promiseEventListener, promiseReadAsText,
initGadgetMixin */
initGadgetMixin, prompt */
(function(window, rJS, RSVP, promiseEventListener, promiseReadAsText, initGadgetMixin) {
"use strict";
function createDocument(gadget, name) {
......@@ -38,12 +38,39 @@
});
});
}
function waitForCreateNew(gadget) {
var json_data, name;
return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("create_new_form")[0], "submit", false);
}).push(function(evt) {
// Prevent double click
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
return gadget.aq_ajax({
url: "../DefaultConfiguration.json",
type: "GET"
});
}).push(function(evt) {
name = prompt("Name for this model");
var data = JSON.parse(evt.target.responseText);
data.general.name = name;
json_data = JSON.stringify(data);
return createDocument(gadget, name);
}).push(function(jio_document) {
// Add JSON as attachment
return gadget.aq_putAttachment({
_id: jio_document.id,
_attachment: "body.json",
_data: json_data,
_mimetype: "application/json"
});
});
}
var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_post", "jio_post").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantsToDisplayThisDocument", "whoWantsToDisplayThisDocument").declareMethod("startService", function() {
gadget_klass.declareAcquiredMethod("aq_post", "jio_post").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantsToDisplayThisDocument", "whoWantsToDisplayThisDocument").declareMethod("startService", function() {
var gadget = this;
return new RSVP.Queue().push(function() {
return waitForImport(gadget);
return RSVP.any([ waitForImport(gadget), waitForCreateNew(gadget) ]);
}).push(function(result) {
return gadget.whoWantsToDisplayThisDocument(result.id);
}).push(function(url) {
......
/*global rJS, RSVP, jQuery, promiseEventListener, initGadgetMixin */
/*global rJS, RSVP, jQuery, promiseEventListener, initGadgetMixin, alert */
/*jslint nomen: true */
(function(window, rJS, RSVP, $, promiseEventListener, initGadgetMixin) {
"use strict";
......
/*global console, jQuery, rJS, RSVP, alert, Handlebars, initGadgetMixin, confirm */
/*global console, jQuery, rJS, RSVP, alert, Handlebars, initGadgetMixin, confirm, alert */
/*jslint nomen: true */
(function(window, $, rJS, RSVP, Handlebars, initGadgetMixin) {
"use strict";
......
......@@ -72,7 +72,7 @@
// style only recursive fieldsets
gadget.props.fieldset_element.style["border-width"] = "1px";
gadget.props.fieldset_element.style["border-radius"] = "5px";
gadget.props.fieldset_element.style["padding"] = "1px";
gadget.props.fieldset_element.style.padding = "1px";
}
if (node_id) {
addField("id", options.property_definition.properties.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