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

erp5_core/web_renderjs_ui: stop using handlebars

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