Commit e7ab51ab authored by Romain Courteaud's avatar Romain Courteaud

erp5_web_renderjs_ui: stop using handlebars

Replace it by domsugar.

This speed up gadget class generation (handlebars template parsing is
slow).
parent d38eae60
<!DOCTYPE html>
<html>
<head>
<!--
data-i18n=Submit
data-i18n=Configure Editor
data-i18n=Close
data-i18n=Add Criteria
data-i18n=Reset
-->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>ERP5 Configure Editor</title>
......@@ -9,52 +16,11 @@
<!-- renderjs -->
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="domsugar.js"></script>
<!-- custom script -->
<script src="gadget_erp5_configure_editor.js"></script>
<script id="column-item-template" type="text/x-handlebars-template">
<button type="button" class="ui-icon ui-icon-minus"></button>
<div class="column_item ui-controlgroup-controls" >
<select>
{{#each option}}
{{#equal value selected_option}}
<option selected="selected" data-i18n="{{text}}" value="{{value}}">{{text}}</option>
{{else}}
<option value="{{value}}" data-i18n="{{text}}">{{text}}</option>
{{/equal}}
{{/each}}
</select>
</div>
</script>
<script id="column-template" type="text/x-handlebars-template">
<div>
<div data-role="header" class="ui-header">
<div class="ui-btn-right">
<div class="ui-controlgroup-controls">
<button data-i18n="Submit" type="submit" class="submit ui-btn-icon-left ui-icon-check">Submit</button>
</div>
</div>
<h1 data-i18n="Configure Editor">Configure Editor</h1>
<div class="ui-btn-left">
<div class="ui-controlgroup-controls">
<button data-i18n="Close" type="button" class="close ui-btn-icon-left ui-icon-times">Close</button>
</div>
</div>
</div>
<section>
<div class="column_item_container"></div>
<button type="button" class="plus ui-icon-plus ui-btn-icon-left">Add Criteria</button>
<button type="button" class="trash ui-icon-trash-o ui-btn-icon-left">Reset</button>
</section>
</div>
</script>
</head>
<body>
<form>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.21395.34848.29713</string> </value>
<value> <string>981.53556.56234.45482</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1537197441.02</float>
<float>1581604573.58</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*jslint indent: 2, maxerr: 3, nomen: true */
/*global window, document, rJS, RSVP, Handlebars*/
(function (window, document, rJS, RSVP, Handlebars) {
/*global window, rJS, domsugar*/
(function (window, rJS, domsugar) {
"use strict";
var gadget_klass = rJS(window),
template_element = gadget_klass.__template_element,
column_item_template = Handlebars.compile(template_element
.getElementById("column-item-template")
.innerHTML),
column_template = Handlebars.compile(template_element
.getElementById("column-template")
.innerHTML);
Handlebars.registerHelper('equal', function (left_value, right_value, options) {
if (arguments.length < 3) {
throw new Error("Handlebars Helper equal needs 2 parameters");
}
if (left_value !== right_value) {
return options.inverse(this);
}
return options.fn(this);
});
function createColumnItemTemplate(gadget, column_value, displayable_column_list) {
function createColumnItemTemplate(column_value, displayable_column_list) {
var column_value_list = column_value || [],
option_list = [],
dom_option_list = [],
option_dict,
i;
for (i = 0; i < displayable_column_list.length; i += 1) {
option_list.push({
text: displayable_column_list[i][1],
option_dict = {
value: displayable_column_list[i][0],
selected_option: column_value_list[0]
});
// Used to be translated
text: displayable_column_list[i][1]
};
if (column_value_list[0] === option_dict.value) {
option_dict.selected = "selected";
}
dom_option_list.push(domsugar('option', option_dict));
}
return gadget.translateHtml(column_item_template({
option: option_list
}));
return domsugar('div', [
domsugar('button', {class: 'ui-icon ui-icon-minus'}),
domsugar('div', {class: 'column_item ui-controlgroup-controls'}, [
domsugar('select', dom_option_list)
])
]);
}
gadget_klass
rJS(window)
//////////////////////////////////////////////
// acquired method
//////////////////////////////////////////////
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("trigger", "trigger")
.onStateChange(function onStateChange() {
var gadget = this,
div = document.createElement("div"),
container = gadget.element.querySelector(".container");
return gadget.translateHtml(column_template())
.push(function (translated_html) {
div.innerHTML = translated_html;
var gadget = this;
return gadget.getTranslationList([
'Submit',
'Configure Editor',
'Close',
'Add Criteria',
'Reset'
])
.push(function (translation_list) {
var column_dom_list =
gadget.state.column_list.map(
function (column_item) {
return createColumnItemTemplate(
column_item,
gadget.state.displayable_column_list
);
}
);
return RSVP.all(gadget.state.column_list
.map(function (column_item) {
return createColumnItemTemplate(gadget, column_item, gadget.state.displayable_column_list);
domsugar(gadget.element.querySelector(".container"), [
domsugar('div', [
domsugar('div', {'data-role': 'header', 'class': 'ui-header'}, [
domsugar('div', {class: 'ui-btn-right'}, [
domsugar('div', {class: 'ui-controlgroup-controls'}, [
domsugar('button', {
type: 'submit',
class: 'submit ui-btn-icon-left ui-icon-check',
text: translation_list[0]
})
);
])
]),
domsugar('h1', {text: translation_list[1]}),
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[2]
})
])
])
]),
domsugar('section', [
domsugar('div', {class: 'column_item_container'},
column_dom_list),
domsugar('button', {
class: 'plus ui-icon-plus ui-btn-icon-left',
text: translation_list[3]
}),
domsugar('button', {
class: 'trash ui-icon-trash-o ui-btn-icon-left',
text: translation_list[4]
})
.push(function (result_list) {
var i,
subdiv,
filter_item_container = div.querySelector('.column_item_container');
for (i = 0; i < result_list.length; i += 1) {
subdiv = document.createElement("div");
subdiv.innerHTML = result_list[i];
filter_item_container.appendChild(subdiv);
}
while (container.firstChild) {
container.removeChild(container.firstChild);
}
container.appendChild(div);
])
])
]);
});
})
......@@ -92,15 +109,11 @@
})
.onEvent('click', function click(evt) {
var gadget = this,
container;
var gadget = this;
if (evt.target.classList.contains('trash')) {
evt.preventDefault();
container = gadget.element.querySelector(".column_item_container");
while (container.firstChild) {
container.removeChild(container.firstChild);
}
domsugar(gadget.element.querySelector(".column_item_container"));
}
if (evt.target.classList.contains('close')) {
......@@ -110,13 +123,11 @@
if (evt.target.classList.contains('plus')) {
evt.preventDefault();
return createColumnItemTemplate(gadget, undefined, gadget.state.displayable_column_list)
.push(function (template) {
var tmp = document.createElement("div");
container = gadget.element.querySelector(".column_item_container");
tmp.innerHTML = template;
container.appendChild(tmp);
});
return gadget.element.querySelector(".column_item_container")
.appendChild(
createColumnItemTemplate(undefined,
gadget.state.displayable_column_list)
);
}
if (evt.target.classList.contains('ui-icon-minus')) {
......@@ -156,4 +167,4 @@
}, true);
});
}(window, document, rJS, RSVP, Handlebars));
\ No newline at end of file
}(window, rJS, domsugar));
\ No newline at end of file
......@@ -148,11 +148,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.7721.48108.61320</string> </value>
<value> <string>981.53717.40963.53708</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1546525778.12</float>
<float>1581612829.76</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -312,7 +322,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,20 +9,9 @@
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="gadget_erp5_field_matrixbox.js" type="text/javascript"></script>
<script id="table-template" type="text/x-handlebars-template">
<thead>
<tr>
<th>{{table_title}}</th>
{{#each header}}
<th>{{this}}</th>
{{/each}}
</tr>
</thead>
</script>
</head>
<body>
<div class="document_table"></div>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.13790.51027.29644</string> </value>
<value> <string>981.53721.61856.48930</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1536846893.61</float>
<float>1581613303.08</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*jslint indent: 2, maxerr: 3, nomen: true */
/*global window, document, rJS, RSVP, Handlebars, JSON*/
/*global window, document, rJS, RSVP, domsugar, JSON*/
/** MatrixBox renders a N-dimensional cube of editable values based on axes description.
*
* Example JSON returned from HATEOAS where cell_range format is
......@@ -33,15 +33,9 @@
see around https://lab.nexedi.com/nexedi/erp5/blob/feature/renderjs-matrixbox/product/ERP5Form/MatrixBox.py#L427
*
*/
(function (window, document, rJS, RSVP, Handlebars, JSON) {
(function (window, document, rJS, RSVP, domsugar, JSON) {
"use strict";
var gadget_klass = rJS(window),
table_template_source = gadget_klass.__template_element
.getElementById("table-template")
.innerHTML,
table_template = Handlebars.compile(table_template_source);
/** Recursively introspect an object if it is empty */
function is_empty_recursive(data) {
var item;
......@@ -77,23 +71,11 @@
key: ''
})
//////////////////////////////////////////////
// acquired method
//////////////////////////////////////////////
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getFieldTypeGadgetUrl", "getFieldTypeGadgetUrl")
.declareAcquiredMethod("renderEditorPanel", "renderEditorPanel")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("translate", "translate")
/** Render constructs and saves gadgets into `props.gadget_dict` if they don not exist yet.
*/
.declareMethod('render', function (options) {
var gadget = this,
element = gadget.element.querySelector('div.document_table'),
data = options.field_json.data,
// note we make COPY of data in their original form - important since
// data.shift used later modify the structure inplace!
......@@ -117,11 +99,7 @@
.push(function () {
return RSVP.all(data.map(function (table, table_index) {
var header = table.shift(), // first item of table is the header
table_title = header.shift(), // first item of header is the table (tab) title
table_body = document.createElement('tbody'),
table_element = document.createElement('table');
table_element.innerHTML = table_template({table_title: table_title, header: header});
table_title = header.shift(); // first item of header is the table (tab) title
return new RSVP.Queue()
.push(function () {
......@@ -158,18 +136,25 @@
}));
})
.push(function (row_element_list) {
row_element_list.forEach(function (row_element) {
table_body.appendChild(row_element);
});
table_element.appendChild(table_body);
return table_element;
var th_dom_list = [
domsugar('th', {text: table_title})
],
i;
for (i = 0; i < header.length; i += 1) {
th_dom_list.push(domsugar('th', {html: header[i]}));
}
return domsugar('table', [
domsugar('thead', [
domsugar('tr', th_dom_list)
]),
domsugar('tbody', row_element_list)
]);
});
}));
})
.push(function (table_element_list) {
table_element_list.forEach(function (table_element) {
element.appendChild(table_element);
});
domsugar(gadget.element.querySelector('div.document_table'),
table_element_list);
return gadget.changeState(new_state);
});
})
......@@ -270,4 +255,4 @@
return true;
});
}(window, document, rJS, RSVP, Handlebars, JSON));
}(window, document, rJS, RSVP, domsugar, JSON));
......@@ -154,11 +154,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -202,16 +204,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -234,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.7721.48108.61320</string> </value>
<value> <string>981.53736.24127.53674</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1542884421.69</float>
<float>1581614139.33</float>
<string>UTC</string>
</tuple>
</state>
......@@ -261,16 +267,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -318,7 +328,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,16 +9,7 @@
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script id="success-button-template" type="text/x-handlebars-template">
<button type="submit" class='success'>{{message}}</button>
</script>
<script id="error-button-template" type="text/x-handlebars-template">
<button type="submit" class='error'>{{message}}</button>
</script>
<script src="domsugar.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_notification.js" type="text/javascript"></script>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>968.5552.51560.44322</string> </value>
<value> <string>981.54768.64025.46796</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1534512344.93</float>
<float>1581675956.38</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, Node, rJS, Handlebars */
(function (window, Node, rJS, Handlebars) {
/*global window, Node, rJS, domsugar */
(function (window, Node, rJS, domsugar) {
"use strict";
var gadget_klass = rJS(window),
success_button_source = gadget_klass.__template_element
.getElementById("success-button-template")
.innerHTML,
success_button_template = Handlebars.compile(success_button_source),
error_button_source = gadget_klass.__template_element
.getElementById("error-button-template")
.innerHTML,
error_button_template = Handlebars.compile(error_button_source);
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
gadget_klass
rJS(window)
.declareMethod('notify', function (options) {
if (options && options.message) {
return this.changeState({
......@@ -51,15 +40,13 @@
}
if (modification_dict.hasOwnProperty('message')) {
if (this.state.status === 'success') {
this.element.innerHTML = success_button_template({
message: this.state.message
});
} else {
this.element.innerHTML = error_button_template({
message: this.state.message
});
}
domsugar(this.element, [
domsugar('button', {
type: 'submit',
class: (this.state.status === 'success') ? 'success' : 'error',
text: this.state.message
})
]);
}
})
......@@ -71,4 +58,4 @@
}
}, false, false);
}(window, Node, rJS, Handlebars));
\ No newline at end of file
}(window, Node, rJS, domsugar));
\ No newline at end of file
......@@ -148,11 +148,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.4168.39270.46967</string> </value>
<value> <string>981.54772.35549.45209</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1514542276.66</float>
<float>1581676122.48</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -312,7 +322,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -16,7 +16,7 @@
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
......@@ -24,20 +24,6 @@
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_action.js" type="text/javascript"></script>
<script id="table-template" type="text/x-handlebars-template">
<section class="ui-content-header-plain">
<h3 data-i18n="[last]{{definition_i18n}}">
<span class="ui-icon ui-icon-{{definition_icon}}">&nbsp;</span>
{{definition_title}}
</h3>
</section>
<ul class="document-listview">
{{#each document_list}}
<li><a data-i18n="{{title}}" href="{{link}}">{{title}}</a></li>
{{/each}}
</ul>
</script>
</head>
<body>
</body>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.21289.29439.33894</string> </value>
<value> <string>981.54796.12366.61201</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1537191116.17</float>
<float>1581689062.62</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, rJS, RSVP, Handlebars, calculatePageTitle, ensureArray */
/*global window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars, calculatePageTitle, ensureArray) {
(function (window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
table_template = Handlebars.compile(gadget_klass.__template_element
.getElementById("table-template")
.innerHTML);
/** Render translated HTML of title + links
*
* @param {string} title - H3 title of the section with the links
* @param {string} icon - alias used in font-awesome iconset
* @param {Array} command_list - array of links obtained from ERP5 HATEOAS
*/
function renderLinkList(gadget, jio_key, title, icon, erp5_link_list,
editable) {
return new RSVP.Queue()
.push(function () {
return RSVP.all(
erp5_link_list.map(function (erp5_link) {
return gadget.getUrlFor({
"command": 'display_with_history_and_cancel',
"options": {
"jio_key": jio_key,
"view": erp5_link.href,
"editable": editable
}
});
})
);
})
.push(function (url_list) {
// prepare links for template (replace @href for RJS link)
return gadget.translateHtml(
table_template({
"definition_i18n": title,
"definition_title": title,
"definition_icon": icon,
"document_list": erp5_link_list.map(function (erp5_link, index) {
return {
"title": erp5_link.title,
"i18n": erp5_link.title,
"link": url_list[index]
};
})
})
);
});
function generateSection(title, icon, view_list) {
var i,
dom_list = [];
for (i = 0; i < view_list.length; i += 1) {
dom_list.push(domsugar('li', [domsugar('a', {
href: view_list[i].link,
text: view_list[i].title
})]));
}
return domsugar(null, [
domsugar('section', {class: 'ui-content-header-plain'}, [
domsugar('h3', [
domsugar('span', {class: 'ui-icon ui-icon-' + icon, html: '&nbsp;'}),
title
])
]),
domsugar('ul', {class: 'document-listview'}, dom_list)
]);
}
gadget_klass
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
/** Render only transforms its arguments and passes them to mutex-protected onStateChange
options:
jio_key: {string} currently viewed document (e.g. foo/1)
page: {string} selected page (always "tab" for page_tab)
view: {string} always "view"
selection, history, selection_index
*/
.declareMethod("render", function (options) {
return this.changeState({
jio_key: options.jio_key,
editable: options.editable,
view: options.view
});
})
.onStateChange(function () {
var gadget = this,
erp5_document;
erp5_document,
group_list;
// Get the whole view as attachment because actions can change based on
// what view we are at. If no view available than fallback to "links".
return gadget.jio_getAttachment(options.jio_key, options.view || "links")
return gadget.jio_getAttachment(gadget.state.jio_key, gadget.state.view || "links")
.push(function (jio_attachment) {
var transition_list = ensureArray(jio_attachment._links.action_workflow),
action_list = ensureArray(jio_attachment._links.action_object_jio_action)
.concat(ensureArray(jio_attachment._links.action_object_jio_button))
.concat(ensureArray(jio_attachment._links.action_object_jio_fast_input)),
clone_list = ensureArray(jio_attachment._links.action_object_clone_action),
delete_list = ensureArray(jio_attachment._links.action_object_delete_action);
erp5_document = jio_attachment;
return RSVP.all([
renderLinkList(gadget, options.jio_key, "Workflows", "random", transition_list),
renderLinkList(gadget, options.jio_key, "Actions", "gear", action_list),
// Stay in editable mode after cloning, as user will probably edit the new document
renderLinkList(gadget, options.jio_key, "Clone", "clone", clone_list, true),
renderLinkList(gadget, options.jio_key, "Delete", "trash-o", delete_list)
]);
})
.push(function (translated_html_link_list) {
gadget.element.innerHTML = translated_html_link_list.join("\n");
return RSVP.all([
calculatePageTitle(gadget, erp5_document),
gadget.getUrlFor({command: 'cancel_dialog_with_history'})
]);
var i,
j,
url_for_kw_list = [];
group_list = [
// Action list, editable, icon
ensureArray(erp5_document._links.action_workflow), undefined, 'random',
ensureArray(erp5_document._links.action_object_jio_action)
.concat(ensureArray(erp5_document._links.action_object_jio_button))
.concat(ensureArray(erp5_document._links.action_object_jio_fast_input)), undefined, 'gear',
ensureArray(erp5_document._links.action_object_clone_action), true, 'clone',
ensureArray(erp5_document._links.action_object_delete_action), undefined, 'trash-o'];
for (i = 0; i < group_list.length; i += 3) {
for (j = 0; j < group_list[i].length; j += 1) {
url_for_kw_list.push({command: 'display_with_history_and_cancel', options: {
jio_key: gadget.state.jio_key,
view: group_list[i][j].href,
editable: group_list[i + 1]
}});
}
}
url_for_kw_list.push({command: 'cancel_dialog_with_history'});
return RSVP.hash({
url_list: gadget.getUrlForList(url_for_kw_list),
translation_list: gadget.getTranslationList(['Workflows', 'Actions', 'Clone', 'Delete']),
page_title: calculatePageTitle(gadget, erp5_document)
});
})
.push(function (result_list) {
.push(function (result_dict) {
var i,
j,
k = 0,
dom_list = [],
link_list;
for (i = 0; i < group_list.length; i += 3) {
link_list = [];
for (j = 0; j < group_list[i].length; j += 1) {
link_list.push({
title: group_list[i][j].title,
link: result_dict.url_list[k]
});
k += 1;
}
dom_list.push(
generateSection(result_dict.translation_list[i / 3], group_list[i + 2], link_list)
);
}
domsugar(gadget.element, dom_list);
return gadget.updateHeader({
page_title: result_list[0],
back_url: result_list[1]
back_url: result_dict.url_list[result_dict.url_list.length - 1],
page_title: result_dict.page_title
});
});
})
......@@ -111,4 +133,4 @@
return;
});
}(window, rJS, RSVP, Handlebars, calculatePageTitle, ensureArray));
\ No newline at end of file
}(window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray));
......@@ -148,11 +148,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>975.28835.21901.16230</string> </value>
<value> <string>981.55016.12244.41318</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1556786223.13</float>
<float>1582128763.98</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -312,7 +322,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,18 +2,20 @@
<html>
<head>
<!--
data-i18n=Report
data-i18n=Export
data-i18n=Reports
data-i18n=Print
-->
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<title>ERP5 Page Action</title>
<title>ERP5 Page Export</title>
<link rel="http://www.renderjs.org/rel/interface" href="interface_page.html">
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
......@@ -21,20 +23,6 @@
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_export.js" type="text/javascript"></script>
<script id="table-template" type="text/x-handlebars-template">
<section class="ui-content-header-plain">
<h3 data-i18n="[last]{{definition_i18n}}">
<span class="ui-icon ui-icon-{{definition_icon}}">&nbsp;</span>
{{definition_title}}
</h3>
</section>
<ul class="document-listview">
{{#each document_list}}
<li><a data-i18n="{{title}}" href="{{link}}">{{title}}</a></li>
{{/each}}
</ul>
</script>
</head>
<body>
</body>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.15569.54382.31129</string> </value>
<value> <string>981.55042.52804.8379</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1537191386.12</float>
<float>1581692371.52</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, rJS, RSVP, Handlebars, calculatePageTitle, ensureArray */
/*global window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars, calculatePageTitle, ensureArray) {
(function (window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
table_template = Handlebars.compile(gadget_klass.__template_element
.getElementById("table-template")
.innerHTML);
/** Render translated HTML of title + links
*
* @param {string} title - H3 title of the section with the links
* @param {string} icon - alias used in font-awesome iconset
* @param {Array} command_list - array of links obtained from ERP5 HATEOAS
*/
function renderLinkList(gadget, jio_key, title, icon, erp5_link_list) {
return new RSVP.Queue()
.push(function () {
// obtain RJS links from ERP5 links
return RSVP.all(
erp5_link_list.map(function (erp5_link) {
return gadget.getUrlFor({
"command": 'display_with_history_and_cancel',
"options": {
"jio_key": jio_key,
"view": erp5_link.href
function generateSection(title, icon, view_list) {
var i,
dom_list = [];
for (i = 0; i < view_list.length; i += 1) {
dom_list.push(domsugar('li', [domsugar('a', {
href: view_list[i].link,
text: view_list[i].title
})]));
}
});
})
);
})
.push(function (url_list) {
// prepare links for template (replace @href for RJS link)
return gadget.translateHtml(
table_template({
"definition_i18n": title,
"definition_title": title,
"definition_icon": icon,
"document_list": erp5_link_list.map(function (erp5_link, index) {
return {
"title": erp5_link.title,
"i18n": erp5_link.title,
"link": url_list[index]
};
})
})
);
});
return domsugar(null, [
domsugar('section', {class: 'ui-content-header-plain'}, [
domsugar('h3', [
domsugar('span', {class: 'ui-icon ui-icon-' + icon, html: '&nbsp;'}),
title
])
]),
domsugar('ul', {class: 'document-listview'}, dom_list)
]);
}
gadget_klass
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("updateHeader", "updateHeader")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
/** Render only transforms its arguments and passes them to mutex-protected onStateChange
options:
jio_key: {string} currently viewed document (e.g. foo/1)
page: {string} selected page (always "tab" for page_tab)
view: {string} always "view"
selection, history, selection_index
*/
.declareMethod("render", function (options) {
return this.changeState({
jio_key: options.jio_key,
editable: options.editable,
view: options.view
});
})
.onStateChange(function () {
var gadget = this,
erp5_document;
erp5_document,
group_list;
// Get the whole view as attachment because actions can change based on
// what view we are at. If no view available than fallback to "links".
return gadget.jio_getAttachment(options.jio_key, options.view || "links")
.push(function (result) {
var export_list = ensureArray(result._links.action_object_jio_exchange),
report_list = ensureArray(result._links.action_object_jio_report),
print_list = ensureArray(result._links.action_object_jio_print);
erp5_document = result;
return RSVP.all([
renderLinkList(gadget, options.jio_key, "Export", "exchange", export_list),
renderLinkList(gadget, options.jio_key, "Reports", "bar-chart-o", report_list),
renderLinkList(gadget, options.jio_key, "Print", "print", print_list)
]);
})
.push(function (translated_html_link_list) {
gadget.element.innerHTML = translated_html_link_list.join("\n");
return RSVP.all([
calculatePageTitle(gadget, erp5_document),
gadget.getUrlFor({command: 'cancel_dialog_with_history', options: {jio_key: options.jio_key}})
]);
return gadget.jio_getAttachment(gadget.state.jio_key, gadget.state.view || "links")
.push(function (jio_attachment) {
erp5_document = jio_attachment;
var i,
j,
url_for_kw_list = [];
group_list = [
// Action list, icon
ensureArray(erp5_document._links.action_object_jio_exchange), "exchange",
ensureArray(erp5_document._links.action_object_jio_report), "bar-chart-o",
ensureArray(erp5_document._links.action_object_jio_print), "print"
];
for (i = 0; i < group_list.length; i += 2) {
for (j = 0; j < group_list[i].length; j += 1) {
url_for_kw_list.push({command: 'display_with_history_and_cancel', options: {
jio_key: gadget.state.jio_key,
view: group_list[i][j].href
}});
}
}
url_for_kw_list.push({command: 'cancel_dialog_with_history'});
return RSVP.hash({
url_list: gadget.getUrlForList(url_for_kw_list),
translation_list: gadget.getTranslationList(['Export', 'Reports', 'Print']),
page_title: calculatePageTitle(gadget, erp5_document)
});
})
.push(function (result_list) {
.push(function (result_dict) {
var i,
j,
k = 0,
dom_list = [],
link_list;
for (i = 0; i < group_list.length; i += 2) {
link_list = [];
for (j = 0; j < group_list[i].length; j += 1) {
link_list.push({
title: group_list[i][j].title,
link: result_dict.url_list[k]
});
k += 1;
}
dom_list.push(
generateSection(result_dict.translation_list[i / 2], group_list[i + 1], link_list)
);
}
domsugar(gadget.element, dom_list);
return gadget.updateHeader({
page_title: result_list[0],
back_url: result_list[1]
back_url: result_dict.url_list[result_dict.url_list.length - 1],
page_title: result_dict.page_title
});
});
})
......@@ -104,4 +130,4 @@
return;
});
}(window, rJS, RSVP, Handlebars, calculatePageTitle, ensureArray));
\ No newline at end of file
}(window, rJS, RSVP, domsugar, calculatePageTitle, ensureArray));
\ No newline at end of file
......@@ -148,11 +148,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>973.127.62172.31061</string> </value>
<value> <string>981.55050.1239.46711</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1547544973.33</float>
<float>1582128655.44</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -312,7 +322,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -9,22 +9,13 @@
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_history.js" type="text/javascript"></script>
<!-- XXX must set theme here! -->
<script id="table-template" type="text/x-handlebars-template">
<ul class="document-listview">
{{#each document_list}}
<li><a href="{{link}}">{{title}}</a></li>
{{/each}}
</ul>
</script>
</head>
<body>
<section class="document_list"></section>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.13790.51027.29644</string> </value>
<value> <string>981.54776.41647.28330</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1537198177.62</float>
<float>1581676366.05</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, rJS, RSVP, Handlebars, SimpleQuery, ComplexQuery, Query */
/*global window, rJS, RSVP, domsugar, SimpleQuery, ComplexQuery, Query */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars, SimpleQuery, ComplexQuery, Query) {
(function (window, rJS, RSVP, domsugar, SimpleQuery, ComplexQuery, Query) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
source = gadget_klass.__template_element
.getElementById("table-template")
.innerHTML,
table_template = Handlebars.compile(source);
gadget_klass
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
......@@ -74,25 +64,29 @@
})
.push(function (url_list) {
var i,
document_list = [],
dom_list = [],
document_dict = {};
for (i = 2; i < url_list.length; i += 1) {
document_dict[row_list[i - 2].id] = {
link: url_list[i],
title: (row_list[i - 2].value.title || row_list[i - 2].id) +
href: url_list[i],
text: (row_list[i - 2].value.title || row_list[i - 2].id) +
" (" + row_list[i - 2].value.translated_portal_type + ")"
};
}
// Sort by access time
for (i = 0; i < id_list.length; i += 1) {
if (document_dict.hasOwnProperty(id_list[i])) {
document_list.push(document_dict[id_list[i]]);
dom_list.push(domsugar('li', [
domsugar('a', document_dict[id_list[i]])
]));
}
}
gadget.element.querySelector('.document_list').innerHTML = table_template(
{document_list: document_list}
);
domsugar(gadget.element.querySelector('.document_list'), [
domsugar('ul', {class: 'document-listview'}, dom_list)
]);
return gadget.updateHeader({
page_title: 'History',
page_icon: 'history',
......@@ -104,4 +98,4 @@
.declareMethod("triggerSubmit", function () {
return;
});
}(window, rJS, RSVP, Handlebars, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file
}(window, rJS, RSVP, domsugar, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file
......@@ -148,11 +148,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>968.45482.36373.28842</string> </value>
<value> <string>981.54787.16313.36608</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1536227205.49</float>
<float>1581677007.38</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -312,7 +322,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -13,29 +13,13 @@
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_worklist.js" type="text/javascript"></script>
<!-- XXX must set theme here! -->
<script id="table-template" type="text/x-handlebars-template">
{{#if document_list }}
<ul class="document-listview">
{{#each document_list}}
<li class="ui-li-has-count"><a href="{{link}}">{{title}} <span class="ui-li-count">{{count}}</span></a></li>
{{/each}}
</ul>
{{else}}
<div class="worklist-empty">
<h2>{{empty_text}}</h2>
<img src="gadget_erp5_worklist_empty.svg?format=svg">
</div>
{{/if}}
</script>
</head>
<body>
<section class="document_list"></section>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.13790.51027.29644</string> </value>
<value> <string>981.54680.42979.46762</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1537197958.47</float>
<float>1581671172.67</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, rJS, RSVP, Handlebars, URI */
/*global window, rJS, RSVP, domsugar, URI */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars, URI) {
(function (window, rJS, RSVP, domsugar, URI) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
source = gadget_klass.__template_element
.getElementById("table-template")
.innerHTML,
table_template = Handlebars.compile(source);
gadget_klass
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
......@@ -85,23 +75,34 @@
})
// Add in the page
.push(function (result_list) {
var line_list = [],
url_list = result_list[1],
i;
var url_list = result_list[1],
i,
dom_list = [];
for (i = 2; i < url_list.length; i += 1) {
line_list.push({
link: url_list[i],
// Remove the counter from the title
title: action_list[i - 2].name,
count: action_list[i - 2].count
});
dom_list.push(domsugar('li', {class: 'ui-li-has-count'}, [
domsugar('a', {href: url_list[i]}, [
action_list[i - 2].name,
' ',
domsugar('span', {class: 'ui-li-count',
text: action_list[i - 2].count})
])
]));
}
if (dom_list.length) {
domsugar(gadget.element.querySelector('.document_list'), [
domsugar('ul', {class: 'document-listview'}, dom_list)
]);
} else {
domsugar(gadget.element.querySelector('.document_list'), [
domsugar('div', {class: 'worklist-empty'}, [
domsugar('h2', {text: result_list[0]}),
domsugar('img', {src: 'gadget_erp5_worklist_empty.svg?format=svg'})
])
]);
}
gadget.element.querySelector('.document_list').innerHTML =
table_template({
document_list: line_list,
empty_text: result_list[0]
});
return gadget.updateHeader({
page_title: 'Worklist',
page_icon: 'tasks',
......@@ -114,4 +115,4 @@
return;
});
}(window, rJS, RSVP, Handlebars, URI));
\ No newline at end of file
}(window, rJS, RSVP, domsugar, URI));
\ No newline at end of file
......@@ -148,11 +148,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.13725.50121.7014</string> </value>
<value> <string>981.54689.51582.13431</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1559812175.93</float>
<float>1581671160.14</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -312,7 +322,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -11,7 +11,7 @@
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script id="dialog-button-template" type="text/x-handlebars-template">
{{#if show_update_button}}
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>976.23831.58029.7424</string> </value>
<value> <string>978.11125.30548.29832</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1560418147.64</float>
<float>1581694316.93</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, document, rJS, RSVP, calculatePageTitle, Handlebars,
/*global window, rJS, RSVP, calculatePageTitle, domsugar,
ensureArray */
(function (window, document, rJS, RSVP, calculatePageTitle, Handlebars,
(function (window, rJS, RSVP, calculatePageTitle, domsugar,
ensureArray) {
"use strict";
......@@ -86,7 +86,8 @@
(!result.view)) {
// don't update navigation history when not really redirecting
return gadget.redirect({command: 'cancel_dialog_with_history'});
} else if (gadget.state.jio_key === result.jio_key) {
}
if (gadget.state.jio_key === result.jio_key) {
command = 'display_with_history_and_cancel';
} else {
// Check if the redirection goes to a same parent's subdocument.
......@@ -133,13 +134,7 @@
return submitDialog.apply(this, [false, param_list[0]]);
}
var gadget_klass = rJS(window),
dialog_button_source = gadget_klass.__template_element
.getElementById("dialog-button-template")
.innerHTML,
dialog_button_template = Handlebars.compile(dialog_button_source);
gadget_klass
rJS(window)
.setState({
'redirect_to_parent': false, // set by a presence of special field
'has_update_action': undefined // default "submit" issue update in case of its presence
......@@ -152,8 +147,7 @@
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("translate", "translate")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("submitContent", "submitContent")
.allowPublicAcquisition("submitDialogWithCustomDialogMethod",
submitDialogWithCustomDialogMethod)
......@@ -238,31 +232,43 @@
// Set the dialog button
if (modification_dict.hasOwnProperty('has_update_action') ||
modification_dict.hasOwnProperty('update_action_title')) {
return form_gadget.translateHtml(dialog_button_template({
show_update_button: form_gadget.state.has_update_action
}))
.push(function (html) {
var div = document.createElement('div'),
dialog_button_container = form_gadget.element
.querySelector('.dialog_button_container');
div.innerHTML = html;
if (form_gadget.state.has_update_action && form_gadget.state.update_action_title) {
div.querySelector('button[name="action_update"]')
.textContent = form_gadget.state.form_definition
.update_action_title;
}
while (dialog_button_container.firstChild) {
dialog_button_container.firstChild.remove();
return form_gadget.getTranslationList(['Update', 'Proceed', 'Cancel'])
.push(function (translation_list) {
var dom_list = [];
if (form_gadget.state.has_update_action) {
dom_list.push(
domsugar('button', {disabled: true,
name: 'action_update',
type: 'button',
text: form_gadget.state.update_action_title || translation_list[0]}
)
);
}
dialog_button_container.innerHTML = div.innerHTML;
dom_list.push(
domsugar('input', {disabled: true,
name: 'action_confirm',
class: 'dialogconfirm',
type: 'submit',
value: translation_list[1]}),
domsugar('a', {class: 'dialogcancel',
text: translation_list[2]})
);
domsugar(form_gadget.element
.querySelector('.dialog_button_container'),
dom_list);
});
}
})
.push(function () {
// Calculate the h3 properties
return RSVP.all([
form_gadget.translate(form_gadget.state.form_definition.title),
form_gadget.translate(title)
return form_gadget.getTranslationList([
form_gadget.state.form_definition.title,
title
]);
})
.push(function (translated_title_list) {
......@@ -345,4 +351,4 @@
}
});
}(window, document, rJS, RSVP, calculatePageTitle, Handlebars, ensureArray));
\ No newline at end of file
}(window, rJS, RSVP, calculatePageTitle, domsugar, ensureArray));
\ No newline at end of file
......@@ -157,7 +157,7 @@
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>superkato</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -179,7 +179,7 @@
</tuple>
<state>
<tuple>
<float>1574441791.15</float>
<float>1523969253.3</float>
<string>UTC</string>
</tuple>
</state>
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.63649.12092.1536</string> </value>
<value> <string>981.55111.20815.20787</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1574441771.59</float>
<float>1581696457.29</float>
<string>UTC</string>
</tuple>
</state>
......@@ -260,144 +260,4 @@
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>superkato</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1523969253.3</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.63390.23192.15445</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1574416039.72</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
......@@ -16,18 +16,7 @@
<!-- custom script -->
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_global.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script id="card-list-template" type="text/x-handlebars-template">
{{#each card_list}}<li>
<h2>{{business_application_translated_title}}</h2>
<ul>
{{#each module_list}}
<li><a href="{{link}}">{{translated_title}}</a></li>
{{/each}}
</ul>
</li>{{/each}}
</script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="gadget_erp5_page_front.js" type="text/javascript"></script>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>968.5552.51560.44322</string> </value>
<value> <string>981.53539.4987.28928</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1534501263.97</float>
<float>1581602343.58</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, rJS, jIO, RSVP, Handlebars */
/*global window, rJS, jIO, RSVP, domsugar */
/*jslint nomen: true, indent: 2, maxerr: 3, maxlen: 80 */
(function (window, rJS, jIO, RSVP, Handlebars) {
(function (window, rJS, jIO, RSVP, domsugar) {
"use strict";
var gadget_klass = rJS(window),
card_list_template_source = gadget_klass.__template_element
.getElementById("card-list-template")
.innerHTML,
card_list_template = Handlebars.compile(card_list_template_source);
function generateCardList(element, card_list) {
var i,
len = card_list.length,
card,
dom_list = [],
sub_dom_list,
len2,
j;
gadget_klass
for (i = 0; i < len; i += 1) {
card = card_list[i];
len2 = card.module_list.length;
sub_dom_list = [];
for (j = 0; j < len2; j += 1) {
sub_dom_list.push(domsugar('li', [
domsugar('a', {
href: card.module_list[j].link,
text: card.module_list[j].translated_title
})
]));
}
dom_list.push(domsugar('li', [
domsugar('h2', {text: card.business_application_translated_title}),
domsugar('ul', sub_dom_list)
]));
}
domsugar(element, dom_list);
}
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
......@@ -121,9 +145,8 @@
module_list: other_module_list
});
}
gadget.element.querySelector('ul').innerHTML = card_list_template({
card_list: card_list
});
generateCardList(gadget.element.querySelector('ul'), card_list);
return gadget.updateHeader({
page_title: 'Modules',
......@@ -134,4 +157,4 @@
});
});
}(window, rJS, jIO, RSVP, Handlebars));
\ No newline at end of file
}(window, rJS, jIO, RSVP, domsugar));
\ No newline at end of file
......@@ -148,11 +148,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>968.45482.36373.28842</string> </value>
<value> <string>981.53549.48387.50790</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1536323881.35</float>
<float>1581602868.55</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -312,7 +322,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -14,11 +14,8 @@
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script id="dialog-button-template" type="text/x-handlebars-template">
<input name="action_update" type="submit" value="{{button_text}}"></input>
</script>
<script src="gadget_erp5_page_language.js" type="text/javascript"></script>
</head>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.21408.22711.6195</string> </value>
<value> <string>981.54790.20438.51626</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1537198115.39</float>
<float>1581677271.66</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, rJS, RSVP, Handlebars */
/*global window, rJS, RSVP, domsugar */
/*jslint nomen: true, indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars) {
(function (window, rJS, RSVP, domsugar) {
"use strict";
var gadget_klass = rJS(window),
dialog_button_source = gadget_klass.__template_element
.getElementById("dialog-button-template")
.innerHTML,
dialog_button_template = Handlebars.compile(dialog_button_source);
gadget_klass
rJS(window)
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("getSettingList", "getSettingList")
.declareAcquiredMethod("setSetting", "setSetting")
......@@ -71,10 +66,11 @@
}
}
gadget.element.querySelector('.dialog_button_container')
.innerHTML = dialog_button_template({
button_text: first_result_list[3][2]
});
domsugar(gadget.element.querySelector('.dialog_button_container'), [
domsugar('input', {name: 'action_update',
type: 'submit',
value: first_result_list[3][2]})
]);
return RSVP.all([
gadget.updateHeader({
......@@ -150,4 +146,4 @@
.declareMethod("triggerSubmit", function () {
return;
});
}(window, rJS, RSVP, Handlebars));
}(window, rJS, RSVP, domsugar));
......@@ -148,11 +148,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>968.45482.36373.28842</string> </value>
<value> <string>981.54793.39964.17766</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1536227225.62</float>
<float>1581677388.59</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -312,7 +322,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html>
<!--
data-i18n=Views
data-i18n=Jumps
data-i18n=Breadcrumb
-->
......@@ -14,27 +15,13 @@
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="handlebars.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_tab.js" type="text/javascript"></script>
<script id="table-template" type="text/x-handlebars-template">
<section class="ui-content-header-plain">
<h3 data-i18n="[last]{{definition_i18n}}">
<span class="ui-icon ui-icon-{{definition_icon}}">&nbsp;</span>
{{definition_title}}
</h3>
</section>
<ul class="document-listview">
{{#each documentlist}}
<li><a data-i18n="{{title}}" href="{{link}}">{{title}}</a></li>
{{/each}}
</ul>
</script>
</head>
<body>
</body>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.15563.53430.2082</string> </value>
<value> <string>981.54724.21456.20138</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1537191667.32</float>
<float>1581674141.88</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -316,7 +326,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*global window, rJS, RSVP, Handlebars, URI, calculatePageTitle, ensureArray */
/*global window, rJS, RSVP, domsugar, URI, calculatePageTitle, ensureArray */
/*jslint nomen: true, indent: 2, maxerr: 3 */
/** Page for displaying Views, Jump and BreadCrumb navigation for a document.
*/
(function (window, rJS, RSVP, Handlebars, URI, calculatePageTitle, ensureArray) {
(function (window, rJS, RSVP, domsugar, URI, calculatePageTitle, ensureArray) {
"use strict";
/////////////////////////////////////////////////////////////////
// Handlebars
/////////////////////////////////////////////////////////////////
// Precompile the templates while loading the first gadget instance
var gadget_klass = rJS(window),
table_template = Handlebars.compile(gadget_klass.__template_element
.getElementById("table-template")
.innerHTML);
/** Go recursively up the parent-chain and insert breadcrumbs in the last argument.
*/
function modifyBreadcrumbList(gadget, parent_link, breadcrumb_action_list) {
......@@ -48,13 +39,37 @@
});
}
gadget_klass
function generateSection(title, icon, view_list) {
var i,
dom_list = [];
for (i = 0; i < view_list.length; i += 1) {
dom_list.push(domsugar('li', [domsugar('a', {
href: view_list[i].link,
text: view_list[i].title
})]));
}
return domsugar(null, [
domsugar('section', {class: 'ui-content-header-plain'}, [
domsugar('h3', [
domsugar('span', {class: 'ui-icon ui-icon-' + icon, html: '&nbsp;'}),
title
])
]),
domsugar('ul', {class: 'document-listview'}, dom_list)
]);
}
rJS(window)
/////////////////////////////////////////////////////////////////
// Acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod("jio_getAttachment", "jio_getAttachment")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("updateHeader", "updateHeader")
/////////////////////////////////////////////////////////////////
......@@ -83,94 +98,77 @@
jump_action_list = [],
breadcrumb_action_list = [],
erp5_document,
tab_title = "Views",
tab_icon = "eye",
jump_list;
return gadget.jio_getAttachment(gadget.state.jio_key, "links")
.push(function (result) {
var i,
promise_list = [];
url_for_kw_list = [];
erp5_document = result;
view_list = ensureArray(erp5_document._links.view);
jump_list = ensureArray(erp5_document._links.action_object_jio_jump);
for (i = 0; i < view_list.length; i += 1) {
promise_list.push(gadget.getUrlFor({command: 'display_with_history', options: {
url_for_kw_list.push({command: 'display_with_history', options: {
jio_key: gadget.state.jio_key,
view: view_list[i].href,
page: undefined // Views in ERP5 must be forms but because of
// OfficeJS we keep it empty for different default
}}));
}});
}
for (i = 0; i < jump_list.length; i += 1) {
promise_list.push(gadget.getUrlFor({command: 'display_dialog_with_history', options: {
url_for_kw_list.push({command: 'display_dialog_with_history', options: {
jio_key: gadget.state.jio_key,
view: jump_list[i].href
}}));
}});
}
promise_list.push(
modifyBreadcrumbList(gadget,
url_for_kw_list.push({command: 'cancel_dialog_with_history'});
return RSVP.hash({
url_list: gadget.getUrlForList(url_for_kw_list),
_: modifyBreadcrumbList(gadget,
erp5_document._links.parent || "#",
breadcrumb_action_list)
);
return RSVP.all(promise_list);
breadcrumb_action_list),
translation_list: gadget.getTranslationList(['Views', 'Jumps', 'Breadcrumb']),
page_title: calculatePageTitle(gadget, erp5_document)
});
})
.push(function (all_result) {
var i, j;
.push(function (result_dict) {
var i,
j = 0;
for (i = 0; i < view_list.length; i += 1) {
tab_list.push({
title: view_list[i].title,
i18n: view_list[i].title,
link: all_result[j]
link: result_dict.url_list[j]
});
j += 1;
}
for (i = 0; i < jump_list.length; i += 1) {
jump_action_list.push({
title: jump_list[i].title,
link: all_result[j],
i18n: jump_list[i].title
link: result_dict.url_list[j]
});
j += 1;
}
return gadget.translateHtml(table_template({
definition_title: tab_title,
definition_i18n: tab_title,
definition_icon: tab_icon,
documentlist: tab_list
}) + table_template({
definition_title: "Jumps",
documentlist: jump_action_list,
definition_icon: "plane",
definition_i18n: "Jumps"
}) + table_template({
definition_title: "Breadcrumb",
documentlist: breadcrumb_action_list,
definition_icon: "ellipsis-v",
definition_i18n: "Breadcrumb"
}));
})
.push(function (my_translated_html) {
gadget.element.innerHTML = my_translated_html;
return RSVP.all([
gadget.getUrlFor({command: 'cancel_dialog_with_history'}),
calculatePageTitle(gadget, erp5_document)
domsugar(gadget.element, [
generateSection(result_dict.translation_list[0], 'eye', tab_list),
generateSection(result_dict.translation_list[1], 'plane', jump_action_list),
generateSection(result_dict.translation_list[2], 'ellipsis-v', breadcrumb_action_list)
]);
})
.push(function (url_list) {
var dict = {
back_url: url_list[0],
page_title: url_list[1]
};
return gadget.updateHeader(dict);
return gadget.updateHeader({
back_url: result_dict.url_list[j],
page_title: result_dict.page_title
});
});
})
.declareMethod("triggerSubmit", function () {
return;
});
}(window, rJS, RSVP, Handlebars, URI, calculatePageTitle, ensureArray));
\ No newline at end of file
}(window, rJS, RSVP, domsugar, URI, calculatePageTitle, ensureArray));
\ No newline at end of file
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>981.4557.25079.32187</string> </value>
<value> <string>981.62315.62619.21640</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1578663234.35</float>
<float>1582128721.85</float>
<string>UTC</string>
</tuple>
</state>
......
<!DOCTYPE html>
<html>
<!--
data-i18n=Submit
data-i18n=Filter Editor
data-i18n=Close
data-i18n=Add Criteria
data-i18n=Reset
data-i18n=All criterions (AND)
data-i18n=At least one (OR)
data-i18n=Contains
......@@ -22,80 +27,12 @@
<!-- renderjs -->
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="domsugar.js"></script>
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_erp5_search_editor.js"></script>
<script id="filter-item-template" type="text/x-handlebars-template">
<button class="ui-icon ui-icon-minus"></button>
<div class="filter_item" >
<select class="column">
{{#each option}}
<option {{#if selected}}selected="selected"{{/if}} data-i18n="{{text}}" value="{{value}}">{{text}}</option>
{{/each}}
</select>
<select>
{{#each operator_option}}
<option {{#if selected}}selected="selected"{{/if}} data-i18n="{{text}}" value="{{value}}">{{text}}</option>
{{/each}}
</select>
{{#if domain_option}}
<select required>
{{#each domain_option}}
<option {{#if selected}}selected="selected"{{/if}} data-i18n="{{text}}" {{#if value}}value="{{value}}"{{/if}}>{{text}}</option>
{{/each}}
</select>
{{else}}
{{#if input_list}}
{{#each input_list}}
<input type="{{type}}" value="{{value}}" {{required}}></input>
{{/each}}
{{else}}
<input type="{{input_type}}" value="{{input_value}}" required></input>
{{/if}}
{{/if}}
</div>
</script>
<script id="filter-template" type="text/x-handlebars-template">
<div>
<div data-role="header" class="ui-header">
<div class="ui-btn-right">
<div class="ui-controlgroup-controls">
<button data-i18n="submit" type="submit" class="ui-btn-icon-left ui-icon-check">Submit</button>
</div>
</div>
<h1 data-i18n="Filter Editor">Filter Editor</h1>
<div class="ui-btn-left">
<div class="ui-controlgroup-controls">
<button data-i18n="Close" class="close ui-btn-icon-left ui-icon-times">Close</button>
</div>
</div>
</div>
<section>
<fieldset>
<select name="heard_about">
<option data-i18n="All criterions (AND)" value="AND">All criterions (AND)</option>
<option data-i18n="At least one (OR)" value="OR">At least one (OR)</option>
</select>
</fieldset>
<div class="filter_item_container">
</div>
<button class="plus ui-icon-plus ui-btn-icon-left">Add Criteria</button>
<button type="button" class="trash ui-icon-trash-o ui-btn-icon-left">Reset</button>
<div class="domain_item_container">
</div>
</section>
</div>
</script>
</head>
<body>
<form>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.30474.16448.375</string> </value>
<value> <string>981.59263.63131.63590</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1550073322.86</float>
<float>1581947972.8</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -318,7 +328,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*jslint indent: 2, maxerr: 3, maxlen: 100, nomen: true */
/*global window, document, rJS, Handlebars,
/*global window, document, rJS, domsugar,
QueryFactory, SimpleQuery, ComplexQuery, Query*/
(function (window, document, rJS, Handlebars,
(function (window, document, rJS, domsugar,
QueryFactory, SimpleQuery, ComplexQuery, Query) {
"use strict";
var gadget_klass = rJS(window),
template_element = gadget_klass.__template_element,
filter_item_template = Handlebars.compile(template_element
.getElementById("filter-item-template")
.innerHTML),
filter_template = Handlebars.compile(template_element
.getElementById("filter-template")
.innerHTML),
NUMERIC = [
var NUMERIC = [
["Equal to", "="], ["Greater than", ">"],
["Less than", "<"], ["Less than or Equal to", "<="],
["Greater than or Equal to", ">="]
......@@ -135,7 +126,63 @@
return {key: key, operator: operator, value_list: value_list};
}
function createFilterItemTemplate(gadget, query_dict) {
function generateFilterItemTemplate(options) {
var column_option_list = options.option.map(function (option) {
return domsugar('option', {
selected: !!option.selected,
value: option.value,
text: option.text
});
}),
operator_option_list = options.operator_option.map(function (option) {
return domsugar('option', {
selected: !!option.selected,
value: option.value,
text: option.text
});
}),
div_dom_list = [
domsugar('select', {class: 'column'}, column_option_list),
domsugar('select', operator_option_list)
];
if (options.domain_option) {
div_dom_list.push(domsugar(
'select',
{required: true},
options.domain_option.map(function (option) {
return domsugar('option', {
selected: !!option.selected,
value: option.value || undefined,
text: option.text
});
})
));
} else if (options.input_list) {
div_dom_list.push.apply(div_dom_list, options.input_list.map(function (option) {
return domsugar('input', {
required: !!option.required,
value: option.value,
type: option.type
});
}));
} else {
div_dom_list.push(domsugar('input', {
type: options.input_type,
value: options.input_value,
required: true
}));
}
return domsugar('div', [
domsugar('button', {class: 'ui-icon ui-icon-minus'}),
domsugar('div', {class: 'filter_item'}, div_dom_list)
]);
}
function createFilterItemTemplate(gadget, query_dict, translation_dict, column_translation_dict) {
var operator_default_list = DEFAULT,
operator_option_list = [],
column_option_list = [],
......@@ -168,7 +215,8 @@
is_selected = is_selected ||
(query_detail_dict.key === gadget.state.search_column_list[i][0]);
column_option_list.push({
text: gadget.state.search_column_list[i][1],
text: column_translation_dict[gadget.state.search_column_list[i][1]] ||
gadget.state.search_column_list[i][1],
value: gadget.state.search_column_list[i][0],
selected: (query_detail_dict.key === gadget.state.search_column_list[i][0])
});
......@@ -181,7 +229,7 @@
is_selected = is_selected ||
("at_least_one_exact_match" === operator_default_list[i][1]);
operator_option_list.push({
text: operator_default_list[i][0],
text: translation_dict[operator_default_list[i][0]],
value: operator_default_list[i][1],
selected: ("at_least_one_exact_match" === operator_default_list[i][1])
});
......@@ -202,7 +250,7 @@
value: "",
required: ""
});
return filter_item_template({
return generateFilterItemTemplate({
option: column_option_list,
operator_option: operator_option_list,
input_list: input_list,
......@@ -247,7 +295,7 @@
for (i = 0; i < operator_default_list.length; i += 1) {
is_selected = is_selected || (query_dict.operator === operator_default_list[i][1]);
operator_option_list.push({
text: operator_default_list[i][0],
text: translation_dict[operator_default_list[i][0]],
value: operator_default_list[i][1],
selected: (query_dict.operator === operator_default_list[i][1])
});
......@@ -271,7 +319,7 @@
query_dict.operator = DEFAULT[0][1];
query_dict.key = PREFIX_RAW;
operator_option_list = [{
text: DEFAULT[0][0],
text: translation_dict[DEFAULT[0][0]],
value: DEFAULT[0][1],
selected: true
}];
......@@ -281,7 +329,8 @@
for (i = 0; i < gadget.state.search_column_list.length; i += 1) {
is_selected = is_selected || (query_dict.key === gadget.state.search_column_list[i][0]);
column_option_list.push({
text: gadget.state.search_column_list[i][1],
text: column_translation_dict[gadget.state.search_column_list[i][1]] ||
gadget.state.search_column_list[i][1],
value: gadget.state.search_column_list[i][0],
selected: (query_dict.key === gadget.state.search_column_list[i][0])
});
......@@ -290,7 +339,7 @@
throw new Error('SearchEditor: no key found for: ' + query_dict.key);
}
return filter_item_template({
return generateFilterItemTemplate({
option: column_option_list,
operator_option: operator_option_list,
input_value: query_dict.value,
......@@ -405,11 +454,11 @@
return index;
}
gadget_klass
rJS(window)
//////////////////////////////////////////////
// acquired method
//////////////////////////////////////////////
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("trigger", "trigger")
......@@ -455,6 +504,7 @@
options.domain_list[i][1]
]);
}
// Translated later
search_column_list.push([PREFIX_TEXT, "Searchable Text"]);
search_column_list.push([PREFIX_RAW, "Search Expression"]);
......@@ -585,6 +635,7 @@
return this.changeState({
search_column_list: search_column_list.concat(additional_search_column_list),
additional_search_column_list: additional_search_column_list,
begin_from_key: options.begin_from,
// [{key: 'title', value: 'Foo', operator: 'like'}]
query_list: query_list,
......@@ -597,13 +648,7 @@
})
.onStateChange(function onStateChange(modification_dict) {
var gadget = this,
container = gadget.element.querySelector(".container"),
div = document.createElement("div"),
subdiv,
operator_select,
filter_item_container,
i;
var gadget = this;
if (modification_dict.update_filter_dom !== undefined &&
Object.keys(modification_dict).length === 1) {
......@@ -611,30 +656,101 @@
return;
}
div.innerHTML = filter_template();
operator_select = div.querySelector("select");
if (gadget.state.operator === "OR") {
operator_select.querySelectorAll("option")[1].setAttribute('selected', 'selected');
}
filter_item_container = div.querySelector(".filter_item_container");
for (i = 0; i < gadget.state.query_list.length; i += 1) {
subdiv = document.createElement("div");
subdiv.innerHTML = createFilterItemTemplate(gadget, gadget.state.query_list[i]);
filter_item_container.appendChild(subdiv);
return gadget.getTranslationList([
'Submit',
'Filter Editor',
'Close',
'Add Criteria',
'Reset',
'All criterions (AND)',
'At least one (OR)',
'Contains',
'Equal to',
'Equal to (at least one)',
'Greater than',
'Less than',
'Less than or Equal to',
'Greater than or Equal to',
'Searchable Text',
'Search Expression'
])
.push(function (translation_list) {
var filter_dom_list =
gadget.state.query_list.map(
function (query) {
return createFilterItemTemplate(
gadget,
query,
{
'Contains': translation_list[7],
'Equal to': translation_list[8],
'Equal to (at least one)': translation_list[9],
'Greater than': translation_list[10],
'Less than': translation_list[11],
'Less than or Equal to': translation_list[12],
'Greater than or Equal to': translation_list[13]
},
{
'Searchable Text': translation_list[14],
'Search Expression': translation_list[15]
}
return gadget.translateHtml(div.innerHTML)
.push(function (translated_html) {
div.innerHTML = translated_html;
while (container.firstChild) {
container.removeChild(container.firstChild);
);
}
);
container.appendChild(div);
domsugar(gadget.element.querySelector(".container"), [
domsugar('div', [
domsugar('div', {'data-role': 'header', 'class': 'ui-header'}, [
domsugar('div', {class: 'ui-btn-right'}, [
domsugar('div', {class: 'ui-controlgroup-controls'}, [
domsugar('button', {
type: 'submit',
class: 'ui-btn-icon-left ui-icon-check',
text: translation_list[0]
})
])
]),
domsugar('h1', {text: translation_list[1]}),
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[2]
})
])
])
]),
domsugar('section', [
domsugar('fieldset', [
domsugar('select', {name: 'heard_about'}, [
domsugar('option', {
value: 'AND',
text: translation_list[5],
selected: (gadget.state.operator === "AND")
}),
domsugar('option', {
value: 'OR',
text: translation_list[6],
selected: (gadget.state.operator === "OR")
})
])
]),
domsugar('div', {class: 'filter_item_container'},
filter_dom_list),
domsugar('button', {
class: 'plus ui-icon-plus ui-btn-icon-left',
text: translation_list[3]
}),
domsugar('button', {
class: 'trash ui-icon-trash-o ui-btn-icon-left',
text: translation_list[4]
})
// domsugar('div', {class: 'domain_item_container'},
// domain_dom_list),
])
])
]);
return gadget.focusOnLastInput(gadget.state.focus_on);
});
})
......@@ -773,5 +889,5 @@
}
}, false, false);
}(window, document, rJS, Handlebars,
}(window, document, rJS, domsugar,
QueryFactory, SimpleQuery, ComplexQuery, Query));
\ No newline at end of file
......@@ -148,11 +148,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>974.50067.21616.14233</string> </value>
<value> <string>981.59395.36158.62156</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1554214739.75</float>
<float>1582023096.49</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -314,7 +324,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<!DOCTYPE html>
<html>
<head>
<!--
data-i18n=ascending
data-i18n=descending
data-i18n=Submit
data-i18n=Sort Editor
data-i18n=Close
data-i18n=Add Criteria
data-i18n=Reset
-->
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>ERP5 Sort Editor</title>
......@@ -9,54 +19,11 @@
<!-- renderjs -->
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="handlebars.js"></script>
<script src="domsugar.js"></script>
<!-- custom script -->
<script src="gadget_erp5_sort_editor.js"></script>
<script id="sort-item-template" type="text/x-handlebars-template">
<button type="submit" class="ui-icon ui-icon-minus"></button>
<div class="sort_item ui-controlgroup-controls" >
<select>
{{#each option}}
<option {{#if selected}}selected="selected"{{/if}} data-i18n="{{text}}" value="{{value}}">{{text}}</option>
{{/each}}
</select>
<select>
<option {{#equal operator "ascending"}}selected="selected"{{/equal}} data-i18n="ascending" value="ascending">ascending</option>
<option {{#equal operator "descending"}}selected="selected"{{/equal}} data-i18n="descending" value="descending">descending</option>
</select>
</div>
</script>
<script id="sort-template" type="text/x-handlebars-template">
<div>
<div data-role="header" class="ui-header">
<div class="ui-btn-right">
<div class="ui-controlgroup-controls">
<button data-i18n="Submit" type="submit" class="ui-btn-icon-left ui-icon-check">Submit</button>
</div>
</div>
<h1 data-i18n="Sort Editor">Sort Editor</h1>
<div class="ui-btn-left">
<div class="ui-controlgroup-controls">
<button data-i18n="Close" type="submit" class="close ui-btn-icon-left ui-icon-times">Close</button>
</div>
</div>
</div>
<section>
<div class="sort_item_container"></div>
<button type="submit" class="plus ui-icon-plus ui-btn-icon-left">Add Criteria</button>
<button type="button" class="trash ui-icon-trash-o ui-btn-icon-left">Reset</button>
</section>
</div>
</script>
</head>
<body>
<form>
......
......@@ -152,11 +152,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -200,16 +202,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -232,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>970.21390.23143.45209</string> </value>
<value> <string>981.59035.44382.29661</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1537197201.96</float>
<float>1581933163.45</float>
<string>UTC</string>
</tuple>
</state>
......@@ -259,16 +265,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -318,7 +328,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
/*jslint indent: 2, maxerr: 3, nomen: true */
/*global window, document, rJS, RSVP, Handlebars*/
(function (window, document, rJS, RSVP, Handlebars) {
/*global window, rJS, domsugar*/
(function (window, rJS, domsugar) {
"use strict";
var gadget_klass = rJS(window),
template_element = gadget_klass.__template_element,
sort_item_template = Handlebars.compile(template_element
.getElementById("sort-item-template")
.innerHTML),
sort_template = Handlebars.compile(template_element
.getElementById("sort-template")
.innerHTML);
Handlebars.registerHelper('equal', function (left_value, right_value, options) {
if (arguments.length < 3) {
throw new Error("Handlebars Helper equal needs 2 parameters");
}
if (left_value !== right_value) {
return options.inverse(this);
}
return options.fn(this);
});
function createSortItemTemplate(gadget, sort_value) {
var sort_column_list = gadget.state.sort_column_list,
sort_value_list = sort_value || [],
option_list = [],
function createSortItemTemplate(sort_value_list, sort_column_list, ascending_text, descending_text) {
var dom_column_option_list = [],
option_dict,
is_selected = false,
i;
for (i = 0; i < sort_column_list.length; i += 1) {
is_selected = is_selected || (sort_value_list[0] === sort_column_list[i][0]);
option_list.push({
text: sort_column_list[i][1],
option_dict = {
value: sort_column_list[i][0],
selected: sort_value_list[0] === sort_column_list[i][0]
});
// Used to be translated
text: sort_column_list[i][1]
};
if (sort_value_list[0] === sort_column_list[i][0]) {
option_dict.selected = "selected";
}
if (!is_selected && (sort_value !== undefined)) {
option_list.push({
dom_column_option_list.push(domsugar('option', option_dict));
}
if (!is_selected && (sort_value_list.length !== 0)) {
dom_column_option_list.push(domsugar('option', {
text: sort_value_list[0],
value: sort_value_list[0],
selected: true
});
}));
}
return gadget.translateHtml(sort_item_template({
option: option_list,
operator: sort_value_list[1]
}));
return domsugar('div', [
domsugar('button', {type: 'submit', class: 'ui-icon ui-icon-minus'}),
domsugar('div', {class: 'sort_item ui-controlgroup-controls'}, [
domsugar('select', dom_column_option_list),
domsugar('select', [
domsugar('option', {
value: 'ascending',
text: ascending_text,
selected: (sort_value_list[1] === 'ascending')
}),
domsugar('option', {
value: 'descending',
text: descending_text,
selected: (sort_value_list[1] === 'descending')
})
])
])
]);
}
/* Valid sort item is a tuple of (column-name, ordering) */
......@@ -58,47 +56,79 @@
(sort_item[1] === 'ascending' || sort_item[1] === 'descending');
}
gadget_klass
rJS(window)
//////////////////////////////////////////////
// acquired method
//////////////////////////////////////////////
.declareAcquiredMethod("translateHtml", "translateHtml")
.declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod("redirect", "redirect")
.declareAcquiredMethod("trigger", "trigger")
.onStateChange(function onStateChange() {
var gadget = this,
div = document.createElement("div"),
container = gadget.element.querySelector(".container");
return gadget.translateHtml(sort_template())
.push(function (translated_html) {
div.innerHTML = translated_html;
return RSVP.all(gadget.state.sort_list
var gadget = this;
return gadget.getTranslationList([
'Submit',
'Sort Editor',
'Close',
'Add Criteria',
'Reset',
'ascending',
'descending'
])
.push(function (translation_list) {
var sort_dom_list = gadget.state.sort_list
.filter(isValidSortItem)
.map(function (sort_item) {
return createSortItemTemplate(gadget, sort_item);
})
return createSortItemTemplate(
sort_item,
gadget.state.sort_column_list,
translation_list[5],
translation_list[6]
);
});
domsugar(gadget.element.querySelector(".container"), [
domsugar('div', [
domsugar('div', {'data-role': 'header', 'class': 'ui-header'}, [
domsugar('div', {class: 'ui-btn-right'}, [
domsugar('div', {class: 'ui-controlgroup-controls'}, [
domsugar('button', {
type: 'submit',
class: 'ui-btn-icon-left ui-icon-check',
text: translation_list[0]
})
])
]),
domsugar('h1', {text: translation_list[1]}),
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[2]
})
])
])
]),
domsugar('section', [
domsugar('div', {class: 'sort_item_container'},
sort_dom_list),
domsugar('button', {
class: 'plus ui-icon-plus ui-btn-icon-left',
text: translation_list[3]
}),
domsugar('button', {
class: 'trash ui-icon-trash-o ui-btn-icon-left',
text: translation_list[4]
})
.push(function (result_list) {
var i,
subdiv,
filter_item_container = div.querySelector('.sort_item_container');
for (i = 0; i < result_list.length; i += 1) {
subdiv = document.createElement("div");
subdiv.innerHTML = result_list[i];
filter_item_container.appendChild(subdiv);
}
while (container.firstChild) {
container.removeChild(container.firstChild);
}
container.appendChild(div);
])
])
]);
});
})
.declareMethod('render', function render(options) {
......@@ -110,15 +140,11 @@
})
.onEvent('click', function click(evt) {
var gadget = this,
container;
var gadget = this;
if (evt.target.classList.contains('trash')) {
evt.preventDefault();
container = gadget.element.querySelector(".sort_item_container");
while (container.firstChild) {
container.removeChild(container.firstChild);
}
domsugar(gadget.element.querySelector(".sort_item_container"), []);
}
if (evt.target.classList.contains('close')) {
......@@ -128,12 +154,21 @@
if (evt.target.classList.contains('plus')) {
evt.preventDefault();
return createSortItemTemplate(gadget)
.push(function (template) {
var tmp = document.createElement("div");
container = gadget.element.querySelector(".sort_item_container");
tmp.innerHTML = template;
container.appendChild(tmp);
return gadget.getTranslationList([
'ascending',
'descending'
])
.push(function (translation_list) {
return gadget.element.querySelector(".sort_item_container")
.appendChild(
createSortItemTemplate(
[],
gadget.state.sort_column_list,
translation_list[0],
translation_list[1]
)
);
});
}
......@@ -170,4 +205,4 @@
}, true);
});
}(window, document, rJS, RSVP, Handlebars));
\ No newline at end of file
}(window, rJS, domsugar));
\ No newline at end of file
......@@ -148,11 +148,13 @@
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -196,16 +198,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -228,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>971.7721.48108.61320</string> </value>
<value> <string>981.59065.52875.58180</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1546525739.0</float>
<float>1582033428.24</float>
<string>UTC</string>
</tuple>
</state>
......@@ -255,16 +261,20 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<tuple>
<none/>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
......@@ -314,7 +324,9 @@
</item>
</dictionary>
</list>
</tuple>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment