2011-03-30 14:35:56 +00:00
|
|
|
openerp.base.list = function (openerp) {
|
2011-03-31 15:25:31 +00:00
|
|
|
openerp.base.views.add('list', 'openerp.base.ListView');
|
2011-04-07 12:12:22 +00:00
|
|
|
openerp.base.ListView = openerp.base.Controller.extend(
|
|
|
|
/** @lends openerp.base.ListView# */ {
|
|
|
|
defaults: {
|
|
|
|
// records can be selected one by one
|
2011-04-07 13:27:26 +00:00
|
|
|
'selectable': true,
|
2011-04-07 15:13:19 +00:00
|
|
|
// list rows can be deleted
|
|
|
|
'deletable': true,
|
2011-04-07 13:27:26 +00:00
|
|
|
// whether the column headers should be displayed
|
2011-04-12 13:02:29 +00:00
|
|
|
'header': true,
|
|
|
|
// display addition button, with that label
|
2011-04-21 12:06:08 +00:00
|
|
|
'addable': "New",
|
|
|
|
// whether the list view can be sorted, note that once a view has been
|
|
|
|
// sorted it can not be reordered anymore
|
|
|
|
'sortable': true,
|
|
|
|
// whether the view rows can be reordered (via vertical drag & drop)
|
|
|
|
'reorderable': true
|
2011-04-07 12:12:22 +00:00
|
|
|
},
|
|
|
|
/**
|
2011-04-21 11:59:24 +00:00
|
|
|
* Core class for list-type displays.
|
|
|
|
*
|
|
|
|
* As a view, needs a number of view-related parameters to be correctly
|
|
|
|
* instantiated, provides options and overridable methods for behavioral
|
|
|
|
* customization.
|
|
|
|
*
|
|
|
|
* See constructor parameters and method documentations for information on
|
|
|
|
* the default behaviors and possible options for the list view.
|
|
|
|
*
|
2011-04-07 12:12:22 +00:00
|
|
|
* @constructs
|
|
|
|
* @param view_manager
|
|
|
|
* @param session An OpenERP session object
|
|
|
|
* @param element_id the id of the DOM elements this view should link itself to
|
|
|
|
* @param {openerp.base.DataSet} dataset the dataset the view should work with
|
|
|
|
* @param {String} view_id the listview's identifier, if any
|
|
|
|
* @param {Object} options A set of options used to configure the view
|
|
|
|
* @param {Boolean} [options.selectable=true] determines whether view rows are selectable (e.g. via a checkbox)
|
2011-04-07 13:27:26 +00:00
|
|
|
* @param {Boolean} [options.header=true] should the list's header be displayed
|
2011-04-07 15:13:19 +00:00
|
|
|
* @param {Boolean} [options.deletable=true] are the list rows deletable
|
2011-04-12 13:02:29 +00:00
|
|
|
* @param {null|String} [options.addable="New"] should the new-record button be displayed, and what should its label be. Use ``null`` to hide the button.
|
2011-04-21 12:06:08 +00:00
|
|
|
* @param {Boolean} [options.sortable=true] is it possible to sort the table by clicking on column headers
|
|
|
|
* @param {Boolean} [options.reorderable=true] is it possible to reorder list rows
|
2011-05-04 09:23:51 +00:00
|
|
|
*
|
|
|
|
* @borrows openerp.base.ActionExecutor#execute_action as #execute_action
|
2011-04-07 12:12:22 +00:00
|
|
|
*/
|
|
|
|
init: function(view_manager, session, element_id, dataset, view_id, options) {
|
2011-05-06 12:28:37 +00:00
|
|
|
var self = this;
|
2011-03-30 14:00:48 +00:00
|
|
|
this._super(session, element_id);
|
2011-04-04 13:47:05 +00:00
|
|
|
this.view_manager = view_manager;
|
2011-03-30 14:00:48 +00:00
|
|
|
this.dataset = dataset;
|
|
|
|
this.model = dataset.model;
|
|
|
|
this.view_id = view_id;
|
|
|
|
|
2011-04-06 13:58:37 +00:00
|
|
|
this.columns = [];
|
|
|
|
this.rows = [];
|
2011-03-30 14:00:48 +00:00
|
|
|
|
2011-04-07 12:12:22 +00:00
|
|
|
this.options = _.extend({}, this.defaults, options || {});
|
2011-05-06 12:28:37 +00:00
|
|
|
|
|
|
|
this.list = new openerp.base.ListView.List({
|
|
|
|
options: this.options,
|
|
|
|
columns: this.columns,
|
|
|
|
rows: this.rows
|
|
|
|
});
|
|
|
|
$(this.list).bind({
|
|
|
|
'selected': function (e, selection) {
|
|
|
|
self.$element.find('#oe-list-delete')
|
|
|
|
.toggle(!!selection.length);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-03-30 14:00:48 +00:00
|
|
|
},
|
2011-04-21 11:59:24 +00:00
|
|
|
/**
|
|
|
|
* View startup method, the default behavior is to set the ``oe-listview``
|
|
|
|
* class on its root element and to perform an RPC load call.
|
|
|
|
*
|
|
|
|
* @returns {$.Deferred} loading promise
|
|
|
|
*/
|
2011-03-30 14:00:48 +00:00
|
|
|
start: function() {
|
2011-04-12 09:22:22 +00:00
|
|
|
this.$element.addClass('oe-listview');
|
2011-04-21 11:59:24 +00:00
|
|
|
return this.rpc("/base/listview/load", {
|
|
|
|
model: this.model,
|
|
|
|
view_id: this.view_id,
|
2011-04-22 15:54:52 +00:00
|
|
|
toolbar: this.view_manager ? !!this.view_manager.sidebar : false
|
2011-04-21 11:59:24 +00:00
|
|
|
}, this.on_loaded);
|
2011-03-30 14:00:48 +00:00
|
|
|
},
|
2011-04-21 11:59:24 +00:00
|
|
|
/**
|
|
|
|
* Called after loading the list view's description, sets up such things
|
|
|
|
* as the view table's columns, renders the table itself and hooks up the
|
|
|
|
* various table-level and row-level DOM events (action buttons, deletion
|
|
|
|
* buttons, selection of records, [New] button, selection of a given
|
|
|
|
* record, ...)
|
|
|
|
*
|
|
|
|
* Sets up the following:
|
|
|
|
*
|
|
|
|
* * Processes arch and fields to generate a complete field descriptor for each field
|
|
|
|
* * Create the table itself and allocate visible columns
|
|
|
|
* * Hook in the top-level (header) [New|Add] and [Delete] button
|
|
|
|
* * Sets up showing/hiding the top-level [Delete] button based on records being selected or not
|
|
|
|
* * Sets up event handlers for action buttons and per-row deletion button
|
|
|
|
* * Hooks global callback for clicking on a row
|
|
|
|
* * Sets up its sidebar, if any
|
|
|
|
*
|
|
|
|
* @param {Object} data wrapped fields_view_get result
|
|
|
|
* @param {Object} data.fields_view fields_view_get result (processed)
|
|
|
|
* @param {Object} data.fields_view.fields mapping of fields for the current model
|
|
|
|
* @param {Object} data.fields_view.arch current list view descriptor
|
|
|
|
*/
|
2011-03-30 14:00:48 +00:00
|
|
|
on_loaded: function(data) {
|
2011-04-12 14:55:16 +00:00
|
|
|
var self = this;
|
2011-03-30 14:00:48 +00:00
|
|
|
this.fields_view = data.fields_view;
|
|
|
|
//this.log(this.fields_view);
|
|
|
|
this.name = "" + this.fields_view.arch.attrs.string;
|
|
|
|
|
2011-04-06 13:58:37 +00:00
|
|
|
var fields = this.fields_view.fields;
|
2011-04-12 06:53:43 +00:00
|
|
|
var domain_computer = openerp.base.form.compute_domain;
|
2011-05-06 12:28:37 +00:00
|
|
|
|
|
|
|
this.columns.splice(0, this.columns.length);
|
|
|
|
this.columns.push.apply(this.columns, _(this.fields_view.arch.children).chain()
|
2011-04-06 13:58:37 +00:00
|
|
|
.map(function (field) {
|
|
|
|
var name = field.attrs.name;
|
2011-04-12 06:53:43 +00:00
|
|
|
var column = _.extend({id: name, tag: field.tag},
|
|
|
|
field.attrs, fields[name]);
|
|
|
|
// attrs computer
|
|
|
|
if (column.attrs) {
|
|
|
|
var attrs = eval('(' + column.attrs + ')');
|
|
|
|
column.attrs_for = function (fields) {
|
|
|
|
var result = {};
|
|
|
|
for (var attr in attrs) {
|
|
|
|
result[attr] = domain_computer(attrs[attr], fields);
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
column.attrs_for = function () { return {}; };
|
|
|
|
}
|
|
|
|
return column;
|
2011-05-06 12:28:37 +00:00
|
|
|
}).value());
|
2011-04-06 13:58:37 +00:00
|
|
|
|
2011-04-07 15:35:27 +00:00
|
|
|
this.visible_columns = _.filter(this.columns, function (column) {
|
|
|
|
return column.invisible !== '1';
|
|
|
|
});
|
2011-05-04 14:47:53 +00:00
|
|
|
|
|
|
|
if (!this.fields_view.sorted) { this.fields_view.sorted = {}; }
|
2011-05-06 12:28:37 +00:00
|
|
|
|
2011-04-06 13:58:37 +00:00
|
|
|
this.$element.html(QWeb.render("ListView", this));
|
2011-04-07 15:35:27 +00:00
|
|
|
|
|
|
|
// Head hook
|
2011-04-12 13:02:29 +00:00
|
|
|
this.$element.find('#oe-list-add').click(this.do_add_record);
|
2011-04-12 12:24:02 +00:00
|
|
|
this.$element.find('#oe-list-delete')
|
|
|
|
.hide()
|
|
|
|
.click(this.do_delete_selected);
|
2011-05-04 14:05:35 +00:00
|
|
|
this.$element.find('thead').delegate('th[data-id]', 'click', function (e) {
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
self.dataset.sort($(this).data('id'));
|
|
|
|
|
2011-05-04 14:47:53 +00:00
|
|
|
// TODO: should only reload content (and set the right column to a sorted display state)
|
2011-05-04 14:05:35 +00:00
|
|
|
self.do_reload();
|
|
|
|
});
|
2011-04-07 15:35:27 +00:00
|
|
|
|
2011-04-12 12:24:02 +00:00
|
|
|
var $table = this.$element.find('table');
|
2011-05-06 12:28:37 +00:00
|
|
|
this.list.move_to($table);
|
2011-04-07 15:35:27 +00:00
|
|
|
// Cell events
|
2011-04-12 14:55:16 +00:00
|
|
|
$table.delegate(
|
|
|
|
'td.oe-field-cell button', 'click', function (e) {
|
2011-05-04 09:23:51 +00:00
|
|
|
e.stopImmediatePropagation();
|
|
|
|
|
2011-04-12 14:55:16 +00:00
|
|
|
var $cell = $(e.currentTarget).closest('td');
|
2011-05-04 09:23:51 +00:00
|
|
|
|
2011-04-12 14:55:16 +00:00
|
|
|
var col_index = $cell.prevAll('td').length;
|
|
|
|
var field = self.visible_columns[col_index];
|
|
|
|
|
|
|
|
var $row = $cell.parent('tr');
|
|
|
|
var row = self.rows[$row.prevAll().length];
|
|
|
|
|
2011-05-04 09:23:51 +00:00
|
|
|
// TODO: we should probably only reload content, also maybe diff records or something, instead of replacing every single row
|
|
|
|
self.execute_action(
|
|
|
|
field, self.dataset, self.session.action_manager,
|
|
|
|
row.data.id.value, self.do_reload);
|
2011-04-12 14:55:16 +00:00
|
|
|
});
|
2011-04-12 12:24:02 +00:00
|
|
|
$table.delegate(
|
2011-04-07 15:13:19 +00:00
|
|
|
'td.oe-record-delete button', 'click', this.do_delete);
|
2011-04-07 15:35:27 +00:00
|
|
|
|
|
|
|
// Global rows handlers
|
2011-05-06 12:28:37 +00:00
|
|
|
$table.delegate('tr', 'click', this.on_select_row);
|
2011-03-30 14:00:48 +00:00
|
|
|
|
2011-04-04 13:47:05 +00:00
|
|
|
// sidebar stuff
|
2011-04-22 15:54:52 +00:00
|
|
|
if (this.view_manager && this.view_manager.sidebar) {
|
2011-04-06 14:47:51 +00:00
|
|
|
this.view_manager.sidebar.set_toolbar(data.fields_view.toolbar);
|
|
|
|
}
|
2011-03-30 14:00:48 +00:00
|
|
|
},
|
2011-04-07 12:12:22 +00:00
|
|
|
/**
|
|
|
|
* Fills the table with the provided records after emptying it
|
|
|
|
*
|
2011-04-21 11:59:24 +00:00
|
|
|
* TODO: should also re-load the table itself, as e.g. columns may have changed
|
|
|
|
*
|
2011-04-21 13:12:39 +00:00
|
|
|
* @param {Object} result filling result
|
|
|
|
* @param {Array} [result.view] the new view (wrapped fields_view_get result)
|
|
|
|
* @param {Array} result.records records the records to fill the list view with
|
2011-04-07 12:12:22 +00:00
|
|
|
*/
|
2011-04-21 13:12:39 +00:00
|
|
|
do_fill_table: function(result) {
|
2011-04-21 13:13:28 +00:00
|
|
|
if (result.view) {
|
|
|
|
this.on_loaded({fields_view: result.view});
|
|
|
|
}
|
2011-04-21 13:12:39 +00:00
|
|
|
var records = result.records;
|
2011-05-06 12:28:37 +00:00
|
|
|
|
|
|
|
this.rows.splice(0, this.rows.length);
|
|
|
|
this.rows.push.apply(this.rows, records);
|
2011-04-12 14:08:29 +00:00
|
|
|
|
|
|
|
// Keep current selected record, if it's still in our new search
|
|
|
|
var current_record_id = this.dataset.ids[this.dataset.index];
|
2011-04-12 06:53:43 +00:00
|
|
|
this.dataset.ids = _(records).chain().map(function (record) {
|
|
|
|
return record.data.id.value;
|
|
|
|
}).value();
|
2011-04-12 14:08:29 +00:00
|
|
|
this.dataset.index = _.indexOf(this.dataset.ids, current_record_id);
|
2011-04-13 07:45:39 +00:00
|
|
|
if (this.dataset.index < 0) {
|
2011-04-12 14:08:29 +00:00
|
|
|
this.dataset.index = 0;
|
|
|
|
}
|
2011-04-13 07:45:39 +00:00
|
|
|
|
|
|
|
this.dataset.count = this.dataset.ids.length;
|
2011-04-12 12:34:07 +00:00
|
|
|
var results = this.rows.length;
|
2011-05-06 12:28:37 +00:00
|
|
|
this.$element.find('table')
|
|
|
|
.find('.oe-pager-last').text(results).end()
|
|
|
|
.find('.oe-pager-total').text(results);
|
2011-04-07 12:12:22 +00:00
|
|
|
|
2011-05-06 12:28:37 +00:00
|
|
|
this.list.refresh();
|
2011-03-31 14:44:22 +00:00
|
|
|
},
|
2011-04-12 13:02:29 +00:00
|
|
|
/**
|
2011-04-21 11:59:24 +00:00
|
|
|
* Used to handle a click on a table row, if no other handler caught the
|
|
|
|
* event.
|
|
|
|
*
|
|
|
|
* The default implementation asks the list view's view manager to switch
|
|
|
|
* to a different view (by calling
|
|
|
|
* :js:func:`~openerp.base.ViewManager.on_mode_switch`), using the
|
|
|
|
* provided record index (within the current list view's dataset).
|
2011-04-12 13:02:29 +00:00
|
|
|
*
|
|
|
|
* If the index is null, ``switch_to_record`` asks for the creation of a
|
|
|
|
* new record.
|
|
|
|
*
|
|
|
|
* @param {Number|null} index the record index (in the current dataset) to switch to
|
2011-04-21 11:59:24 +00:00
|
|
|
* @param {String} [view="form"] the view type to switch to
|
2011-04-12 13:02:29 +00:00
|
|
|
*/
|
|
|
|
switch_to_record:function (index, view) {
|
|
|
|
view = view || 'form';
|
|
|
|
this.dataset.index = index;
|
|
|
|
_.delay(_.bind(function () {
|
2011-04-22 15:54:52 +00:00
|
|
|
if(this.view_manager) {
|
|
|
|
this.view_manager.on_mode_switch(view);
|
|
|
|
}
|
2011-04-12 13:02:29 +00:00
|
|
|
}, this));
|
|
|
|
},
|
2011-04-21 11:59:24 +00:00
|
|
|
/**
|
|
|
|
* Base handler for clicking on a row, discovers the index of the record
|
|
|
|
* corresponding to the clicked row in the list view's dataset.
|
|
|
|
*
|
|
|
|
* Should not be overridden, use
|
|
|
|
* :js:func:`~openerp.base.ListView.switch_to_record` to customize the
|
|
|
|
* behavior of the list view when clicking on a row instead.
|
|
|
|
*
|
|
|
|
* @param {Object} event jQuery DOM event object
|
|
|
|
*/
|
2011-04-07 06:07:20 +00:00
|
|
|
on_select_row: function (event) {
|
2011-04-07 09:09:00 +00:00
|
|
|
var $target = $(event.currentTarget);
|
|
|
|
if (!$target.parent().is('tbody')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// count number of preceding siblings to line clicked
|
|
|
|
var row = this.rows[$target.prevAll().length];
|
2011-04-07 06:07:20 +00:00
|
|
|
|
2011-04-12 06:53:43 +00:00
|
|
|
var index = _.indexOf(this.dataset.ids, row.data.id.value);
|
2011-04-07 06:07:20 +00:00
|
|
|
if (index == undefined || index === -1) {
|
|
|
|
return;
|
|
|
|
}
|
2011-04-21 11:59:24 +00:00
|
|
|
this.switch_to_record(index);
|
|
|
|
},
|
2011-04-04 15:34:26 +00:00
|
|
|
do_show: function () {
|
|
|
|
this.$element.show();
|
2011-04-12 14:08:29 +00:00
|
|
|
if (this.hidden) {
|
|
|
|
this.do_reload();
|
|
|
|
this.hidden = false;
|
|
|
|
}
|
2011-04-04 15:34:26 +00:00
|
|
|
},
|
|
|
|
do_hide: function () {
|
|
|
|
this.$element.hide();
|
2011-04-12 14:08:29 +00:00
|
|
|
this.hidden = true;
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* Reloads the search view based on the current settings (dataset & al)
|
|
|
|
*/
|
|
|
|
do_reload: function () {
|
|
|
|
// TODO: need to do 5 billion tons of pre-processing, bypass
|
|
|
|
// DataSet for now
|
|
|
|
//self.dataset.read_slice(self.dataset.fields, 0, self.limit,
|
|
|
|
// self.do_fill_table);
|
2011-04-13 11:45:06 +00:00
|
|
|
this.dataset.offset = 0;
|
|
|
|
this.dataset.limit = false;
|
2011-04-12 14:08:29 +00:00
|
|
|
return this.rpc('/base/listview/fill', {
|
|
|
|
'model': this.dataset.model,
|
|
|
|
'id': this.view_id,
|
|
|
|
'context': this.dataset.context,
|
2011-05-04 14:05:35 +00:00
|
|
|
'domain': this.dataset.domain,
|
|
|
|
'sort': this.dataset.sort && this.dataset.sort()
|
2011-04-12 14:08:29 +00:00
|
|
|
}, this.do_fill_table);
|
2011-04-04 15:34:26 +00:00
|
|
|
},
|
2011-04-21 11:59:24 +00:00
|
|
|
/**
|
|
|
|
* Event handler for a search, asks for the computation/folding of domains
|
|
|
|
* and contexts (and group-by), then reloads the view's content.
|
|
|
|
*
|
|
|
|
* @param {Array} domains a sequence of literal and non-literal domains
|
|
|
|
* @param {Array} contexts a sequence of literal and non-literal contexts
|
|
|
|
* @param {Array} groupbys a sequence of literal and non-literal group-by contexts
|
|
|
|
* @returns {$.Deferred} fold request evaluation promise
|
|
|
|
*/
|
2011-03-31 14:44:22 +00:00
|
|
|
do_search: function (domains, contexts, groupbys) {
|
|
|
|
var self = this;
|
2011-04-12 14:08:29 +00:00
|
|
|
return this.rpc('/base/session/eval_domain_and_context', {
|
2011-03-31 14:44:22 +00:00
|
|
|
domains: domains,
|
|
|
|
contexts: contexts,
|
|
|
|
group_by_seq: groupbys
|
|
|
|
}, function (results) {
|
|
|
|
// TODO: handle non-empty results.group_by with read_group
|
2011-04-04 15:06:19 +00:00
|
|
|
self.dataset.context = results.context;
|
|
|
|
self.dataset.domain = results.domain;
|
2011-04-12 14:08:29 +00:00
|
|
|
return self.do_reload();
|
2011-03-31 14:44:22 +00:00
|
|
|
});
|
2011-04-05 10:38:35 +00:00
|
|
|
},
|
|
|
|
do_update: function () {
|
|
|
|
var self = this;
|
2011-04-12 14:34:51 +00:00
|
|
|
//self.dataset.read_ids(self.dataset.ids, self.dataset.fields, self.do_fill_table);
|
2011-04-07 12:46:39 +00:00
|
|
|
},
|
2011-04-07 15:13:19 +00:00
|
|
|
/**
|
|
|
|
* Handles the signal to delete a line from the DOM
|
|
|
|
*
|
2011-04-21 11:59:24 +00:00
|
|
|
* @param e jQuery event object
|
2011-04-07 15:13:19 +00:00
|
|
|
*/
|
|
|
|
do_delete: function (e) {
|
|
|
|
// don't link to forms
|
|
|
|
e.stopImmediatePropagation();
|
|
|
|
this.dataset.unlink(
|
2011-04-12 08:20:28 +00:00
|
|
|
[this.rows[$(e.currentTarget).closest('tr').prevAll().length].data.id.value]);
|
2011-04-07 15:13:19 +00:00
|
|
|
},
|
2011-04-12 13:02:29 +00:00
|
|
|
/**
|
|
|
|
* Handles signal for the addition of a new record (can be a creation,
|
|
|
|
* can be the addition from a remote source, ...)
|
|
|
|
*
|
|
|
|
* The default implementation is to switch to a new record on the form view
|
|
|
|
*/
|
|
|
|
do_add_record: function () {
|
2011-04-12 13:21:20 +00:00
|
|
|
this.notification.notify('Add', "New record");
|
|
|
|
this.switch_to_record(null);
|
2011-04-12 13:02:29 +00:00
|
|
|
},
|
2011-04-07 15:35:27 +00:00
|
|
|
/**
|
|
|
|
* Handles deletion of all selected lines
|
|
|
|
*/
|
|
|
|
do_delete_selected: function () {
|
2011-05-06 12:28:37 +00:00
|
|
|
var selection = this.list.get_selection();
|
2011-04-07 15:35:27 +00:00
|
|
|
if (selection.length) {
|
|
|
|
this.dataset.unlink(selection);
|
|
|
|
}
|
2011-05-06 12:28:37 +00:00
|
|
|
}
|
|
|
|
// TODO: implement reorder (drag and drop rows)
|
|
|
|
});
|
|
|
|
_.extend(openerp.base.ListView.prototype, openerp.base.ActionExecutor);
|
|
|
|
|
|
|
|
openerp.base.ListView.List = Class.extend({
|
|
|
|
init: function (opts) {
|
|
|
|
var self = this;
|
|
|
|
// columns, rows, options
|
|
|
|
|
|
|
|
this.options = opts.options;
|
|
|
|
this.columns = opts.columns;
|
|
|
|
this.rows = opts.rows;
|
|
|
|
|
|
|
|
this.$_element = $('<tbody class="ui-widget-content">')
|
|
|
|
.appendTo(document.body)
|
|
|
|
.delegate('th.oe-record-selector', 'click', function (e) {
|
|
|
|
e.stopImmediatePropagation();
|
|
|
|
$(self).trigger('selected', [self.get_selection()]);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
move_to: function (element) {
|
|
|
|
this.$current = this.$_element.clone(true).appendTo(element);
|
|
|
|
this.render();
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
render: function () {
|
|
|
|
this.$current.empty().append($(QWeb.render('ListView.rows', this)));
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
refresh: function () {
|
|
|
|
this.render();
|
|
|
|
return this;
|
2011-04-07 15:35:27 +00:00
|
|
|
},
|
2011-04-07 12:46:39 +00:00
|
|
|
/**
|
|
|
|
* Gets the ids of all currently selected records, if any
|
2011-04-21 11:59:24 +00:00
|
|
|
* @returns {Array} empty if no record is selected (or the list view is not selectable)
|
2011-04-07 12:46:39 +00:00
|
|
|
*/
|
|
|
|
get_selection: function () {
|
|
|
|
if (!this.options.selectable) {
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
var rows = this.rows;
|
2011-05-06 12:28:37 +00:00
|
|
|
return this.$current.find('th.oe-record-selector input:checked')
|
2011-04-07 12:46:39 +00:00
|
|
|
.closest('tr').map(function () {
|
2011-04-12 08:20:28 +00:00
|
|
|
return rows[$(this).prevAll().length].data.id.value;
|
2011-04-07 12:46:39 +00:00
|
|
|
}).get();
|
2011-03-30 14:00:48 +00:00
|
|
|
}
|
2011-05-06 12:28:37 +00:00
|
|
|
// Click events: action, delete, row itself
|
|
|
|
// drag and drop
|
|
|
|
// editable?
|
2011-03-30 14:00:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
openerp.base.TreeView = openerp.base.Controller.extend({
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
// vim:et fdc=0 fdl=0 foldnestmax=3 fdm=syntax:
|