Commit 378c6554 authored by Gabriel Monnerat's avatar Gabriel Monnerat

erp5_web_renderjs_ui: Initial implementation of Graphic Gadget

* Render graphics in RJS without code
* Supporting the generation of bar graphics using domains
* Build graphics from listbox

The idea is get more information from listbox and make the script a bit smarter
parent 76754c91
import random
from DateTime import DateTime
from datetime import timedelta
portal = context.getPortalObject()
now = DateTime().asdatetime()
text_list = [
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
"Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?",
"But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?",
"At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.",
"On the other hand, we denounce with righteous indignation and dislike men who are so beguiled and demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain and trouble that are bound to ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains."
]
title_list = [
"The standard Lorem Ipsum passage, used since the 1500s",
"Section 1.10.32 of 'de Finibus Bonorum et Malorum', written by Cicero in 45 BC",
"1914 translation by H. Rackham",
"Section 1.10.33 of 'de Finibus Bonorum et Malorum', written by Cicero in 45 BC",
"1915 translation by H. Rackham",
"1916 translation by H. Rackham"
]
portal.portal_caches.clearAllCache()
resource_list = [
"erp5_officejs_support_request_ui_test_service_001",
"erp5_officejs_support_request_ui_test_service_002",
"erp5_officejs_support_request_ui_test_service_003",
"erp5_officejs_support_request_ui_test_service_004",
]
for _ in range(amount):
support_request = portal.support_request_module.newContent(
portal_type='Support Request',
title=random.choice(title_list),
start_date=DateTime(now - timedelta(days=random.choice(range(1, 100)))),
resource_value=getattr(portal.service_module, random.choice(resource_list)),
source_project_value=portal.project_module.erp5_officejs_support_request_ui_test_project_001,
)
support_request.submit()
if random.choice([True, False]):
support_request.validate()
if random.choice([True, False]):
support_request.invalidate()
elif random.choice([True, False]):
support_request.suspend()
portal.post_module.PostModule_createHTMLPostForSupportRequest(
follow_up=support_request.getRelativeUrl(),
predecessor=None,
data=random.choice(text_list),
file=None,
web_site_relative_url=portal.web_site_module.erp5_officejs_support_request_ui.getRelativeUrl(),
)
if len(portal.support_request_module.contentIds()) < limit:
# Use after_method_id just to not kill the dev instance
return portal.support_request_module.activate(after_method_id=(
'recursiveImmediateReindexObject',
'immediateReindexObject',
'Post_ingestMailMessageForSupportRequest',
"searchAndActivate")).ERP5Site_createMassiveSupportRequestDataSet(amount, limit)
<?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>amount=10, limit=10</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>ERP5Site_createMassiveSupportRequestDataSet</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Base Domain" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAY=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>domain_generator_method_id</string> </key>
<value> <string>Base_generateDeliveryStartDateDomain</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>graphic_gadget_delivery_start_date_domain</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Base Domain</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Graphic Gadget Delivery Start Date Domain</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
......@@ -27,14 +27,15 @@
if (!rendered_document.hasOwnProperty(field_name)) {
return;
}
suboptions = {
hide_enabled: form_definition.hide_enabled, // listbox specific
configure_enabled: form_definition.configure_enabled, // listbox specific
extended_search: (is_first_bottom_listbox && (form_definition.extended_search)), // searchfield specific
field_type: rendered_document[field_name].type,
label: ((group_name !== "bottom") && (rendered_document[field_name].title.length > 0)), // no label for bottom group and field without title
field_json: rendered_document[field_name] // pass
field_json: rendered_document[field_name], // pass
jio_key: modification_dict.jio_key,
enable_graphic: modification_dict.enable_graphic
};
// XXX: what is the purpose of this?
......@@ -186,10 +187,10 @@
if (options.form_definition.hasOwnProperty("edit_form_update_href")) {
hash += "edit_form_update_action";
}
return this.changeState({
erp5_document: options.erp5_document,
form_definition: options.form_definition,
enable_graphic: options.enable_graphic,
jio_key: options.jio_key,
hash: hash,
view: options.view,
......@@ -299,6 +300,15 @@
begin_from: 0
};
}, {mutex: 'changestate'})
.declareMethod("getGraphicType", function () {
var gadget = this;
if (gadget.props.listbox_gadget) {
return gadget.props.listbox_gadget.getGraphicType();
}
return;
}, {mutex: 'changestate'})
.declareMethod("getContent", function (options) {
var form_gadget = this,
k,
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>991.26405.47.57924</string> </value>
<value> <string>997.49201.45822.48315</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1618519262.64</float>
<float>1643133280.23</float>
<string>UTC</string>
</tuple>
</state>
......
div[data-gadget-url$="gadget_erp5_graphic_editor.html"] .graphic-listview {
text-align: center;
}
div[data-gadget-url$="gadget_erp5_graphic_editor.html"] ul.graphic-listview li a {
display: block;
padding: 6pt 12pt;
padding-right: 24pt;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<!--
data-i18n=Close
data-i18n=Change Graphic
-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>ERP5 Sort Editor</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_sub_editor_panel.html">
<!-- renderjs -->
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="domsugar.js"></script>
<script src="jiodev.js"></script>
<link rel="stylesheet" href="gadget_erp5_graphic_editor.css">
<!-- custom script -->
<script src="gadget_erp5_graphic_editor.js"></script>
</head>
<body>
<form>
<div class="container"></div>
</form>
</body>
</html>
\ No newline at end of file
/*jslint indent: 2, maxerr: 3, maxlen: 100, nomen: true */
/*global window, rJS, domsugar, console, RSVP*/
(function (window, rJS, domsugar, RSVP) {
"use strict";
rJS(window)
//////////////////////////////////////////////
// acquired method
//////////////////////////////////////////////
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("trigger", "trigger")
//////////////////////////////////////////////
// initialize the gadget content
//////////////////////////////////////////////
.declareMethod('render', function render(options) {
return this.changeState({
"jio_key": options.jio_key,
"graphic_option_list": options.graphic_option_list
});
})
.onStateChange(function onStateChange(modification_dict) {
var i,
option_list = modification_dict.graphic_option_list,
url_list = [],
gadget = this;
for (i = 0; i < option_list.length; i += 1) {
url_list.push({
"command": "store_and_change",
"options": {
"jio_key": gadget.state.jio_key,
"graphic_type": option_list[i][0]
}
});
}
return new RSVP.Queue(
RSVP.all([
gadget.getTranslationList([
'Close',
'Change Graphic'
]),
gadget.getUrlForList(url_list)
])
)
.push(function (result_list) {
var translation_list = result_list[0],
li_list = [];
for (i = 0; i < result_list[1].length; i += 1) {
li_list.push(domsugar("li", [
domsugar("a", {
"href": result_list[1][i],
"text": option_list[i][1]
})
]));
}
domsugar(gadget.element.querySelector(".container"), [
domsugar('div', [
domsugar('div', {'data-role': 'header', 'class': 'ui-header'}, [
domsugar('div', {"class": 'ui-btn-left'}, [
domsugar('div', {"class": 'ui-controlgroup-controls'}, [
domsugar('button', {
"type": 'submit',
"class": 'close ui-btn-icon-left ui-icon-times',
"text": translation_list[0]
})
])
]),
domsugar('h1', {"text": translation_list[1]}),
domsugar('div', {"class": 'ui-btn-left'}, [
domsugar('div', {"class": 'ui-controlgroup-controls'}, [
domsugar('button')
])
])
]),
domsugar("ul", {
"class": "graphic-listview"
}, li_list)
])
]);
});
})
.onEvent('click', function click(evt) {
if (evt.target.classList.contains('close')) {
evt.preventDefault();
this.trigger();
}
}, false, false);
}(window, rJS, domsugar, RSVP));
\ No newline at end of file
......@@ -337,6 +337,14 @@
});
}, {mutex: 'changestate'})
.declareMethod('getGraphicType', function getGraphicType() {
var argument_list = arguments;
return this.getDeclaredGadget(SCOPE)
.push(function (gadget) {
return gadget.getGraphicType.apply(gadget, argument_list);
});
}, {mutex: 'changestate'})
.allowPublicAcquisition("notifyFocus", function notifyFocus() {
return this.changeState({display_error_text: true});
})
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>991.31753.10689.19694</string> </value>
<value> <string>997.7172.17438.7031</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1618839010.44</float>
<float>1643134111.55</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -34,7 +34,7 @@
</head>
<body>
<div class="document_table">
</div>
<div class="graphic_section"></div>
<div class="document_table"></div>
</body>
</html>
\ No newline at end of file
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>993.55171.44758.6877</string> </value>
<value> <string>994.9738.18277.17732</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1628545474.29</float>
<float>1629923258.92</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>ERP5TypeTestCase</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -242,7 +242,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>994.13949.44825.36573</string> </value>
<value> <string>1006.49813.52078.33996</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -262,7 +262,7 @@
</tuple>
<state>
<tuple>
<float>1629394496.1</float>
<float>1677704743.9</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -1212,12 +1212,6 @@ div[data-gadget-scope='header'] .ui-header ul {
flex: 7;
}
}
.gadget-content .bottom iframe {
height: 80vh;
}
.gadget-content .bottom div[data-gadget-url$="gadget_erp5_field_listbox.html"] iframe {
height: 30vh;
}
.gadget-content form .ui-field-contain {
position: relative;
}
......@@ -1374,6 +1368,14 @@ div[data-gadget-scope='erp5_searchfield'] div.search_parsed_value button {
-o-text-overflow: ellipsis;
-ms-text-overflow: ellipsis;
}
div[data-gadget-scope='field_listbox'] .graphic_section {
text-align: center;
padding-bottom: 0.3em;
}
div[data-gadget-scope='field_listbox'] .graphic_section select {
width: 50%;
font-size: 12pt;
}
.document_table .ui-table-header {
display: flex;
padding-top: 3pt;
......
......@@ -248,7 +248,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>990.6663.38009.56354</string> </value>
<value> <string>994.39809.40344.18312</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -268,7 +268,7 @@
</tuple>
<state>
<tuple>
<float>1613660719.23</float>
<float>1630946631.88</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>994.51234.65222.57241</string> </value>
<value> <string>1001.44568.42311.25019</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1632227052.12</float>
<float>1658171641.42</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>994.55137.25232.35430</string> </value>
<value> <string>1001.44890.56940.59050</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1632227072.53</float>
<float>1658174386.58</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -31,7 +31,6 @@
<!-- XXX action, method, fieldset -->
<form>
<button type="submit" class="ui-icon-action ui-btn-icon-right ui-screen-hidden">Submit</button>
<div data-gadget-url="gadget_erp5_searchfield.html"
data-gadget-scope="erp5_searchfield"
data-gadget-sandbox="public"></div>
......@@ -41,6 +40,5 @@
data-gadget-sandbox="public"></div>
</form>
</body>
</html>
\ No newline at end of file
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.48720.1486.39116</string> </value>
<value> <string>997.39276.32766.15104</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1554191230.42</float>
<float>1642645073.04</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, renderFormViewHeader, renderFormListHeader,
SimpleQuery, ComplexQuery,
Query, QueryFactory, ensureArray, triggerListboxClipboardAction,
declareGadgetClassCanHandleListboxClipboardAction*/
declareGadgetClassCanHandleListboxClipboardAction, RSVP*/
/*jslint nomen: true, indent: 2, maxerr: 3, continue: true */
(function (window, rJS, renderFormViewHeader, renderFormListHeader,
SimpleQuery, ComplexQuery,
Query, QueryFactory, ensureArray, triggerListboxClipboardAction,
declareGadgetClassCanHandleListboxClipboardAction) {
declareGadgetClassCanHandleListboxClipboardAction, RSVP) {
"use strict";
function updateSearchQueryFromSelection(extended_search, checked_uid_list,
......@@ -113,13 +113,21 @@
});
})
.onStateChange(function onStateChange() {
var form_gadget = this;
.onStateChange(function onStateChange(modification_dict) {
var erp5_form,
graphic_type,
enable_graphic = false,
form_gadget = this;
// render the erp5 form
return form_gadget.getDeclaredGadget("erp5_form")
.push(function (erp5_form) {
return new RSVP.Queue(RSVP.all([
form_gadget.getDeclaredGadget("erp5_form"),
form_gadget.getUrlParameter("graphic_type")
]))
.push(function (result_list) {
var form_options = form_gadget.state.erp5_form;
erp5_form = result_list[0];
graphic_type = result_list[1];
form_options.erp5_document = form_gadget.state.erp5_document;
form_options.form_definition = form_gadget.state.form_definition;
......@@ -135,20 +143,35 @@
if (form_gadget.state.extended_search) {
form_options.form_definition.extended_search = form_gadget.state.extended_search;
}
if (modification_dict.hasOwnProperty("enable_graphic")) {
enable_graphic = modification_dict.enable_graphic;
} else if (
graphic_type || (!form_gadget.state.extended_search && !graphic_type)
) {
enable_graphic = true;
}
form_options.enable_graphic = enable_graphic;
return erp5_form.render(form_options);
})
// render the search field
.push(function () {
return form_gadget.getDeclaredGadget("erp5_searchfield");
return RSVP.all([
form_gadget.getDeclaredGadget("erp5_searchfield"),
erp5_form.getGraphicType()
]);
})
.push(function (search_gadget) {
var search_options = {};
.push(function (result_list) {
var search_gadget = result_list[0],
search_options = {};
// XXX not generic, fix later
if (form_gadget.state.extended_search) {
search_options.extended_search = form_gadget.state.extended_search;
}
search_options.enable_graphic = enable_graphic;
search_options.graphic_type = result_list[1];
search_options.jio_key = form_gadget.state.jio_key;
return search_gadget.render(search_options);
})
......@@ -167,7 +190,6 @@
form_gadget.state.view,
form_gadget.state.erp5_document, true);
});
})
.declareMethod('triggerSubmit', function triggerSubmit(options) {
......@@ -228,6 +250,11 @@
}, false, true)
.allowPublicAcquisition("disableGraphic", function disableGraphic() {
this.changeState({
"enable_graphic": false
});
})
// Handle listbox custom button
.allowPublicAcquisition("getListboxSelectActionList", function getListboxSelectActionList() {
var gadget = this;
......@@ -267,7 +294,23 @@
return result_list;
});
})
.allowPublicAcquisition("triggerListboxGraphicSelection", function triggerListboxGraphicSelection() {
var gadget = this;
return this.getDeclaredGadget("erp5_form")
.push(function (declared_gadget) {
return RSVP.all([
declared_gadget.getListboxInfo(),
gadget.getUrlParameter("graphic_type")
]);
})
.push(function (result_list) {
return gadget.renderEditorPanel("gadget_erp5_graphic_editor.html", {
graphic_option_list: result_list[0].graphic_option_list,
jio_key: gadget.state.jio_key,
graphic_type: result_list[1]
});
});
})
.allowPublicAcquisition("triggerListboxSelectAction", function triggerListboxSelectAction(argument_list) {
var action = argument_list[0],
checked_uid_list = argument_list[1],
......@@ -311,4 +354,4 @@
}(window, rJS, renderFormViewHeader, renderFormListHeader, SimpleQuery,
ComplexQuery, Query,
QueryFactory, ensureArray, triggerListboxClipboardAction,
declareGadgetClassCanHandleListboxClipboardAction));
\ No newline at end of file
declareGadgetClassCanHandleListboxClipboardAction, RSVP));
\ No newline at end of file
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.58033.54588.53418</string> </value>
<value> <string>1006.4925.35513.18500</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1574153832.0</float>
<float>1675261450.24</float>
<string>UTC</string>
</tuple>
</state>
......
div[data-gadget-url$="gadget_erp5_searchfield.html"] .graphic-button-section > button {
border: 1px solid rgba(0, 0, 0, 0.14);
margin-right: 6pt;
border-radius: 0.325em;
}
.graphic-button-section {
float: left;
}
\ No newline at end of file
......@@ -9,13 +9,16 @@
<!-- renderjs -->
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="domsugar.js"></script>
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_searchfield.js"></script>
<link rel="stylesheet" type="text/css" href="gadget_erp5_searchfield.css">
</head>
<body>
<div class="graphic-button-section"></div>
<div class="ui-input-text">
<div class="search_parsed_value"></div>
<div data-gadget-url="gadget_html5_input.html"
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.15561.39912.10990</string> </value>
<value> <string>1001.49559.167.9728</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1537193726.71</float>
<float>1658784884.74</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, document, Node,
QueryFactory, SimpleQuery, ComplexQuery, Query*/
/*global window, rJS, Node,
QueryFactory, SimpleQuery, ComplexQuery, Query, domsugar*/
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, document, Node,
QueryFactory, SimpleQuery, ComplexQuery, Query) {
(function (window, rJS, Node,
QueryFactory, SimpleQuery, ComplexQuery, Query, domsugar) {
"use strict";
function convertQueryToSearchText(query) {
......@@ -29,19 +29,41 @@
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("getUrlParameter",
"getUrlParameter")
.declareMethod('render', function (options) {
var state_dict = {
extended_search: options.extended_search || ""
var gadget = this,
state_dict = {
extended_search: options.extended_search || "",
graphic_type: options.graphic_type,
enable_graphic: options.enable_graphic,
jio_key: options.jio_key
};
return this.changeState(state_dict);
})
return gadget.getUrlParameter("only_graphic")
.push(function (only_graphic) {
if (typeof only_graphic === "string") {
state_dict.only_graphic = only_graphic === "true";
} else if (only_graphic === undefined) {
state_dict.only_graphic = true;
} else {
state_dict.only_graphic = only_graphic;
}
return gadget.changeState(state_dict);
});
})
.declareAcquiredMethod("triggerListboxGraphicSelection",
"triggerListboxGraphicSelection")
.onStateChange(function () {
var gadget = this,
i,
len,
listbox_button_class,
graphic_button_class,
only_graphic = gadget.state.only_graphic,
button_container = gadget.element.querySelector('div.search_parsed_value'),
button,
graphic_container = gadget.element.querySelector(".graphic-button-section"),
hide_button_class = "ui-screen-hidden",
operator = 'AND',
jio_query_list = [],
query_text_list = [],
......@@ -52,7 +74,30 @@
input_value = '',
continue_full_text_query_search = true;
if (gadget.state.enable_graphic) {
listbox_button_class = "ui-btn-icon-notext ui-icon-list-alt switch-listbox";
graphic_button_class = "ui-btn-icon-notext ui-icon-bar-chart-o switch-graph";
if (!only_graphic) {
listbox_button_class = listbox_button_class + " " + hide_button_class;
} else if (only_graphic) {
graphic_button_class = graphic_button_class + " " + hide_button_class;
}
domsugar(graphic_container, [
domsugar("button", {
"class": listbox_button_class,
"type": "button"
}),
domsugar("button", {
"class": graphic_button_class,
"type": "button"
})
]);
}
if (gadget.state.extended_search) {
// Parse the raw query
try {
jio_query = QueryFactory.create(gadget.state.extended_search);
......@@ -114,15 +159,17 @@
button_container.innerHTML = '';
len = query_text_list.length;
for (i = 0; i < len; i += 1) {
button = document.createElement('button');
button.textContent = query_text_list[i];
button.value = i;
button_container.appendChild(button);
button_container.appendChild(
domsugar("button", {
"text": query_text_list[i],
"value": i
})
);
}
button = document.createElement('input');
button.setAttribute("type", "hidden");
button.value = parsed_value;
button_container.appendChild(button);
button_container.appendChild(domsugar("input", {
"type": "hidden",
"value": parsed_value
}));
return gadget.getDeclaredGadget('input')
.push(function (input_gadget) {
......@@ -222,17 +269,33 @@
// But, in the case of panel, we don't need to handle anything.
return;
})
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("triggerSubmit", "triggerSubmit")
.onEvent('click', function (evt) {
var gadget = this,
options;
if (evt.target.tagName === 'BUTTON') {
if ((evt.target.nodeType === Node.ELEMENT_NODE) &&
(evt.target.tagName === 'BUTTON') &&
(evt.target.value)) {
// Open the filter panel if one 'search' button is clicked
evt.preventDefault();
return this.triggerSubmit({focus_on: parseInt(evt.target.value, 10)});
}
if (evt.target.classList.contains("switch-listbox") ||
evt.target.classList.contains("switch-graph")) {
evt.target.disabled = true;
return gadget.redirect({
command: "change",
options: {
jio_key: gadget.state.jio_key,
graphic_type: gadget.state.graphic_type,
extended_search: gadget.state.extended_search,
only_graphic: evt.target.classList.contains("switch-graph") ? true : false
}
});
}
}
}, false, false);
}(window, rJS, document, Node,
QueryFactory, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file
}(window, rJS, Node,
QueryFactory, SimpleQuery, ComplexQuery, Query, domsugar));
\ No newline at end of file
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>987.27464.21813.55483</string> </value>
<value> <string>1006.26456.53090.63095</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1604428536.71</float>
<float>1676557532.21</float>
<string>UTC</string>
</tuple>
</state>
......
div[data-gadget-url$="gadget_graphic.html"] iframe {
height: 100%;
}
div[data-gadget-url$="gadget_graphic.html"] .ui-field-contain .graph-spinner {
position: absolute;
top: 100px;
width: 120px;
}
div[data-gadget-url$="gadget_graphic.html"] .left {
height: 50%;
width: 100%;
}
div[data-gadget-url$="gadget_graphic.html"] .ui-field-contain .bottom .first-line-buttons {
-webkit-appearance: none;
margin-top: 0;
margin-bottom: 20px;
}
div[data-gadget-url$="gadget_graphic.html"] .graph-section {
height: 300px;
}
div[data-gadget-url$="gadget_graphic.html"] .graph-button {
font-size: 13pt;
}
<html>
<!--
data-i18n=No data
data-i18n=Quantity
-->
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>Graphic Gadget</title>
<!-- renderjs -->
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="jiodev.js"></script>
<!-- custom script -->
<script src="gadget_graphic.js"></script>
<link rel="stylesheet" type="text/css" href="gadget_graphic.css">
</head>
<body>
<div class="ui-field-contain">
<div class="left">
<div class="ui-icon-spinner ui-btn-icon-notext first-loader graph-spinner"></div>
<div class="graph-section"></div>
<button class="graph-button" type="button"></button>
</div>
</div>
</body>
</html>
\ No newline at end of file
......@@ -28,6 +28,11 @@
<dd>Call getListboxInfo on the main listbox. Return {} by default.</dd>
<dl></dl>
<dt>getGraphicType</dt>
<dd>Return the graphic type</dd>
<dl>
</dl>
</dl>
</body>
</html>
\ No newline at end of file
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.16925.34276.10717</string> </value>
<value> <string>1006.12186.32555.36096</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1536929445.0</float>
<float>1675999574.87</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -26,6 +26,11 @@
<dl>
</dl>
<dt>getGraphicType</dt>
<dd>Return the graphic type</dd>
<dl>
</dl>
</dl>
</body>
</html>
\ No newline at end of file
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.16996.41795.16162</string> </value>
<value> <string>1006.12186.32555.36096</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1536933590.29</float>
<float>1675999781.59</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -13,6 +13,11 @@
<dl>
</dl>
<dt>getGraphicType</dt>
<dd>Return the graphic type</dd>
<dl>
</dl>
</dl>
</body>
</html>
\ No newline at end of file
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.13790.51027.29644</string> </value>
<value> <string>1006.17223.54353.23278</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -260,7 +260,7 @@
</tuple>
<state>
<tuple>
<float>1536933717.51</float>
<float>1675999313.61</float>
<string>UTC</string>
</tuple>
</state>
......
domain_id = listbox.get_value("domain_root_list")[0][0]
portal = context.getPortalObject()
base_category = getattr(portal.portal_categories, domain_id, None)
# We should not group by catalog keys like translate_*_title.
# For now, we keep a dict here, to convert this key by another faster catalog ket
perfomance_mapping = {
"translated_simulation_state_title": "simulation_state"
}
if base_category is not None:
label_list, domain_list = [], []
# should we get childs recursively?
for child in base_category.objectValues():
label_list.append(child.getTranslatedTitle())
domain_list.append(child.getId())
else:
label_list, domain_list = context.Base_getSubdomainTitleAndIdList(domain_id)
default_param_dict = {}
default_param_list = listbox.get_value('default_params') or []
group_by, group_by_title = None, ""
column_list = listbox.get_value("columns") or []
for column in column_list:
key, title = column
if any([i in key for i in ("validation_state", "simulation_state")]):
group_by = key
group_by_title = title
assert group_by, "group_by not found"
if default_param_list:
list_method, relative_url = None, None
# Use dict() is simpler but is slower
for (key, value) in default_param_list:
if isinstance(value, list):
default_param_dict.setdefault(key, []).extend(value)
else:
default_param_dict.setdefault(key, []).append(value)
else:
relative_url = context.getObject().getRelativeUrl()
list_method = listbox.get_value("list_method").getMethodName()
# XXX - hack to build absolute_url to add hateoas script through hateoas web site
script_id = "ERP5Document_getHateoas"
root_url = context.getWebSiteValue().hateoas.absolute_url()
list_method_template = (
"%(root_url)s/%(script_id)s?mode=search"
"{&query,select_list*,limit*,group_by*,sort_on*,"
"local_roles*,selection_domain*,list_method*,relative_url*}") % {"root_url": root_url, "script_id": script_id}
return [
("group_by", perfomance_mapping.get(group_by, None) or group_by),
("list_method_template", list_method_template),
("list_method", list_method),
("relative_url", relative_url),
("query_by", default_param_dict),
("title", listbox.get_value("title")),
("layout", {
"x": {
"title": group_by_title,
"key": group_by,
"domain_id": domain_id,
"column_list": label_list,
"domain_list": domain_list
},
"y": {
"title": "Quantity"
}
})
]
<?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>listbox</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_extractGadgetDataDictFromListbox</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
now = DateTime()
domain_mapping_dict = {
'< 2': {
"range": "min",
"query": (now - 2).earliestTime()
},
'2 - 7': {
"range": "minmax",
"query": ((now - 7).earliestTime(), (now - 2).latestTime())
},
'7 - 30': {
"range": "minmax",
"query": ((now - 30).earliestTime(), (now - 7).latestTime())
},
'> 30': {
"range": "max",
"query": ((now - 30).earliestTime())
}
}
generateDomain = context.Base_generateDomain
return [
generateDomain(parent, 'delivery_start_date_lt2', '< 2', 'delivery.start_date', domain_mapping_dict["< 2"]),
generateDomain(parent, 'delivery_start_date_2to7', '2 - 7', 'delivery.start_date', domain_mapping_dict["2 - 7"]),
generateDomain(parent, 'delivery_start_date_7to30', '7 - 30', 'delivery.start_date', domain_mapping_dict["7 - 30"]),
generateDomain(parent, 'delivery_start_date_gt30', '> 30', 'delivery.start_date', domain_mapping_dict["> 30"]),
]
<?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>depth, parent, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_generateDeliveryStartDateDomain</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
# Fail if domain does not exists
domain = context.getPortalObject().portal_domains[domain_id]
id_list, title_list = [], []
for subdomain in domain.getDomainGeneratorList():
id_list.append(subdomain.id)
title_list.append(subdomain.title)
return title_list, id_list
<?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>domain_id</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_getSubdomainTitleAndIdList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
return context.get_value("field_domain_tree")
data_dict = {
# ("group_by", "simulation_state"),
# ("query_by", {"parent_uid": context.getUid()}),
"title": context.get_value("title"),
"layout": {
"x": {
# "title": translateString("Days"),
# "key": "getTranslatedSimulationStateTitle",
# "domain_id": domain_id,
# "column_list": column_list,
# "domain_list": domain_list
},
"y": {
# "title": translateString("Quantity")
}
}
}
if context.get_value("field_domain_tree"):
domain_id = context.get_value("field_domain_root_list")[0][0]
column_list, domain_list = context.Base_getSubdomainTitleAndIdList(domain_id)
data_dict["layout"]["x"]["column_list"] = column_list
data_dict["layout"]["x"]["domain_list"] = domain_list
return data_dict.items()
<?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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Listbox_getGraphicGadgetDataList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,6 +2,8 @@ web_section = context
# Add all ERP5JS gadget
url_list = [
'echarts-all.js',
'favicon.ico',
'font-awesome/font-awesome-webfont.eot',
'font-awesome/font-awesome-webfont.woff',
'font-awesome/font-awesome-webfont.woff2',
......@@ -135,9 +137,13 @@ url_list = [
'gadget_erp5_search_editor.js',
'gadget_erp5_searchfield.html',
'gadget_erp5_searchfield.js',
'gadget_erp5_searchfield.css',
'gadget_erp5_sort_editor.html',
'gadget_erp5_sort_editor.js',
'gadget_global.js',
'gadget_graphic.html',
'gadget_graphic.js',
'gadget_graphic.css',
'gadget_html5_element.html',
'gadget_html5_element.js',
'gadget_html5_input.html',
......@@ -164,6 +170,8 @@ url_list = [
'jiodev.js',
'renderjs.js',
'rsvp.js',
'unsafe/gadget_field_graph_echarts.html',
'unsafe/gadget_field_graph_echarts.js'
]
# Add all root gadgets
......
......@@ -1406,19 +1406,6 @@ div[data-gadget-scope='header'] .ui-header {
}
}
// Increase the size of the editors when placed
// in the bottom group
.bottom {
iframe {
height: 80vh;
}
div[data-gadget-url$="gadget_erp5_field_listbox.html"] {
iframe {
height: 30vh;
}
}
}
/*
@media @smartphone {
.ui-field-contain {
......
......@@ -7,6 +7,7 @@ portal_contribution_registry/web_script_mimetype
portal_contribution_registry/web_style_by_content
portal_contribution_registry/web_style_extension
portal_contribution_registry/web_style_mimetype
portal_domains/graphic_gadget_delivery_start_date_domain
web_page_module/rjs_*
web_site_module/renderjs_runner
web_site_module/renderjs_runner/**
\ No newline at end of file
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="ActionInformation" module="Products.CMFCore.ActionInformation"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>action_type/object_jio_report</string>
</tuple>
</value>
</item>
<item>
<key> <string>category</string> </key>
<value> <string>object_jio_report</string> </value>
</item>
<item>
<key> <string>condition</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>icon</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>test_graphic_gadget_report</string> </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>priority</string> </key>
<value> <float>15.0</float> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Test Graphic Gadget Report</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}/EventModule_viewExamplesOfGraphicGadgetReport</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
now = DateTime()
domain_mapping_dict = {
'< 2': {
"range": "min",
"query": (now - 2).earliestTime()
},
'2 - 7': {
"range": "minmax",
"query": ((now - 7).earliestTime(), (now - 2).latestTime())
},
'7 - 30': {
"range": "minmax",
"query": ((now - 30).earliestTime(), (now - 7).latestTime())
},
'> 30': {
"range": "max",
"query": ((now - 30).earliestTime())
}
}
generateDomain = context.Base_generateDomain
return [
generateDomain(parent, 'creation_date_lt2', '< 2', 'creation_date', domain_mapping_dict["< 2"]),
generateDomain(parent, 'creation_date_2to7', '2 - 7', 'creation_date', domain_mapping_dict["2 - 7"]),
generateDomain(parent, 'creation_date_7to30', '7 - 30', 'creation_date', domain_mapping_dict["7 - 30"]),
generateDomain(parent, 'creation_date_gt30', '> 30', 'creation_date', domain_mapping_dict["> 30"]),
]
<?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>depth, parent, **kw</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_generateCreationDateDomain</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
now = DateTime()
domain_mapping_dict = {
'< 2': {
"range": "min",
"query": (now - 2).earliestTime()
},
'2 - 7': {
"range": "minmax",
"query": ((now - 7).earliestTime(), (now - 2).latestTime())
},
'7 - 30': {
"range": "minmax",
"query": ((now - 30).earliestTime(), (now - 7).latestTime())
},
'> 30': {
"range": "max",
"query": ((now - 30).earliestTime())
}
}
generateDomain = context.Base_generateDomain
return [
generateDomain(parent, 'modification_date_lt2', '< 2', 'modification_date', domain_mapping_dict["< 2"]),
generateDomain(parent, 'modification_date_2to7', '2 - 7', 'modification_date', domain_mapping_dict["2 - 7"]),
generateDomain(parent, 'modification_date_7to30', '7 - 30', 'modification_date', domain_mapping_dict["7 - 30"]),
generateDomain(parent, 'modification_date_gt30', '> 30', 'modification_date', domain_mapping_dict["> 30"]),
]
translateString = context.Base_translateString
return [
("group_by", ["portal_type",]),
("query_by", {"portal_type": context.getPortalDocumentTypeList()}),
("title", translateString("Number of Documents")),
("layout", {
"x": {
"title": translateString("Portal Type"),
"key": "getTranslatedPortalType"
},
"y": {
"title": translateString("Quantity")
}
})
]
Event Module | test_graphic_gadget_report
Foo | view_complex_time_serie_graph
Foo | view_dialog_without_action
Foo | view_field_submit_action_dialog
......
portal_domains/graphic_gadget_creation_date_domain
portal_domains/graphic_gadget_modification_date_domain
portal_tests/renderjs_ui_check_box_field_zuite
portal_tests/renderjs_ui_check_box_field_zuite/**
portal_tests/renderjs_ui_date_time_field_zuite
......
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