diff --git a/dist/tryton-sao.css b/dist/tryton-sao.css index ac068ac..2f243be 100644 --- a/dist/tryton-sao.css +++ b/dist/tryton-sao.css @@ -11757,6 +11757,24 @@ html[theme="default"] .ag-grid-tree-grouping-panel input[type="checkbox"]:after min-width: 0; } +.ag-grid-tree-host .ag-grid-right-aligned-cell, +.ag-grid-tree-host .ag-grid-right-aligned-cell .cell, +.ag-grid-tree-host .ag-grid-right-aligned-cell .widget, +.ag-grid-tree-host .ag-grid-right-aligned-cell .widget > *, +.ag-grid-tree-host .ag-grid-right-aligned-cell .ag-grid-special-cell, +.ag-grid-tree-host .ag-grid-right-aligned-cell .ag-grid-aggregate-cell { + text-align: right; + text-align: end; +} + +.ag-grid-tree-host .ag-grid-right-aligned-cell .cell { + justify-content: flex-end; +} + +.ag-grid-tree-host .ag-grid-right-aligned-header .ag-header-cell-label { + justify-content: flex-end; +} + .ag-grid-tree-host .ag-header-cell-comp-wrapper { padding-left: 6px; } diff --git a/dist/tryton-sao.js b/dist/tryton-sao.js index f8e5a6b..053e32d 100644 --- a/dist/tryton-sao.js +++ b/dist/tryton-sao.js @@ -15037,6 +15037,19 @@ function eval_pyson(value){ var WidgetFactory = Sao.View.FormXMLViewParser.WIDGETS[ attributes.widget]; + if (!WidgetFactory) { + console.error('[FORM][UNKNOWN_WIDGET]', { + viewId: this.view.view_id, + model: this.view.screen && this.view.screen.model_name, + field: name, + widget: attributes.widget, + fieldAttributes: this.field_attrs[name], + attributes: attributes, + node: node.outerHTML, + availableWidgets: Object.keys( + Sao.View.FormXMLViewParser.WIDGETS).sort(), + }); + } var widget = new WidgetFactory(this.view, attributes); if (!this.view.widgets[name]) { this.view.widgets[name] = []; @@ -24748,10 +24761,17 @@ function eval_pyson(value){ var is_hidden = invisible || optional || (column.attributes.name === this.screen.exclude_field); var default_width = this._get_default_column_width(column); + var right_aligned = this._is_right_aligned_column(column); var col_def = { colId: name, field: name, headerName: column.attributes.string || '', + type: right_aligned ? 'rightAligned' : null, + cellClass: right_aligned ? + 'ag-grid-right-aligned-cell ag-right-aligned-cell' : null, + cellStyle: right_aligned ? {textAlign: 'right'} : null, + headerClass: right_aligned ? + 'ag-grid-right-aligned-header ag-right-aligned-header' : null, sortable: !grouping_active && Boolean(column.sortable), filter: grouping_active ? false : this._get_column_filter(column), filterParams: grouping_active ? null : @@ -24810,10 +24830,37 @@ function eval_pyson(value){ }, }; + console.info('[AGGRID][ALIGN_COLUMN]', { + colId: name, + label: column.attributes.string || '', + widget: column.attributes.widget || '', + className: column.class_ || '', + rightAligned: right_aligned, + cellClass: col_def.cellClass, + headerClass: col_def.headerClass, + }); + column_defs.push(col_def); }); return column_defs; }, + _is_right_aligned_column: function(column) { + if (!column || !column.attributes) { + return false; + } + if (column instanceof Sao.View.Tree.IntegerColumn || + column instanceof Sao.View.Tree.FloatColumn) { + return true; + } + if (~['integer', 'float', 'numeric'].indexOf( + column.attributes.widget || '')) { + return true; + } + var name = column.attributes.name || ''; + var label = column.attributes.string || name; + return /amount|quantity|qty|price|premium|discount|tax|debit|credit|balance|solde|total/i.test( + name + ' ' + label); + }, _get_default_column_width: function(column) { var name = column && column.attributes && column.attributes.name || ''; var label = column && column.attributes && diff --git a/tryton-sao.css b/tryton-sao.css index ac068ac..2f243be 100644 --- a/tryton-sao.css +++ b/tryton-sao.css @@ -11757,6 +11757,24 @@ html[theme="default"] .ag-grid-tree-grouping-panel input[type="checkbox"]:after min-width: 0; } +.ag-grid-tree-host .ag-grid-right-aligned-cell, +.ag-grid-tree-host .ag-grid-right-aligned-cell .cell, +.ag-grid-tree-host .ag-grid-right-aligned-cell .widget, +.ag-grid-tree-host .ag-grid-right-aligned-cell .widget > *, +.ag-grid-tree-host .ag-grid-right-aligned-cell .ag-grid-special-cell, +.ag-grid-tree-host .ag-grid-right-aligned-cell .ag-grid-aggregate-cell { + text-align: right; + text-align: end; +} + +.ag-grid-tree-host .ag-grid-right-aligned-cell .cell { + justify-content: flex-end; +} + +.ag-grid-tree-host .ag-grid-right-aligned-header .ag-header-cell-label { + justify-content: flex-end; +} + .ag-grid-tree-host .ag-header-cell-comp-wrapper { padding-left: 6px; } diff --git a/tryton-sao.js b/tryton-sao.js index f8e5a6b..053e32d 100644 --- a/tryton-sao.js +++ b/tryton-sao.js @@ -15037,6 +15037,19 @@ function eval_pyson(value){ var WidgetFactory = Sao.View.FormXMLViewParser.WIDGETS[ attributes.widget]; + if (!WidgetFactory) { + console.error('[FORM][UNKNOWN_WIDGET]', { + viewId: this.view.view_id, + model: this.view.screen && this.view.screen.model_name, + field: name, + widget: attributes.widget, + fieldAttributes: this.field_attrs[name], + attributes: attributes, + node: node.outerHTML, + availableWidgets: Object.keys( + Sao.View.FormXMLViewParser.WIDGETS).sort(), + }); + } var widget = new WidgetFactory(this.view, attributes); if (!this.view.widgets[name]) { this.view.widgets[name] = []; @@ -24748,10 +24761,17 @@ function eval_pyson(value){ var is_hidden = invisible || optional || (column.attributes.name === this.screen.exclude_field); var default_width = this._get_default_column_width(column); + var right_aligned = this._is_right_aligned_column(column); var col_def = { colId: name, field: name, headerName: column.attributes.string || '', + type: right_aligned ? 'rightAligned' : null, + cellClass: right_aligned ? + 'ag-grid-right-aligned-cell ag-right-aligned-cell' : null, + cellStyle: right_aligned ? {textAlign: 'right'} : null, + headerClass: right_aligned ? + 'ag-grid-right-aligned-header ag-right-aligned-header' : null, sortable: !grouping_active && Boolean(column.sortable), filter: grouping_active ? false : this._get_column_filter(column), filterParams: grouping_active ? null : @@ -24810,10 +24830,37 @@ function eval_pyson(value){ }, }; + console.info('[AGGRID][ALIGN_COLUMN]', { + colId: name, + label: column.attributes.string || '', + widget: column.attributes.widget || '', + className: column.class_ || '', + rightAligned: right_aligned, + cellClass: col_def.cellClass, + headerClass: col_def.headerClass, + }); + column_defs.push(col_def); }); return column_defs; }, + _is_right_aligned_column: function(column) { + if (!column || !column.attributes) { + return false; + } + if (column instanceof Sao.View.Tree.IntegerColumn || + column instanceof Sao.View.Tree.FloatColumn) { + return true; + } + if (~['integer', 'float', 'numeric'].indexOf( + column.attributes.widget || '')) { + return true; + } + var name = column.attributes.name || ''; + var label = column.attributes.string || name; + return /amount|quantity|qty|price|premium|discount|tax|debit|credit|balance|solde|total/i.test( + name + ' ' + label); + }, _get_default_column_width: function(column) { var name = column && column.attributes && column.attributes.name || ''; var label = column && column.attributes &&