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_source": "Sale Invoice Transaction",
"portal_type_title": "invoices", "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, "form_wrapper": null,
"initial_query": {"include_documents": true, "limit":[0,10]}, "initial_query": {"include_documents": true, "limit":[0,10]},
"configuration": { "configuration": {
......
...@@ -347,8 +347,10 @@ ...@@ -347,8 +347,10 @@
property, property,
keys, keys,
title, title,
temp = {},
set, set,
text,
temp = {},
link = undefined,
check = settings.configuration.table.checkbox_rows, check = settings.configuration.table.checkbox_rows,
merger = settings.configuration.table.mergeable_columns, merger = settings.configuration.table.mergeable_columns,
target = settings.layout.columns, target = settings.layout.columns,
...@@ -382,6 +384,7 @@ ...@@ -382,6 +384,7 @@
} }
for (l = 0; l < target.length; l += 1) { for (l = 0; l < target.length; l += 1) {
link = undefined;
field = target[l]; field = target[l];
config = {}; config = {};
property = field.title; property = field.title;
...@@ -398,20 +401,33 @@ ...@@ -398,20 +401,33 @@
if (field.persist === undefined) { if (field.persist === undefined) {
config["data-priority"] = field.priority || 6; config["data-priority"] = field.priority || 6;
} }
if (settings.configuration.table.sorting_columns && field.sort) {
config["data-sorting"] = true;
}
if (field_config) { if (field_config) {
title = temp[property] || field_config.widget.title; title = temp[property] || field_config.widget.title;
} else { } else {
title = util.capFirstLetter(property); 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( cell = factory.generateElement(
"th", "th", {"className":"translate"}, config, text
{"className":"translate"},
config,
{"text": title }
); );
if (link) {
cell.appendChild(link);
}
if (merger) { if (merger) {
row.insertBefore( row.insertBefore(
cell, cell,
...@@ -2871,10 +2887,17 @@ ...@@ -2871,10 +2887,17 @@
/* ***************************** ENTRY POINT *************************** */ /* ***************************** ENTRY POINT *************************** */
// NOTE: // NOTE:
// util = utilities methods // INSTRUCTIONS
// factory = content generator methods // util = utilities/helper methods
// factory = content generator methods (templating system)
// init = initialization methods // 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 // TODO: run earlier, not on "ready" > http://bit.ly/10Nvgly
$(document) $(document)
...@@ -2902,7 +2925,7 @@ ...@@ -2902,7 +2925,7 @@
.on("pageremove", "div.ui-page", function (e) { .on("pageremove", "div.ui-page", function (e) {
var id = e.target.id; var id = e.target.id;
// clear memory // clear cache for this page!
delete ram_cache[id]; delete ram_cache[id];
}); });
......
...@@ -457,7 +457,6 @@ $.widget( "mobile.table", $.mobile.table, { ...@@ -457,7 +457,6 @@ $.widget( "mobile.table", $.mobile.table, {
columnPopupTheme: null, columnPopupTheme: null,
columnBtnText: "Columns...", columnBtnText: "Columns...",
columnBtnIcon: "Search", columnBtnIcon: "Search",
sort: null,
wrap: null, wrap: null,
embedded: null, embedded: null,
topGrid: null, topGrid: null,
...@@ -500,9 +499,6 @@ $.widget( "mobile.table", $.mobile.table, { ...@@ -500,9 +499,6 @@ $.widget( "mobile.table", $.mobile.table, {
// add responsive CSS // add responsive CSS
this._addResponsiveClassAndLabel(); this._addResponsiveClassAndLabel();
} }
if (o.sort) {
this._setSorting();
}
if (o.wrap) { if (o.wrap) {
this._wrapTable(); this._wrapTable();
} }
...@@ -705,17 +701,6 @@ $.widget( "mobile.table", $.mobile.table, { ...@@ -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() { rebuild: function() {
this._super(); 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