Commit b849729e authored by Roque's avatar Roque

erp5_officejs: common clone action gadget (text editor updated)

parent b2181b84
......@@ -51,6 +51,10 @@ url_list = [
"officejs_logo.png",
"jio_appcachestorage.js",
"jio_configuration_storage.js",
#app actions
"action_clone.html",
"action_clone.js"
]
base64_url_list = context.WebSection_getBase64ConfigurationUrlList(batch_mode=1)
......
......@@ -5,11 +5,11 @@
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OfficeJS Texteditor Clone Action</title>
<title>OfficeJS Clone Action</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="action_texteditor_clone.js"></script>
<script src="action_clone.js"></script>
</head>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>action_texteditor_clone.html</string> </value>
<value> <string>action_clone.html</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
/*global window, rJS, RSVP */
/*global window, rJS, RSVP, jIO */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP) {
(function (window, rJS, RSVP, jIO) {
"use strict";
rJS(window)
......@@ -10,6 +10,9 @@
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("jio_putAttachment", "jio_putAttachment")
.declareAcquiredMethod("jio_allAttachments", "jio_allAttachments")
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -38,16 +41,36 @@
}
}, gadget = this,
document = parent_options.doc,
property;
delete content_dict.dialog_method;
for (property in content_dict) {
if (content_dict.hasOwnProperty(property)) {
document[property] = content_dict[property];
}
}
return gadget.jio_post(document)
.push(function (jio_key) {
return_submit_dict.notify.message = "Data Updated";
all_attachments,
promise_list = [],
parent_jio_key = parent_options.action_options.jio_key,
jio_key;
return gadget.jio_allAttachments(parent_jio_key)
.push(function (result) {
var property;
all_attachments = result;
return gadget.jio_post(document);
})
.push(function (result_jio_key) {
var attachment_id;
jio_key = result_jio_key;
for (attachment_id in all_attachments) {
if (all_attachments.hasOwnProperty(attachment_id)) {
promise_list.push(gadget.jio_getAttachment(parent_jio_key, attachment_id));
}
}
return RSVP.all(promise_list);
})
.push(function (result_list) {
var i;
promise_list = [];
for (i = 0; i < result_list.length; i += 1) {
promise_list.push(gadget.jio_putAttachment(jio_key, Object.keys(all_attachments)[i], result_list[i]));
}
return RSVP.all(promise_list);
})
.push(function () {
return_submit_dict.notify.message = "Clone Document Created";
return_submit_dict.notify.status = "success";
return_submit_dict.redirect.options = {
jio_key: jio_key,
......@@ -64,4 +87,4 @@
});
});
}(window, rJS, RSVP));
\ No newline at end of file
}(window, rJS, RSVP, jIO));
\ No newline at end of file
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>__name__</string> </key>
<value> <string>action_texteditor_clone.js</string> </value>
<value> <string>action_clone.js</string> </value>
</item>
<item>
<key> <string>content_type</string> </key>
......
......@@ -209,7 +209,7 @@
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string>action_texteditor_clone.html</string> </value>
<value> <string>action_clone.html</string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
......
......@@ -4,10 +4,6 @@ url_list = [
"gadget_officejs_text_editor.json",
"officejs_logo_text_editor.png",
"gadget_officejs_text_editor_router.html",
#app custom actions
"action_texteditor_clone.html",
"action_texteditor_clone.js"
]
return url_list
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ZopePageTemplate" module="Products.PageTemplates.ZopePageTemplate"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>content_type</string> </key>
<value> <string>text/html</string> </value>
</item>
<item>
<key> <string>expand</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>testOfficeJSTextEditorClone</string> </value>
</item>
<item>
<key> <string>output_encoding</string> </key>
<value> <string>utf-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <unicode></unicode> </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