Commit 55efebea authored by Romain Courteaud's avatar Romain Courteaud

erp5_core/web_renderjs_ui: stop using handlebars

parent e6454e94
......@@ -3,22 +3,8 @@
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width" />
<script src="handlebars.js" type="text/javascript"></script>
<script src="jslint.js" type="text/javascript"></script>
<script id="jslint_template" type="text/x-handlebars-template">
{{#each error_list}}
{{#if this}}
<tr class="Data{{this.line_letter}}">
<td class="listbox-table-data-cell">line: {{this.line}}: {{this.character}}: {{this.evidence}}</td>
<td class="listbox-table-data-cell">{{this.reason}}</td>
</tr>
{{/if}}
{{else}}
<tr class="DataA"><td>No error!</td></tr>
{{/each}}
</script>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="gadget_jslint.js" type="text/javascript"></script>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......
/*global window, rJS, JSLINT, Handlebars */
/*global window, rJS, JSLINT, document */
/*jslint nomen: true, maxlen:80, indent:2*/
(function (rJS, Handlebars, JSLINT, window) {
(function (rJS, JSLINT, window, document) {
"use strict";
var gk = rJS(window),
template_source = gk.__template_element
.getElementById('jslint_template')
.innerHTML,
template = Handlebars.compile(template_source);
rJS(window)
.ready(function (g) {
g.props = {};
})
.ready(function (g) {
return g.getElement().push(function (element) {
g.props.element = element;
});
})
.declareMethod("render", function (options) {
var text_content = options.value,
data,
......@@ -25,21 +11,43 @@
i,
line_letter = "A",
len,
gadget = this;
gadget = this,
fragment = document.createDocumentFragment(),
td_element,
tr_element;
JSLINT(text_content, {});
data = JSLINT.data();
for (i = 0, len = data.errors.length; i < len; i += 1) {
if (data.errors[i] !== null) {
data.errors[i].line_letter = line_letter;
line_letter = line_letter === "A" ? "B" : "A";
tr_element = document.createElement('tr');
tr_element.setAttribute('class', 'Data' + line_letter);
line_letter = (line_letter === "A") ? "B" : "A";
fragment.appendChild(tr_element);
td_element = document.createElement('td');
td_element.setAttribute('class', 'listbox-table-data-cell');
td_element.textContent = "line: " + data.errors[i].line + ": " +
data.errors[i].character + ": " +
data.errors[i].evidence;
tr_element.appendChild(td_element);
td_element = document.createElement('td');
td_element.setAttribute('class', 'listbox-table-data-cell');
td_element.textContent = data.errors[i].reason;
tr_element.appendChild(td_element);
}
}
html_content = template({
error_list: data.errors
});
if (len === 0) {
tr_element = document.createElement('tr');
tr_element.setAttribute('class', 'DataA');
fragment.appendChild(tr_element);
td_element = document.createElement('td');
td_element.textContent = "No error!";
tr_element.appendChild(td_element);
}
gadget.props.element.querySelector("tbody")
.innerHTML = html_content;
gadget.element.querySelector("tbody").appendChild(fragment);
});
}(rJS, Handlebars, JSLINT, window));
\ No newline at end of file
}(rJS, JSLINT, window, document));
\ No newline at end of file
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......
......@@ -8,23 +8,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>
<!-- custom script -->
<script src="domsugar.js" type="text/javascript"></script>
<script src="gadget_erp5_page_router_test.js" type="text/javascript"></script>
<script id="result-list-template" type="text/x-handlebars-template">
<p class="result-{{i}}">
Test {{i}} : <a href="{{link}}">Link {{i}}</a>
</p>
</script>
</head>
<body>
<h2>Test router commands. Each line is the result of a test</h2>
<div class='result-block'>
<p>
Test 1 : <a href="#">Link 1</a>
</p>
</div>
<div class='result-block'></div>
</body>
</html>
\ No newline at end of file
/*global window, rJS, RSVP, Handlebars */
/*global window, rJS, domsugar */
/*jslint indent: 2, maxerr: 3 */
(function (window, rJS, RSVP, Handlebars) {
(function (window, rJS, domsugar) {
"use strict";
var gadget_klass = rJS(window),
template_element = gadget_klass.__template_element,
result_list_template = Handlebars.compile(
template_element
.getElementById("result-list-template")
.innerHTML
);
gadget_klass
rJS(window)
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareMethod('render', function (options) {
var gadget = this,
result_inner_html = "";
.declareMethod('render', function () {
var gadget = this;
return gadget.getUrlFor({command: 'display_erp5_action', options: {jio_key: "foo_module", page: "empty_mass_action"}})
return gadget.getUrlFor({
command: 'display_erp5_action',
options: {jio_key: "foo_module", page: "empty_mass_action"}
})
.push(function (link) {
gadget.element.querySelector(".result-block").innerHTML = result_list_template({
"i": 0,
"link": link
});
domsugar(
gadget.element.querySelector(".result-block"),
[
domsugar('p', {class: 'result-0'}, [
"Test 0",
domsugar('a', {href: link, text: "Link 0"})
])
]
);
});
});
}(window, rJS, RSVP, Handlebars));
\ No newline at end of file
}(window, rJS, domsugar));
\ No newline at end of file
......@@ -4,83 +4,14 @@
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width,height=device-height,initial-scale=1" />
<title>Activity watcher gadget</title>
<script src="handlebars.js" type="text/javascript"></script>
<script id="getData" type="text/x-handlebars-template">
Date : {{time}}
<table>
<thead>
<tr>
<th>Type</th>
<th>Count</th>
<th>Method Id</th>
<th>Processing Node</th>
<th>Min pri</th>
<th>Max pri</th>
</tr>
</thead><tbody>
{{#each messageList1}}
<tr>
<td>{{this.messagetype}} </td>
<td>{{this.count}}</td>
<td>{{this.method_id}}</td>
<td>{{this.node}}</td>
<td>{{this.min_pri}}</td>
<td>{{this.max_pri}}</td>
</tr>
{{/each}}
{{#each messageList2}}
<tr>
<td>{{this.messagetype}} </td>
<td>{{this.count}}</td>
<td>{{this.method_id}}</td>
<td>{{this.node}}</td>
<td>{{this.min_pri}}</td>
<td>{{this.max_pri}}</td>
</tr>
{{/each}}
</tbody>
</table>
<table>
<thead>
<tr>
<th>Type</th>
<th>Priority</th>
<th>Min</th>
<th>Avg</th>
<th>Max</th>
</tr>
</thead><tbody>
{{#each messagePri1}}
<tr>
<td>{{this.messagetype}} </td>
<td>{{this.pri}}</td>
<td>{{this.min}}</td>
<td>{{this.avg}}</td>
<td>{{this.max}}</td>
</tr>
{{/each}}
{{#each messagePri2}}
<tr>
<td>{{this.messagetype}} </td>
<td>{{this.pri}}</td>
<td>{{this.min}}</td>
<td>{{this.avg}}</td>
<td>{{this.max}}</td>
</tr>
{{/each}}
</tbody>
</table>
</script>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jio.js" type="text/javascript"></script>
<script src="gadget_activity_watcher.js" type="text/javascript"></script>
</head>
<body>
<div class="activity_watcher_gadget"></div>
</body>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jio.js" type="text/javascript"></script>
<script src="domsugar.js" type="text/javascript"></script>
<script src="gadget_activity_watcher.js" type="text/javascript"></script>
</head>
<body>
<div class="activity_watcher_gadget"></div>
</body>
</html>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......
/*global window, rJS, RSVP, Handlebars, jIO, console */
/*global window, rJS, RSVP, domsugar, jIO, console */
/*jslint nomen: true, maxlen:80, indent:2*/
(function (rJS, jIO, Handlebars, RSVP, window) {
(function (rJS, jIO, domsugar, RSVP, window) {
"use strict";
var gk = rJS(window),
data_source = gk.__template_element.getElementById('getData').innerHTML,
get_data_template = Handlebars.compile(data_source);
function putMessageType(data, messagetype, string) {
function putMessageType(data, messagetype, string, array) {
var i;
if (data[string] && data[string].line_list) {
for (i = 0; i < data[string].line_list.length; i += 1) {
data[string].line_list[i].messagetype = messagetype;
array.push(domsugar('tr', [
domsugar('td', {text: messagetype}),
domsugar('td', {text: data[string].line_list[i].count}),
domsugar('td', {text: data[string].line_list[i].method_id}),
domsugar('td', {text: data[string].line_list[i].node}),
domsugar('td', {text: data[string].line_list[i].min_pri}),
domsugar('td', {text: data[string].line_list[i].max_pri})
]));
}
}
}
function putMessageType2(data, messagetype, string, array) {
var i;
if (data[string] && data[string].line_list) {
for (i = 0; i < data[string].line_list.length; i += 1) {
array.push(domsugar('tr', [
domsugar('td', {text: messagetype}),
domsugar('td', {text: data[string].line_list[i].pri}),
domsugar('td', {text: data[string].line_list[i].min}),
domsugar('td', {text: data[string].line_list[i].avg}),
domsugar('td', {text: data[string].line_list[i].max})
]));
}
return data[string].line_list;
}
return '';
}
rJS(window)
......@@ -42,15 +60,40 @@
);
})
.push(function (evt) {
var data = JSON.parse(evt.target.response);
form_gadget.element.querySelector(".activity_watcher_gadget")
.innerHTML = get_data_template({
time: new Date().toTimeString(),
messageList1: putMessageType(data, 'dict', 'SQLDict'),
messageList2: putMessageType(data, 'queue', 'SQLQueue'),
messagePri1: putMessageType(data, 'dict', 'SQLDict2'),
messagePri2: putMessageType(data, 'queue', 'SQLQueue2')
});
var data = JSON.parse(evt.target.response),
tbody1_content_list = [],
tbody2_content_list = [];
putMessageType(data, 'dict', 'SQLDict', tbody1_content_list);
putMessageType(data, 'queue', 'SQLQueue', tbody1_content_list);
putMessageType2(data, 'dict', 'SQLDict2', tbody2_content_list);
putMessageType2(data, 'queue', 'SQLQueue2', tbody2_content_list);
domsugar(form_gadget.element.querySelector(".activity_watcher_gadget"), [
'Date : ',
new Date().toTimeString(),
domsugar('table', [
domsugar('thead', [domsugar('tr', [
domsugar('th', {text: 'Type'}),
domsugar('th', {text: 'Count'}),
domsugar('th', {text: 'Method Id'}),
domsugar('th', {text: 'Processing Node'}),
domsugar('th', {text: 'Min pri'}),
domsugar('th', {text: 'Max pri'})
])]),
domsugar('tbody', tbody1_content_list)
]),
domsugar('table', [
domsugar('thead', [domsugar('tr', [
domsugar('th', {text: 'Type'}),
domsugar('th', {text: 'Priority'}),
domsugar('th', {text: 'Min'}),
domsugar('th', {text: 'Avg'}),
domsugar('th', {text: 'Max'})
])]),
domsugar('tbody', tbody2_content_list)
])
]);
}, function (error) {
//Exception is raised if network is lost for some reasons,
......@@ -61,4 +104,4 @@
});
}, 1000);
}(rJS, jIO, Handlebars, RSVP, window));
\ No newline at end of file
}(rJS, jIO, domsugar, RSVP, window));
\ No newline at end of file
......@@ -8,7 +8,7 @@
<dictionary>
<item>
<key> <string>_Cacheable__manager_id</string> </key>
<value> <string>http_cache</string> </value>
<value> <string>must_revalidate_http_cache</string> </value>
</item>
<item>
<key> <string>__name__</string> </key>
......
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