Commit f2744263 authored by Jérome Perrin's avatar Jérome Perrin

static version

parent b4875f4e
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit Available Capacity Spreadsheet</title>
<title>Edit Required Capacity 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>
......
......@@ -19,7 +19,7 @@
});
}).push(function(body) {
var data = JSON.parse(body);
data.capacity_by_project_spreadsheet = JSON.parse(editor_data);
data.capacity_by_station_spreadsheet = JSON.parse(editor_data);
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json",
......@@ -44,7 +44,8 @@
_attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).capacity_by_project_spreadsheet), {
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).capacity_by_station_spreadsheet), {
minSpareCols: 1,
minSpareRows: 1
});
});
......
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Edit Required Capacity Spreadsheet</title>
<title>Edit Available Capacity 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>
......
......@@ -19,7 +19,7 @@
});
}).push(function(body) {
var data = JSON.parse(body);
data.capacity_by_station_spreadsheet = JSON.parse(editor_data);
data.capacity_by_project_spreadsheet = JSON.parse(editor_data);
return gadget.aq_putAttachment({
_id: gadget.props.jio_key,
_attachment: "body.json",
......@@ -44,8 +44,7 @@
_attachment: "body.json"
}), gadget.getDeclaredGadget("tableeditor") ]);
}).push(function(result_list) {
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).capacity_by_station_spreadsheet), {
minSpareCols: 1,
return result_list[1].render(JSON.stringify(JSON.parse(result_list[0]).capacity_by_project_spreadsheet), {
minSpareRows: 1
});
});
......
......@@ -9,16 +9,24 @@
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window), source = gadget_klass.__template_element.getElementById("label-template").innerHTML, label_template = Handlebars.compile(source);
initGadgetMixin(gadget_klass);
gadget_klass.declareMethod("render", function(property_list, data) {
gadget_klass.declareMethod("render", function(property_list, data, key) {
var gadget = this, queue, value, property;
gadget.key = key;
// used for recursive fieldsets
gadget.props.field_gadget_list = [];
function addField(property, value) {
var sub_gadget;
queue.push(function() {
// XXX this is incorrect for recursive fieldsets.
// we should use nested fieldset with legend
gadget.props.element.insertAdjacentHTML("beforeend", label_template({
"for": property.id,
name: property.name || property.id
}));
if (property._class === "Dream.PropertyList") {
// Create a recursive fieldset for this key.
return gadget.declareGadget("../fieldset/index.html");
}
if (property.type === "number") {
return gadget.declareGadget("../number_field/index.html");
}
......@@ -27,9 +35,13 @@
}
return gadget.declareGadget("../string_field/index.html");
}).push(function(gg) {
var choice = property.choice || [], default_opt = choice[0] ? [ choice[0][1] ] : [ "" ];
sub_gadget = gg;
var choice = property.choice || [], default_opt = choice[0] ? [ choice[0][1] ] : [ "" ];
value = data[property.id] === undefined ? value : data[property.id];
if (gg.__title === "Fieldset") {
// XXX there must be a better way instead of using __title ?
return gg.render(property.property_list, value, property.id);
}
return sub_gadget.render({
field_json: {
title: property.description || "",
......@@ -49,26 +61,27 @@
queue = new RSVP.Queue().push(function() {
Object.keys(property_list).forEach(function(i) {
property = property_list[i];
if (property._class === "Dream.Property") {
value = property._default || "";
addField(property, value);
}
value = property._default || "";
addField(property, value);
});
});
return queue;
}).declareMethod("getContent", function() {
var i, promise_list = [];
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());
}
return RSVP.Queue().push(function() {
return RSVP.all(promise_list);
}).push(function(result_list) {
var name, result = {};
var name, result = {}, content = result;
if (gadget.key) {
content = result[gadget.key] = {};
}
for (i = 0; i < result_list.length; i += 1) {
for (name in result_list[i]) {
if (result_list[i].hasOwnProperty(name)) {
result[name] = result_list[i][name];
content[name] = result_list[i][name];
}
}
}
......
......@@ -24,7 +24,7 @@
<template id="popup-edit-template">
<div id="node-edit-popup" data-position-to="origin">
<div data-role="header" data-theme="a">
<h1>Node edition</h1>
<h1 class="node_class">Node edition</h1>
<a href="#" data-rel="back" class="ui-btn ui-corner-all ui-shadow ui-btn-a ui-icon-delete ui-btn-icon-notext ui-btn-right">Close</a>
</div>
<br/>
......
......@@ -364,6 +364,8 @@
}
gadget.props.element.appendChild(document.importNode(popup_edit_template.content, true).children[0]);
node_edit_popup = $(gadget.props.element).find("#node-edit-popup");
// Set the name of the popup to the node class
node_edit_popup.find(".node_class").text(node_data._class);
fieldset_element = node_edit_popup.find("fieldset")[0];
node_edit_popup.popup();
node_data.id = node_id;
......@@ -442,7 +444,7 @@
"class": element._class.replace(".", "-"),
element_id: element.element_id,
title: element.name || element.id,
name: element.name
name: element.name || element.id
}), "text/html").querySelector(".window");
render_element.append(domElement);
waitForNodeClick(gadget, domElement, configuration);
......
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