Commit 771da240 authored by Sven Franck's avatar Sven Franck Committed by Sebastien Robin

Listbox: added pagination

parent 3706a115
...@@ -131,6 +131,11 @@ html form {\n ...@@ -131,6 +131,11 @@ html form {\n
overflow: hidden;\n overflow: hidden;\n
}\n }\n
\n \n
/* readonly */\n
.custom-readonly {\n
opacity: 1;\n
}\n
\n
/* ------------------------------ Global Font ---------------------------- */\n /* ------------------------------ Global Font ---------------------------- */\n
/* NOTE: family/size should only be set here! */\n /* NOTE: family/size should only be set here! */\n
body, input, select, textarea, button, p, h1, h2, h3, h4, h5, h6,\n body, input, select, textarea, button, p, h1, h2, h3, h4, h5, h6,\n
......
...@@ -124,6 +124,7 @@ ...@@ -124,6 +124,7 @@
//////////////////////////////////////////////\n //////////////////////////////////////////////\n
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")\n .declareAcquiredMethod("jio_allDocs", "jio_allDocs")\n
.declareAcquiredMethod("whoWantToDisplayThis", "whoWantToDisplayThis")\n .declareAcquiredMethod("whoWantToDisplayThis", "whoWantToDisplayThis")\n
.declareAcquiredMethod("pleasePublishMyState", "pleasePublishMyState")\n
//////////////////////////////////////////////\n //////////////////////////////////////////////\n
// initialize the gadget content\n // initialize the gadget content\n
//////////////////////////////////////////////\n //////////////////////////////////////////////\n
...@@ -155,7 +156,10 @@ ...@@ -155,7 +156,10 @@
begin_from = gadget.props.begin_from,\n begin_from = gadget.props.begin_from,\n
table = gadget.props.element.querySelector(\'table\'),\n table = gadget.props.element.querySelector(\'table\'),\n
tbody = document.createElement("tbody"),\n tbody = document.createElement("tbody"),\n
lines = field_json.lines,\n
select_list = [],\n select_list = [],\n
dataset,\n
counter,\n
i;\n i;\n
\n \n
for (i = 0; i < field_json.column_list.length; i += 1) {\n for (i = 0; i < field_json.column_list.length; i += 1) {\n
...@@ -164,12 +168,13 @@ ...@@ -164,12 +168,13 @@
\n \n
return gadget.jio_allDocs({\n return gadget.jio_allDocs({\n
"query": new URI(field_json.query).query(true).query,\n "query": new URI(field_json.query).query(true).query,\n
"limit": [begin_from, begin_from + field_json.lines + 1],\n "limit": [begin_from, begin_from + lines + 1],\n
"select_list": select_list\n "select_list": select_list\n
}).push(function (result) {\n }).push(function (result) {\n
var promise_list = [result];\n var promise_list = [result];\n
counter = Math.min(result.data.total_rows, lines);\n
\n \n
for (i = 0; i < (result.data.rows.length - 1); i += 1) {\n for (i = 0; i < counter; i += 1) {\n
promise_list.push(\n promise_list.push(\n
gadget.whoWantToDisplayThis(result.data.rows[i].id)\n gadget.whoWantToDisplayThis(result.data.rows[i].id)\n
);\n );\n
...@@ -181,13 +186,11 @@ ...@@ -181,13 +186,11 @@
tr,\n tr,\n
th,\n th,\n
a,\n a,\n
result = result_list[0],\n result = dataset = result_list[0],\n
url_param = {},\n
tmp_url;\n tmp_url;\n
\n \n
for (i = 0; i < (result.data.rows.length - 1); i += 1) {\n for (i = 0; i < counter; i += 1) {\n
tr = document.createElement("tr");\n tr = document.createElement("tr");\n
// tmp_url = "#/f/" + encodeURIComponent(result.data.rows[i].id) + "/view";\n
tmp_url = result_list[i + 1];\n tmp_url = result_list[i + 1];\n
\n \n
for (j = 0; j < field_json.column_list.length; j += 1) {\n for (j = 0; j < field_json.column_list.length; j += 1) {\n
...@@ -202,28 +205,77 @@ ...@@ -202,28 +205,77 @@
tbody.appendChild(tr);\n tbody.appendChild(tr);\n
}\n }\n
\n \n
if (result.data.rows.length > field_json.lines) {\n }).push(function () {\n
url_param.begin_from = begin_from + field_json.lines;\n var prev_param = {},\n
next_param = {};\n
\n
function setNext() {\n
if (dataset.data.rows.length > lines) {\n
next_param.begin_from = begin_from + lines;\n
}\n
}\n }\n
// return gadget.acquire("generateMyUrlXXX", url_param);\n \n
if (begin_from === 0) {\n
setNext();\n
} else {\n
prev_param.begin_from = begin_from - lines;\n
setNext();\n
}\n
\n
return RSVP.all([\n return RSVP.all([\n
gadget.aq_pleasePublishMyState({}),\n gadget.pleasePublishMyState(prev_param),\n
gadget.aq_pleasePublishMyState(url_param)\n gadget.pleasePublishMyState(next_param)\n
]);\n ]);\n
// return gadget.acquire("generateMyUrlXXX", url_param);\n \n
// [{jio_key: param_list[0]}]);\n }).push(function (url_list) {\n
}).push(function () {\n var fragment = document.createDocumentFragment(),\n
// if (begin_from !== 0) {\n tfoot = document.createElement("tfoot"),\n
// tmp_element_1.innerHTML += "<a href=\'" + lala[0] +\n tr = document.createElement("tr"),\n
// "\'>Start</a> ";\n th = document.createElement("th"),\n
// }\n paging_prev = document.createElement("a"),\n
// tmp_element_1.innerHTML += "<a href=\'" + lala[1] +\n paging_next = document.createElement("a"),\n
// "\'>Next page!</a>";\n paging_info = document.createElement("span"),\n
table.appendChild(tbody);\n paging_menu = document.createElement("div"),\n
// if (result.data.rows.length > field_json.lines) {\n paging_wrap = document.createElement("div"),\n
// tmp_element_1.innerHTML += "<a href=\'#begin_from=56\'>Next page!</a>";\n len;\n
// window.location = "http://www.free.fr";\n \n
// }\n th.colspan = lines;\n
\n
paging_menu.className = "ui-controlgroup ui-controlgroup-horizontal ui-corner-all";\n
paging_wrap.className = "ui-controlgroup-controls";\n
\n
paging_prev.className = "ui-btn ui-icon-carat-l ui-btn-icon-left ui-first-child";\n
paging_prev.textContent = "Previous";\n
paging_prev.href = url_list[0];\n
paging_info.className = "ui-btn ui-disabled custom-readonly";\n
paging_info.textContent = "Page " + ((begin_from + lines)/lines);\n
paging_next.className = "ui-btn ui-icon-carat-r ui-btn-icon-right ui-last-child";\n
paging_next.textContent = "Next";\n
paging_next.href = url_list[1];\n
\n
if (begin_from === 0) {\n
paging_prev.className += " ui-disabled";\n
}\n
if (dataset.data.rows.length <= lines) {\n
paging_next.className += " ui-disabled";\n
}\n
\n
paging_wrap.appendChild(paging_prev);\n
paging_wrap.appendChild(paging_info);\n
paging_wrap.appendChild(paging_next);\n
paging_menu.appendChild(paging_wrap);\n
th.appendChild(paging_menu);\n
tr.appendChild(th);\n
tfoot.appendChild(tr);\n
fragment.appendChild(tbody);\n
fragment.appendChild(tfoot);\n
\n
for (len = table.children.length; len > 0; len -= 1) {\n
table.removeChild(table.lastChild);\n
}\n
\n
table.appendChild(fragment);\n
\n
});\n });\n
});\n });\n
\n \n
......
15 16
\ No newline at end of file \ No newline at end of file
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