Commit 80002630 authored by Tomáš Peterka's avatar Tomáš Peterka

WWIP

parent f4e03d67
......@@ -45,14 +45,14 @@
<script id="listbox-hidden-tbody-template" type="text/x-handlebars-template">
<table>
<tbody class="tbody">
{{#each body_value}}
{{#each row_list}}
<tr>
{{#if ../show_anchor}}
<th>
<a class="ui-link ui-btn ui-corner-all ui-icon-carat-r ui-btn-icon-notext" href="{{jump}}"></a>
</th>
{{/if}}
{{#each tr_value}}
{{#each cell_list}}
<td>
{{#if type}}
{{#if editable}}
......@@ -82,7 +82,7 @@
<script id="listbox-show-tbody-template" type="text/x-handlebars-template">
<table>
<tbody class="tbody">
{{#each body_value}}
{{#each row_list}}
<tr>
{{#if ../show_anchor}}
<th>
......@@ -92,7 +92,7 @@
<td>
<input value="{{value}}" type="checkbox" checked="true" class="hide_element">
</td>
{{#each tr_value}}
{{#each cell_list}}
<td>
{{#if type}}
{{#if editable}}
......@@ -118,7 +118,42 @@
</table>
</script>
<script id="listbox-tfoot-template" type="text/x-handlebars-template">
<script id="listbox-tfoot-sum-template" type="text/x-handlebars-template">
<table>
<tfoot class="ui-bar-inherit tfoot summary">
{{#each row_list}}
<tr>
{{#each cell_list}}
<td>
{{#if type}}
{{#if editable}}
<div class="editable_div" data-column="{{column}}" data-line="{{line}}"></div>
{{else}}
<a href="{{href}}" class="ui-link">
<div class="editable_div" data-column="{{column}}" data-line="{{line}}"></div>
</a>
{{/if}}
{{else}}
<a href="{{href}}" class="ui-link">{{text}}</a>
{{/if}}
</td>
{{/each}}
</tr>
{{/each}}
<th colspan="{{colspan}}">
<div class="ui-controlgroup ui-controlgroup-horizontal ui-corner-all ui-paging-menu">
<div class="ui-controlgroup-controls">
<a class="{{previous_classname}}" data-i18n="Previous" href="{{previous_url}}">Previous</a>
<a class="{{next_classname}}" data-i18n="Next" href="{{next_url}}">Next</a>
<span class="ui-btn ui-disabled" data-i18n="{{record}}">{{record}}</span>
</div>
</div>
</th>
</tfoot>
</table>
</script>
<script id="listbox-tfoot-count-template" type="text/x-handlebars-template">
<table>
<tfoot class="ui-bar-inherit tfoot">
<th colspan="{{colspan}}">
......@@ -155,9 +190,8 @@
</table>
</div>
</script>
<script id="error-message-template" type="text/x-handlebars-template">
<div class="ui-listbox-error">
<a class="ui-btn ui-corner-all ui-btn-inline" href="{{reset_url}}">
......
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>962.24395.32903.29832</string> </value>
<value> <string>963.47536.5989.57173</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1506526285.9</float>
<float>1511764805.38</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -19,10 +19,15 @@
.innerHTML,
listbox_show_tbody_template = Handlebars.compile(listbox_show_tbody_source),
listbox_tfoot_source = gadget_klass.__template_element
.getElementById("listbox-tfoot-template")
listbox_tfoot_sum_source = gadget_klass.__template_element
.getElementById("listbox-tfoot-sum-template")
.innerHTML,
listbox_tfoot_template = Handlebars.compile(listbox_tfoot_source),
listbox_tfoot_sum_template = Handlebars.compile(listbox_tfoot_sum_source),
listbox_tfoot_count_source = gadget_klass.__template_element
.getElementById("listbox-tfoot-count-template")
.innerHTML,
listbox_tfoot_count_template = Handlebars.compile(listbox_tfoot_count_source),
listbox_source = gadget_klass.__template_element
.getElementById("listbox-template")
......@@ -49,14 +54,15 @@
gadget.props.listbox_uid_dict = {};
gadget.props.cell_gadget_list = [];
function renderSubCell(element, sub_field_json) {
sub_field_json.editable = sub_field_json.editable && gadget.state.editable; // XXX
sub_field_json.editable = sub_field_json.editable && gadget.state.editable; // XXX
return gadget.declareGadget('gadget_erp5_label_field.html', {element: element, scope: sub_field_json.key})
.push(function (cell_gadget) {
gadget.props.cell_gadget_list.push(cell_gadget);
return cell_gadget.render({
field_type: sub_field_json.type,
field_json: sub_field_json,
label: false});
label: false
});
});
}
for (i = 0; i < element_list.length; i += 1) {
......@@ -79,41 +85,47 @@
return RSVP.all(promise_list);
}
/**Put resulting `row_list` into `template` together with necessary gadget.state parameters.
function renderListboxTbody(gadget, template, body_value) {
var tmp,
First, it removes all similar containers from within the table! Currently it is tricky
to have multiple tbody/thead/tfoot elements! Feel free to refactor.
Example call: renderListboxTbody(gadget, compiled_template, row_list, "tbody");
**/
function renderListboxTbody(gadget, template, row_list, container_name) {
var container,
column_list = JSON.parse(gadget.state.column_list_json);
return gadget.translateHtml(template(
{
"body_value": body_value,
"row_list": row_list,
"show_anchor": gadget.state.show_anchor,
"column_list": column_list
}
))
.push(function (my_html) {
tmp = document.createElement("tbody");
tmp.innerHTML = my_html;
return renderEditableField(gadget, tmp, column_list);
container = document.createElement(container_name);
container.innerHTML = my_html;
return renderEditableField(gadget, container, column_list);
})
.push(function () {
var table = gadget.element.querySelector("table"),
tbody = table.querySelector("tbody");
table.removeChild(tbody);
table.appendChild(tmp);
old_container = table.querySelector(container_name);
table.removeChild(old_container);
table.appendChild(container);
});
}
function renderListboxTfoot(gadget, foot) {
return gadget.translateHtml(listbox_tfoot_template(
function renderListboxTfoot(gadget, foot_count, foot_sum) {
return gadget.translateHtml(listbox_tfoot_count_template(
{
"colspan": foot.colspan,
"previous_classname": foot.previous_classname,
"previous_url": foot.previous_url,
"record": foot.record,
"next_classname": foot.next_classname,
"next_url": foot.next_url
"colspan": foot_count.colspan,
"previous_classname": foot_count.previous_classname,
"previous_url": foot_count.previous_url,
"record": foot_count.record,
"next_classname": foot_count.next_classname,
"next_url": foot_count.next_url
}
));
}
......@@ -455,18 +467,18 @@
})
.push(function (result_list) {
var value,
body_value = [],
tr_value = [],
var row_list = [],
value,
cell_list,
tmp_url,
listbox_tbody_template;
for (i = 0; i < counter; i += 1) {
tmp_url = result_list[i];
tr_value = [];
cell_list = [];
for (j = 0; j < column_list.length; j += 1) {
value = allDocs_result.data.rows[i].value[column_list[j][0]] || "";
tr_value.push({
cell_list.push({
"type": value.type,
"editable": value.editable && gadget.state.editable,
"href": tmp_url,
......@@ -475,10 +487,10 @@
"column": j
});
}
body_value.push({
row_list.push({
"value": allDocs_result.data.rows[i].value.uid,
"jump": tmp_url,
"tr_value": tr_value,
"cell_list": cell_list,
"line_icon": gadget.state.line_icon
});
}
......@@ -489,7 +501,7 @@
listbox_tbody_template = listbox_hidden_tbody_template;
}
return renderListboxTbody(gadget, listbox_tbody_template, body_value);
return renderListboxTbody(gadget, listbox_tbody_template, row_list, "tbody");
})
.push(function () {
var prev_param = {},
......@@ -513,28 +525,32 @@
})
.push(function (url_list) {
var foot = {};
foot.colspan = column_list.length + gadget.state.show_anchor +
var tfoot_count = {
"previous_url": url_list[0],
"next_url": url_list[1],
"previous_classname": "ui-btn ui-icon-carat-l ui-btn-icon-left responsive ui-first-child",
"next_classname": "ui-btn ui-icon-carat-r ui-btn-icon-right responsive ui-last-child"
},
tfoot_sum = {};
tfoot_count.colspan = column_list.length + gadget.state.show_anchor +
(gadget.state.line_icon ? 1 : 0);
foot.previous_classname = "ui-btn ui-icon-carat-l ui-btn-icon-left responsive ui-first-child";
foot.previous_url = url_list[0];
foot.next_classname = "ui-btn ui-icon-carat-r ui-btn-icon-right responsive ui-last-child";
foot.next_url = url_list[1];
if ((gadget.state.begin_from === 0) && (counter === 0)) {
foot.record = variable.translated_no_record;
tfoot_count.record = variable.translated_no_record;
} else if ((allDocs_result.data.rows.length <= lines) && (gadget.state.begin_from === 0)) {
foot.record = counter + " " + variable.translated_records;
tfoot_count.record = counter + " " + variable.translated_records;
} else {
foot.record = variable.translated_records + " " + (((gadget.state.begin_from + lines) / lines - 1) * lines + 1) + " - " + (((gadget.state.begin_from + lines) / lines - 1) * lines + counter);
tfoot_count.record = variable.translated_records + " " + (((gadget.state.begin_from + lines) / lines - 1) * lines + 1) + " - " + (((gadget.state.begin_from + lines) / lines - 1) * lines + counter);
}
if (gadget.state.begin_from === 0) {
foot.previous_classname += " ui-disabled";
tfoot_count.previous_classname += " ui-disabled";
}
if (allDocs_result.data.rows.length <= lines) {
foot.next_classname += " ui-disabled";
tfoot_count.next_classname += " ui-disabled";
}
return renderListboxTfoot(gadget, foot);
return renderListboxTfoot(gadget, tfoot_count, tfoot_sum);
})
.push(function (my_html) {
gadget.element.querySelector(".tfoot").innerHTML = my_html;
......
......@@ -236,7 +236,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.56527.16709.20804</string> </value>
<value> <string>963.47634.31999.4898</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -254,7 +254,7 @@
</tuple>
<state>
<tuple>
<float>1506527031.12</float>
<float>1511765129.91</float>
<string>UTC</string>
</tuple>
</state>
......
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