Commit bffb2b53 authored by Ayush Tiwari's avatar Ayush Tiwari Committed by Vincent Bechu

Iodide Notebook Export Import

/reviewed-on nexedi/erp5!764
parent 7d1fa942
......@@ -28,7 +28,7 @@
.push(function (name) {
if (name === storage_name) {
return RSVP.all([
gadget.getUrlFor({command: "display", options: {page: "ojs_document_list"}}),
gadget.getUrlFor({command: "display"}),
gadget.getUrlFor(
{command: "display", options: {page: "ojs_sync", auto_repair: true}}
),
......
......@@ -227,7 +227,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.345.43627.54220</string> </value>
<value> <string>970.37259.50413.8226</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -245,7 +245,7 @@
</tuple>
<state>
<tuple>
<float>1501149936.88</float>
<float>1538752874.77</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -133,7 +133,7 @@
// Update the global links
.push(function () {
return RSVP.all([
context.getUrlFor({command: 'display', options: {page: "ojs_document_list"}}),
context.getUrlFor({command: 'display'}),
context.getUrlFor({command: 'display', options: {page: "ojs_configurator"}}),
context.getUrlFor({command: 'display', options: {page: "ojs_sync", 'auto_repair': true}})
]);
......
......@@ -213,7 +213,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>vincent</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -227,7 +227,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>964.45954.1063.61457</string> </value>
<value> <string>970.37259.50413.8226</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -245,7 +245,7 @@
</tuple>
<state>
<tuple>
<float>1515509961.05</float>
<float>1538643425.79</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -126,7 +126,7 @@
gadget.getUrlFor({command: "change", options: {"page": "ojs_add_document"}}),
gadget.getSetting('document_title_plural'),
gadget.getUrlFor({command: "change", options: {"page": "ojs_upload_convert"}}),
gadget.getSetting('conversion_dict', false)
gadget.getSetting('upload_dict', false)
]);
})
.push(function (result) {
......
......@@ -255,7 +255,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>P0</string> </value>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.27633.19787.19507</string> </value>
<value> <string>970.37259.50413.8226</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1533639709.89</float>
<float>1538642530.57</float>
<string>UTC</string>
</tuple>
</state>
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Notebook List</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojs_notebook_list.js"></script>
</head>
<body>
<div data-gadget-url="gadget_erp5_pt_form_list.html" data-gadget-scope="form_list"></div>
</body>
</html>
/*global window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getSetting", "getSetting")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition("jio_allDocs", function (param_list) {
var gadget = this;
return gadget.jio_allDocs(param_list[0])
.push(function (result) {
var i, date, len = result.data.total_rows;
for (i = 0; i < len; i += 1) {
if (result.data.rows[i].value.hasOwnProperty("modification_date")) {
date = new Date(result.data.rows[i].value.modification_date);
result.data.rows[i].value.modification_date = {
field_gadget_param: {
allow_empty_time: 0,
ampm_time_style: 0,
css_class: "date_field",
date_only: 0,
description: "The Date",
editable: 0,
hidden: 0,
hidden_day_is_last_day: 0,
"default": date.toUTCString(),
key: "modification_date",
required: 0,
timezone_style: 0,
title: "Modification Date",
type: "DateTimeField"
}
};
result.data.rows[i].value["listbox_uid:list"] = {
key: "listbox_uid:list",
value: 2713
};
}
}
return result;
});
})
.allowPublicAcquisition('notifySubmit', function () {
return this.triggerSubmit();
})
.declareMethod("triggerSubmit", function () {
var argument_list = arguments;
return this.getDeclaredGadget('form_list')
.push(function (gadget) {
return gadget.triggerSubmit.apply(gadget, argument_list);
});
})
.declareMethod("render", function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget('form_list'),
gadget.getSetting("portal_type")
]);
})
.push(function (result) {
var column_list = [
['title', 'Title'],
['reference', 'Reference'],
['language', 'Language'],
['description', 'Description'],
['version', 'Version'],
['modification_date', 'Modification Date']
];
return result[0].render({
erp5_document: {
"_embedded": {"_view": {
"listbox": {
"column_list": column_list,
"show_anchor": 0,
"default_params": {},
"editable": 1,
"editable_column_list": [],
"key": "field_listbox",
"lines": 30,
"list_method": "portal_catalog",
"query": "urn:jio:allDocs?query=portal_type%3A%22" +
result[1] + "%22",
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": column_list,
"sort": [['modification_date', 'descending']],
"title": "Documents",
"type": "ListBox"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
group_list: [[
"bottom",
[["listbox"]]
]]
}
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: "change", options: {"page": "ojs_add_document"}}),
gadget.getSetting('document_title_plural'),
gadget.getUrlFor({command: "change", options: {"page": "ojs_upload"}}),
gadget.getSetting('upload_dict', false)
]);
})
.push(function (result) {
var header = {
page_title: result[1],
filter_action: true,
add_url: result[0]
};
if (result[3]) {
header.upload_url = result[2];
}
return gadget.updateHeader(header);
});
});
}(window, rJS, RSVP));
\ No newline at end of file
......@@ -149,7 +149,11 @@
return RSVP.all([
gadget.getUrlFor({command: 'history_previous'}),
gadget.getUrlFor({command: 'selection_previous'}),
gadget.getUrlFor({command: 'selection_next'})
gadget.getUrlFor({command: 'selection_next'}),
gadget.getUrlFor({
command: 'change',
options: {'page': "ojs_download"}
})
]);
})
.push(function (url_list) {
......@@ -158,7 +162,8 @@
save_action: true,
selection_url: url_list[0],
previous_url: url_list[1],
next_url: url_list[2]
next_url: url_list[2],
download_url: url_list[3]
});
});
});
......
......@@ -189,7 +189,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>967.7617.12272.21725</string> </value>
<value> <string>970.42986.60138.7065</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -207,7 +207,7 @@
</tuple>
<state>
<tuple>
<float>1525268826.83</float>
<float>1538406432.04</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -121,6 +121,12 @@ gadget_officejs_notebook_router.html\n
gadget_officejs_jio_notebook_view.html\n
gadget_officejs_jio_notebook_view.js\n
gadget_officejs_jio_notebook.js\n
gadget_erp5_page_ojs_upload.js\n
gadget_erp5_page_ojs_upload.html\n
gadget_erp5_page_ojs_download.js\n
gadget_erp5_page_ojs_download.html\n
gadget_erp5_page_ojs_notebook_list.js\n
gadget_erp5_page_ojs_notebook_list.html\n
gadget_notebook.html\n
iodide_master.js\n
iodide_master.css\n
......@@ -394,7 +400,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>969.57706.26709.14899</string> </value>
<value> <string>970.45844.6229.15906</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -412,7 +418,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1533713860.15</float>
<float>1538640809.38</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -19,6 +19,7 @@
<script data-renderjs-configuration="document_title_plural" type="text/x-renderjs-configuration">Notebooks</script>
<script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">notebook_module</script>
<script data-renderjs-configuration="erp5_attachment_synchro" type="text/x-renderjs-configuration"></script>
<script data-renderjs-configuration="upload_dict" type="text/x-renderjs-configuration">{"txt": "txt"}</script>
<script data-renderjs-configuration="dropbox_app_key" type="text/x-renderjs-configuration">82g9eir551nhovs</script>
<div data-gadget-url="gadget_erp5_router.html" data-gadget-scope="erp5_router"></div>
</body>
......
......@@ -280,7 +280,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.920.25206.36915</string> </value>
<value> <string>970.46890.21036.35140</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -298,7 +298,7 @@
</tuple>
<state>
<tuple>
<float>1535969105.6</float>
<float>1539004524.37</float>
<string>UTC</string>
</tuple>
</state>
......
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Gadget OfficeJS Upload</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojs_download.js"></script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*global window, rJS, Blob */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, Blob) {
"use strict";
function downloadFromTextContent(gadget, text_content, title) {
var element = gadget.element,
a = window.document.createElement("a"),
url = window.URL.createObjectURL(new Blob([text_content], {type: 'text/plain'})),
name_list = [title, ""];
element.appendChild(a);
a.style = "display: none";
a.href = url;
a.download = name_list.join('.');
a.click();
element.removeChild(a);
window.URL.revokeObjectURL(url);
}
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("redirect", "redirect")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this;
return gadget.jio_get(options.jio_key)
.push(function (doc) {
return downloadFromTextContent(gadget, doc.text_content, doc.title);
})
.push(function () {
return gadget.redirect({
'command': 'display',
'options': {
'jio_key': options.jio_key
}
});
});
});
}(window, rJS, Blob));
\ 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>Gadget OfficeJS Upload</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_erp5_page_ojs_upload.js"></script>
</head>
<body>
<form class="save_form ui-body-c" novalidate>
<button type="submit" class="ui-btn ui-btn-b ui-btn-inline
ui-icon-edit ui-btn-icon-right ui-screen-hidden"></button>
<div data-gadget-url="gadget_erp5_pt_form_dialog.html"
data-gadget-scope="form_view"
data-gadget-sandbox="public">
</div>
</form>
</body>
</html>
\ No newline at end of file
/*global window, rJS, RSVP, jIO */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, jIO) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("redirect", "redirect")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.allowPublicAcquisition('submitContent', function () {
var gadget = this;
return gadget.notifySubmitting()
.push(function () {
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
return RSVP.all([
form_gadget.getContent(),
gadget.getSetting('portal_type'),
gadget.getSetting('content_type'),
gadget.getSetting('file_extension'),
gadget.getSetting('parent_relative_url')
]);
})
.push(function (result) {
var file_name_list, data, filename, queue;
if (result[0].file !== undefined) {
file_name_list = result[0].file.file_name.split('.');
if (file_name_list[1] === result[3]) {
filename = file_name_list[0];
data = jIO.util.dataURItoBlob(result[0].file.url);
queue = new RSVP.Queue()
.push(function () {
return jIO.util.readBlobAsText(data);
})
.push(function (evt) {
return evt.target.result;
})
.push(function (data_content) {
return gadget.jio_post({
title: filename,
portal_type: result[1],
content_type: result[2],
parent_relative_url: result[4],
text_content: data_content
});
})
.push(function (jio_key) {
return gadget.redirect({
'command': 'display',
'options': {
'jio_key': jio_key
}
});
});
return queue;
}
return gadget.notifySubmitted({
message: "Wrong format, use format : " +
window.Object.keys(gadget.state.upload).join(', '),
status: "error"
});
}
return gadget.notifySubmitted({
message: "File is required",
status: "error"
});
})
.push(function () {
return;
});
})
.declareMethod("triggerSubmit", function () {
return this.element.querySelector('button[type="submit"]').click();
})
.declareMethod("render", function () {
var gadget = this;
return gadget.getSetting('upload_dict')
.push(function (upload_dict) {
return gadget.changeState({
upload: window.JSON.parse(upload_dict)
});
});
})
.onStateChange(function () {
var gadget = this;
return gadget.getDeclaredGadget('form_view')
.push(function (form_gadget) {
return form_gadget.render({
erp5_document: {
"_embedded": {"_view": {
"_actions": {"put": {}},
"form_id": {},
"dialog_id": {},
"my_file": {
"description": "",
"title": "File",
"default": "",
"css_class": "",
"required": 1,
"editable": 1,
"key": "file",
"hidden": 0,
"type": "FileField"
},
"your_format": {
"title": "Format Avaible",
"required": 0,
"editable": 0,
"default": window.Object.keys(gadget.state.upload).join(', '),
"type": "StringField"
}
}},
"_links": {
"type": {
// form_list display portal_type in header
name: ""
}
}
},
form_definition: {
title: "Upload",
group_list: [[
"center",
[["my_file"], ["your_format"]]
]]
}
});
})
.push(function () {
return RSVP.all([
gadget.getUrlFor({command: 'display'})
]);
})
.push(function (url_list) {
return gadget.updateHeader({
page_title: "Upload File",
selection_url: url_list[0]
});
});
});
}(window, rJS, RSVP, jIO));
\ No newline at end of file
......@@ -328,7 +328,7 @@
</item>
<item>
<key> <string>configuration_frontpage_gadget_url</string> </key>
<value> <string>ojs_document_list</string> </value>
<value> <string>ojs_notebook_list</string> </value>
</item>
<item>
<key> <string>configuration_hateoas_url</string> </key>
......@@ -633,7 +633,7 @@
</item>
<item>