summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/list.js
diff options
context:
space:
mode:
authorJiten (OpenERP) <jra@tinyerp.com>2011-09-13 16:47:54 +0530
committerJiten (OpenERP) <jra@tinyerp.com>2011-09-13 16:47:54 +0530
commit47cdc8d62d3627d3d03e5d0963a5104e7dff9d7e (patch)
tree6b6a28e30a036024c18b35e25a75aaa11faf1fa5 /addons/web/static/src/js/list.js
parent655d615f52fabf821d354f0399a792ac595de88e (diff)
parenta6b981eca52e04678b74acedeba21c2f4c2c5155 (diff)
[MERGE] Merge from openerp-web.
bzr revid: jra@tinyerp.com-20110913111754-zk57t5dqc22s98vm
Diffstat (limited to 'addons/web/static/src/js/list.js')
-rw-r--r--addons/web/static/src/js/list.js83
1 files changed, 69 insertions, 14 deletions
diff --git a/addons/web/static/src/js/list.js b/addons/web/static/src/js/list.js
index 6029b30f866..cca616d0055 100644
--- a/addons/web/static/src/js/list.js
+++ b/addons/web/static/src/js/list.js
@@ -27,7 +27,9 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
* See constructor parameters and method documentations for information on
* the default behaviors and possible options for the list view.
*
- * @constructs
+ * @constructs openerp.web.ListView
+ * @extends openerp.web.View
+ *
* @param parent parent object
* @param element_id the id of the DOM elements this view should link itself to
* @param {openerp.web.DataSet} dataset the dataset the view should work with
@@ -49,6 +51,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
this.dataset = dataset;
this.model = dataset.model;
this.view_id = view_id;
+ this.previous_colspan = null;
this.columns = [];
@@ -58,6 +61,13 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
if (this.dataset instanceof openerp.web.DataSetStatic) {
this.groups.datagroup = new openerp.web.StaticDataGroup(this.dataset);
+ } else {
+ this.groups.datagroup = new openerp.web.DataGroup(
+ this, this.model,
+ dataset.get_domain(),
+ dataset.get_context(),
+ {});
+ this.groups.datagroup.sort = this.dataset._sort;
}
this.page = 0;
@@ -346,7 +356,7 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
if (this.sidebar) {
this.sidebar.$element.show();
}
- if (this.hidden) {
+ if (!_(this.dataset.ids).isEmpty()) {
this.reload_content();
}
},
@@ -355,7 +365,6 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
if (this.sidebar) {
this.sidebar.$element.hide();
}
- this.hidden = true;
},
/**
* Reloads the list view based on the current settings (dataset & al)
@@ -603,6 +612,49 @@ openerp.web.ListView = openerp.web.View.extend( /** @lends openerp.web.ListView#
get_selected_ids: function() {
var ids = this.groups.get_selection().ids;
return ids;
+ },
+ /**
+ * Adds padding columns at the start or end of all table rows (including
+ * field names row)
+ *
+ * @param {Number} count number of columns to add
+ * @param {Object} options
+ * @param {"before"|"after"} [position="after"] insertion position for the new columns
+ * @param {Object} [except] content row to not pad
+ */
+ pad_columns: function (count, options) {
+ options = options || {};
+ // padding for action/pager header
+ var $first_header = this.$element.find('thead tr:first th');
+ var colspan = $first_header.attr('colspan');
+ if (colspan) {
+ if (!this.previous_colspan) {
+ this.previous_colspan = colspan;
+ }
+ $first_header.attr('colspan', parseInt(colspan, 10) + count);
+ }
+ // Padding for column titles, footer and data rows
+ var $rows = this.$element
+ .find('.oe-listview-header-columns, tr:not(thead tr)')
+ .not(options['except']);
+ var newcols = new Array(count+1).join('<td class="oe-listview-padding"></td>');
+ if (options.position === 'before') {
+ $rows.prepend(newcols);
+ } else {
+ $rows.append(newcols);
+ }
+ },
+ /**
+ * Removes all padding columns of the table
+ */
+ unpad_columns: function () {
+ this.$element.find('.oe-listview-padding').remove();
+ if (this.previous_colspan) {
+ this.$element
+ .find('thead tr:first th')
+ .attr('colspan', this.previous_colspan);
+ this.previous_colspan = null;
+ }
}
});
openerp.web.ListView.List = openerp.web.Class.extend( /** @lends openerp.web.ListView.List# */{
@@ -630,7 +682,9 @@ openerp.web.ListView.List = openerp.web.Class.extend( /** @lends openerp.web.Lis
* Triggered when a row of the table is clicked, provides the index (in
* the rows array) and id of the selected record to the handle function.
*
- * @constructs
+ * @constructs openerp.web.ListView.List
+ * @extends openerp.web.Class
+ *
* @param {Object} opts display options, identical to those of :js:class:`openerp.web.ListView`
*/
init: function (group, opts) {
@@ -835,7 +889,9 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L
* Provides events similar to those of
* :js:class:`~openerp.web.ListView.List`
*
- * @constructs
+ * @constructs openerp.web.ListView.Groups
+ * @extends openerp.web.Class
+ *
* @param {openerp.web.ListView} view
* @param {Object} [options]
* @param {Collection} [options.records]
@@ -1168,10 +1224,9 @@ openerp.web.ListView.Groups = openerp.web.Class.extend( /** @lends openerp.web.L
});
/**
- * @class
- * @extends openerp.web.Class
+ * @mixin Events
*/
-var Events = {
+var Events = /** @lends Events# */{
/**
* @param {String} event event to listen to on the current object, null for all events
* @param {Function} handler event handler to bind to the relevant event
@@ -1221,10 +1276,10 @@ var Events = {
};
var Record = openerp.web.Class.extend(/** @lends Record# */{
/**
- * @constructs
+ * @constructs Record
* @extends openerp.web.Class
- * @borrows Events#bind as this.bind
- * @borrows Events#trigger as this.trigger
+ *
+ * @mixes Events
* @param {Object} [data]
*/
init: function (data) {
@@ -1288,10 +1343,10 @@ var Collection = openerp.web.Class.extend(/** @lends Collection# */{
* Using a "dumb" array of records makes synchronization between the
* various serious
*
- * @constructs
+ * @constructs Collection
* @extends openerp.web.Class
- * @borrows Events#bind as this.bind
- * @borrows Events#trigger as this.trigger
+ *
+ * @mixes Events
* @param {Array} [records] records to initialize the collection with
* @param {Object} [options]
*/