Commit 593276bd authored by Roque's avatar Roque

erp5_officejs: general code cleanup and refactorign

parent 8d3a3b52
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Action Information" module="erp5.portal_type"/>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
......@@ -13,20 +13,20 @@
</value>
</item>
<item>
<key> <string>action_permission</string> </key>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>Add portal content</string>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_js_script</string>
</tuple>
</value>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -35,17 +35,19 @@
</value>
</item>
<item>
<key> <string>float_index</string> </key>
<value> <float>35.0</float> </value>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>text_editor_clone</string> </value>
<value> <string>definition_view</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<key> <string>permissions</string> </key>
<value>
<none/>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
......@@ -53,12 +55,12 @@
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>reference</string> </key>
<value> <string>text_editor_clone</string> </value>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Clone</string> </value>
<value> <string>View</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
......@@ -75,7 +77,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/TextEditor_cloneDocument</string> </value>
<value> <string>string:${object_url}/ActionInformation_view</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Action Information" module="erp5.portal_type"/>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
......@@ -13,20 +13,20 @@
</value>
</item>
<item>
<key> <string>action_permission</string> </key>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>View</string>
<string>action_type/object_view</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_view</string>
</tuple>
</value>
<key> <string>category</string> </key>
<value> <string>object_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -35,17 +35,19 @@
</value>
</item>
<item>
<key> <string>float_index</string> </key>
<value> <float>35.0</float> </value>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>text_editor_view</string> </value>
<value> <string>definition_view</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<key> <string>permissions</string> </key>
<value>
<none/>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
......@@ -53,8 +55,8 @@
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>reference</string> </key>
<value> <string>text_editor_view</string> </value>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
......@@ -75,7 +77,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/WebPage_viewAsTextDocument</string> </value>
<value> <string>string:${object_url}/BaseType_view</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Action Information" module="erp5.portal_type"/>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
......@@ -12,14 +12,6 @@
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>action_permission</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
......@@ -28,6 +20,14 @@
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_view</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
......@@ -35,12 +35,12 @@
</value>
</item>
<item>
<key> <string>float_index</string> </key>
<value> <float>35.0</float> </value>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>jio_view</string> </value>
<value> <string>definition_view</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -48,17 +48,25 @@
<none/>
</value>
</item>
<item>
<key> <string>permissions</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Action Information</string> </value>
</item>
<item>
<key> <string>reference</string> </key>
<value> <string>jio_view</string> </value>
<key> <string>priority</string> </key>
<value> <float>1.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View</string> </value>
<value> <string>Definition View</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
......@@ -75,7 +83,7 @@
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/WebPage_viewAsJio</string> </value>
<value> <string>string:${object_url}/ERP5Form_viewAsDefinition</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Action Information" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>action_permission</string> </key>
<value>
<tuple>
<string>View</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_list</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>float_index</string> </key>
<value> <float>10.0</float> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>text_editor_view</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>reference</string> </key>
<value> <string>text_editor_view</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>View</string> </value>
</item>
<item>
<key> <string>visible</string> </key>
<value> <int>1</int> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Expression" module="Products.CMFCore.Expression"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>text</string> </key>
<value> <string>string:${object_url}/WebPageModule_viewWebPageListAsJio</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,7 +9,7 @@
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="gadget_officejs_common_utils.js"></script>
<script src="gadget_officejs_common_util.js"></script>
</head>
......
......@@ -87,7 +87,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_common_utils.html</string> </value>
<value> <string>gadget_officejs_common_util.html</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -97,7 +97,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_officejs_common_utils_html</string> </value>
<value> <string>gadget_officejs_common_util_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -136,7 +136,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget OfficeJS Common Utils</string> </value>
<value> <string>Gadget OfficeJS Common Util</string> </value>
</item>
<item>
<key> <string>url_string</string> </key>
......@@ -273,7 +273,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.50798.33418.15411</string> </value>
<value> <string>977.16290.38883.28228</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -291,7 +291,7 @@
</tuple>
<state>
<tuple>
<float>1563365949.47</float>
<float>1563811367.37</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP, Query, SimpleQuery, ComplexQuery, console */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 80 */
(function (window, rJS, RSVP, Query, SimpleQuery, ComplexQuery, console) {
"use strict";
// TODO: check if there are other categories that are 'views' and find a less hardcoded way to get this
var view_categories = ["object_view", "object_jio_view", "object_web_view", "object_list"];
// TODO: check if there are other categories that are 'views'
// and find a less hardcoded way to get this
var view_categorie_list = ["object_view", "object_jio_view",
"object_web_view", "object_list"];
function filterViews(views_dict, app_view, default_view) {
function filterViewList(views_dict, app_view, default_view) {
// there must be only one "View" action (title = "View")
// this is for scenarios were the portal type has several "View" (like view, jio_view, custom_view)
// this is for scenarios were the portal type has several "View"
// (like view, jio_view, custom_view)
// priority: app_view ; default_view ; other
var only_view, key,
view_list = Object.keys(views_dict).map(function (key) {
......@@ -29,76 +32,81 @@
return views_dict;
}
function formatSettingList(configuration_list_string, portal_type) {
var i = 0, formatted_list = [], configuration_list, pair;
try {
configuration_list_string = configuration_list_string.replace(/\(/g, '[')
.replace(/\)/g, ']')
.replace(/,\]/g, ']')
.replace(/\'/g, '"');
configuration_list = JSON.parse(configuration_list_string);
for (i = 0; i < configuration_list.length; i += 1) {
pair = configuration_list[i].split(" | ");
if (pair.length !== 2) {
throw new SyntaxError();
}
if (!portal_type || pair[0] === portal_type) {
formatted_list.push(pair);
}
}
} catch (e) {
if (e instanceof SyntaxError) {
console.log("Error parsing configuration settings. Format error?");
console.log("Please check site configuration 'app_allowed_sub_types'");
console.log(e);
formatted_list = [];
} else {
throw e;
}
}
return formatted_list;
}
function buildSearchQuery(portal_type, action_reference) {
var query_list = [];
query_list.push(new SimpleQuery({
key: "portal_type",
operator: "",
type: "simple",
value: "Action Information"
}));
query_list.push(new SimpleQuery({
key: "parent_relative_url",
operator: "",
type: "simple",
value: "portal_types/" + portal_type
}));
if (action_reference) {
query_list.push(new SimpleQuery({
key: "reference",
operator: "",
type: "simple",
value: action_reference
}));
}
return Query.objectToSearchText(new ComplexQuery({
operator: "AND",
query_list: query_list,
type: "complex"
}));
}
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("isDesktopMedia", "isDesktopMedia")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("formatSettingList", function (configuration_list_string, portal_type) {
var i = 0, formatted_list = [], configuration_list, pair;
try {
configuration_list_string = configuration_list_string.replace(/\(/g, '[')
.replace(/\)/g, ']')
.replace(/,\]/g, ']')
.replace(/\'/g, '"');
configuration_list = JSON.parse(configuration_list_string);
for (i = 0; i < configuration_list.length; i += 1) {
pair = configuration_list[i].split(" | ");
if (!portal_type || pair[0] === portal_type) {
formatted_list.push(pair);
}
}
} catch (e) {
console.log("Error while parsing configuration settings. Format error maybe?");
console.log(e);
}
return formatted_list;
})
.declareMethod("getAppActions", function (portal_type) {
var gadget = this;
return gadget.getSetting('app_actions')
.push(function (app_actions_setting) {
return gadget.formatSettingList(app_actions_setting, portal_type);
});
})
.declareMethod("getAllViewsAndActions", function (portal_type, jio_key) {
.declareMethod("getViewAndActionDict", function (portal_type, jio_key) {
var gadget = this,
action_info_dict = {views: {}, actions: {}},
query_type = new SimpleQuery({
key: "portal_type",
operator: "",
type: "simple",
value: "Action Information"
}),
query_parent = new SimpleQuery({
key: "parent_relative_url",
operator: "",
type: "simple",
value: "portal_types/" + portal_type
}),
query = Query.objectToSearchText(new ComplexQuery({
operator: "AND",
query_list: [query_type, query_parent],
type: "complex"
})),
action_info_dict = {view_list: {}, action_list: {}},
query = buildSearchQuery(portal_type),
app_actions,
app_view,
default_view;
......@@ -106,13 +114,14 @@
.push(function () {
return RSVP.all([
gadget.getSetting('app_view_reference'),
gadget.getSetting('default_view_reference')
gadget.getSetting('default_view_reference'),
gadget.getSetting('app_actions')
]);
})
.push(function (result_list) {
app_view = result_list[0];
default_view = result_list[1];
return gadget.getAppActions(portal_type);
return formatSettingList(result_list[2], portal_type);
})
.push(function (app_actions_result) {
app_actions = app_actions_result.map(function (pair) {
......@@ -123,7 +132,9 @@
var path_for_jio_get_list = [], row;
for (row in action_list.data.rows) {
if (action_list.data.rows.hasOwnProperty(row)) {
path_for_jio_get_list.push(gadget.jio_get(action_list.data.rows[row].id));
path_for_jio_get_list.push(gadget.jio_get(action_list
.data.rows[row]
.id));
}
}
return RSVP.all(path_for_jio_get_list);
......@@ -143,17 +154,22 @@
action_type: action_doc.action_type,
parent_portal_type: portal_type
};
if (view_categories.includes(action_settings.action_type)) {
if (view_categorie_list.includes(action_settings
.action_type)) {
action_settings.page = "ojs_local_controller";
action_info_dict.views[action_settings.action] = action_settings;
action_info_dict.view_list[action_settings.action] =
action_settings;
} else {
action_settings.page = "handle_action";
action_info_dict.actions[action_settings.action] = action_settings;
action_info_dict.action_list[action_settings.action] =
action_settings;
}
}
}
}
action_info_dict.views = filterViews(action_info_dict.views, app_view, default_view);
action_info_dict.view_list =
filterViewList(action_info_dict.view_list,
app_view, default_view);
return action_info_dict;
});
});
......@@ -183,43 +199,28 @@
return [form_type, child_gadget_url];
})
.declareMethod("getFormDefinition", function (portal_type, action_reference) {
.declareMethod("getFormDefinition", function (portal_type,
action_reference) {
var gadget = this,
query,
query = buildSearchQuery(portal_type, action_reference),
action_type,
action_title,
form_definition,
query_type,
query_parent,
query_reference,
portal_skin_folder,
error;
query_reference = new SimpleQuery({
key: "reference",
operator: "",
type: "simple",
value: action_reference
});
query_type = new SimpleQuery({
key: "portal_type",
operator: "",
type: "simple",
value: "Action Information"
});
query_parent = new SimpleQuery({
key: "parent_relative_url",
operator: "",
type: "simple",
value: "portal_types/" + portal_type
});
query = Query.objectToSearchText(new ComplexQuery({
operator: "AND",
query_list: [query_type, query_parent, query_reference],
type: "complex"
}));
return gadget.jio_allDocs({query: query})
return gadget.getSetting("portal_skin_folder")
.push(function (result) {
if (!result) {
throw new Error("Missing site configuration 'portal_skin_folder'");
}
result = "portal_skins/" + result;
portal_skin_folder = result;
return gadget.jio_allDocs({query: query});
})
.push(function (data) {
if (data.data.rows.length === 0) {
error = new Error("Can not find action '" + action_reference + "' for portal type '" + portal_type + "'");
error = new Error("Can not find action '" + action_reference +
"' for portal type '" + portal_type + "'");
error.status_code = 400;
throw error;
}
......@@ -229,32 +230,48 @@
action_title = action_result.title;
action_type = action_result.action_type;
if (action_result.action.includes("string:${object_url}")) {
action_result.action = action_result.action.replace("string:${object_url}", "portal_skins/erp5_web_officejs_ui");
action_result.action = action_result.action
.replace("string:${object_url}", portal_skin_folder);
}
return gadget.jio_get(action_result.action);
})
.push(function (form_result) {
form_definition = form_result.raw_dict._embedded._view._embedded.form_definition;
form_definition.fields_raw_properties = form_result.raw_dict._embedded._view.my_fields_raw_properties["default"];
form_definition._actions = form_result.raw_dict._embedded._view._actions;
form_definition = form_result.raw_dict._embedded._view
._embedded.form_definition;
form_definition.fields_raw_properties = form_result.raw_dict
._embedded._view.my_fields_raw_properties["default"];
form_definition._actions = form_result.raw_dict._embedded
._view._actions;
//[PATCH] if custom action and anonymous
// get _actions field from fields_raw_properties
if ("_actions" in form_definition.fields_raw_properties) {
if (!form_definition._actions &&
action_type === "object_jio_js_script") {
form_definition._actions = form_definition
.fields_raw_properties._actions;
}
delete form_definition.fields_raw_properties._actions;
}
form_definition.group_list = form_result.raw_dict.group_list;
form_definition.action_type = action_type;
form_definition.title = action_title;
return gadget.getSetting("app_allowed_sub_types");
})
.push(function (allowed_sub_types_setting) {
return gadget.formatSettingList(allowed_sub_types_setting, portal_type);
return formatSettingList(allowed_sub_types_setting, portal_type);
})
.push(function (allowed_sub_types_pairs) {
var allowed_sub_types = allowed_sub_types_pairs.map(function (pair) {
return pair[1];
});
form_definition.allowed_sub_types_list = allowed_sub_types;
return gadget.getAllViewsAndActions(portal_type);
return gadget.getViewAndActionDict(portal_type);
})
.push(function (actions_views_dict) {
form_definition.has_more_views = Object.keys(actions_views_dict.views).length > 1;
form_definition.has_more_actions = Object.keys(actions_views_dict.actions).length > 0;
.push(function (action_view_dict) {
form_definition.has_more_views =
Object.keys(action_view_dict.view_list).length > 1;
form_definition.has_more_actions =
Object.keys(action_view_dict.action_list).length > 0;
return gadget.getSetting('hide_header_add_button');
})
.push(function (hide_add_button_setting) {
......
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_officejs_common_utils.js</string> </value>
<value> <string>gadget_officejs_common_util.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -93,7 +93,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_officejs_common_utils_js</string> </value>
<value> <string>gadget_officejs_common_util_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -132,7 +132,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget OfficeJS Common Utils JS</string> </value>
<value> <string>Gadget OfficeJS Common Util JS</string> </value>
</item>
<item>
<key> <string>url_string</string> </key>
......@@ -269,7 +269,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>977.8828.22214.8772</string> </value>
<value> <string>977.16294.5398.40106</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -287,7 +287,7 @@
</tuple>
<state>
<tuple>
<float>1563365942.38</float>
<float>1563811574.1</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -83,7 +83,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_officejs_page_local_controller_html</string> </value>
<value> <string>gadget_officejs_controller_page_local_controller_html</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.52707.23546.23773</string> </value>
<value> <string>977.15823.10779.36625</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1563366544.73</float>
<float>1563811084.56</float>
<string>UTC</string>
</tuple>
</state>
......
/*global document, window, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 80 */
(function (document, window, rJS, RSVP) {
"use strict";
......@@ -10,16 +10,9 @@
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("isDesktopMedia", "isDesktopMedia")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod('getUrlParameter', 'getUrlParameter')
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
.declareAcquiredMethod("redirect", "redirect")
/////////////////////////////////////////////////////////////////
// declared methods
......@@ -30,24 +23,25 @@
default_view,
app_view,
form_definition,
gadget_utils,
gadget_util,
jio_document,
portal_type,
front_page;
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.declareGadget("gadget_officejs_common_utils.html"),
gadget.declareGadget("gadget_officejs_common_util.html"),
gadget.getSetting('app_view_reference'),
gadget.getSetting('default_view_reference'),
gadget.getSetting('documents_editable')
]);
})
.push(function (result_list) {
gadget_utils = result_list[0];
gadget_util = result_list[0];
app_view = options.action || result_list[1];
default_view = result_list[2];
options.editable = ((result_list[3] == "1") ? true : options.editable);
options.editable = ((result_list[3] == "1") ?
true : options.editable);
return gadget.jio_get(options.jio_key);
})
.push(function (result) {
......@@ -71,19 +65,19 @@
portal_type = parent_portal_type;
}
front_page = portal_type === parent_portal_type;
return gadget_utils.getFormDefinition(portal_type, app_view);
return gadget_util.getFormDefinition(portal_type, app_view);
})
.push(function (result) {
return result;
}, function (error) {
if (error.status_code === 400) {
return gadget_utils.getFormDefinition(portal_type, default_view);
return gadget_util.getFormDefinition(portal_type, default_view);
}
throw error;
})
.push(function (result) {
form_definition = result;
return gadget_utils.getFormInfo(form_definition);
return gadget_util.getFormInfo(form_definition);
})
.push(function (form_info) {
var form_type = form_info[0],
......@@ -109,8 +103,8 @@
this.element.removeChild(this.element.firstChild);
}
this.element.appendChild(fragment);
return gadget.declareGadget("gadget_officejs_form_view.html", {element: fragment,
scope: 'form_view'})
return gadget.declareGadget("gadget_officejs_form_view.html",
{element: fragment, scope: 'form_view'})
.push(function (form_view_gadget) {
return form_view_gadget.render(gadget.state);
});
......@@ -137,7 +131,8 @@
return gadget.notifySubmitting();
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
return gadget.notifySubmitted({message: 'Data Updated',
status: 'success'});
});
})
......
/*global document, window, rJS, RSVP, ensureArray */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 80 */
(function (document, window, rJS, RSVP, ensureArray) {
"use strict";
function renderField(field_id, field_definition, document) {
var key, raw_value, tales_expr, override, final_value, item_list, result = {};
function renderField(field_id, field_definition, context_document) {
var key, raw_value, override, final_value, item_list, result = {};
for (key in field_definition.values) {
if (field_definition.values.hasOwnProperty(key)) {
// order to get the final value (based on Field.py get_value)
// 1.tales, 2.override, 3.form-def-value, 4.context-default
// 1.override, 2.form-def-value, 3.context-default
raw_value = field_definition.values[key];
tales_expr = field_definition.tales[key];
override = field_definition.overrides[key];
final_value = undefined;
if (tales_expr !== undefined && tales_expr !== null && tales_expr !== '') {
try {
throw "error";
//final_value = eval(tales_expr);
} catch (ignore) {} // TALES expressions are usually python code, so for now ignore
}
if (final_value === undefined) {
if (override !== undefined && override !== null && override !== '') {
final_value = override;
} else if (raw_value !== undefined && raw_value !== null && raw_value !== '') {
} else if (raw_value !== undefined && raw_value !== null &&
raw_value !== '') {
final_value = raw_value;
} else if (document && document.hasOwnProperty(key)) {
final_value = document[key];
} else if (context_document && context_document.hasOwnProperty(key)) {
final_value = context_document[key];
}
}
if (final_value !== undefined && final_value !== null && final_value !== '') {
if (final_value !== undefined && final_value !== null &&
final_value !== '') {
result[key] = final_value;
}
}
}
result.type = field_definition.type;
result.key = field_id;
if (document && document.hasOwnProperty(field_id)) {
if (context_document && context_document.hasOwnProperty(field_id)) {
if (field_definition.type === "ListField") {
item_list = ensureArray(document[field_id]).map(function (item) {
if (Array.isArray(item)) {return item; }
return [item, item];
});
item_list = ensureArray(context_document[field_id])
.map(function (item) {
if (Array.isArray(item)) {return item; }
return [item, item];
});
result.items = item_list;
} else {
result["default"] = document[field_id];
result["default"] = context_document[field_id];
}
}
return result;
}
function renderForm(form_definition, context_document) {
var i, j, field_list, field_info, my_element, element_id, rendered_field,
raw_properties = form_definition.fields_raw_properties,
form_json = {
erp5_document: {
"_embedded": {"_view": {}},
"_links": {}
},
form_definition: form_definition
};
for (i = 0; i < form_definition.group_list.length; i += 1) {
field_list = form_definition.group_list[i][1];
for (j = 0; j < field_list.length; j += 1) {
my_element = field_list[j][0];
if (my_element.startsWith("my_")) {
element_id = my_element.replace("my_", "");
} else if (my_element.startsWith("your_")) {
element_id = my_element.replace("your_", "");
} else {
element_id = my_element;
}
if (element_id && raw_properties.hasOwnProperty(my_element)) {
field_info = raw_properties[my_element];
rendered_field = renderField(element_id, field_info,
context_document);
form_json.erp5_document._embedded._view[my_element] =
rendered_field;
}
}
}
form_json.erp5_document._embedded._view._actions =
form_definition._actions;
form_json.erp5_document._links = form_definition._links;
return form_json;
}
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
......@@ -57,14 +89,7 @@
.declareAcquiredMethod("isDesktopMedia", "isDesktopMedia")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_put", "jio_put")
.declareAcquiredMethod("jio_post", "jio_post")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
// XXX Hardcoded for modification_date rendering
.allowPublicAcquisition("jio_allDocs", function (param_list) {
......@@ -107,39 +132,6 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("renderForm", function (form_definition, document) {
var i, j, fields, field_info, my_element, element_id, rendered_field,
raw_properties = form_definition.fields_raw_properties,
form_json = {
erp5_document: {
"_embedded": {"_view": {}},
"_links": {}
},
form_definition: form_definition
};
for (i = 0; i < form_definition.group_list.length; i += 1) {
fields = form_definition.group_list[i][1];
for (j = 0; j < fields.length; j += 1) {
my_element = fields[j][0];
if (my_element.startsWith("my_")) {
element_id = my_element.replace("my_", "");
} else if (my_element.startsWith("your_")) {
element_id = my_element.replace("your_", "");
} else {
element_id = my_element;
}
if (element_id && raw_properties.hasOwnProperty(my_element)) {
field_info = raw_properties[my_element];
rendered_field = renderField(element_id, field_info, document);
form_json.erp5_document._embedded._view[my_element] = rendered_field;
}
}
}
form_json.erp5_document._embedded._view._actions = form_definition._actions;
form_json.erp5_document._links = form_definition._links;
return form_json;
})
.declareMethod("triggerSubmit", function (argument_list) {
return this.getDeclaredGadget('fg')
.push(function (gadget) {
......@@ -148,20 +140,28 @@
})
.declareMethod("render", function (options) {
var state_dict = {
doc: options.doc,
form_definition: options.form_definition,
child_gadget_url: options.child_gadget_url,
options: options
};
return this.changeState(state_dict);
})
.onStateChange(function onStateChange() {
var fragment = document.createElement('div'),
gadget = this,
form_json;
return gadget.renderForm(options.form_definition, options.doc)
.push(function (json) {
form_json = json;
while (gadget.element.firstChild) {
gadget.element.removeChild(gadget.element.firstChild);
}
gadget.element.appendChild(fragment);
return gadget.declareGadget(options.child_gadget_url, {element: fragment, scope: 'fg'});
})
form_json = renderForm(gadget.state.form_definition, gadget.state.doc);
while (gadget.element.firstChild) {
gadget.element.removeChild(gadget.element.firstChild);
}
gadget.element.appendChild(fragment);
return gadget.declareGadget(gadget.state.child_gadget_url,
{element: fragment, scope: 'fg'})
.push(function (form_gadget) {
return gadget.renderSubGadget(options, form_gadget, form_json);
return gadget.renderSubGadget(gadget.state.options, form_gadget,
form_json);
});
})
......@@ -182,7 +182,9 @@
.push(function () {
var url_for_parameter_list = [
{command: 'change', options: {page: "tab"}},
{command: 'change', options: {page: "action_officejs", jio_key: options.jio_key, portal_type: options.portal_type}},
{command: 'change', options: {page: "action_officejs",
jio_key: options.jio_key,
portal_type: options.portal_type}},
{command: 'history_previous'},
{command: 'selection_previous'},
{command: 'selection_next'},
......@@ -196,7 +198,15 @@
if (form_json.form_definition.allowed_sub_types_list &&
form_json.form_definition.allowed_sub_types_list.length > 0 &&
!form_json.form_definition.hide_add_button) {
url_for_parameter_list.push({command: 'change', options: {page: "create_document", jio_key: options.jio_key, portal_type: options.portal_type, allowed_sub_types_list: form_json.form_definition.allowed_sub_types_list}});
url_for_parameter_list.push({command: 'change',
options: {page: "create_document",
jio_key: options.jio_key,
portal_type:
options.portal_type,
allowed_sub_types_list:
form_json.form_definition
.allowed_sub_types_list
}});
add_url = true;
}
return RSVP.all([
......@@ -243,7 +253,8 @@
header_dict.save_action = true;
}
}
if (options.form_definition.has_more_actions || options.form_definition.has_more_views) {
if (options.form_definition.has_more_actions ||
options.form_definition.has_more_views) {
header_dict.actions_url = url_list[1];
}
if (add_url) {
......
/*global window, window, rJS, jIO, RSVP, document, URLSearchParams, UriTemplate, console */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS, jIO, RSVP, document, URLSearchParams, UriTemplate, console) {
/*jslint indent: 2, maxerr: 10, maxlen: 80 */
(function (window, rJS, jIO, RSVP, document, URLSearchParams, UriTemplate,
console) {
"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({command: 'display', options: {page: 'ojs_configurator'}});
return gadget.redirect({command: 'display',
options: {page: 'ojs_configurator'}});
}
return storage[method_name].apply(storage, argument_list)
.push(undefined, function (error) {
......@@ -27,7 +29,8 @@
return gadget.redirect({
command: 'raw',
options: {
url: UriTemplate.parse(regexp.exec(login_page)[1]).expand({came_from: came_from})
url: UriTemplate.parse(regexp.exec(login_page)[1])
.expand({came_from: came_from})
}
});
});
......@@ -50,7 +53,8 @@
}
// User entered wrong password ?
// Notify
return gadget.notifySubmitted({message: 'Unauthorized storage access', status: 'error'})
return gadget.notifySubmitted({message: 'Unauthorized storage access',
status: 'error'})
.push(function () {
return gadget.redirect({command: 'display',
options: {page: 'ojs_configurator'}});
......@@ -61,19 +65,21 @@
}
function processHateoasDict(raw_dict) {
var raw_fields, type, parent, field_key, field_id, return_dict = {};
var raw_field_list, type, parent, field_key, field_id, return_dict = {};
return_dict.raw_dict = raw_dict;
/*jslint nomen: true*/
if (raw_dict.hasOwnProperty("_embedded") && raw_dict._embedded.hasOwnProperty("_view")) {
raw_fields = raw_dict._embedded._view;
if (raw_dict.hasOwnProperty("_embedded") &&
raw_dict._embedded.hasOwnProperty("_view")) {
raw_field_list = raw_dict._embedded._view;
type = raw_dict._links.type.name;
parent = raw_dict._links.parent.name;
return_dict.parent_relative_url = "portal_types/" + parent;
return_dict.portal_type = type;
for (field_key in raw_fields) {
if (raw_fields.hasOwnProperty(field_key)) {
for (field_key in raw_field_list) {
if (raw_field_list.hasOwnProperty(field_key)) {
field_id = "";
if (raw_fields[field_key]["default"] !== undefined && raw_fields[field_key]["default"] !== "") {
if (raw_field_list[field_key]["default"] !== undefined &&
raw_field_list[field_key]["default"] !== "") {
if (field_key.startsWith("my_")) {
field_id = field_key.replace("my_", "");
} else if (field_key.startsWith("your_")) {
......@@ -81,7 +87,7 @@
} else {
field_id = field_key;
}
return_dict[field_id] = raw_fields[field_key]["default"];
return_dict[field_id] = raw_field_list[field_key]["default"];
}
}
}
......@@ -109,7 +115,8 @@
var appcache_storage,
origin_url = window.location.href,
hateoas_script = "hateoas_appcache/ERP5Document_getHateoas",
// TODO manifest should come from gadget.props.cache_file -add script in html body
// TODO manifest should come from gadget.props.cache_file
// add script in html body
manifest = "gadget_officejs_text_editor.configuration",
jio_appchache_options = {
type: "replicate",
......@@ -144,7 +151,8 @@
if (jio_options === undefined) {
return;
}
jio_appchache_options.local_sub_storage = JSON.parse(JSON.stringify(jio_options));
jio_appchache_options.local_sub_storage = JSON.parse(
JSON.stringify(jio_options));
jio_options = {
type: 'dateupdater',
sub_storage: jio_options,
......@@ -173,9 +181,13 @@
for (id in attachment_dict) {
if (attachment_dict.hasOwnProperty(id)) {
if (id.indexOf(hateoas_script) === -1) {
promise_list.push(appcache_storage.getAttachment(origin_url, id));
promise_list.push(appcache_storage
.getAttachment(origin_url, id));
} else {
promise_list.push(appcache_storage.getAttachment(origin_url, id, {"format": "json"}));
promise_list.push(
appcache_storage
.getAttachment(origin_url, id,
{"format": "json"}));
}
configuration_ids_list[i] = id;
i += 1;
......@@ -203,9 +215,12 @@
.push(undefined);
});
}, function (error) {
console.log("Error while appcache-local storage synchronization");
if (error && error.currentTarget && error.currentTarget.status === "401") {
console.log("Unauthorized access to storage, sync cancelled");
console.log("Error while appcache-local " +
"storage synchronization");
if (error && error.currentTarget &&
error.currentTarget.status === "401") {
console.log("Unauthorized access to storage," +
"sync cancelled");
return;
}
throw error;
......
/*global window, rJS, RSVP, Handlebars */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 80 */
(function (window, rJS, RSVP, Handlebars) {
"use strict";
......@@ -36,52 +36,50 @@
);
}
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("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("getHTMLElementList", function (element_list) {
var gadget = this,
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;
});
})
.declareMethod("render", function (options) {
var gadget = this,
portal_type,
......@@ -96,20 +94,20 @@
})
.push(function (result) {
portal_type = result;
return gadget.declareGadget("gadget_officejs_common_utils.html");
return gadget.declareGadget("gadget_officejs_common_util.html");
})
.push(function (gadget_utils) {
// TODO views are also listed here
// should views be handled in another gadget like "..tab_office.js" ?
return gadget_utils.getAllViewsAndActions(portal_type, options.jio_key);
return gadget_utils.getViewAndActionDict(portal_type,
options.jio_key);
})
.push(function (action_info_dict) {
return RSVP.all([
gadget.getHTMLElementList(action_info_dict.views),
gadget.getHTMLElementList(action_info_dict.actions)
getHTMLElementList(gadget, action_info_dict.view_list),
getHTMLElementList(gadget, action_info_dict.action_list)
]);
})
// check other lists like clone or delete? NO. For now, they will be actions
.push(function (all_html_elements) {
return RSVP.all([
renderLinkList(gadget, "Views", "eye", all_html_elements[0]),
......@@ -118,7 +116,8 @@
})
.push(function (translated_html_link_list) {
gadget.element.innerHTML = translated_html_link_list.join("\n");
return gadget.getUrlFor({command: 'change', options: {page: undefined}});
return gadget.getUrlFor({command: 'change',
options: {page: undefined}});
})
.push(function (back_url) {
return gadget.updateHeader({
......
/*global window, document, rJS */
/*jslint nomen: true, indent: 2, maxerr: 13 */
/*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 80 */
(function (window, document, rJS) {
"use strict";
......@@ -8,12 +8,6 @@
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_get", "jio_get")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("jio_post", "jio_post")
......@@ -22,7 +16,8 @@
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod("createDocument", function (portal_type, parent_portal_type) {
.declareMethod("createDocument", function (portal_type,
parent_portal_type) {
var gadget = this,
doc = {
title: "Untitled Document",
......@@ -58,13 +53,21 @@
})
.push(function (portal_type_result) {
portal_type = portal_type_result;
// TODO: somehow (a generic action?) get the path string:${object_url}/Base_viewNewContentDialog
return gadget.jio_get("portal_skins/erp5_hal_json_style/Base_viewNewContentDialog");
return gadget.getSetting("new_content_action");
})
.push(function (new_content_action) {
if (!new_content_action) {
throw new Error("Missing site configuration 'new_content_action'");
}
return gadget.jio_get(new_content_action);
})
.push(function (form_result) {
form_definition = form_result.raw_dict._embedded._view._embedded.form_definition;
form_definition.fields_raw_properties = form_result.raw_dict._embedded._view.my_fields_raw_properties["default"];
form_definition._actions = form_result.raw_dict._embedded._view._actions;
form_definition = form_result.raw_dict._embedded._view
._embedded.form_definition;
form_definition.fields_raw_properties = form_result.raw_dict._embedded
._view.my_fields_raw_properties["default"];
form_definition._actions = form_result.raw_dict._embedded
._view._actions;
form_definition.group_list = form_result.raw_dict.group_list;
form_definition.title = "Create Document";
return gadget.changeState({
......@@ -88,15 +91,17 @@
this.element.removeChild(this.element.firstChild);
}
this.element.appendChild(fragment);
return gadget.declareGadget("gadget_officejs_form_view.html", {element: fragment,
scope: 'fg'})
return gadget.declareGadget("gadget_officejs_form_view.html",
{element: fragment, scope: 'fg'})
.push(function (form_view_gadget) {
return form_view_gadget.render(gadget.state);
});
} else {
// if there is only one sub portal type, skip create document dialog rendering
// if there is only one sub portal type
// skip create document dialog rendering
return gadget.createDocument(gadget.state.doc.portal_type[0],
gadget.state.parent_portal_type.replace(/ /g, '_').toLowerCase());
gadget.state.parent_portal_type
.replace(/ /g, '_').toLowerCase());
}
})
......@@ -104,7 +109,8 @@
var gadget = this,
content_dict = options[2];
return gadget.createDocument(content_dict.portal_type,
gadget.state.parent_portal_type.replace(/ /g, '_').toLowerCase());
gadget.state.parent_portal_type
.replace(/ /g, '_').toLowerCase());
});
}(window, document, rJS));
\ No newline at end of file
/*global window, document, rJS, RSVP */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*jslint nomen: true, indent: 2, maxerr: 10, maxlen: 80 */
(function (window, document, rJS, RSVP) {
"use strict";
......@@ -8,7 +8,6 @@
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("getSetting", "getSetting")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("notifySubmitted", 'notifySubmitted')
.declareAcquiredMethod("notifySubmitting", "notifySubmitting")
......@@ -24,46 +23,51 @@
.push(function () {
return RSVP.all([
gadget.getUrlParameter("parent_portal_type"),
gadget.declareGadget("gadget_officejs_common_utils.html")
gadget.declareGadget("gadget_officejs_common_util.html")
]);
})
.push(function (result) {
parent_portal_type = result[0];
return result[1].getFormDefinition(parent_portal_type, action_reference);
return result[1].getFormDefinition(parent_portal_type,
action_reference);
});
})
.declareMethod("render", function (options) {
var gadget = this, action_reference, gadget_utils, form_definition;
var gadget = this, action_reference, gadget_util, form_definition;
return RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getUrlParameter('portal_type'),
gadget.getUrlParameter('parent_relative_url'),
gadget.getUrlParameter("action"),
gadget.declareGadget("gadget_officejs_common_utils.html")
gadget.declareGadget("gadget_officejs_common_util.html")
]);
})
.push(function (result) {
if (result[0] !== undefined) { options.portal_type = result[0]; }
if (result[1] !== undefined) { options.parent_relative_url = result[1]; }
if (result[1] !== undefined) {
options.parent_relative_url = result[1];
}
action_reference = result[2];
gadget_utils = result[3];
gadget_util = result[3];
return gadget.getActionFormDefinition(action_reference);
})
.push(function (result) {
form_definition = result;
return gadget_utils.getFormInfo(form_definition);
return gadget_util.getFormInfo(form_definition);
})
.push(function (form_info) {
var fragment = document.createElement('div'),
action_gadget_url,
form_type = form_info[0],
child_gadget_url = form_info[1],
//an action form must have a GadgetField called "gadget_field_new_action_js_script"
//an action form must have a GadgetField called
//"gadget_field_new_action_js_script"
//this gadget will point the custom action gadget
valid_action = form_definition.action_type === "object_jio_js_script" &&
form_definition.fields_raw_properties.hasOwnProperty("gadget_field_action_js_script"),
valid_action = form_definition.action_type ===
"object_jio_js_script" && form_definition.fields_raw_properties
.hasOwnProperty("gadget_field_action_js_script"),
state_options = {
doc: {},
action_options: options,
......@@ -74,9 +78,12 @@
valid_action: valid_action
};
if (valid_action) {
action_gadget_url = form_definition.fields_raw_properties.gadget_field_action_js_script.values.gadget_url;
// as custom gadget render is being done here, avoid to child gadget to render it
delete form_definition.fields_raw_properties.gadget_field_action_js_script;
action_gadget_url = form_definition.fields_raw_properties
.gadget_field_action_js_script.values.gadget_url;
// as custom gadget render is being done here
// avoid to child gadget to render it
delete form_definition.fields_raw_properties
.gadget_field_action_js_script;
gadget.element.appendChild(fragment);
return gadget.declareGadget(action_gadget_url, {
scope: "action_field",
......@@ -103,8 +110,8 @@
this.element.removeChild(this.element.firstChild);
}
this.element.appendChild(fragment);
return gadget.declareGadget("gadget_officejs_form_view.html", {element: fragment,
scope: 'fg'})
return gadget.declareGadget("gadget_officejs_form_view.html",
{element: fragment, scope: 'fg'})
.push(function (form_view_gadget) {
return form_view_gadget.render(gadget.state);
});
......@@ -137,7 +144,8 @@
return gadget.notifySubmitting();
})
.push(function () {
return gadget.notifySubmitted({message: 'Data Updated', status: 'success'});
return gadget.notifySubmitted({message: 'Data Updated',
status: 'success'});
})
.push(function () {
return gadget.redirect({
......@@ -149,7 +157,9 @@
});
});
} else {
return gadget.notifySubmitted({message: 'Could not perform this action: configuration error', status: 'fail'});
return gadget.notifySubmitted(
{message: 'Could not perform this action: configuration error',
status: 'fail'});
}
});
......
......@@ -230,8 +230,8 @@ gadget_officejs_form_view.html\n
gadget_officejs_form_view.js\n
gadget_erp5_page_handle_action.html\n
gadget_erp5_page_handle_action.js\n
gadget_officejs_common_utils.html\n
gadget_officejs_common_utils.js\n
gadget_officejs_common_util.html\n
gadget_officejs_common_util.js\n
gadget_erp5_page_create_document.html\n
gadget_erp5_page_create_document.js\n
\n
......@@ -746,7 +746,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>977.10238.57791.10683</string> </value>
<value> <string>977.8821.29343.5888</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -764,7 +764,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1563448279.94</float>
<float>1563363682.11</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -134,7 +134,7 @@ NETWORK:\n
</item>
<item>
<key> <string>title</string> </key>
<value> <string>OfficeJS Configuration</string> </value>
<value> <string>OfficeJS Text Editor Configuration</string> </value>
</item>
<item>
<key> <string>url_string</string> </key>
......@@ -271,7 +271,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>977.10238.54043.341</string> </value>
<value> <string>976.64206.22853.836</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -289,7 +289,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1563448274.75</float>
<float>1563193388.95</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -21,6 +21,14 @@
<script data-renderjs-configuration="parent_relative_url" type="text/x-renderjs-configuration">web_page_module</script>
<script data-renderjs-configuration="hide_listbox_buttons" type="text/x-renderjs-configuration">1</script>
<script data-renderjs-configuration="documents_editable" type="text/x-renderjs-configuration">1</script>
<script data-renderjs-configuration="portal_skin_folder" type="text/x-renderjs-configuration">erp5_web_officejs_ui</script>
<!-- TODO: somehow (a generic action?) get the path string:${object_url}/Base_viewNewContentDialog. For now it's in new_content_action -->
<script data-renderjs-configuration="new_content_action" type="text/x-renderjs-configuration">portal_skins/erp5_hal_json_style/Base_viewNewContentDialog</script>
<script data-renderjs-configuration="app_view_reference" type="text/x-renderjs-configuration">text_editor_view</script>
<script data-renderjs-configuration="app_actions" type="text/x-renderjs-configuration">('Web Page | text_editor_view', 'Web Page | text_editor_clone')</script>
<script data-renderjs-configuration="app_allowed_sub_types" type="text/x-renderjs-configuration">('Web Page Module | Web Page',)</script>
<script data-renderjs-configuration="hide_header_add_button" type="text/x-renderjs-configuration">0</script>
<script data-renderjs-configuration="header_jump_button" type="text/x-renderjs-configuration">0</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">n692ixxhyg9zhqs</script>
<div data-gadget-url="gadget_erp5_router.html" data-gadget-scope="erp5_router"></div>
......
......@@ -787,7 +787,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.64179.17400.52480</string> </value>
<value> <string>977.15998.30713.4488</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -805,7 +805,7 @@
</tuple>
<state>
<tuple>
<float>1563192454.2</float>
<float>1563801605.23</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -2,28 +2,10 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Site" module="erp5.portal_type"/>
<global name="Web Section" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Manager</string>
<string>Member</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
......@@ -67,24 +49,7 @@
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Authenticated</string>
<string>Author</string>
<string>Manager</string>
<string>Member</string>
<string>Owner</string>
<string>Reviewer</string>
</tuple>
</value>
</item>
......@@ -133,7 +98,7 @@
<key>
<tuple>
<int>99</int>
<string>ERP5 Web Site/hateoas_appcache</string>
<string>ERP5 Web Section/hateoas_appcache</string>
</tuple>
</key>
<value>
......@@ -143,117 +108,22 @@
</dictionary>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_x_frame_options</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_content_security_policy</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_login</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>configuration_logout</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAc=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>authorization_forced</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>available_language</string> </key>
<value>
<tuple>
<string>en</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>configuration_content_security_policy</string> </key>
<value> <string>default-src \'self\'; img-src \'self\' data:; media-src \'self\' blob:; connect-src \'self\' https://localhost:5000 mail.tiolive.com data: *.host.vifib.net *.node.vifib.com *.erp5.net *.erp5.ru; script-src \'self\' \'unsafe-eval\'; font-src netdna.bootstrapcdn.com; style-src \'self\' netdna.bootstrapcdn.com \'unsafe-inline\' data:; frame-src \'self\' data: *.app.officejs.com</string> </value>
</item>
<item>
<key> <string>configuration_login</string> </key>
<value> <string>connection/login_form{?came_from}</string> </value>
</item>
<item>
<key> <string>configuration_logout</string> </key>
<value> <string>connection/WebSite_logout{?came_from}</string> </value>
</item>
<item>
<key> <string>configuration_x_frame_options</string> </key>
<value> <string>ALLOW-FROM-ALL</string> </value>
</item>
<item>
<key> <string>container_layout</string> </key>
<value> <string>ERP5Document_getHateoas</string> </value>
......@@ -272,6 +142,10 @@
<none/>
</value>
</item>
<item>
<key> <string>empty_criterion_valid</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>hateoas_appcache</string> </value>
......@@ -282,7 +156,7 @@
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Site</string> </value>
<value> <string>Web Section</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
......@@ -294,10 +168,6 @@
<key> <string>skin_selection_name</string> </key>
<value> <string>Hal</string> </value>
</item>
<item>
<key> <string>static_language_selection</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Hateoas appcache</string> </value>
......@@ -309,7 +179,7 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAg=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -317,19 +187,13 @@
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="WebSiteTraversalHook" module="Products.ERP5.Document.WebSite"/>
<global name="WebSectionTraversalHook" module="Products.ERP5.Document.WebSection"/>
</pickle>
<pickle>
<dictionary/>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -344,15 +208,7 @@
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="6" aka="AAAAAAAAAAY=">
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -367,15 +223,7 @@
</dictionary>
</pickle>
</record>
<record id="7" aka="AAAAAAAAAAc=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="8" aka="AAAAAAAAAAg=">
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
......@@ -388,13 +236,13 @@
<item>
<key> <string>category_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAk=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAo=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAc=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -403,7 +251,7 @@
</dictionary>
</pickle>
</record>
<record id="9" aka="AAAAAAAAAAk=">
<record id="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......@@ -414,7 +262,9 @@
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish</string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actor</string> </key>
......@@ -440,7 +290,7 @@
</tuple>
<state>
<tuple>
<float>1562751918.1</float>
<float>1563793675.89</float>
<string>UTC</string>
</tuple>
</state>
......@@ -449,14 +299,14 @@
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published</string> </value>
<value> <string>embedded</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="10" aka="AAAAAAAAAAo=">
<record id="7" aka="AAAAAAAAAAc=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
......@@ -485,7 +335,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.64170.30918.60808</string> </value>
<value> <string>977.16127.15783.5358</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -503,7 +353,7 @@
</tuple>
<state>
<tuple>
<float>1562752490.8</float>
<float>1563801586.91</float>
<string>UTC</string>
</tuple>
</state>
......
<registered_skin_selection>
<skin_folder_selection>
<skin_folder>erp5_web_officejs_ui</skin_folder>
<skin_selection>RJS,View</skin_selection>
<skin_selection>Hal,RJS,View</skin_selection>
</skin_folder_selection>
</registered_skin_selection>
\ No newline at end of file
<?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>_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>Base ERP5 Form view for rendering in renderjs UI</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></string> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<list>
<string>left</string>
<string>right</string>
<string>center</string>
<string>bottom</string>
<string>hidden</string>
</list>
</value>
</item>
<item>
<key> <string>groups</string> </key>
<value>
<dictionary>
<item>
<key> <string>bottom</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>center</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>hidden</string> </key>
<value>
<list/>
</value>
</item>
<item>
<key> <string>left</string> </key>
<value>
<list>
<string>my_fields_raw_properties</string>
</list>
</value>
</item>
<item>
<key> <string>right</string> </key>
<value>
<list/>
</value>
</item>
</dictionary>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Form_viewAsDefinition</string> </value>
</item>
<item>
<key> <string>method</string> </key>
<value> <string>POST</string> </value>
</item>
<item>
<key> <string>name</string> </key>
<value> <string>ERP5Form_viewAsJio</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></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="StringField" module="Products.Formulator.StandardFields"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>my_fields_raw_properties</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>required_not_found</string> </key>
<value> <string>Input is required but no input given.</string> </value>
</item>
<item>
<key> <string>too_long</string> </key>
<value> <string>Too much input was given.</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>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</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>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</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>default</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</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>hidden</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>whitespace_preserve</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>default</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_maxwidth</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>display_width</string> </key>
<value> <int>20</int> </value>
</item>
<item>
<key> <string>editable</string> </key>
<value> <int>0</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>hidden</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>input_type</string> </key>
<value> <string>text</string> </value>
</item>
<item>
<key> <string>max_length</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>required</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Fields raw properties</string> </value>
</item>
<item>
<key> <string>truncate</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>unicode</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>whitespace_preserve</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="TALESMethod" module="Products.Formulator.TALESField"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_text</string> </key>
<value> <string>python: here.Form_getFieldsRawProperties(REQUEST)</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
from Products.ERP5Type.Log import log
def getRealRelativeUrl(document):
return '/'.join(context.getPortalObject().portal_url.getRelativeContentPath(document))
def getFieldRawProperties(field, meta_type=None, key=None, key_prefix=None):
""" Return the raw properties of the field """
if meta_type is None:
meta_type = field.meta_type
if key is None:
key = field.generate_field_key(key_prefix=key_prefix)
if meta_type == "ProxyField":
meta_type = field.getRecursiveTemplateField().meta_type
result = {
"type": meta_type,
"key": key,
"values": {},
"overrides": field.overrides,
"message_values": field.message_values
}
# these patchs change the field property names as are required by js rendering
form_list_patch = False
gadget_field_patch = False
for key in field.values.keys():
# sometimes, field.values returns a key as string and also as a tuple
if type(key) is str:
result["values"][key] = field.values[key]
if key == "columns":
form_list_patch = True
if key == "gadget_url":
gadget_field_patch = True
if form_list_patch:
try:
result["values"]["column_list"] = result["values"]["columns"]
result["values"]["sort_column_list"] = result["values"]["sort_columns"]
result["values"]["search_column_list"] = result["values"]["search_columns"]
portal_type = result["values"]["portal_types"][0][0] if "portal_types" in result["values"] else False
if not portal_type:
portal_type = result["values"]["portal_type"][0][0] if "portal_type" in result["values"] else False
query = "portal_type%3A%22" + portal_type + "%22" if portal_type else ""
full_query = "urn:jio:allDocs?query=" + query
result["values"]["query"] = full_query
except KeyError:
log("error while patching form list definition")
if gadget_field_patch:
try:
result["values"]["url"] = result["values"]["gadget_url"]
result["values"]["renderjs_extra"] = result["values"]["renderjs_extra"][0][0]
except (ValueError, KeyError, IndexError):
log("error while patching form gadget list definition")
return result
if REQUEST.get("view") == "definition_view":
traversed_document = context
traversed_document_portal_type = traversed_document.getPortalType()
fields_raw_properties = {}
if traversed_document_portal_type in ("ERP5 Form", "ERP5 Report"):
custom_action_script = False
for group in traversed_document.Form_getGroupTitleAndId():
if 'hidden' in group["gid"]:
for field in traversed_document.get_fields_in_group(group["goid"]):
if field.id == "gadget_field_action_js_script":
custom_action_script = True
fields_raw_properties[field.id] = getFieldRawProperties(field, key_prefix=None)
continue
for field in traversed_document.get_fields_in_group(group["goid"]):
if field.id == "gadget_field_action_js_script":
custom_action_script = True
fields_raw_properties[field.id] = getFieldRawProperties(field, key_prefix=None)
if custom_action_script:
fields_raw_properties['_actions'] = {
'put': {
"href": "%(traversed_document_url)s/%(action_id)s" % {
"traversed_document_url": context.getPortalObject().absolute_url() + "/" + getRealRelativeUrl(traversed_document),
"action_id": "Base_edit"
},
"action": "Base_edit",
"method": "POST",
}
}
if fields_raw_properties:
return fields_raw_properties
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<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_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<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>_params</string> </key>
<value> <string>REQUEST=None</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Form_getFieldsRawProperties</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Action Information | definition_view
Base Type | definition_view
ERP5 Form | definition_view
Web Page Module | text_editor_view
Web Page | text_editor_clone
Web Page | text_editor_view
\ No newline at end of file
......@@ -40,5 +40,4 @@ web_site_module/officejs_todomvc
web_site_module/officejs_wallsearch
web_site_module/officejs_wallsearch/**
web_site_module/officejs_whiteboard
web_site_module/officejs_media_player/**
web_site_module/hateoas_appcache
\ No newline at end of file
web_site_module/officejs_media_player/**
\ No newline at end of file
......@@ -40,5 +40,4 @@ web_site_module/officejs_todomvc
web_site_module/officejs_wallsearch
web_site_module/officejs_wallsearch/**
web_site_module/officejs_whiteboard
web_site_module/officejs_media_player/**
web_site_module/hateoas_appcache
\ No newline at end of file
web_site_module/officejs_media_player/**
\ No newline at end of file
......@@ -5,10 +5,6 @@ image_module/hr_logo_svg
image_module/officejs_audioplayer_*
image_module/officejs_todomvc_*
image_module/wallsearch_icon_svg
portal_types/Web Page Module/text_editor_view
portal_types/Web Page/jio_view
portal_types/Web Page/text_editor_clone
portal_types/Web Page/text_editor_view
web_page_module/dhtmlx_gantt_*
web_page_module/fb_sdk_js
web_page_module/gadget_field_*
......@@ -18,7 +14,6 @@ web_page_module/officejs_audioplayer_*
web_page_module/officejs_todomvc_*
web_page_module/ojs_*
web_page_module/wallsearch_privacy_policy_html
web_site_module/hateoas_appcache
web_site_module/officejs_audioplayer
web_site_module/officejs_audioplayer/**
web_site_module/officejs_bookmark_manager
......
erp5_web_officejs_ui | Hal
erp5_web_officejs_ui | RJS
erp5_web_officejs_ui | View
\ No newline at end of file
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