From 5ceebbf80cefbe3838fa63c0a061950c4652ef98 Mon Sep 17 00:00:00 2001 From: laurentbarontini Date: Tue, 2 Jun 2026 18:09:55 +0200 Subject: [PATCH] Badge --- dist/tryton-sao.css | 18 ++++++++++++++++-- dist/tryton-sao.js | 42 ++++++++++++++++++++++++++++-------------- tryton-sao.css | 18 ++++++++++++++++-- tryton-sao.js | 42 ++++++++++++++++++++++++++++-------------- 4 files changed, 88 insertions(+), 32 deletions(-) diff --git a/dist/tryton-sao.css b/dist/tryton-sao.css index aec7ff3..900d6bf 100644 --- a/dist/tryton-sao.css +++ b/dist/tryton-sao.css @@ -11774,9 +11774,19 @@ html[theme="default"] .ag-grid-tree-grouping-panel input[type="checkbox"]:after .ag-grid-tree-host .ag-grid-badge-cell { display: flex; align-items: center; + justify-content: center; min-width: 0; } +.ag-grid-tree-host .ag-grid-badge-column-cell { + text-align: center; +} + +.ag-grid-tree-host .ag-grid-badge-column-header .ag-header-cell-label { + justify-content: center; + padding-left: 0; +} + .ag-grid-tree-host .ag-grid-badge { display: inline-flex; align-items: center; @@ -11785,15 +11795,19 @@ html[theme="default"] .ag-grid-tree-grouping-panel input[type="checkbox"]:after padding: 2px 10px; border-radius: 999px; background: #6c757d; - color: #fff; + color: #f7fbf9; font-size: 12px; - font-weight: 700; + font-weight: 500; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.ag-grid-tree-host .ag-grid-badge-bold { + font-weight: 700; +} + .ag-grid-tree-host .ag-grid-right-aligned-header .ag-header-cell-label { justify-content: flex-end; } diff --git a/dist/tryton-sao.js b/dist/tryton-sao.js index 31a8acd..3262cd3 100644 --- a/dist/tryton-sao.js +++ b/dist/tryton-sao.js @@ -24762,16 +24762,21 @@ function eval_pyson(value){ (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 badge_column = this._is_badge_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, + cellClass: badge_column ? 'ag-grid-badge-column-cell' : + (right_aligned ? + 'ag-grid-right-aligned-cell ag-right-aligned-cell' : null), + cellStyle: right_aligned && !badge_column ? + {textAlign: 'right'} : null, + headerClass: badge_column ? 'ag-grid-badge-column-header' : + (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 : @@ -24814,7 +24819,7 @@ function eval_pyson(value){ if (!params.data.__record) { return ''; } - if (this._is_badge_column(column)) { + if (badge_column) { return this._render_badge_cell( column, params.data.__record); } @@ -26079,15 +26084,18 @@ function eval_pyson(value){ color = color === null || color === undefined ? '' : String(color).trim(); var palette = { - red: '#dc3545', - danger: '#dc3545', - orange: '#f59f00', - warning: '#f59f00', + red: '#e06a6a', + danger: '#e06a6a', + coral: '#e06a6a', + orange: '#d99a2b', + warning: '#d99a2b', + amber: '#d99a2b', yellow: '#f1c40f', - green: '#28a745', - success: '#28a745', - blue: '#17a2b8', - info: '#17a2b8', + green: '#2b8c87', + success: '#2b8c87', + teal: '#2b8c87', + blue: '#57c1b9', + info: '#57c1b9', gray: '#6c757d', grey: '#6c757d', muted: '#6c757d', @@ -26101,6 +26109,9 @@ function eval_pyson(value){ var mapped = this._parse_badge_colors(attributes.badge_colors); if (Object.prototype.hasOwnProperty.call(mapped, text)) { color = mapped[text]; + } else if (Object.prototype.hasOwnProperty.call( + mapped, String(text).toLowerCase())) { + color = mapped[String(text).toLowerCase()]; } if (!color && attributes.badge_color_field) { color = this._get_record_field_value( @@ -26139,6 +26150,9 @@ function eval_pyson(value){ 'class': 'ag-grid-badge', 'text': text, }); + if (parseInt(column.attributes.badge_bold || '0', 10)) { + badge.addClass('ag-grid-badge-bold'); + } var colors = this._get_badge_colors(column, record, text); if (colors.background) { badge.css('background-color', colors.background); diff --git a/tryton-sao.css b/tryton-sao.css index aec7ff3..900d6bf 100644 --- a/tryton-sao.css +++ b/tryton-sao.css @@ -11774,9 +11774,19 @@ html[theme="default"] .ag-grid-tree-grouping-panel input[type="checkbox"]:after .ag-grid-tree-host .ag-grid-badge-cell { display: flex; align-items: center; + justify-content: center; min-width: 0; } +.ag-grid-tree-host .ag-grid-badge-column-cell { + text-align: center; +} + +.ag-grid-tree-host .ag-grid-badge-column-header .ag-header-cell-label { + justify-content: center; + padding-left: 0; +} + .ag-grid-tree-host .ag-grid-badge { display: inline-flex; align-items: center; @@ -11785,15 +11795,19 @@ html[theme="default"] .ag-grid-tree-grouping-panel input[type="checkbox"]:after padding: 2px 10px; border-radius: 999px; background: #6c757d; - color: #fff; + color: #f7fbf9; font-size: 12px; - font-weight: 700; + font-weight: 500; line-height: 1.35; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } +.ag-grid-tree-host .ag-grid-badge-bold { + font-weight: 700; +} + .ag-grid-tree-host .ag-grid-right-aligned-header .ag-header-cell-label { justify-content: flex-end; } diff --git a/tryton-sao.js b/tryton-sao.js index 31a8acd..3262cd3 100644 --- a/tryton-sao.js +++ b/tryton-sao.js @@ -24762,16 +24762,21 @@ function eval_pyson(value){ (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 badge_column = this._is_badge_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, + cellClass: badge_column ? 'ag-grid-badge-column-cell' : + (right_aligned ? + 'ag-grid-right-aligned-cell ag-right-aligned-cell' : null), + cellStyle: right_aligned && !badge_column ? + {textAlign: 'right'} : null, + headerClass: badge_column ? 'ag-grid-badge-column-header' : + (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 : @@ -24814,7 +24819,7 @@ function eval_pyson(value){ if (!params.data.__record) { return ''; } - if (this._is_badge_column(column)) { + if (badge_column) { return this._render_badge_cell( column, params.data.__record); } @@ -26079,15 +26084,18 @@ function eval_pyson(value){ color = color === null || color === undefined ? '' : String(color).trim(); var palette = { - red: '#dc3545', - danger: '#dc3545', - orange: '#f59f00', - warning: '#f59f00', + red: '#e06a6a', + danger: '#e06a6a', + coral: '#e06a6a', + orange: '#d99a2b', + warning: '#d99a2b', + amber: '#d99a2b', yellow: '#f1c40f', - green: '#28a745', - success: '#28a745', - blue: '#17a2b8', - info: '#17a2b8', + green: '#2b8c87', + success: '#2b8c87', + teal: '#2b8c87', + blue: '#57c1b9', + info: '#57c1b9', gray: '#6c757d', grey: '#6c757d', muted: '#6c757d', @@ -26101,6 +26109,9 @@ function eval_pyson(value){ var mapped = this._parse_badge_colors(attributes.badge_colors); if (Object.prototype.hasOwnProperty.call(mapped, text)) { color = mapped[text]; + } else if (Object.prototype.hasOwnProperty.call( + mapped, String(text).toLowerCase())) { + color = mapped[String(text).toLowerCase()]; } if (!color && attributes.badge_color_field) { color = this._get_record_field_value( @@ -26139,6 +26150,9 @@ function eval_pyson(value){ 'class': 'ag-grid-badge', 'text': text, }); + if (parseInt(column.attributes.badge_bold || '0', 10)) { + badge.addClass('ag-grid-badge-bold'); + } var colors = this._get_badge_colors(column, record, text); if (colors.background) { badge.css('background-color', colors.background);