Commit 0dde05d0 authored by Roque's avatar Roque

erp5_officejs_ooffice: spreadsheet editor uses custom view

parent b6c05716
......@@ -1246,6 +1246,8 @@ onlyoffice/fonts/ttf/ktwsh55ufijgk35iptozrmuwqtuy.ttf\n
onlyoffice/fonts/ttf/ktwsh55ufirzeamcpft1h7dwca.ttf\n
onlyoffice/fonts/ttf/p7agk5uum7xi6muwqtuy.ttf\n
\n
only_office_document_view.html\n
only_office_document_view.js\n
\n
#new approach (storage hateoas requests)\n
gadget_erp5_pt_form_view_editable.html\n
......@@ -1450,7 +1452,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.32692.9728.38877</string> </value>
<value> <string>978.32699.16100.53452</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -1468,7 +1470,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1568728034.72</float>
<float>1569595016.24</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -22,8 +22,8 @@
<script data-renderjs-configuration="app_actions" type="text/x-renderjs-configuration">('Spreadsheet | ooffice_spreadsheet_view', 'Document Module | ooffice_spreadsheet_view', 'Document Module | ooffice_upload_document', 'Spreadsheet | ooffice_download_document')</script>
<script data-renderjs-configuration="app_allowed_sub_types" type="text/x-renderjs-configuration">('Document Module | Spreadsheet',)</script>
<script data-renderjs-configuration="app_view_reference" type="text/x-renderjs-configuration">ooffice_spreadsheet_view</script>
<script data-renderjs-configuration="document_module_dict" type="text/x-renderjs-configuration">{"front_page": 1, "editable": 0, "hide_add_button": 0, "jump_button": 0, "fast_input_button": 0, "export_button": 0, "filter_action": 1, "panel_action": 1, "previous_next_button": 0, "history_previous_link": 0, "title": "Spreadsheets", "hide_listbox_buttons": 1, "blob_type": "", "blob_create_object_url": 0, "only_office": 1, "file_extension": "xlsy"}</script>
<script data-renderjs-configuration="spreadsheet_dict" type="text/x-renderjs-configuration"> {"front_page": 0, "editable": 1, "hide_add_button": 0, "jump_button": 0, "fast_input_button": 0, "export_button": 0, "filter_action": 0, "panel_action": 1, "previous_next_button": 1, "history_previous_link": 1, "title": "Spreadsheet", "hide_listbox_buttons": 1, "blob_type": "", "blob_create_object_url": 0, "only_office": 1, "file_extension": "xlsy"}</script>
<script data-renderjs-configuration="document_module_dict" type="text/x-renderjs-configuration">{"front_page": 1, "editable": 0, "hide_add_button": 0, "jump_button": 0, "fast_input_button": 0, "export_button": 0, "filter_action": 1, "panel_action": 1, "previous_next_button": 0, "history_previous_link": 0, "title": "Spreadsheets", "hide_listbox_buttons": 1, "blob_type": "", "blob_create_object_url": 0, "file_extension": "xlsy"}</script>
<script data-renderjs-configuration="spreadsheet_dict" type="text/x-renderjs-configuration"> {"front_page": 0, "editable": 1, "hide_add_button": 0, "jump_button": 0, "fast_input_button": 0, "export_button": 0, "filter_action": 0, "panel_action": 1, "previous_next_button": 1, "history_previous_link": 1, "title": "Spreadsheet", "hide_listbox_buttons": 1, "blob_type": "", "blob_create_object_url": 0, "file_extension": "xlsy", "custom_view_gadget": "only_office_document_view.html"}</script>
<script data-renderjs-configuration="erp5_attachment_synchro" type="text/x-renderjs-configuration">/{+id}/Document_downloadForOnlyOfficeApp</script>
<script data-renderjs-configuration="dropbox_app_key" type="text/x-renderjs-configuration">hxq0vjiu9v0r4mu</script>
<script data-renderjs-configuration="content_type" type="text/x-renderjs-configuration">application/x-asc-spreadsheet</script>
......
......@@ -241,7 +241,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.36905.14567.21981</string> </value>
<value> <string>978.36906.26142.38092</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -259,7 +259,7 @@
</tuple>
<state>
<tuple>
<float>1568980463.92</float>
<float>1569594974.27</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 Document View</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="only_office_document_view.js"></script>
</head>
<body>
<form class="save_form ui-body-c" novalidate>
</form>
</body>
</html>
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>only_office_document_view.html</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global document, window, rJS, RSVP, jIO, Blob */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (document, window, rJS, RSVP, jIO, Blob) {
"use strict";
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("notifySubmitted", "notifySubmitted")
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('render', function (options) {
var gadget = this,
state_dict = {
doc: options.doc,
form_definition: options.form_definition,
child_gadget_url: options.child_gadget_url,
options: options
},
portal_type_dict = options.form_definition.portal_type_dict,
form_view_div = document.createElement('div'),
extension,
blob;
return gadget.getSetting("file_extension")
.push(function (file_extension) {
if (file_extension.substring(file_extension.length - 1) == "y") {
file_extension = file_extension.replace(/.$/, "x");
}
extension = file_extension;
gadget.element.appendChild(form_view_div);
return gadget.declareGadget("gadget_officejs_form_view.html",
{element: form_view_div, scope: 'form_view'});
})
.push(function (form_view_gadget) {
if (!state_dict.doc.filename) {
state_dict.doc.filename = "default." + extension;
}
state_dict.mime_type = portal_type_dict.file_extension;
if (options.doc.action) {
return form_view_gadget.changeState(state_dict);
}
state_dict.content_editable = options.doc.content_type === undefined ||
options.doc.content_type.indexOf("application/x-asc") === 0;
return new RSVP.Queue()
.push(function () {
if (!state_dict.content_editable) {
return gadget.jio_getAttachment(options.jio_key, "data");
}
return gadget.declareGadget("gadget_ojs_cloudooo.html")
.push(function (ojs_cloudooo) {
return ojs_cloudooo.getConvertedBlob({
jio_key: options.jio_key,
format: state_dict.mime_type,
filename: options.doc.filename
});
});
})
.push(undefined, function (error) {
if (error instanceof jIO.util.jIOError &&
error.status_code === 404) {
return new Blob();
}
throw error;
})
.push(function (blob) {
if (state_dict.content_editable) {
return jIO.util.readBlobAsDataURL(blob);
}
return jIO.util.readBlobAsText(blob);
})
.push(function (result) {
state_dict.data = result.target.result;
state_dict.blob_type = portal_type_dict.blob_type;
return form_view_gadget.changeState(state_dict);
});
});
})
.declareMethod("triggerSubmit", function () {
var argument_list = arguments, gadget = this, child_gadget, view_gadget, content_dict, data, name_list;
return gadget.notifySubmitting()
.push(function (view_gadget) {
return gadget.getDeclaredGadget('form_view');
})
.push(function (result) {
view_gadget = result;
return view_gadget.getDeclaredGadget('erp5_pt_gadget');
})
.push(function (result) {
child_gadget = result;
if (!child_gadget.state.editable) {
return child_gadget.triggerSubmit(argument_list);
}
return child_gadget.getContent();
})
.push(function (result) {
content_dict = result;
if (!content_dict) { return; }
data = content_dict.text_content;
delete content_dict.text_content;
name_list = view_gadget.state.doc.filename.split('.');
if (name_list.pop() !== view_gadget.state.mime_type) {
name_list.push(view_gadget.state.mime_type);
content_dict.filename = name_list.join('.');
}
return gadget.getSetting("content_type");
})
.push(function (content_type) {
content_dict.content_type = content_type;
return child_gadget.submitContent(
child_gadget.state.jio_key, undefined, content_dict
);
})
.push(function () {
return gadget
.jio_putAttachment(child_gadget.state.jio_key, 'data',
jIO.util.dataURItoBlob(data))
.push(function () {
return gadget.declareGadget("gadget_ojs_cloudooo.html");
})
.push(function (cloudooo) {
return cloudooo
.putAllCloudoooConvertionOperation({
format: view_gadget.state.mime_type,
jio_key: child_gadget.state.jio_key
});
});
}, function (error) {
console.log(error);
return gadget.notifySubmitted({
message: "Submit failed",
status: "error"
});
});
});
}(document, window, rJS, RSVP, jIO, Blob));
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="File" module="OFS.Image"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>only_office_document_view.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>application/javascript</string> </value>
</item>
<item>
<key> <string>precondition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
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