Commit c4161eab authored by Vincent Bechu's avatar Vincent Bechu

erp5_officejs: add cribjs

parent 27a96d0b
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="favicon.ico">
<title>Cribjs</title>
<link href="//netdna.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="jquerymobile.css">
<link rel="stylesheet" href="gadget_erp5.css">
<script data-renderjs-configuration="application_title" type="text/x-renderjs-configuration">Cribjs</script>
<script data-renderjs-configuration="panel_gadget" type="text/x-renderjs-configuration">gadget_officejs_crib_panel.html</script>
<script data-renderjs-configuration="action_view" type="text/x-renderjs-configuration">object_view</script>
<script data-renderjs-configuration="default_view_reference" type="text/x-renderjs-configuration">view</script>
<script data-renderjs-configuration="hateoas_url" type="text/x-renderjs-configuration">hateoas/</script>
<script src="jquery.js"></script>
<script src="jquerymobile.js"></script>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_global.js" ></script>
<script src="erp5_launcher.js"></script>
</head>
<body>
<div data-role="page">
<div data-gadget-url="gadget_jio.html"
data-gadget-scope="setting_gadget"
data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_officejs_crib_router.html"
data-gadget-scope="router"
data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_translation.html"
data-gadget-scope="translation_gadget"
data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_officejs_header.html"
data-gadget-scope="header"
data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_officejs_jio_crib_from.html"
data-gadget-scope="jio_gadget"
data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_erp5_editor_panel.html"
data-gadget-scope="editor_panel"
data-gadget-sandbox="public"></div>
<div data-gadget-url="gadget_officejs_crib_panel.html"
data-gadget-scope="panel"
data-gadget-sandbox="public"></div>
<div role="main" class="ui-content gadget-content"></div>
</div>
<!-- This is a new dev version -->
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>OfficeJS Cribjs Gadget</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="jquery.js" type="text/javascript"></script>
<script src="jquerymobile.js" type="text/javascript"></script>
<script id="panel-template-header" type="text/x-handlebars-template">
<div data-role="header" class="ui-bar-inherit">
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-left">
<div class="ui-controlgroup-controls">
<form action="#" method="post">
<input type="submit" data-i18n="[value]Close" data-icon="delete" data-iconpos="notext" value="Close" />
</form>
</div>
</div>
<img class="ui-title" alt="ERP5" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJcAAAA/CAMAAADaDqrIAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNiAoTWFjaW50b3NoKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowMEM5NUE4MzQ5NjQxMUUzOUZEQUU2NUY1RTI1RjdCQiIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowMEM5NUE4NDQ5NjQxMUUzOUZEQUU2NUY1RTI1RjdCQiI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjAwQzk1QTgxNDk2NDExRTM5RkRBRTY1RjVFMjVGN0JCIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjAwQzk1QTgyNDk2NDExRTM5RkRBRTY1RjVFMjVGN0JCIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+J9MJsAAAAwBQTFRF///////M//+Z//9m//8z//8A/8z//8zM/8yZ/8xm/8wz/8wA/5n//5nM/5mZ/5lm/5kz/5kA/2b//2bM/2aZ/2Zm/2Yz/2YA/zP//zPM/zOZ/zNm/zMz/zMA/wD//wDM/wCZ/wBm/wAz/wAAzP//zP/MzP+ZzP9mzP8zzP8AzMz/zMzMzMyZzMxmzMwzzMwAzJn/zJnMzJmZzJlmzJkzzJkAzGb/zGbMzGaZzGZmzGYzzGYAzDP/zDPMzDOZzDNmzDMzzDMAzAD/zADMzACZzABmzAAzzAAAmf//mf/Mmf+Zmf9mmf8zmf8Amcz/mczMmcyZmcxmmcwzmcwAmZn/mZnMmZmZmZlmmZkzmZkAmWb/mWbMmWaZmWZmmWYzmWYAmTP/mTPMmTOZmTNmmTMzmTMAmQD/mQDMmQCZmQBmmQAzmQAAZv//Zv/MZv+ZZv9mZv8zZv8AZsz/ZszMZsyZZsxmZswzZswAZpn/ZpnMZpmZZplmZpkzZpkAZmb/ZmbMZmaZZmZmZmYzZmYAZjP/ZjPMZjOZZjNmZjMzZjMAZgD/ZgDMZgCZZgBmZgAzZgAAM///M//MM/+ZM/9mM/8zM/8AM8z/M8zMM8yZM8xmM8wzM8wAM5n/M5nMM5mZM5lmM5kzM5kAM2b/M2bMM2aZM2ZmM2YzM2YAMzP/MzPMMzOZMzNmMzMzMzMAMwD/MwDMMwCZMwBmMwAzMwAAAP//AP/MAP+ZAP9mAP8zAP8AAMz/AMzMAMyZAMxmAMwzAMwAAJn/AJnMAJmZAJlmAJkzAJkAAGb/AGbMAGaZAGZmAGYzAGYAADP/ADPMADOZADNmADMzADMAAAD/AADMAACZAABmAAAzAAAAHHa7K3/AOojESZHJWZvNaKTSd63Whrbblb/fpMjks9Howtrt4e320uTx8Pb6AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAdfKHSQAAAOh0Uk5T////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////ALItoLoAAAJkSURBVHja7NlZsqsgEABQ979C5kGGddxo4os0Q8BAynoFn0nUU23TNGRB9xzLdE3XdE3XdP2fLnIzF2VSrsYvC72HizAh9eZ5DVuOl15S4/jWwC+kDC8HPzCSJVHcRY8QXV2PwQuujUYTsYrvYlBv1yKLrsXHsPghnvR3Lazoip/JKuwpF8sm6/bY01Ow9CBlTXi53PNoRcUktEZT1NV1PIPnXAjtMJIMlzerFIzU1dVWF7aPj3Tetae4gjdxktG2et/qQjJ4kZFrv6ED4bK4eR1qduHzvEi4+PbGwD0EGu9CQQLFrv1F4jBc6BcuW3YhkPiPX1hOfxQvnHfh0HVMRqc4HuqiQf5k3mO6dq1s8Hx0H/Le5kq9YaNcxAcrZLpOvAv+ClcgNcZFtnrucd5Fwx4mXj0drnbBYXMuJmFDAV3Uhm4qlbHh3ddOrmholHNxFTVC+xTl2mf6pI4uVe4LwSp0DPGOmh/hAnM94bKZjkHlWuiLeV+cTab4luMKk82wy/Px2fLJskvKUk03hRf9RZ0wiYiZ4uVwVwTb9E71y0XboTYXGuTaa33Y47W5zBjXM3P11y7TfR2ycFdxyaW7uwSc5m0un9ix91m3TWJfW+1ijfW+wcVAfjS5dOP62LyvZZdcLHnA1MkFAtbgwq+Vm47po8OA1buwyy/a1ec5urzveAes2sV8kfW963mFaHNhlT0b6+Yi5+StchH1CtaK0ThXELDPLiyOPZHldzm/J1z9O/B14g7/K+DtkP7U8ivSeD4xaPCTSQvy+YIfubZWzRgtRe1iMP+3mq7pmq7p6jv+BBgAPrgi/TzwWzkAAAAASUVORK5CYII="/>
<div class="ui-controlgroup ui-controlgroup-horizontal ui-btn-right">
<div class="ui-controlgroup-controls">
<a href="#" class="ui-btn ui-btn-icon-notext ui-icon-home" data-i18n="Home">Home</a>
</div>
</div>
</div>
</script>
<script id="panel-template-body" type="text/x-handlebars-template">
<div class="ui-content">
<ul data-role="listview" class="ui-listview">
<li><a href="#page=document_list" data-i18n="Document List">Document List</a></li>
<li><a href="#page=application_list" data-i18n="Application List">Application List</a></li>
<li><a href="#page=jio_crib_configurator&communication_gadget=gadget_officejs_liberator.html&application_name=Crib" data-i18n="Edit Myself">Edit Myself</a></li>
<li><a href="#page=sync&auto_repair=true" data-i18n="Synchronize"> Synchronize </a></li>
</ul>
</div>
</script>
<!-- custom script -->
<script src="gadget_officejs_application_panel.js" type="text/javascript"></script>
</head>
<body>
<div class="jqm-navmenu-panel"></div>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>OfficeJS Router Gadget</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_router.js" type="text/javascript"></script>
</head>
<body>
<script data-renderjs-configuration="portal_type" type="text/x-renderjs-configuration">Web Page","Web Script","Web Style","Web Manifest</script>
<script data-renderjs-configuration="forced_view" type="text/x-renderjs-configuration">crib</script>
<script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">web_page_module</script>
<script data-renderjs-configuration="document_title" type="text/x-renderjs-configuration">Source Code</script>
<script data-renderjs-configuration="document_title_plural" type="text/x-renderjs-configuration">Source Code</script>
<script data-renderjs-configuration="global_setting_gadget_url" type="text/x-renderjs-configuration">../officejs_setting_gadget/</script>
</body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>Jio Gadget</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="jio_mappingstorage.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_jio_crib_from.js" type="text/javascript"></script>
</head>
<body>
<div style="display:none"></div>
</body>
</html>
\ No newline at end of file
/*global window, rJS, jIO, FormData */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS, jIO) {
"use strict";
// jIO call wrapper for redirection to authentication page if needed
function wrapJioCall(gadget, method_name, argument_list) {
var storage = gadget.state_parameter_dict.jio_storage;
if (storage === undefined) {
return gadget.redirect({page: "jio_crib_configurator"});
}
return storage[method_name].apply(storage, argument_list);
}
rJS(window)
.ready(function (gadget) {
gadget.state_parameter_dict = {};
})
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("getSetting", "getSetting")
.declareMethod('createJio', function (jio_options) {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return new RSVP.all([
gadget.getSetting("communication_gadget", false),
gadget.getSetting("edited_erp5_url", "")
]);
})
.push(function (url_list) {
if (url_list[0]) {
return gadget.declareGadget(url_list[0], {
scope: "communication_gadget",
element: gadget.element.querySelector("div"),
sandbox: "iframe"
})
.push(function (bridge_gadget) {
gadget.state_parameter_dict.jio_storage = bridge_gadget;
return bridge_gadget.createStorage(url_list[1]);
});
}
});
})
.declareMethod('allDocs', function () {
return wrapJioCall(this, 'allDocs', arguments);
})
.declareMethod('allAttachments', function () {
return wrapJioCall(this, 'allAttachments', arguments);
})
.declareMethod('get', function () {
return wrapJioCall(this, 'get', arguments);
})
.declareMethod('put', function () {
return wrapJioCall(this, 'put', arguments);
})
.declareMethod('post', function () {
return wrapJioCall(this, 'post', arguments);
})
.declareMethod('remove', function () {
return wrapJioCall(this, 'remove', arguments);
})
.declareMethod('getAttachment', function () {
return wrapJioCall(this, 'gettAttachment', arguments);
})
.declareMethod('putAttachment', function () {
return wrapJioCall(this, 'putAttachment', arguments);
})
.declareMethod('removeAttachment', function () {
return wrapJioCall(this, 'removeAttachment', arguments);
})
.declareMethod('repair', function () {
return wrapJioCall(this, 'repair', arguments);
});
}(window, rJS, jIO));
\ No newline at end of file
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Jio Web Page View</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script class="view-web-page-template" type="text/x-handlebars-template">
<form class="view-web-page-form">
<div class="center">
<div class="ui-field-contain">
<label data-i18n="Title:">Title:</label>
<div class="ui-input-text ui-body-inherit ui-corner-all ui-shadow-inset">
<input type="text" name="title" value="{{title}}">
</div>
</div>
<button type="submit" data-i18n="Save" style="display:none;">Save</button>
<div class="ui-field-contain">
<label data-i18n="Reference:">Reference</label>
<input type="text" name="reference" value="{{reference}}" required>
</div>
<div class="ui-field-contain">
<label data-i18n="Content Type:">Content Type:</label>
<input type="text" name="content_type" value="{{content_type}}">
</div>
<div class='document-content'></div>
</div>
</div>
</form>
</script>
<script src="gadget_officejs_jio_crib_view.js"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*globals window, rJS, Handlebars, RSVP, loopEventListener, console*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, RSVP, rJS, Handlebars, loopEventListener) {
"use strict";
function saveContent(gadget, submit_event) {
var i,
doc = gadget.options.doc,
now = new Date(),
dict_map = {"text/html": "Web Page", "text/javascript": "Web Script", "text/css": "Web Style", "text/cache-manifest": "Web Manifest"};
doc.modification_date = now.toISOString();
for (i = 0; i < submit_event.target.length; i += 1) {
// XXX Should check input type instead
if (submit_event.target[i].name) {
doc[submit_event.target[i].name] = submit_event.target[i].value;
}
}
doc.portal_type = dict_map[doc.content_type] || "Web Page";
return new RSVP.Queue()
.push(function () {
return gadget.getDeclaredGadget("my_text_content");
})
.push(function (text_content_gadget) {
return text_content_gadget.getContent();
})
.push(function (data) {
doc.text_content = data.text_content;
doc.parent_relative_url = data.parent_relative_url || "web_page_module";
if (gadget.options.jio_key !== doc.reference) {
window.history.replaceState(
window.history.state,
"parameters changement",
encodeURI("#jio_key=" + doc.reference + "&page=view")
);
return gadget.remove(gadget.options.jio_key);
}
})
.push(function () {
return gadget.put(doc.reference, doc);
})
.push(function () {
gadget.options.jio_key = doc.reference;
return gadget.getSetting("edited_application_name");
})
.push(function (app_name) {
return gadget.updateHeader({
title: doc.reference + ' | ' + app_name
});
});
}
function maximize(gadget) {
var iframe = gadget.props.element.querySelector('iframe'),
iframe_class_string = iframe.getAttribute('class') || "",
class_name = "ui-content-maximize",
class_index = iframe_class_string.indexOf(class_name);
if (class_index === -1) {
iframe_class_string += ' ' + class_name;
iframe.setAttribute('style', '');
iframe.setAttribute('class', iframe_class_string);
return true;
}
iframe_class_string = iframe_class_string.substring(0, class_index)
+ iframe_class_string.substring(class_index + class_name.length);
iframe.setAttribute('style', 'width:100%; border: 0 none; height: 600px');
iframe.setAttribute('class', iframe_class_string);
return false;
}
var gadget_klass = rJS(window),
source = gadget_klass.__template_element
.querySelector(".view-web-page-template")
.innerHTML,
template = Handlebars.compile(source);
gadget_klass
.ready(function (g) {
g.props = {};
g.options = null;
return g.getElement()
.push(function (element) {
g.props.element = element;
g.props.deferred = RSVP.defer();
});
})
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("get", "jio_get")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("put", "jio_put")
.declareAcquiredMethod("remove","jio_remove")
.declareAcquiredMethod('allDocs', 'jio_allDocs')
.declareAcquiredMethod("redirect", "redirect")
.allowPublicAcquisition('triggerSubmit', function (option) {
if (option[0] === "maximize" || option === "maximize") {
var gadget = this;
return RSVP.Queue()
.push(function () {
return maximize(gadget);
});
}
return this.props.element.querySelector('button').click();
})
.declareMethod('triggerSubmit', function (option) {
if (option[0] === "maximize" || option === "maximize") {
var gadget = this;
return RSVP.Queue()
.push(function () {
return maximize(gadget);
});
}
return this.props.element.querySelector('button').click();
})
.declareMethod("render", function (options) {
var gadget = this;
gadget.options = options;
gadget.options.doc.title = gadget.options.doc.title || "";
gadget.options.jio_key = gadget.options.doc.reference;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.translateHtml(template(options.doc)),
gadget.getSetting("edited_application_name")
]);
})
.push(function (result) {
gadget.props.element.innerHTML = result[0];
return gadget.updateHeader({
title: options.doc.reference + ' | ' +
result[1],
save_action: true,
maximize_action: true,
maximized: gadget.options.doc.content_type !== ""
});
})
.push(function () {
return gadget.props.deferred.resolve();
});
})
/////////////////////////////////////////
// Render text content gadget
/////////////////////////////////////////
.declareService(function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.props.deferred.promise;
})
.push(function () {
return gadget.declareGadget(
"../../officejs_codemirror/development/",
{
scope: "my_text_content",
sandbox: "iframe",
element: gadget.props.element.querySelector(".document-content")
}
);
})
.push(function (text_content_gadget) {
var iframe = gadget.props.element.querySelector('iframe');
iframe.setAttribute(
'style',
'width:100%; border: 0 none; height: 600px'
);
return text_content_gadget.render({
"key": 'text_content',
"value": gadget.options.doc.text_content,
"mode": gadget.options.doc.content_type
});
})
.push(function () {
if (gadget.options.doc.content_type !== "") {
return gadget.triggerSubmit("maximize");
}
})
.push(undefined, function (error) {
var display_error_element;
if (error === "Timed out after 5000 ms") {
display_error_element =
gadget.props.element.querySelector(
"form div.ui-field-contain fieldset"
);
display_error_element.innerHTML =
'<br/><p style="color: red"></p><br/><br/>';
display_error_element.querySelector('p').textContent =
"TIMEOUT: The editor gadget is taking too long to load but is" +
" currently being cached, please wait for the page to load" +
" (check your browser loading icon) and then refresh.";
} else {
throw error;
}
});
})
/////////////////////////////////////////
// Form submit
/////////////////////////////////////////
.declareService(function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.props.deferred.promise;
})
.push(function () {
return loopEventListener(
gadget.props.element.querySelector('form'),
'submit',
true,
function (event) {
return saveContent(gadget, event);
}
);
});
});
}(window, RSVP, rJS, Handlebars, loopEventListener));
\ No newline at end of file
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<script src="renderjs.js" type="text/javascript"></script> <script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script> <script src="jiodev.js" type="text/javascript"></script>
<script src="jio_mappingstorage.js" type="text/javascript"></script>
<!-- custom script --> <!-- custom script -->
<script src="gadget_officejs_liberator.js" type="text/javascript"></script> <script src="gadget_officejs_liberator.js" type="text/javascript"></script>
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.64903.6566.48281</string> </value> <value> <string>957.595.54010.19848</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485868069.39</float> <float>1486738936.31</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
}, },
remote_sub_storage: { remote_sub_storage: {
type: "mapping", type: "mapping",
id: ["equalSubProperty", "url_string"], id: ["equalSubProperty", "reference"],
property: { property: {
"relative_url": ["ignore"], "relative_url": ["ignore"],
"version": ["ignore"] "version": ["ignore"]
......
...@@ -242,7 +242,7 @@ ...@@ -242,7 +242,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>956.64692.55224.61132</string> </value> <value> <string>956.64903.6566.48281</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1485781806.83</float> <float>1486739049.18</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Application List</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="gadget_officejs_page_application_list.js"></script>
</head>
<body>
<table class="ui-responsive ui-body-c ui-table-inset custom-force-list">
<thead><tr><th>App Name</th><th>Free Web Gadget Url</th><th>ERP5 Url</th><th></th></tr></thead>
<tbody class="connect_list"></tbody>
</table>
</body>
</html>
\ No newline at end of file
/*global window, document, rJS, RSVP,
loopEventListener*/
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, document, RSVP) {
"use strict";
function addLine(gadget, app_name, edited_app_dict) {
return new RSVP.Queue()
.push(function () {
return gadget.getUrlFor({page: "jio_crib_configurator", communication_gadget: edited_app_dict[app_name].communication_gadget, application_name: app_name});
})
.push(function (url) {
var line = document.createElement("tr"),
table = gadget.element.querySelector(".connect_list");
line.innerHTML = '<td><a class="ui-link" href="' + url + '">' + app_name +
'</a></td><td><a class="ui-link" href="' + url + '">' + edited_app_dict[app_name].communication_gadget +
'</a></td><td><a class="ui-link" href="' + url + '">' + edited_app_dict[app_name].erp5_url + '</a></td>';
table.appendChild(line);
return;
});
}
var gadget_klass = rJS(window);
gadget_klass
.ready(function (g) {
g.props = {};
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getSetting", "getSetting")
.declareMethod("render", function (options) {
var gadget = this;
return gadget.getUrlFor({page: "jio_crib_configurator"})
.push(function (url) {
return gadget.updateHeader({
title: "Application List",
add_url: url
});
})
.push(function () {
return gadget.getSetting("edited_app_dict", {});
})
.push(function (edited_app_dict) {
var app_name, promise_list = [];
for (app_name in edited_app_dict) {
promise_list.push(addLine(gadget, app_name, edited_app_dict));
}
return RSVP.all(promise_list);
});
})
}(window, rJS, document, RSVP));
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, user-scalable=no" />
<title>OfficeJS Cribjs Configurator Gadget</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_officejs_page_jio_crib_configurator.js" type="text/javascript"></script>
</head>
<body>
<section class="ui-content-header-plain">
<h3 class="ui-content-title ui-body-c">
<span class="ui-icon ui-icon-custom ui-icon-database">&nbsp;</span>
Your Application Parameters
</h3>
</section>
<section class="ui-body-c ui-content-section">
<form class="communication-configuration-form">
<div class="ui-form">
<div class="ui-field-contain">
<label data-i18n="Free Web Gadget Url:">Free Web Gadget Url:</label>
<input type="text" name="communication_url" required/>
<label data-i18n="Application Name:">Application name:</label>
<input type="text" name="edited_application_name" required/>
<label data-i18n="Erp5 Url:">Erp5 Url:</label>
<input type="text" name="erp5_url" required/>
</div>
</div>
<div class="select-storage ui-controlgroup ui-controlgroup-horizontal">
<div class="ui-grid-b ui-responsive">
<div class="ui-block-a"></div>
<div class="ui-block-b"></div>
<div class="ui-block-c">
<button type="submit" data-i18n="Connect" class="ui-btn-btn-right">Connect</button>
</div>
</div>
</div>
</form>
<div class="test_communication_url" style="display: none;"></div>
</section>
<div class="communication_url_error"></div>
</body>
</html>
\ No newline at end of file
/*global window, document, rJS, RSVP, URI, location,
loopEventListener*/
/*jslint nomen: true, indent: 2, maxerr: 3*/
(function (window, rJS, RSVP) {
"use strict";
function setCribConfiguration(gadget) {
var communication_url = gadget.element.querySelector('[name="communication_url"]').value,
application_name = gadget.element.querySelector('[name="edited_application_name"]').value,
erp5_url = gadget.element.querySelector('[name="erp5_url"]').value;
return gadget.declareGadget(communication_url, {element: gadget.element.querySelector(".test_communication_url"), sandbox: "iframe", scope: "test_communication_gadget"})
.push(function (crib_gadget) {
return crib_gadget.createStorage();
})
.push(function () {
return gadget.setSetting("communication_gadget", communication_url);
})
.push(function () {
return gadget.setSetting("edited_application_name", application_name);
})
.push(function () {
return gadget.setSetting("edited_erp5_url", erp5_url);
})
.push(function () {
return gadget.getSetting("edited_app_dict", {});
})
.push(function (dict) {
dict[application_name] = {
"name": application_name,
"communication_gadget": communication_url,
"erp5_url": erp5_url
};
return gadget.setSetting("edited_app_dict", dict)
})
.push(function () {
return gadget.reload();
})
.push(function () {
return gadget.redirect({page: "document_list"});
})
.push(undefined, function (error) {
gadget.element.querySelector(".communication_url_error").innerHTML = "Bad Free Web Gadget Url";
});
}
var gadget_klass = rJS(window);
gadget_klass
.ready(function (g) {
g.props = {};
return g.getElement()
.push(function (element) {
g.props.element = element;
});
})
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("reload", "reload")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getSetting", "getSetting")
.declareMethod("render", function (options) {
var gadget = this;
gadget.props.options = options || {};
return gadget.updateHeader({
title: "Storage Configuration"
}).push(function () {
return RSVP.all([
gadget.getSetting("communication_gadget", ""),
gadget.getSetting("edited_application_name", ""),
gadget.getSetting("edited_erp5_url", "")
]);
}).push(function (result) {
gadget.props.element.querySelector('[name="communication_url"]').value = gadget.props.options.communication_gadget || result[0];
gadget.props.element.querySelector('[name="edited_application_name"]').value = gadget.props.options.application_name || result[1];
gadget.props.element.querySelector('[name="erp5_url"]').value = gadget.props.options.erp5_url || result[2];
});
})
/////////////////////////////////////////
// Form submit
/////////////////////////////////////////
.declareService(function () {
var gadget = this;
if (gadget.props.options !== undefined && gadget.props.options.auto_connect) {
return setCribConfiguration(gadget, gadget.props.options);
}
return new RSVP.Queue()
.push(function () {
loopEventListener(
gadget.props.element.querySelector('form.communication-configuration-form'),
'submit',
true,
function () {
return setCribConfiguration(gadget);
}
);
});
});
}(window, rJS, RSVP));
\ No newline at end of file
...@@ -273,7 +273,7 @@ ...@@ -273,7 +273,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>957.13706.29150.15172</string> </value> <value> <string>957.15138.20000.4881</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -291,7 +291,7 @@ ...@@ -291,7 +291,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1486654781.05</float> <float>1486741091.54</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -103,12 +103,20 @@ ...@@ -103,12 +103,20 @@
options: args options: args
}; };
} }
return gadget.jio_get(args.jio_key) return new RSVP.Queue()
.push(function (doc) { .push(function () {
return RSVP.all([
gadget.jio_get(args.jio_key),
gadget.getSetting("forced_view")
]);
})
.push(function (result) {
var sub_options = {}, var sub_options = {},
base_portal_type = doc.portal_type.toLowerCase().replace(/\s/g, "_"); base_portal_type = result[1] === undefined ?
result[0].portal_type.toLowerCase().replace(/\s/g, "_") :
result[1];
sub_options = { sub_options = {
doc: doc, doc: result[0],
jio_key: args.jio_key, jio_key: args.jio_key,
search: args.search search: args.search
}; };
...@@ -129,6 +137,8 @@ ...@@ -129,6 +137,8 @@
}) })
.declareAcquiredMethod('jio_get', 'jio_get') .declareAcquiredMethod('jio_get', 'jio_get')
.declareAcquiredMethod('getSetting', 'getSetting')
.declareAcquiredMethod('setSetting', 'setSetting')
.declareAcquiredMethod('renderApplication', 'renderApplication') .declareAcquiredMethod('renderApplication', 'renderApplication')
.declareMethod('start', function () { .declareMethod('start', function () {
var gadget = this, var gadget = this,
......
...@@ -236,7 +236,7 @@ ...@@ -236,7 +236,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>947.54085.31754.65399</string> </value> <value> <string>957.15167.59077.43741</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -254,7 +254,7 @@ ...@@ -254,7 +254,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1450274255.9</float> <float>1486742528.7</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -19,4 +19,6 @@ web_site_module/officejs_svg_editor_gadget/** ...@@ -19,4 +19,6 @@ web_site_module/officejs_svg_editor_gadget/**
web_site_module/officejs_pdf_viewer_gadget web_site_module/officejs_pdf_viewer_gadget
web_site_module/officejs_pdf_viewer_gadget/** web_site_module/officejs_pdf_viewer_gadget/**
web_site_module/officejs_codemirror web_site_module/officejs_codemirror
web_site_module/officejs_codemirror/** web_site_module/officejs_codemirror/**
\ No newline at end of file web_site_module/officejs_cribjs
web_site_module/officejs_cribjs/**
\ No newline at end of file
...@@ -19,4 +19,6 @@ web_site_module/officejs_ckeditor_gadget/** ...@@ -19,4 +19,6 @@ web_site_module/officejs_ckeditor_gadget/**
web_site_module/officejs_pdf_viewer_gadget web_site_module/officejs_pdf_viewer_gadget
web_site_module/officejs_pdf_viewer_gadget/** web_site_module/officejs_pdf_viewer_gadget/**
web_site_module/officejs_codemirror web_site_module/officejs_codemirror
web_site_module/officejs_codemirror/** web_site_module/officejs_codemirror/**
\ No newline at end of file web_site_module/officejs_cribjs
web_site_module/officejs_cribjs/**
\ No newline at end of file
...@@ -8,6 +8,8 @@ web_site_module/officejs_ckeditor_gadget ...@@ -8,6 +8,8 @@ web_site_module/officejs_ckeditor_gadget
web_site_module/officejs_ckeditor_gadget/** web_site_module/officejs_ckeditor_gadget/**
web_site_module/officejs_codemirror web_site_module/officejs_codemirror
web_site_module/officejs_codemirror/** web_site_module/officejs_codemirror/**
web_site_module/officejs_cribjs
web_site_module/officejs_cribjs/**
web_site_module/officejs_pdf_viewer web_site_module/officejs_pdf_viewer
web_site_module/officejs_pdf_viewer/** web_site_module/officejs_pdf_viewer/**
web_site_module/officejs_pdf_viewer_gadget web_site_module/officejs_pdf_viewer_gadget
......
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