Skip to content
Permalink
Browse files

[IMP]web: Few cosmetic changes and document string added

  • Loading branch information...
msh-odoo committed Mar 20, 2019
1 parent dd98385 commit 69f5e3585944d964db7738017c9c35a1b1d7663e
@@ -474,7 +474,7 @@ ListRenderer.include({
// is trash icon available, we will have optional dropdown icon on header and all rows
// of tbody will have trash icon, so if trash icon and optionalColumns available then n--
if (this.addTrashIcon && this.optionalColumns) {
n--
n--;
}
return n;
},
@@ -565,9 +565,7 @@ ListRenderer.include({
*/
_renderOptionalCell: function ($cells) {
if (!this.addTrashIcon) {
$cells.push($("<td/>", {
class: 'o-data-cell',
}));
$cells.push($("<td/>"));
}
},
/**
@@ -790,7 +788,14 @@ ListRenderer.include({
// Handlers
//--------------------------------------------------------------------------

/**
* override this method to unselect row before optional column added to listview
*
* @override
* @private
*/
_onAddColumn: function (ev) {
var self = this;
var _super = this._super.bind(this);
this.unselectRow().then(function () {
_super.apply(self, [ev]);
@@ -171,18 +171,30 @@ var ListRenderer = BasicRenderer.extend({
};
}
},
/**
* This method computes non optional columns i.e. columns which are going to display
* in list view
*
* @private
*/
_computeColumns: function () {
var self = this;
return _.filter(this.allColumns, function (col) {
return !(col.attrs.optional && !!JSON.parse(col.attrs.optional))
|| (col.attrs.modifiers && col.attrs.modifiers.required)
|| _.contains(self.optionalColumnsEnabled, col.attrs.name)
|| _.contains(self.optionalColumnsEnabled, col.attrs.name);
});
},
/**
* This method computes optional columns i.e. columns which displayed
* inside optional dropdown in list view header
*
* @private
*/
_computeOptionalColumns: function () {
return _.filter(this.allColumns, function (col) {
return (col.attrs.optional && !!JSON.parse(col.attrs.optional))
&& !(col.attrs.modifiers && col.attrs.modifiers.required)
&& !(col.attrs.modifiers && col.attrs.modifiers.required);
});
},
/**
@@ -450,7 +462,7 @@ var ListRenderer = BasicRenderer.extend({
if (this.hasSelectors) {
$cells.unshift($('<td>'));
}
if (this.optionalColumns) {
if (this.optionalColumns && this.optionalColumns.length) {
this._renderOptionalCell($cells);
}
return $('<tfoot>').append($('<tr>').append($cells));
@@ -655,9 +667,7 @@ var ListRenderer = BasicRenderer.extend({
* @private
*/
_renderOptionalCell: function ($cells) {
$cells.push($("<td/>", {
class: 'o-data-cell',
}));
$cells.push($("<td/>"));
},
/**
* Render a row, corresponding to a record.
@@ -671,7 +681,7 @@ var ListRenderer = BasicRenderer.extend({
var $cells = this.columns.map(function (node, index) {
return self._renderBodyCell(record, node, index, { mode: 'readonly' });
});
if (this.optionalColumns) {
if (this.optionalColumns && this.optionalColumns.length) {
this._renderOptionalCell($cells);
}

@@ -835,7 +845,6 @@ var ListRenderer = BasicRenderer.extend({
* @param {MouseEvent} ev
*/
_onAddColumn: function (ev) {
var self = this;
var currentElement = ev.currentTarget;
if (!currentElement.checked) {
this.trigger_up('toggle_optional_column', {id: this.state.id, name: currentElement.name});

0 comments on commit 69f5e35

Please sign in to comment.
You can’t perform that action at this time.