Commit a35e00e7 authored by Ludovic Kiefer's avatar Ludovic Kiefer

erp5_officejs: add a new view to edit the slideshow source code

parent bfa1550f
<!DOCTYPE html>
<html>
<head>
<!--
data-i18n=Workflows
data-i18n=Actions
data-i18n=Clone
data-i18n=Delete
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Officejs Page Action</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_page.html">
<!-- 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="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_tab_officejs.js" type="text/javascript"></script>
<script id="table-template" type="text/x-handlebars-template">
<section class="ui-content-header-plain">
<h3 data-i18n="[last]{{definition_i18n}}">
<span class="ui-icon ui-icon-{{definition_icon}}">&nbsp;</span>
{{definition_title}}
</h3>
</section>
<ul class="document-listview">
{{#each document_list}}
<li><a data-i18n="{{title}}" href="{{link}}">{{title}}</a></li>
{{/each}}
</ul>
</script>
</head>
<body>
</body>
</html>
\ No newline at end of file
/*global window, rJS, RSVP, Handlebars */
/*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 80 */
(function (window, rJS, RSVP, Handlebars) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
table_template = Handlebars.compile(gadget_klass.__template_element
.getElementById("table-template")
.innerHTML);
/** Render translated HTML of title + links
*
* @param {string} title - H3 title of the section with the links
* @param {string} icon - alias used in font-awesome iconset
* @param {Array} command_list - array of links obtained from ERP5 HATEOAS
*/
function renderLinkList(gadget, title, icon, erp5_link_list) {
// prepare links for template (replace @href for RJS link)
return gadget.translateHtml(
table_template({
"definition_i18n": title,
"definition_title": title,
"definition_icon": icon,
"document_list": erp5_link_list.map(function (erp5_link, index) {
return {
"title": erp5_link.title,
"i18n": erp5_link.title,
"link": erp5_link_list[index].href
};
})
})
);
}
function getHTMLElementList(gadget, element_list) {
var i = 0,
element_info_list = [],
url_for_parameter_list = [],
element_info,
key;
for (key in element_list) {
if (element_list.hasOwnProperty(key)) {
element_info = element_list[key];
url_for_parameter_list.push({ command: 'change',
options: element_info });
element_info_list[i] = { reference: element_info.reference,
title: element_info.title};
i += 1;
}
}
return gadget.getUrlForList(url_for_parameter_list)
.push(function (url_list) {
var html_element_list = [], j, element;
for (j = 0; j < url_list.length; j += 1) {
element = { href: url_list[j],
icon: null,
name: element_info_list[j].reference,
title: element_info_list[j].title };
html_element_list.push(element);
}
return html_element_list;
});
}
gadget_klass
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSettingList", "getSettingList")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("render", function (options) {
var gadget = this,
portal_type,
document_title,
gadget_utils;
return gadget.jio_get(options.jio_key)
.push(function (document) {
document_title = document.title;
return document.portal_type;
}, function () {
document_title = options.portal_type;
return options.portal_type;
})
.push(function (result) {
portal_type = result;
return gadget.declareGadget("gadget_officejs_common_util.html");
})
.push(function (result) {
gadget_utils = result;
return gadget.getSettingList(['app_view_reference',
'default_view_reference',
'app_actions']);
})
.push(function (setting_list) {
// TODO views are also listed here
// should views be handled in another gadget like "..tab_office.js" ?
return gadget_utils.getViewAndActionDict(portal_type, setting_list[0],
setting_list[1], setting_list[2], options.jio_key);
})
.push(function (action_info_dict) {
return RSVP.all([
getHTMLElementList(gadget, action_info_dict.view_list),
getHTMLElementList(gadget, action_info_dict.action_list)
]);
})
.push(function (all_html_elements) {
return RSVP.all([
renderLinkList(gadget, "Views", "eye", all_html_elements[0])
]);
})
.push(function (translated_html_link_list) {
gadget.element.innerHTML = translated_html_link_list.join("\n");
return gadget.getUrlFor({command: 'change',
options: {page: undefined}});
})
.push(function (back_url) {
return gadget.updateHeader({
page_title: document_title,
back_url: back_url
});
});
})
.declareMethod("triggerSubmit", function () {
return;
});
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
......@@ -288,7 +288,7 @@
// render the header
.push(function () {
var url_for_parameter_list = [
{command: 'change', options: {page: "tab"}},
{command: 'change', options: {page: "tab_officejs"}},
{command: 'change', options: {page: "action_officejs",
jio_key: options.jio_key,
portal_type: options.portal_type}},
......
......@@ -275,7 +275,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.7520.54247.47189</string> </value>
<value> <string>985.28933.8790.47291</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -293,7 +293,7 @@
</tuple>
<state>
<tuple>
<float>1571065315.5</float>
<float>1598262754.73</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -97,12 +97,14 @@
<item>
<key> <string>text_content</string> </key>
<value> <string>CONFIGURATION MANIFEST\n
# generated on Wed Jul 22 12:45:33 2020\n
# generated on Fri Aug 28 09:18:44 2020\n
CACHE:\n
\n
hateoas_appcache/definition_view/cG9ydGFsX3R5cGVzL1Rlc3QgUGFnZQ==\n
hateoas_appcache/definition_view/cG9ydGFsX3R5cGVzL1Rlc3QgUGFnZS9zbGlkZXNob3dfZWRpdG9yX3ZpZXc=\n
hateoas_appcache/definition_view/cG9ydGFsX3NraW5zL2VycDVfb2ZmaWNlanNfc2xpZGVzaG93X2VkaXRvci9UZXN0UGFnZV92aWV3Rm9yU2xpZGVzaG93RWRpdG9y\n
hateoas_appcache/definition_view/cG9ydGFsX3R5cGVzL1Rlc3QgUGFnZS9zbGlkZXNob3dfZWRpdG9yX3ZpZXdfc291cmNl\n
hateoas_appcache/definition_view/cG9ydGFsX3NraW5zL2VycDVfb2ZmaWNlanNfc2xpZGVzaG93X2VkaXRvci9UZXN0UGFnZV92aWV3Rm9yU2xpZGVzaG93RWRpdG9yU291cmNl\n
hateoas_appcache/definition_view/cG9ydGFsX3R5cGVzL1Rlc3QgUGFnZSBNb2R1bGU=\n
hateoas_appcache/definition_view/cG9ydGFsX3R5cGVzL1Rlc3QgUGFnZSBNb2R1bGUvc2xpZGVzaG93X2VkaXRvcl92aWV3\n
hateoas_appcache/definition_view/cG9ydGFsX3NraW5zL2VycDVfb2ZmaWNlanNfc2xpZGVzaG93X2VkaXRvci9UZXN0UGFnZU1vZHVsZV92aWV3Rm9yU2xpZGVzaG93RWRpdG9y\n
......
......@@ -20,10 +20,10 @@
<script data-renderjs-configuration="parent_portal_type" type="text/x-renderjs-configuration">Test Page Module</script>
<script data-renderjs-configuration="portal_skin_folder" type="text/x-renderjs-configuration">erp5_officejs_slideshow_editor</script>
<script data-renderjs-configuration="app_view_reference" type="text/x-renderjs-configuration">slideshow_editor_view</script>
<script data-renderjs-configuration="app_actions" type="text/x-renderjs-configuration">('Test Page Module | slideshow_editor_view','Test Page | slideshow_editor_view')</script>
<script data-renderjs-configuration="app_actions" type="text/x-renderjs-configuration">('Test Page Module | slideshow_editor_view','Test Page | slideshow_editor_view','Test Page | slideshow_editor_view_source')</script>
<script data-renderjs-configuration="app_allowed_sub_types" type="text/x-renderjs-configuration">('Test Page Module | Test Page')</script>
<script data-renderjs-configuration="test_page_module_dict" type="text/x-renderjs-configuration">{"title": "Test Page Documents", "filter_action": 1, "hide_add_button": 0, "history_previous_link": 1}</script>
<script data-renderjs-configuration="test_page_dict" type="text/x-renderjs-configuration">{"title": "Test Page Document", "editable": 1, "history_previous_link": 1}</script>
<script data-renderjs-configuration="test_page_dict" type="text/x-renderjs-configuration">{"title": "Test Page Document", "editable": 1, "history_previous_link": 1, "panel_action": 1}</script>
<script data-renderjs-configuration="erp5_attachment_synchro" type="text/x-renderjs-configuration"></script>
<script data-renderjs-configuration="dropbox_app_key" type="text/x-renderjs-configuration">28fxd7m6ogxh6b5</script>
<div data-gadget-url="gadget_erp5_router.html" data-gadget-scope="erp5_router"></div>
......
......@@ -279,7 +279,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>985.27452.53555.61064</string> </value>
<value> <string>986.5246.62595.53606</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -297,7 +297,7 @@
</tuple>
<state>
<tuple>
<float>1595421110.02</float>
<float>1598260519.84</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -746,7 +746,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>985.28933.8790.47291</string> </value>
<value> <string>985.56432.38559.33877</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -764,7 +764,7 @@
</tuple>
<state>
<tuple>
<float>1595511939.13</float>
<float>1597929074.87</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -680,7 +680,7 @@ WebSection_getSlideshowEditorPrecacheManifestList</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>985.48901.24799.34611</string> </value>
<value> <string>986.3732.5004.21060</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -698,7 +698,7 @@ WebSection_getSlideshowEditorPrecacheManifestList</string> </value>
</tuple>
<state>
<tuple>
<float>1596706956.07</float>
<float>1598350191.73</float>
<string>UTC</string>
</tuple>
</state>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ERP5 Form" module="erp5.portal_type"/>
</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/>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_objects</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>action</string> </key>
<value> <string>Base_edit</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>edit_order</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>enctype</string> </key>
<value> <string>multipart/form-data</string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left (Document Reference)</string>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom (Preview)</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom (Preview)</string> </key>
<value>
<list>
<string>text_content</string>
</list>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list>
<string>my_description</string>
</list>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_title</string>
<string>my_reference</string>
</list>
</value>
</item>
<item>
<key> <string>left (Document Reference)</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list>
<string>my_version</string>
<string>my_language</string>
</list>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TestPage_viewForSlideshowEditorSource</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>WebPage_view</string> </value>
</item>
<item>
<key> <string>pt</string> </key>
<value> <string>form_view</string> </value>
</item>
<item>
<key> <string>row_length</string> </key>
<value> <int>4</int> </value>
</item>
<item>
<key> <string>stored_encoding</string> </key>
<value> <string>UTF-8</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Test Page</string> </value>
</item>
<item>
<key> <string>unicode_mode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>update_action</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>update_action_title</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="GadgetField" module="Products.ERP5Form.GadgetField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>text_content</string> </value>
</item>
<item>
<key> <string>message_values</string> </key>
<value>
<dictionary>
<item>
<key> <string>external_validator_failed</string> </key>
<value> <string>The input failed the external validator.</string> </value>
</item>
<item>
<key> <string>no_validator</string> </key>
<value> <string>Does not support this operation.</string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>overrides</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>tales</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>values</string> </key>
<value>
<dictionary>
<item>
<key> <string>alternate_name</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>css_class</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>data_url</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>enabled</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>external_validator</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>extra</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>gadget_url</string> </key>
<value> <string>gadget_editor.html</string> </value>
</item>
<item>
<key> <string>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>js_sandbox</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>renderjs_extra</string> </key>
<value>
<list>
<tuple>
<string>{"editor": "codemirror", "maximize": true}</string>
<string>{"editor": "codemirror", "maximize": true}</string>
</tuple>
</list>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Page Content</string> </value>
</item>
<item>
<key> <string>validator_field_id</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>validator_form_id</string> </key>
<value> <string></string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -3,7 +3,11 @@ url_list = [
"gadget_officejs_slideshow_editor_router.html",
"slideeditor.gadget.html",
"slideeditor.gadget.js",
"slideeditor.gadget.css"
"slideeditor.gadget.css",
"gadget_erp5_page_tab_officejs.js",
"gadget_erp5_page_tab_officejs.html",
"codemirror.gadget.html",
"codemirror.gadget.js",
]
return url_list
......@@ -15,6 +15,7 @@ web_page_module/officejs_todomvc_*
web_page_module/ojs_*
web_site_module/officejs_media_player
web_page_module/wallsearch_privacy_policy_html
web_page_module/gadget_erp5_page_tab_officejs_*
web_site_module/officejs_smart_assistant
web_site_module/officejs_smart_assistant/**
web_site_module/officejs_audioplayer
......
......@@ -15,6 +15,7 @@ web_page_module/officejs_audioplayer_*
web_page_module/officejs_todomvc_*
web_page_module/ojs_*
web_page_module/wallsearch_privacy_policy_html
web_page_module/gadget_erp5_page_tab_officejs_*
web_site_module/officejs_smart_assistant
web_site_module/officejs_smart_assistant/**
web_site_module/officejs_audioplayer
......
......@@ -18,6 +18,7 @@ portal_types/Web Page/text_editor_view
portal_types/Web Script/codemirror_view
web_page_module/dhtmlx_gantt_*
web_page_module/fb_sdk_js
web_page_module/gadget_erp5_page_tab_officejs_*
web_page_module/gadget_field_*
web_page_module/gadget_officejs_*
web_page_module/jio_*
......
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