Commit 0ecc3b2f authored by Jérome Perrin's avatar Jérome Perrin

update static version

parent 3b69c6cb
......@@ -11,13 +11,10 @@
<script src="InputModule_viewAddDocumentDialog.js" type="text/javascript"></script>
</head>
<body>
<form class="new_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline ui-icon-plus ui-btn-icon-right">Empty</button>
</form>
<form class="import_form">
<input id="dream_import" type="file" required=""
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>
</body>
</html>
</html>
\ No newline at end of file
......@@ -38,42 +38,12 @@
});
});
}
function waitForNew(gadget) {
var json_data = {
nodes: {},
edges: {},
preference: {},
general: {},
wip_part_spreadsheet: [ [ "Order ID", "Due Date", "Priority", "Project Manager", "Part", "Part Type", "Sequence", "Processing Times", "Prerequisites Parts" ] ],
shift_spreadsheet: [ [ "Day", "Machines", // XXX more generic name ?
"Start", "End" ] ],
capacity_by_project_spreadsheet: [ [ "Project Name", "Sequence", "Capacity Requirements" ] ],
capacity_by_station_spreadsheet: [ [ "Day", "CS1" ] ],
dp_capacity_spreadsheet: [ [] ],
dp_route_spreadsheet: [ [] ]
}, name = "Untitled";
return new RSVP.Queue().push(function() {
return promiseEventListener(gadget.props.element.getElementsByClassName("new_form")[0], "submit", false);
}).push(function(evt) {
// Prevent double click
evt.target.getElementsByClassName("ui-btn")[0].disabled = true;
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.stringify(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() {
var gadget = this;
return new RSVP.Queue().push(function() {
return RSVP.any([ waitForImport(gadget), waitForNew(gadget) ]);
return waitForImport(gadget);
}).push(function(result) {
return gadget.whoWantsToDisplayThisDocument(result.id);
}).push(function(url) {
......
......@@ -15,6 +15,10 @@
</head>
<body>
<a class="export_link ui-btn ui-btn-inline ui-icon-action ui-btn-icon-right">Export</a>
<form id="export_form" style="display:none" method="post" action="../../postJSONData">
<textarea id="export_json" name="data"></textarea>
</form>
<form class="knowledge_form">
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-refresh ui-btn-icon-right">Run Knowledge Extraction Tool</button>
......
......@@ -2,13 +2,6 @@
promiseEventListener, initGadgetMixin */
(function(window, rJS, RSVP, $, promiseEventListener, initGadgetMixin) {
"use strict";
function datatouri(data, mime_type) {
var result = "data:";
if (mime_type !== undefined) {
result += mime_type;
}
return result + ";base64," + window.btoa(data);
}
function disableAllButtons(gadget) {
// Prevent double click
var i, button_list = gadget.props.element.getElementsByClassName("ui-btn");
......@@ -87,8 +80,11 @@
}) ]);
}).push(function(result_list) {
var export_link = gadget.props.element.querySelector(".export_link");
export_link.download = result_list[0].data.title;
export_link.href = datatouri(result_list[1], "application/json");
// XXX this breaks promise chain
$(export_link).click(function() {
$("#export_json").val(result_list[1]);
return $("#export_form").submit();
});
});
}).declareMethod("startService", function() {
return RSVP.all([ waitForDeletion(this), waitForKnowledgeExtraction(this) ]);
......
......@@ -89,7 +89,7 @@
}
default_value = properties_dict[sub_title].default;
// find previous value if any
if (gadget.props.options.value[prop_name]) {
if (gadget.props.options.value && gadget.props.options.value[prop_name]) {
if (gadget.props.options.value[prop_name][sub_title] || gadget.props.options.value[prop_name][sub_title] === "") {
previous_value = gadget.props.options.value[prop_name][sub_title];
}
......@@ -150,6 +150,14 @@
}
}
function handleSelectChange() {
try {
return _handleSelectChange.bind(this)();
} catch (e) {
console.log("ERROR in handleSelectChange", e);
console.log(e.stack);
}
}
function _handleSelectChange() {
//evt) {
console.log("UPDATING FIELDS DUE TO SELECTION CHANGE");
var gadget = this, oneOf_list, i, prop_name = gadget.props.definition.property_def.title, select = gadget.props.element.getElementsByTagName("select")[0], update_name = select.options[select.selectedIndex].value;
......@@ -515,6 +523,8 @@
console.log("thr r " + promise_list.length + " subgadget promises");
return RSVP.all(promise_list);
}).push(function() {
// XXX return is required so that we see errors, but it blocks everything
/* return */
waitForListFieldSelection(gadget);
});
});
......
......@@ -20,12 +20,21 @@
var sub_gadget;
//console.log("addField", property_id, property_definition, value);
queue.push(function() {
// XXX this is incorrect for recursive fieldsets.
// we should use nested fieldset with legend
gadget.props.element.insertAdjacentHTML("beforeend", label_template({
gadget.props.fieldset_element.insertAdjacentHTML("beforeend", label_template({
"for": property_id,
name: property_definition.name || property_definition.description || property_id
}));
// use expandable field if we have a oneOf in the schema
if (property_definition.oneOf) {
property_definition = {
allOf: [ {
properties: property_definition.properties
}, {
oneOf: property_definition.oneOf
} ]
};
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");
......@@ -47,20 +56,25 @@
}).push(function() {
return sub_gadget.getElement();
}).push(function(sub_element) {
gadget.props.element.appendChild(sub_element);
gadget.props.fieldset_element.appendChild(sub_element);
gadget.props.field_gadget_list.push(sub_gadget);
});
}
queue = new RSVP.Queue().push(function() {
//gadget.props.fieldset_element = document.createElement("fieldset");
//gadget.props.element.appendChild(gadget.props.fieldset_element);
gadget.props.fieldset_element = gadget.props.element;
if (gadget.props.key) {
// style only recursive fieldsets
gadget.props.fieldset_element.style["border-width"] = "1px";
}
if (node_id) {
addField("id", {
type: "string"
}, node_id);
}
//console.log(options.property_definition);
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];
//console.log(property_name, property_definition);
// XXX some properties are not editable
// XXX should not be defined here
if (property_name !== "coordinate" && property_name !== "_class" && property_name !== "id") {
......@@ -69,6 +83,14 @@
});
});
return queue;
}).declareMethod("startService", function() {
var i, gadget = this, promise_list = [];
for (i = 0; i < gadget.props.field_gadget_list.length; i += 1) {
if (gadget.props.field_gadget_list[i].startService) {
promise_list.push(gadget.props.field_gadget_list[i].startService());
}
}
return RSVP.all(promise_list);
}).declareMethod("getContent", function() {
var i, promise_list = [], gadget = this;
for (i = 0; i < this.props.field_gadget_list.length; i += 1) {
......
......@@ -295,21 +295,34 @@
}
return schema;
}
function clone(obj) {
return JSON.parse(JSON.stringify(obj));
}
function expandSchema(class_definition, full_schema) {
// minimal expanding of json schema, supports merging allOf and $ref
// references
// XXX this should probably be moved to fieldset ( and not handle
// class_definition here)
var referenced, i, expanded_class_definition = {
properties: class_definition.properties || {}
};
var referenced, i, property, class_definition = clone(class_definition), expanded_class_definition = clone(class_definition) || {};
if (!expanded_class_definition.properties) {
expanded_class_definition.properties = {};
}
// expand direct ref
if (class_definition.$ref) {
referenced = expandSchema(resolveReference(class_definition.$ref, full_schema.class_definition), full_schema);
if (referenced.properties) {
delete referenced.properties;
}
$.extend(expanded_class_definition, referenced);
delete expanded_class_definition.$ref;
}
// expand ref in properties
for (property in class_definition.properties) {
if (class_definition.properties.hasOwnProperty(property)) {
if (class_definition.properties[property].$ref) {
referenced = expandSchema(resolveReference(class_definition.properties[property].$ref, full_schema.class_definition), full_schema);
//expanded_class_definition.properties[property] = referenced;
$.extend(expanded_class_definition.properties[property], referenced);
delete expanded_class_definition.properties[property].$ref;
}
}
}
if (class_definition.oneOf) {
expanded_class_definition.oneOf = [];
......@@ -326,11 +339,14 @@
}
$.extend(expanded_class_definition, referenced);
}
if (expanded_class_definition.allOf) {
delete expanded_class_definition.allOf;
}
}
if (expanded_class_definition.$ref) {
delete expanded_class_definition.$ref;
}
return Object.create(expanded_class_definition);
return clone(expanded_class_definition);
}
function openEdgeEditionDialog(gadget, connection) {
var edge_id = connection.id, edge_data = gadget.props.data.graph.edge[edge_id], edit_popup = $(gadget.props.element).find("#popup-edit-template"), schema, fieldset_element, delete_promise;
......@@ -384,6 +400,9 @@
edit_popup.enhanceWithin();
edit_popup.popup("open");
return fieldset_gadget[0];
}).push(function(fieldset_gadget) {
fieldset_gadget.startService();
return fieldset_gadget;
}).push(function(fieldset_gadget) {
// Expose the dialog handling promise so that we can wait for it in
// test.
......@@ -447,6 +466,9 @@
node_edit_popup.enhanceWithin();
node_edit_popup.popup("open");
return fieldset_gadget[0];
}).push(function(fieldset_gadget) {
fieldset_gadget.startService();
return fieldset_gadget;
}).push(function(fieldset_gadget) {
// Expose the dialog handling promise so that we can wait for it in
// test.
......@@ -541,7 +563,7 @@
function resolver(resolve, reject) {
callback = function(evt) {
try {
var class_name = JSON.parse(evt.dataTransfer.getData("application/json")), offset = $(gadget.props.main).offset(), relative_position = convertToRelativePosition(gadget, evt.clientX - offset.left + "px", evt.clientY - offset.top + "px");
var class_name = JSON.parse(evt.dataTransfer.getData("text")), offset = $(gadget.props.main).offset(), relative_position = convertToRelativePosition(gadget, evt.clientX - offset.left + "px", evt.clientY - offset.top + "px");
addNode(gadget, generateNodeId(gadget, {
_class: class_name
}), {
......
......@@ -150,7 +150,7 @@
e.dataTransfer = {
getData: function(type) {
// make sure we are called properly
equal("application/json", type, "The drag&dropped element must have data type application/json");
equal("text", type, "The drag&dropped element must have data type text");
return JSON.stringify("Example.Node");
}
};
......@@ -397,7 +397,7 @@
e.dataTransfer = {
getData: function(type) {
// make sure we are called properly
equal("application/json", type, "The drag&dropped element must have data type application/json");
equal("text", type, "The drag&dropped element must have data type text");
return JSON.stringify("Example.Node");
}
};
......@@ -471,7 +471,7 @@
e.dataTransfer = {
getData: function(type) {
// make sure we are called properly
equal("application/json", type, "The drag&dropped element must have data type application/json");
equal("text", type, "The drag&dropped element must have data type text");
return JSON.stringify("Example.Node");
}
};
......
This diff is collapsed.
/*!
* QUnit 1.14.0
* QUnit 1.17.1
* http://qunitjs.com/
*
* Copyright 2013 jQuery Foundation and other contributors
* Copyright jQuery Foundation and other contributors
* Released under the MIT license
* http://jquery.org/license
*
* Date: 2014-01-31T16:40Z
* Date: 2015-01-20T19:39Z
*/
/** Font Family and Sizes */
......@@ -62,14 +62,14 @@
}
#qunit-testrunner-toolbar {
padding: 0.5em 0 0.5em 2em;
padding: 0.5em 1em 0.5em 1em;
color: #5E740B;
background-color: #EEE;
overflow: hidden;
}
#qunit-userAgent {
padding: 0.5em 0 0.5em 2.5em;
padding: 0.5em 1em 0.5em 1em;
background-color: #2B81AF;
color: #FFF;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
......@@ -77,6 +77,18 @@
#qunit-modulefilter-container {
float: right;
padding: 0.2em;
}
.qunit-url-config {
display: inline-block;
padding: 0.1em;
}
.qunit-filter {
display: block;
float: right;
margin-left: 1em;
}
/** Tests: Pass/Fail */
......@@ -86,12 +98,24 @@
}
#qunit-tests li {
padding: 0.4em 0.5em 0.4em 2.5em;
padding: 0.4em 1em 0.4em 1em;
border-bottom: 1px solid #FFF;
list-style-position: inside;
}
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
#qunit-tests > li {
display: none;
}
#qunit-tests li.running,
#qunit-tests li.pass,
#qunit-tests li.fail,
#qunit-tests li.skipped {
display: list-item;
}
#qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass {
display: none;
}
......@@ -99,6 +123,10 @@
cursor: pointer;
}
#qunit-tests li.skipped strong {
cursor: default;
}
#qunit-tests li a {
padding: 0.5em;
color: #C2CCD1;
......@@ -211,11 +239,26 @@
#qunit-banner.qunit-fail { background-color: #EE5757; }
/*** Skipped tests */
#qunit-tests .skipped {
background-color: #EBECE9;
}
#qunit-tests .qunit-skipped-label {
background-color: #F4FF77;
display: inline-block;
font-style: normal;
color: #366097;
line-height: 1.8em;
padding: 0 0.5em;
margin: -0.4em 0.4em -0.4em 0;
}
/** Result */
#qunit-testresult {
padding: 0.5em 0.5em 0.5em 2.5em;
padding: 0.5em 1em 0.5em 1em;
color: #2B81AF;
background-color: #D2E0E6;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -14,7 +14,7 @@
function itsANonResolvableTrap(resolve, reject) {
callback = function(evt) {
try {
evt.dataTransfer.setData("application/json", tool.dataset.class_name);
evt.dataTransfer.setData("text", tool.dataset.class_name);
} catch (e) {
reject(e);
}
......
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