static update

parent 408ec70d
......@@ -84,20 +84,22 @@
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window);
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) {
var gadget = this, property_list, data;
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, data;
this.props.jio_key = options.id;
return gadget.aq_getAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json"
}).push(function(json) {
data = JSON.parse(json).general;
return gadget.aq_getConfigurationDict();
}).push(function(configuration_dict) {
property_list = configuration_dict["Dream-Configuration"].property_list;
return gadget.getDeclaredGadget("fieldset");
}).push(function(fieldset_gadget) {
return fieldset_gadget.render(property_list, data);
var application_configuration = {};
data = JSON.parse(json);
application_configuration = data.application_configuration.general || {};
return gadget.getDeclaredGadget("fieldset").push(function(fieldset_gadget) {
return fieldset_gadget.render({
value: data.general,
property_definition: application_configuration
});
});
});
}).declareMethod("startService", function() {
return waitForRunSimulation(this);
......
......@@ -303,15 +303,10 @@
$(panel).trigger("create");
});
}).ready(function(g) {
var jio_gadget;
//console.log('@@@@@@@@@@@@@@@getting DeclalredGadget@@@@@@@@@@@@@@@');
//console.log(g);
return g.getDeclaredGadget("jio").push(function(gadget) {
jio_gadget = gadget;
//console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
//console.log(jio_gadget);
//console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
return jio_gadget.createJio({
return gadget.createJio({
type: "local",
username: "dream",
applicationname: "dream"
......@@ -354,7 +349,28 @@
console.log(portal_type);
console.log(options);
console.log(portal_types[portal_type]);
/*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) {
page_gadget = g;
if (page_gadget.render !== undefined) {
......
......@@ -152,8 +152,6 @@
var gadget, doc_list, innerHTML;
gadget = this;
doc_list = gadget.props.element.querySelector(".document_list");
console.log("list created? 1");
console.log(doc_list);
// helper: add options to selects
function makeListItems(row_list) {
console.log("MAKEDOCUMENTLIST 1");
......@@ -202,9 +200,7 @@
form = e.target;
element = form.querySelector("div.ui-focus");
if (element === null || element === "undefined") {
console.log(0);
element = form.querySelector("input.ui-state-focus");
console.log(element);
id = element.name.replace("record_", "");
} else {
id = element.childNodes[1].name.replace("record_", "");
......@@ -242,14 +238,11 @@
form = e.target;
promise_list = [];
element_list = form.querySelectorAll("label.ui-checkbox-on");
console.log(element_list);
if (element_list) {
for (i = 0, len = element_list.length; i < len; i += 1) {
element = element_list[i].nextSibling;
id = element.name.replace("record_", "");
console.log(id);
list_element = element.parentNode.parentNode.parentNode;
console.log(list_element);
list_element.parentNode.removeChild(list_element);
if (form.querySelector("ul").children.length === 0) {
fragment = document.createElement("li");
......@@ -267,8 +260,6 @@
}
}
console.log("HANDLING DELETE 2");
console.log("list created? 1");
console.log(doc_list);
return RSVP.all(promise_list);
}
return gadget.aq_allDocs({
......@@ -290,8 +281,6 @@
while (doc_list.firstChild) {
doc_list.removeChild(doc_list.firstChild);
}
console.log("list created? last");
console.log(doc_list);
doc_list.innerHTML = innerHTML;
// enhance/refresh
$doc = $(doc_list);
......@@ -310,10 +299,8 @@
console.log("VIEWADDINSTANCE STARTSERVICE 1");
var gadget = this;
return new RSVP.Queue().push(function() {
console.log("VIEWADDINSTANCE STARTSERVICE 2");
return RSVP.any([ waitForImport(gadget), waitForDefault(gadget) ]);
}).push(function(result) {
console.log("VIEWADDINSTANCE STARTSERVICE 3");
return gadget.whoWantsToDisplayThisDocument(result[0].id);
}).push(function(url) {
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,
promiseEventListener, initGadgetMixin*/
promiseEventListener, initGadgetMixin, console */
/*jslint nomen: true */
(function(window, rJS, RSVP, Handlebars, initGadgetMixin) {
"use strict";
......@@ -13,6 +13,9 @@
// XXX node_id is added like a property so that one can change the node
// id
var gadget = this, queue;
console.log("FIELDSET RENDER 1");
console.log(options);
console.log(node_id);
gadget.props.key = options.key;
// used for recursive fieldsets
gadget.props.field_gadget_list = [];
......@@ -21,10 +24,23 @@
queue.push(function() {
// XXX this is incorrect for recursive fieldsets.
// we should use nested fieldset with legend
console.log("insertingAdjacentHTML for:" + property_id);
gadget.props.element.insertAdjacentHTML("beforeend", label_template({
"for": 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") {
// Create a recursive fieldset for this key.
return gadget.declareGadget("../fieldset/index.html");
......@@ -57,9 +73,27 @@
}, node_id);
}
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];
// XXX some properties are not editable
if (property_name !== "coordinate" && property_name !== "_class") {
var property_definition = options.property_definition.properties[property_name], value = property_definition.default, i = 0, property;
if (property_definition.allOf) {
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);
}
});
......
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