Commit be5140df authored by Sven Franck's avatar Sven Franck

removes column sorting from JQM table extension to template factory

parent 556f8af9
{
"portal_type_source": "Sale Invoice Transaction",
"portal_type_title": "invoices",
"base_element": {"type": "table", "direct": {"id": "invoices_01","className":"table-stroke ui-responsive"}, "attributes": {"data-filter":"true", "data-sort":"true", "data-input":"#global_search_invoices","data-mode": "columntoggle","data-use-pop": false,"data-wrap": "both","data-top-grid": 3,"data-bottom-grid": 1, "data-sorting":"true"}, "logic": {}},
"base_element": {"type": "table", "direct": {"id": "invoices_01","className":"table-stroke ui-responsive"}, "attributes": {"data-filter":"true", "data-input":"#global_search_invoices","data-mode": "columntoggle","data-use-pop": false,"data-wrap": "both","data-top-grid": 3,"data-bottom-grid": 1, "data-sorting":"true"}, "logic": {}},
"form_wrapper": null,
"initial_query": {"include_documents": true, "limit":[0,10]},
"configuration": {
......
......@@ -347,8 +347,10 @@
property,
keys,
title,
temp = {},
set,
text,
temp = {},
link = undefined,
check = settings.configuration.table.checkbox_rows,
merger = settings.configuration.table.mergeable_columns,
target = settings.layout.columns,
......@@ -382,6 +384,7 @@
}
for (l = 0; l < target.length; l += 1) {
link = undefined;
field = target[l];
config = {};
property = field.title;
......@@ -398,20 +401,33 @@
if (field.persist === undefined) {
config["data-priority"] = field.priority || 6;
}
if (settings.configuration.table.sorting_columns && field.sort) {
config["data-sorting"] = true;
}
if (field_config) {
title = temp[property] || field_config.widget.title;
} else {
title = util.capFirstLetter(property);
}
if (settings.configuration.table.sorting_columns && field.sort) {
text = {}
link = factory.generateElement(
"a",
{"className":"action ui-sorting ui-btn ui-icon-sort " +
"ui-icon ui-btn-icon-right"},
{
"data-action":"sort",
"data-i18n":"",
"data-reference": settings.base_element.direct.id
},
{"text": title}
);
} else {
text = {"text": title }
}
cell = factory.generateElement(
"th",
{"className":"translate"},
config,
{"text": title }
"th", {"className":"translate"}, config, text
);
if (link) {
cell.appendChild(link);
}
if (merger) {
row.insertBefore(
cell,
......@@ -2871,10 +2887,17 @@
/* ***************************** ENTRY POINT *************************** */
// NOTE:
// util = utilities methods
// factory = content generator methods
// INSTRUCTIONS
// util = utilities/helper methods
// factory = content generator methods (templating system)
// init = initialization methods
// erp5 = custom methods for erp5 = "mapped" to factory object
// erp5 = custom methods for erp5 = "mapped" to factory
// ACTIONS
// > class "action" data-action="which_action" data-reference="which_id"
// > set these on an element to hook up to handlers
// > in erp5.map_actions, add a method "which_action"
// > will be run on "click" & "change"
// TODO: run earlier, not on "ready" > http://bit.ly/10Nvgly
$(document)
......@@ -2902,7 +2925,7 @@
.on("pageremove", "div.ui-page", function (e) {
var id = e.target.id;
// clear memory
// clear cache for this page!
delete ram_cache[id];
});
......
......@@ -457,7 +457,6 @@ $.widget( "mobile.table", $.mobile.table, {
columnPopupTheme: null,
columnBtnText: "Columns...",
columnBtnIcon: "Search",
sort: null,
wrap: null,
embedded: null,
topGrid: null,
......@@ -500,9 +499,6 @@ $.widget( "mobile.table", $.mobile.table, {
// add responsive CSS
this._addResponsiveClassAndLabel();
}
if (o.sort) {
this._setSorting();
}
if (o.wrap) {
this._wrapTable();
}
......@@ -705,17 +701,6 @@ $.widget( "mobile.table", $.mobile.table, {
}
},
_setSorting: function () {
var sorts = this.element.find( "thead tr th[data-sorting]" ),
btn = $("<a />", {
class: "ui-sorting ui-btn ui-icon-sort ui-icon ui-btn-icon-right",
});
sorts.each(function(i, el) {
var $el = $(el);
$el.html( btn.clone().text( $el.text() ) );
});
},
rebuild: function() {
this._super();
......
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