Commit 7d312eda authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

ideas on how to solve back-to-first-bage buggy rendering

parent f9a6a539
......@@ -7,6 +7,7 @@
<link rel="stylesheet" href="inputModule_viewAddInstanceDefinitionDialog.css" />
<script src="../lib/rsvp.min.js" type="text/javascript"></script>
<script src="../<%= copy.handlebars.relative_dest %>" type="text/javascript"></script>
<script src="../lib/renderjs.min.js" type="text/javascript"></script>
<script src="mixin_gadget.js" type="text/javascript"></script>
<script src="mixin_promise.js" type="text/javascript"></script>
......@@ -20,6 +21,11 @@
{{/documentlist}}
</ul>
</script-->
<!--script id="li-template" type="text/x-handlebars-template">
<div class="ui-btn ui-input-btn ui-corner-all ui-shadow"> {{value}}
<input type="submit" value="{{value}}" name= "{{name}}">
</div>
</script-->
</head>
<body>
......
/*global $, rJS, RSVP, promiseEventListener, promiseReadAsText,
initGadgetMixin, console */
initGadgetMixin, Handlebars, console */
(function (window, rJS, RSVP, promiseEventListener,
promiseReadAsText, initGadgetMixin) {
promiseReadAsText, initGadgetMixin) { /* Handlebars*/
"use strict";
// delete last session document
function removeLastSession(gadget, name) {
......@@ -172,6 +172,11 @@
}
var gadget_klass = rJS(window);
//var gadget_klass = rJS(window),
// source = gadget_klass.__template_element
// .getElementById("li-template")
// .innerHTML,
// li_template = Handlebars.compile(source);
initGadgetMixin(gadget_klass);
gadget_klass.declareAcquiredMethod("aq_post", "jio_post")
/////////////////////////////////////////////////////////////////
......@@ -199,18 +204,29 @@
gadget.state_parameter_dict = {};
})
.declareMethod("render", function () {
console.log("VIEWADDINSTANCE RENDER 1");
var gadget, doc_list;
gadget = this;
doc_list = gadget.props.element.querySelector("ul.document-list");
// helper: add options to selects
function makeListItems(row_list) {
var i, len, fragment, item, record, button, box, label; /*text_node*/
console.log("MAKEDOCUMENTLIST 1");
var i, len, fragment, record, item, button, box, label; //test;
fragment = document.createDocumentFragment();
for (i = 0, len = row_list.length; i < len; i += 1) {
record = row_list[i].doc;
item = document.createElement("li");
//test = document.createElement("li");
/*jslint nomen: true*/
//test.innerHTML = li_template({
// value: record.title + " (" + record.date + ")",
// name: "record_" + record._id
//});
/*jslint nomen: false*/
button = document.createElement("input");
button.type = "submit";
button.value = record.title + " (" + record.date + ")";
......@@ -218,6 +234,7 @@
button.setAttribute("name", "record_" + record._id);
/*jslint nomen: false*/
label = document.createElement("label");
box = document.createElement("input");
box.type = "checkbox";
......@@ -227,10 +244,14 @@
/*jslint nomen: false*/
label.appendChild(box);
//test.appendChild(label);
item.appendChild(button);
item.appendChild(label);
fragment.appendChild(item);
}
console.log("MAKEDOCUMENTLIST 2");
return fragment;
}
// helper: select a configuration dictionary from a doc
......@@ -240,7 +261,12 @@
//prevent default
e.preventDefault();
form = e.target;
console.log('HANDLEDICTSELECT');
console.log(form);
element = form.querySelector("div.ui-focus");
if (element === undefined || null) {
element = form.querySelector("input.ui-state-focus");
}
id = element.childNodes[1].name.replace("record_", "");
return gadget.aq_getAttachment({
"_id": id,
......@@ -307,6 +333,7 @@
"select_list": ["title", "modified"]
})
.push(function (document_list) {
console.log("VIEWADDINSTANCE RENDER 2");
var len, data, $doc, fragment;
data = document_list.data;
len = data.total_rows;
......@@ -328,6 +355,7 @@
}
})
.push(function () {
console.log("VIEWADDINSTANCE RENDER 3");
if (!gadget.state_parameter_dict.bound) {
gadget.state_parameter_dict.bound = true;
return RSVP.all([
......@@ -347,19 +375,23 @@
});/*.fail(console.log);*/
})
.declareMethod("startService", function () {
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");
return gadget.pleaseRedirectMyHash(url);
});
});
}(window, rJS, RSVP, promiseEventListener, promiseReadAsText,
initGadgetMixin));
\ No newline at end of file
initGadgetMixin)); /* Handlebars*/
\ No newline at end of file
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