static update

parent 408ec70d
...@@ -84,20 +84,22 @@ ...@@ -84,20 +84,22 @@
// Precompile the templates while loading the first gadget instance // Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window); var gadget_klass = rJS(window);
initGadgetMixin(gadget_klass); initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("aq_getConfigurationDict", "getConfigurationDict").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantsToDisplayThisDocument", "whoWantsToDisplayThisDocument").declareMethod("render", function(options) { gadget_klass.declareAcquiredMethod("aq_getAttachment", "jio_getAttachment").declareAcquiredMethod("aq_putAttachment", "jio_putAttachment").declareAcquiredMethod("aq_ajax", "jio_ajax").declareAcquiredMethod("pleaseRedirectMyHash", "pleaseRedirectMyHash").declareAcquiredMethod("whoWantsToDisplayThisDocument", "whoWantsToDisplayThisDocument").declareMethod("render", function(options) {
var gadget = this, property_list, data; var gadget = this, data;
this.props.jio_key = options.id; this.props.jio_key = options.id;
return gadget.aq_getAttachment({ return gadget.aq_getAttachment({
_id: gadget.props.jio_key, _id: gadget.props.jio_key,
_attachment: "body.json" _attachment: "body.json"
}).push(function(json) { }).push(function(json) {
data = JSON.parse(json).general; var application_configuration = {};
return gadget.aq_getConfigurationDict(); data = JSON.parse(json);
}).push(function(configuration_dict) { application_configuration = data.application_configuration.general || {};
property_list = configuration_dict["Dream-Configuration"].property_list; return gadget.getDeclaredGadget("fieldset").push(function(fieldset_gadget) {
return gadget.getDeclaredGadget("fieldset"); return fieldset_gadget.render({
}).push(function(fieldset_gadget) { value: data.general,
return fieldset_gadget.render(property_list, data); property_definition: application_configuration
});
});
}); });
}).declareMethod("startService", function() { }).declareMethod("startService", function() {
return waitForRunSimulation(this); return waitForRunSimulation(this);
......
...@@ -303,15 +303,10 @@ ...@@ -303,15 +303,10 @@
$(panel).trigger("create"); $(panel).trigger("create");
}); });
}).ready(function(g) { }).ready(function(g) {
var jio_gadget;
//console.log('@@@@@@@@@@@@@@@getting DeclalredGadget@@@@@@@@@@@@@@@'); //console.log('@@@@@@@@@@@@@@@getting DeclalredGadget@@@@@@@@@@@@@@@');
//console.log(g); //console.log(g);
return g.getDeclaredGadget("jio").push(function(gadget) { return g.getDeclaredGadget("jio").push(function(gadget) {
jio_gadget = gadget; return gadget.createJio({
//console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
//console.log(jio_gadget);
//console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
return jio_gadget.createJio({
type: "local", type: "local",
username: "dream", username: "dream",
applicationname: "dream" applicationname: "dream"
...@@ -354,7 +349,28 @@ ...@@ -354,7 +349,28 @@
console.log(portal_type); console.log(portal_type);
console.log(options); console.log(options);
console.log(portal_types[portal_type]); console.log(portal_types[portal_type]);
// Get the action information /*return gadget.getDeclaredGadget("jio")
.push(function(jio_gadget) {
if (options.id) {
return jio_gadget.getAttachment({
"_id": options.id,
"_attachment": "body.json"
});
}
})
.push(function(result) {
var data;
if (result) {
data = JSON.parse(result);
gadget.props.data = data;
portal_types.Input = data.application_configuration.input;
portal_types.Output = data.application_configuration.output;
}
// Get the action information
return gadget.declareGadget(
portal_types[portal_type][options.action].gadget + ".html"
);
})*/
return gadget.declareGadget(portal_types[portal_type][options.action].gadget + ".html").push(function(g) { return gadget.declareGadget(portal_types[portal_type][options.action].gadget + ".html").push(function(g) {
page_gadget = g; page_gadget = g;
if (page_gadget.render !== undefined) { if (page_gadget.render !== undefined) {
......
...@@ -152,8 +152,6 @@ ...@@ -152,8 +152,6 @@
var gadget, doc_list, innerHTML; var gadget, doc_list, innerHTML;
gadget = this; gadget = this;
doc_list = gadget.props.element.querySelector(".document_list"); doc_list = gadget.props.element.querySelector(".document_list");
console.log("list created? 1");
console.log(doc_list);
// helper: add options to selects // helper: add options to selects
function makeListItems(row_list) { function makeListItems(row_list) {
console.log("MAKEDOCUMENTLIST 1"); console.log("MAKEDOCUMENTLIST 1");
...@@ -202,9 +200,7 @@ ...@@ -202,9 +200,7 @@
form = e.target; form = e.target;
element = form.querySelector("div.ui-focus"); element = form.querySelector("div.ui-focus");
if (element === null || element === "undefined") { if (element === null || element === "undefined") {
console.log(0);
element = form.querySelector("input.ui-state-focus"); element = form.querySelector("input.ui-state-focus");
console.log(element);
id = element.name.replace("record_", ""); id = element.name.replace("record_", "");
} else { } else {
id = element.childNodes[1].name.replace("record_", ""); id = element.childNodes[1].name.replace("record_", "");
...@@ -242,14 +238,11 @@ ...@@ -242,14 +238,11 @@
form = e.target; form = e.target;
promise_list = []; promise_list = [];
element_list = form.querySelectorAll("label.ui-checkbox-on"); element_list = form.querySelectorAll("label.ui-checkbox-on");
console.log(element_list);
if (element_list) { if (element_list) {
for (i = 0, len = element_list.length; i < len; i += 1) { for (i = 0, len = element_list.length; i < len; i += 1) {
element = element_list[i].nextSibling; element = element_list[i].nextSibling;
id = element.name.replace("record_", ""); id = element.name.replace("record_", "");
console.log(id);
list_element = element.parentNode.parentNode.parentNode; list_element = element.parentNode.parentNode.parentNode;
console.log(list_element);
list_element.parentNode.removeChild(list_element); list_element.parentNode.removeChild(list_element);
if (form.querySelector("ul").children.length === 0) { if (form.querySelector("ul").children.length === 0) {
fragment = document.createElement("li"); fragment = document.createElement("li");
...@@ -267,8 +260,6 @@ ...@@ -267,8 +260,6 @@
} }
} }
console.log("HANDLING DELETE 2"); console.log("HANDLING DELETE 2");
console.log("list created? 1");
console.log(doc_list);
return RSVP.all(promise_list); return RSVP.all(promise_list);
} }
return gadget.aq_allDocs({ return gadget.aq_allDocs({
...@@ -290,8 +281,6 @@ ...@@ -290,8 +281,6 @@
while (doc_list.firstChild) { while (doc_list.firstChild) {
doc_list.removeChild(doc_list.firstChild); doc_list.removeChild(doc_list.firstChild);
} }
console.log("list created? last");
console.log(doc_list);
doc_list.innerHTML = innerHTML; doc_list.innerHTML = innerHTML;
// enhance/refresh // enhance/refresh
$doc = $(doc_list); $doc = $(doc_list);
...@@ -310,10 +299,8 @@ ...@@ -310,10 +299,8 @@
console.log("VIEWADDINSTANCE STARTSERVICE 1"); console.log("VIEWADDINSTANCE STARTSERVICE 1");
var gadget = this; var gadget = this;
return new RSVP.Queue().push(function() { return new RSVP.Queue().push(function() {
console.log("VIEWADDINSTANCE STARTSERVICE 2");
return RSVP.any([ waitForImport(gadget), waitForDefault(gadget) ]); return RSVP.any([ waitForImport(gadget), waitForDefault(gadget) ]);
}).push(function(result) { }).push(function(result) {
console.log("VIEWADDINSTANCE STARTSERVICE 3");
return gadget.whoWantsToDisplayThisDocument(result[0].id); return gadget.whoWantsToDisplayThisDocument(result[0].id);
}).push(function(url) { }).push(function(url) {
console.log("VIEWADDINSTANCE STARTSERVICE 4"); console.log("VIEWADDINSTANCE STARTSERVICE 4");
......
This diff is collapsed.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Fieldset</title>
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="../lib/handlebars.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 id="expand-label-template" type="text/x-handlebars-template">
<label for="{{for}}">{{name}}</label>
</script>
<script id="expand-option-template" type="text/x-handlebars-template">
<option value="{{value}}">{{text}}</option>
</script>
<script id="selected-expand-option-template" type="text/x-handlebars-template">
<option selected="selected" value="{{value}}">{{text}}</option>
</script>
<script src="../dream/mixin_gadget.js" type="text/javascript"></script>
<script src="expandablefield.js" type="text/javascript"></script>
</head>
<body>
<select />
</body>
</html>
/*global rJS, RSVP, jQuery, Handlebars, /*global rJS, RSVP, jQuery, Handlebars,
promiseEventListener, initGadgetMixin*/ promiseEventListener, initGadgetMixin, console */
/*jslint nomen: true */ /*jslint nomen: true */
(function(window, rJS, RSVP, Handlebars, initGadgetMixin) { (function(window, rJS, RSVP, Handlebars, initGadgetMixin) {
"use strict"; "use strict";
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
// XXX node_id is added like a property so that one can change the node // XXX node_id is added like a property so that one can change the node
// id // id
var gadget = this, queue; var gadget = this, queue;
console.log("FIELDSET RENDER 1");
console.log(options);
console.log(node_id);
gadget.props.key = options.key; gadget.props.key = options.key;
// used for recursive fieldsets // used for recursive fieldsets
gadget.props.field_gadget_list = []; gadget.props.field_gadget_list = [];
...@@ -21,10 +24,23 @@ ...@@ -21,10 +24,23 @@
queue.push(function() { queue.push(function() {
// XXX this is incorrect for recursive fieldsets. // XXX this is incorrect for recursive fieldsets.
// we should use nested fieldset with legend // we should use nested fieldset with legend
console.log("insertingAdjacentHTML for:" + property_id);
gadget.props.element.insertAdjacentHTML("beforeend", label_template({ gadget.props.element.insertAdjacentHTML("beforeend", label_template({
"for": property_id, "for": property_id,
name: property_definition.name || property_id name: property_definition.name || property_id
})); }));
console.log("....................");
console.log(property_id);
console.log(property_definition);
console.log(value);
// XXX maybe type should be used instead
if (property_definition.allOf) {
// if there is type property then remove it
if (property_definition.allOf[0].type) {
delete property_definition.allOf[0].type;
}
return gadget.declareGadget("../expandable_field/index.html");
}
if (property_definition.type === "object") { if (property_definition.type === "object") {
// Create a recursive fieldset for this key. // Create a recursive fieldset for this key.
return gadget.declareGadget("../fieldset/index.html"); return gadget.declareGadget("../fieldset/index.html");
...@@ -57,9 +73,27 @@ ...@@ -57,9 +73,27 @@
}, node_id); }, node_id);
} }
Object.keys(options.property_definition.properties).forEach(function(property_name) { Object.keys(options.property_definition.properties).forEach(function(property_name) {
var property_definition = options.property_definition.properties[property_name], value = (options.value || {})[property_name] === undefined ? property_definition._default : options.value[property_name]; var property_definition = options.property_definition.properties[property_name], value = property_definition.default, i = 0, property;
// XXX some properties are not editable if (property_definition.allOf) {
if (property_name !== "coordinate" && property_name !== "_class") { if (property_definition.allOf[0].properties) {
for (property in property_definition.allOf[0].properties) {
if (property_definition.allOf[0].properties.hasOwnProperty(property)) {
i += 1;
if (i > 1) {
console.log("something is wrong!");
}
value = property_definition.allOf[0].properties[property].default;
}
}
}
}
console.log("TRYING TO FIND A VALUE!!!!");
console.log(options);
console.log(options.value);
console.log(property_name);
value = (options.value || {})[property_name] === undefined ? value : options.value[property_name];
if (property_name !== "coordinate" && property_name !== "_class" && property_name !== "id") {
console.log("ADDING FIELD FOR " + property_name + "!!!!!!!");
addField(property_name, property_definition, value); addField(property_name, property_definition, value);
} }
}); });
......
This diff is collapsed.
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