Browse Source

Report templates: added border color, width and style settings for table columns, and a double line style for borders and dividers (#16287)

* Changes for reporting tables

* Added min and step to border width

* Removed borderRadius - not supported in peropting library

* Returned background color

* Style changes

* Changes after review

* Fixes after review

* Set min value for DOUBLE border type

* Enforce double-border 3 px minimum at config time, not render time

* Treat double border width as single-line thickness instead of enforcing a 3px minimum

Width now means the thickness of each line; a double border is rendered
as two such lines with an equal gap (CSS width = width x 3), matching how
Word stores double border widths. This removes the dynamic-form validator
extension and the divider min-width validation, and shows a hint only
when Double is selected.

---------

Co-authored-by: Vladyslav_Prykhodko <vprykhodko@thingsboard.io>
pull/16644/head
Valeriia Koriavikova 3 weeks ago
committed by GitHub
parent
commit
cc1f9976d5
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 4
      common/data/src/main/java/org/thingsboard/server/common/data/report/configuration/CellSettings.java
  2. 14
      common/data/src/main/java/org/thingsboard/server/common/data/report/configuration/style/BorderType.java
  3. 6
      common/report/src/main/java/org/thingsboard/server/report/renderer/DividerRenderer.java
  4. 95
      common/report/src/main/java/org/thingsboard/server/report/renderer/TableWithLayoutComponentRenderer.java
  5. 20
      common/report/src/main/resources/html/components/table-template.html
  6. 4
      ui-ngx/src/app/modules/home/pages/reporting/template/components/alarm-table-preview.component.ts
  7. 3
      ui-ngx/src/app/modules/home/pages/reporting/template/components/divider-config.component.html
  8. 3
      ui-ngx/src/app/modules/home/pages/reporting/template/components/divider-config.component.ts
  9. 7
      ui-ngx/src/app/modules/home/pages/reporting/template/components/divider-preview.component.ts
  10. 4
      ui-ngx/src/app/modules/home/pages/reporting/template/components/entity-table-preview.component.ts
  11. 8
      ui-ngx/src/app/modules/home/pages/reporting/template/components/report-table-preview.component.html
  12. 44
      ui-ngx/src/app/modules/home/pages/reporting/template/components/report-table-preview.component.ts
  13. 4
      ui-ngx/src/app/modules/home/pages/reporting/template/components/timeseries-table-preview.component.ts
  14. 2
      ui-ngx/src/app/shared/models/dynamic-form.models.ts
  15. 82
      ui-ngx/src/app/shared/models/report-component.models.ts
  16. 3
      ui-ngx/src/assets/locale/locale.constant-en_US.json

4
common/data/src/main/java/org/thingsboard/server/common/data/report/configuration/CellSettings.java

@ -3,6 +3,7 @@
package org.thingsboard.server.common.data.report.configuration;
import lombok.Data;
import org.thingsboard.server.common.data.report.configuration.style.BorderType;
import org.thingsboard.server.common.data.report.configuration.style.Font;
import org.thingsboard.server.common.data.report.configuration.style.TextAlignment;
import org.thingsboard.server.common.data.report.configuration.style.VerticalAlignment;
@ -15,5 +16,8 @@ public class CellSettings {
private String backgroundColor;
private TextAlignment textAlignment;
private VerticalAlignment verticalAlignment;
private BorderType borderType;
private Integer borderWidth;
private String borderColor;
}

14
common/data/src/main/java/org/thingsboard/server/common/data/report/configuration/style/BorderType.java

@ -8,7 +8,7 @@ import lombok.Getter;
public enum BorderType {
SOLID("solid"), DASHED("dashed"), DOTTED("dotted");
SOLID("solid"), DASHED("dashed"), DOTTED("dotted"), DOUBLE("double");
@Getter
private final String value;
@ -22,6 +22,18 @@ public enum BorderType {
return value;
}
/**
* Converts the configured width into the CSS border-width.
* <p>
* The configured width is the thickness of a single line. For {@link #DOUBLE} the border is drawn as
* two lines of that thickness with an equal gap between them, so the CSS width is three times larger.
* This matches how Word stores the width of double borders (LibreOffice multiplies it by 3 when importing
* Word documents). CSS uses the total width instead, so a "1px double" border would render as a single solid line.
*/
public int toCssWidth(int lineWidth) {
return this == DOUBLE ? lineWidth * 3 : lineWidth;
}
@JsonCreator
public static BorderType fromLabel(String value) {
for (BorderType type : values()) {

6
common/report/src/main/java/org/thingsboard/server/report/renderer/DividerRenderer.java

@ -22,10 +22,10 @@ public class DividerRenderer extends ReportComponentWithLayoutRenderer<DividerCo
protected String renderContent(DividerComponent component, ComponentData reportDataSource) {
HashMap<String, Object> componentVariables = new HashMap<>();
componentVariables.put("width", component.getLength() != null && component.getLength() == SHORT ? "50%" : "100%");
String borderWidth = component.getWidthPx() != null ? component.getWidthPx() + "px" : "1px";
BorderType borderType = component.getBorderType() != null ? component.getBorderType() : BorderType.SOLID;
String borderWidth = borderType.toCssWidth(component.getWidthPx() != null ? component.getWidthPx() : 1) + "px";
String borderColor = component.getColor() != null ? ColorUtils.normalizeCssColor(component.getColor()) : "#000";
String borderType = component.getBorderType() != null ? component.getBorderType().getValue() : BorderType.SOLID.getValue();
componentVariables.put("borderStyle", borderWidth + " " + borderType + " " + borderColor);
componentVariables.put("borderStyle", borderWidth + " " + borderType.getValue() + " " + borderColor);
return ThymeleafUtil.renderFromHtmlTemplate("html/components/divider-template", componentVariables);
}

95
common/report/src/main/java/org/thingsboard/server/report/renderer/TableWithLayoutComponentRenderer.java

@ -15,6 +15,7 @@ import org.thingsboard.server.common.data.report.configuration.DataKeySettings;
import org.thingsboard.server.common.data.report.configuration.DataSource;
import org.thingsboard.server.common.data.report.configuration.TableSortOrder;
import org.thingsboard.server.common.data.report.configuration.components.TableWithLayoutReportComponent;
import org.thingsboard.server.common.data.report.configuration.style.BorderType;
import org.thingsboard.server.common.data.report.configuration.style.Font;
import org.thingsboard.server.common.data.report.configuration.style.FontStyle;
import org.thingsboard.server.common.data.report.configuration.style.FontWeight;
@ -180,22 +181,24 @@ public abstract class TableWithLayoutComponentRenderer<C extends TableWithLayout
protected HashMap<String, CellVariables> buildCellVariables(List<DataKey> columns, boolean isHeader) {
HashMap<String, CellVariables> result = new LinkedHashMap<>();
boolean firstColumn = true;
for (DataKey dataKey : columns) {
result.put(dataKey.getLabel(), toCellVariables(dataKey, isHeader));
result.put(dataKey.getLabel(), toCellVariables(dataKey, isHeader, firstColumn));
firstColumn = false;
}
return result;
}
protected CellVariables toCellVariables(DataKey dataKey, boolean isHeader) {
protected CellVariables toCellVariables(DataKey dataKey, boolean isHeader, boolean isFirstColumn) {
DataKeySettings settings = dataKey.getSettings();
ColumnSettings columnSettings = null;
if (settings instanceof ColumnSettings) {
columnSettings = (ColumnSettings) settings;
}
return toCellVariables(dataKey.getName(), columnSettings, isHeader);
return toCellVariables(dataKey.getName(), columnSettings, isHeader, isFirstColumn);
}
protected CellVariables toCellVariables(String key, ColumnSettings columnSettings, boolean isHeader) {
protected CellVariables toCellVariables(String key, ColumnSettings columnSettings, boolean isHeader, boolean isFirstColumn) {
if (columnSettings != null) {
CellVariables cellVariables;
CellSettings cellSettings = isHeader ? columnSettings.getHeader() : columnSettings.getCell();
@ -203,6 +206,8 @@ public abstract class TableWithLayoutComponentRenderer<C extends TableWithLayout
Font font = cellSettings.getFont();
cellVariables = CellVariables.builder()
.key(key)
.header(isHeader)
.firstColumn(isFirstColumn)
.color(cellSettings.getColor() != null ? ColorUtils.normalizeCssColor(cellSettings.getColor()) : null)
.backgroundColor(cellSettings.getBackgroundColor() != null ? ColorUtils.normalizeCssColor(cellSettings.getBackgroundColor()) : null)
.fontSize(font != null && font.getSize() != null && font.getSize() > 0 ? font.getSize() : null)
@ -211,16 +216,19 @@ public abstract class TableWithLayoutComponentRenderer<C extends TableWithLayout
.fontFamily(font != null && font.getFamily() != null && !font.getFamily().isEmpty() ? font.getFamily() : null)
.textAlignment(cellSettings.getTextAlignment() != null ? cellSettings.getTextAlignment().name() : null)
.verticalAlignment(cellSettings.getVerticalAlignment() != null ? cellSettings.getVerticalAlignment().name() : null)
.borderType(cellSettings.getBorderType())
.borderWidth(cellSettings.getBorderWidth())
.borderColor(cellSettings.getBorderColor() != null ? ColorUtils.normalizeCssColor(cellSettings.getBorderColor()) : null)
.build();
} else {
cellVariables = new CellVariables(key);
cellVariables = new CellVariables(key, isHeader, isFirstColumn);
}
if (isHeader && !StringUtils.isBlank(columnSettings.getColumnWidth())) {
cellVariables.setWidth(columnSettings.getColumnWidth());
}
return cellVariables;
}
return new CellVariables(key);
return new CellVariables(key, isHeader, isFirstColumn);
}
private Font getHeadingFont(Heading tableHeading) {
@ -240,6 +248,9 @@ public abstract class TableWithLayoutComponentRenderer<C extends TableWithLayout
@NoArgsConstructor
@Builder(toBuilder = true)
static class CellVariables {
// matches the 1px baseline set on th/td in main.css / report-component-style.scss
private static final int DEFAULT_BORDER_WIDTH_PX = 1;
private String key;
private String value;
private String width;
@ -251,10 +262,82 @@ public abstract class TableWithLayoutComponentRenderer<C extends TableWithLayout
private String fontFamily;
private String textAlignment;
private String verticalAlignment;
private BorderType borderType;
private Integer borderWidth;
private String borderColor;
private boolean header;
private boolean firstColumn;
public CellVariables(String key) {
this.key = key;
}
public CellVariables(String key, boolean header, boolean firstColumn) {
this.key = key;
this.header = header;
this.firstColumn = firstColumn;
}
public String getStyle() {
StringBuilder style = new StringBuilder("display: table-cell;");
if (textAlignment != null) {
style.append("text-align:").append(textAlignment).append(";");
}
if (verticalAlignment != null) {
style.append("vertical-align:").append(verticalAlignment).append(";");
}
if (color != null) {
style.append("color:").append(color).append(";");
}
if (backgroundColor != null) {
style.append("background-color:").append(backgroundColor).append(";");
}
if (fontSize != null) {
style.append("font-size:").append(fontSize).append("pt;");
}
if (fontFamily != null) {
style.append("font-family:").append(fontFamily).append(";");
}
if (fontStyle != null) {
style.append("font-style:").append(fontStyle).append(";");
}
if (fontWeight != null) {
style.append("font-weight:").append(fontWeight).append(";");
}
appendBorderStyle(style);
return style.toString();
}
// The base stylesheet (main.css / report-component-style.scss) only ever draws
// border-right/border-bottom on every cell, border-left on the first column, and
// border-top on header cells. With border-collapse: separate, painting a custom
// border on any other side would sit right next to the neighboring cell's own
// border and look doubled, so custom borders are restricted to those same sides.
private void appendBorderStyle(StringBuilder style) {
if (borderWidth == null && borderType == null && borderColor == null) {
return;
}
int lineWidth = borderWidth != null ? borderWidth : DEFAULT_BORDER_WIDTH_PX;
int width = borderType != null ? borderType.toCssWidth(lineWidth) : lineWidth;
List<String> sides = new ArrayList<>();
sides.add("right");
sides.add("bottom");
if (firstColumn) {
sides.add("left");
}
if (header) {
sides.add("top");
}
for (String side : sides) {
style.append("border-").append(side).append("-width:").append(width).append("px;");
if (borderType != null) {
style.append("border-").append(side).append("-style:").append(borderType.getValue()).append(";");
}
if (borderColor != null) {
style.append("border-").append(side).append("-color:").append(borderColor).append(";");
}
}
}
}
}

20
common/report/src/main/resources/html/components/table-template.html

@ -21,30 +21,14 @@
</tr>
<tr>
<th th:each="label : ${columns.keySet()}"
th:style="|display: table-cell;
${columns.get(label).textAlignment != null ? 'text-align:' + columns.get(label).textAlignment + ';' : ''}
${columns.get(label).verticalAlignment != null ? 'vertical-align:' + columns.get(label).verticalAlignment + ';' : ''}
${columns.get(label).color != null ? 'color:' + columns.get(label).color + ';' : ''}
${columns.get(label).backgroundColor != null ? 'background-color:' + columns.get(label).backgroundColor + ';' : ''}
${columns.get(label).fontSize != null ? 'font-size:' + columns.get(label).fontSize + 'pt;' : ''}
${columns.get(label).fontFamily != null ? 'font-family:' + columns.get(label).fontFamily + ';' : ''}
${columns.get(label).fontStyle != null ? 'font-style:' + columns.get(label).fontStyle + ';' : ''}
${columns.get(label).fontWeight != null ? 'font-weight:' + columns.get(label).fontWeight + ';' : ''}|"
th:style="${columns.get(label).style}"
th:text="${label}">Header</th>
</tr>
</thead>
<tbody>
<tr th:each="row : ${rows}">
<td th:each="label : ${columns.keySet()}"
th:style="|display: table-cell;
${row.get(label).textAlignment != null ? 'text-align:' + row.get(label).textAlignment + ';' : ''}
${row.get(label).verticalAlignment != null ? 'vertical-align:' + row.get(label).verticalAlignment + ';' : ''}
${row.get(label).color != null ? 'color:' + row.get(label).color + ';' : ''}
${row.get(label).backgroundColor != null ? 'background-color:' + row.get(label).backgroundColor + ';' : ''}
${row.get(label).fontSize != null ? 'font-size:' + row.get(label).fontSize + 'pt;' : ''}
${row.get(label).fontFamily != null ? 'font-family:' + row.get(label).fontFamily + ';' : ''}
${row.get(label).fontStyle != null ? 'font-style:' + row.get(label).fontStyle + ';' : ''}
${row.get(label).fontWeight != null ? 'font-weight:' + row.get(label).fontWeight + ';' : ''}|"
th:style="${row.get(label).style}"
th:utext="${row.get(label).value}">[Value]</td>
</tr>
<!-- Empty table fallback row -->

4
ui-ngx/src/app/modules/home/pages/reporting/template/components/alarm-table-preview.component.ts

@ -57,8 +57,8 @@ export class AlarmTablePreviewComponent extends AbstractReportTablePreviewCompon
}
}
protected styleFromColumnSettings(column: DataKey, header = false): ComponentStyle {
const style = super.styleFromColumnSettings(column, header);
protected styleFromColumnSettings(column: DataKey, header = false, firstColumn = false): ComponentStyle {
const style = super.styleFromColumnSettings(column, header, firstColumn);
if (!this.isPlainFormat && !header) {
const alarmField = alarmFields[column.name];
if (alarmField?.time) {

3
ui-ngx/src/app/modules/home/pages/reporting/template/components/divider-config.component.html

@ -39,6 +39,9 @@
<div matSuffix>px</div>
</mat-form-field>
</div>
@if (reportConfigForm.get('borderType').value === BorderType.double) {
<div class="tb-form-hint tb-primary-fill">{{ 'report-template.double-border-width-hint' | translate }}</div>
}
<div class="tb-form-row space-between">
<div translate>color.color</div>
<tb-color-input asBoxInput

3
ui-ngx/src/app/modules/home/pages/reporting/template/components/divider-config.component.ts

@ -6,6 +6,7 @@ import {
AbstractReportComponentConfig
} from '@home/pages/reporting/template/components/report-component-config.component';
import {
BorderType,
borderLengths,
borderLengthTranslations,
borderTypes,
@ -30,6 +31,8 @@ export class DividerConfigComponent extends AbstractReportComponentConfig<Divide
borderTypes = borderTypes;
borderTypeTranslations = borderTypeTranslations;
readonly BorderType = BorderType;
protected buildForm(reportComponentConfig: DividerReportComponentConfig): FormGroup {
return this.fb.group({
length: [reportComponentConfig.length, []],

7
ui-ngx/src/app/modules/home/pages/reporting/template/components/divider-preview.component.ts

@ -1,7 +1,7 @@
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
// SPDX-License-Identifier: BUSL-1.1
import { Component, ViewEncapsulation } from '@angular/core';
import { BorderLength, BorderType, DividerReportComponentConfig } from '@shared/models/report-component.models';
import { BorderLength, BorderType, borderCssWidth, DividerReportComponentConfig } from '@shared/models/report-component.models';
import { ComponentStyle } from '@shared/models/widget-settings.models';
import { isDefinedAndNotNull } from '@core/utils';
import { AbstractReportComponentPreview } from '@home/pages/reporting/template/components/report-component.component';
@ -19,9 +19,10 @@ export class DividerPreviewComponent extends AbstractReportComponentPreview<Divi
onComponentUpdated() {
this.dividerStyle = {};
this.dividerStyle.width = this.reportComponent.length === BorderLength.SHORT ? '50%' : '100%';
const borderWidth = isDefinedAndNotNull(this.reportComponent.widthPx) ? this.reportComponent.widthPx + 'px' : '1px';
const borderColor = this.reportComponent.color || '#000';
const borderStyle = this.reportComponent.borderType || BorderType.solid;
const lineWidth = isDefinedAndNotNull(this.reportComponent.widthPx) ? this.reportComponent.widthPx : 1;
const borderWidth = borderCssWidth(borderStyle, lineWidth) + 'px';
const borderColor = this.reportComponent.color || '#000';
this.dividerStyle.borderBottom = `${borderWidth} ${borderColor} ${borderStyle}`;
}

4
ui-ngx/src/app/modules/home/pages/reporting/template/components/entity-table-preview.component.ts

@ -42,8 +42,8 @@ export class EntityTablePreviewComponent extends AbstractReportTablePreviewCompo
}
}
protected styleFromColumnSettings(column: DataKey, header = false): ComponentStyle {
const style = super.styleFromColumnSettings(column, header);
protected styleFromColumnSettings(column: DataKey, header = false, firstColumn = false): ComponentStyle {
const style = super.styleFromColumnSettings(column, header, firstColumn);
if (!this.isPlainFormat && !header) {
if (column.name === 'createdTime') {
style.fontSize = style.fontSize || '9pt';

8
ui-ngx/src/app/modules/home/pages/reporting/template/components/report-table-preview.component.html

@ -23,8 +23,8 @@
</tr>
}
<tr>
@for (column of columns; track column) {
<th [style]="headerStyle(column)">{{ column.label }}
@for (column of columns; track column; let first = $first) {
<th [style]="headerStyle(column, first)">{{ column.label }}
@if (hasSortOrder(column)) {
<mat-icon class="tb-mat-16 sort-order">
{{ ascSortOrder() ? 'arrow_upward' : 'arrow_downward' }}
@ -36,8 +36,8 @@
</thead>
<tbody>
<tr>
@for (column of columns; track column) {
<td [style]="cellStyle(column)" [innerHTML]="cellContent(column) | safe: 'html'"></td>
@for (column of columns; track column; let first = $first) {
<td [style]="cellStyle(column, first)" [innerHTML]="cellContent(column) | safe: 'html'"></td>
}
</tr>
</tbody>

44
ui-ngx/src/app/modules/home/pages/reporting/template/components/report-table-preview.component.ts

@ -2,12 +2,14 @@
// SPDX-License-Identifier: BUSL-1.1
import { Directive } from '@angular/core';
import { AbstractReportComponentPreview } from '@home/pages/reporting/template/components/report-component.component';
import { TableReportColumnSettings, TableReportComponentConfig } from '@shared/models/report-component.models';
import { borderCssWidth, TableReportCellSettings, TableReportColumnSettings, TableReportComponentConfig } from '@shared/models/report-component.models';
import { ComponentStyle, Font, textStyle } from '@shared/models/widget-settings.models';
import { deepClone } from '@core/utils';
import { DataKey } from '@shared/models/widget.models';
import { Direction } from '@shared/models/page/sort-order';
const DEFAULT_TABLE_BORDER_WIDTH_PX = 1;
@Directive()
export abstract class AbstractReportTablePreviewComponent<C extends TableReportComponentConfig> extends AbstractReportComponentPreview<C> {
@ -56,12 +58,12 @@ export abstract class AbstractReportTablePreviewComponent<C extends TableReportC
}
headerStyle(column: DataKey): ComponentStyle {
return this.styleFromColumnSettings(column, true);
headerStyle(column: DataKey, firstColumn: boolean): ComponentStyle {
return this.styleFromColumnSettings(column, true, firstColumn);
}
cellStyle(column: DataKey): ComponentStyle {
return this.styleFromColumnSettings(column);
cellStyle(column: DataKey, firstColumn: boolean): ComponentStyle {
return this.styleFromColumnSettings(column, false, firstColumn);
}
columnWidth(column: DataKey): string {
@ -86,7 +88,7 @@ export abstract class AbstractReportTablePreviewComponent<C extends TableReportC
return '${' + column.label + '}';
}
protected styleFromColumnSettings(column: DataKey, header = false): ComponentStyle {
protected styleFromColumnSettings(column: DataKey, header = false, firstColumn = false): ComponentStyle {
let style: ComponentStyle = {};
if (!this.isPlainFormat && column?.settings) {
const columnSettings: TableReportColumnSettings = column.settings;
@ -101,9 +103,39 @@ export abstract class AbstractReportTablePreviewComponent<C extends TableReportC
style.verticalAlign = cellSettings.verticalAlignment;
style.color = cellSettings.color;
style.backgroundColor = cellSettings.backgroundColor;
this.applyBorderStyle(style, cellSettings, header, firstColumn);
}
}
}
return style;
}
// The base stylesheet (report-component-style.scss) only ever draws border-right/border-bottom
// on every cell, border-left on the first column, and border-top on header cells. With
// border-collapse: separate, a custom border on any other side would sit right next to the
// neighboring cell's own border and look doubled, so custom borders are restricted to those
// same sides, matching the Thymeleaf table template this preview mirrors.
private applyBorderStyle(style: ComponentStyle, cellSettings: TableReportCellSettings, header: boolean, firstColumn: boolean): void {
if (cellSettings.borderWidth == null && cellSettings.borderColor == null && cellSettings.borderType == null) {
return;
}
const lineWidth = cellSettings.borderWidth ?? DEFAULT_TABLE_BORDER_WIDTH_PX;
const width = (cellSettings.borderType ? borderCssWidth(cellSettings.borderType, lineWidth) : lineWidth) + 'px';
const sides = ['Right', 'Bottom'];
if (firstColumn) {
sides.push('Left');
}
if (header) {
sides.push('Top');
}
for (const side of sides) {
style['border' + side + 'Width'] = width;
if (cellSettings.borderType != null) {
style['border' + side + 'Style'] = cellSettings.borderType;
}
if (cellSettings.borderColor != null) {
style['border' + side + 'Color'] = cellSettings.borderColor;
}
}
}
}

4
ui-ngx/src/app/modules/home/pages/reporting/template/components/timeseries-table-preview.component.ts

@ -79,8 +79,8 @@ export class TimeseriesTablePreviewComponent extends AbstractReportTablePreviewC
}
}
protected styleFromColumnSettings(column: DataKey, header = false): ComponentStyle {
const style = super.styleFromColumnSettings(column, header);
protected styleFromColumnSettings(column: DataKey, header = false, firstColumn = false): ComponentStyle {
const style = super.styleFromColumnSettings(column, header, firstColumn);
if (!this.isPlainFormat && !header) {
if (['ts', 'createdTime'].includes(column.name)) {
style.fontSize = style.fontSize || '9pt';

2
ui-ngx/src/app/shared/models/dynamic-form.models.ts

@ -356,7 +356,7 @@ const toPropertyContainers = (properties: FormProperty[],
label: property.name,
type: FormPropertyContainerType.htmlSection,
htmlClass: property.htmlClassList ? property.htmlClassList.join(' ') : '',
safeHtml: sanitizer.bypassSecurityTrustHtml(property.htmlContent),
safeHtml: sanitizer.bypassSecurityTrustHtml(customTranslate.transform(property.htmlContent)),
visible: true
};
result.push(propertyHtml);

82
ui-ngx/src/app/shared/models/report-component.models.ts

@ -133,12 +133,41 @@ export interface ReportDataKeySettings {
type: ReportDataKeySettingsType;
}
export enum BorderType {
solid = 'solid',
dashed = 'dashed',
dotted = 'dotted',
double = 'double'
}
export const borderTypes = Object.keys(BorderType) as BorderType[];
export const borderTypeTranslations = new Map<BorderType, string>(
[
[BorderType.solid, 'report-template.component.divider.line-type-solid'],
[BorderType.dashed, 'report-template.component.divider.line-type-dashed'],
[BorderType.dotted, 'report-template.component.divider.line-type-dotted'],
[BorderType.double, 'report-template.component.divider.line-type-double']
]
);
/**
* Converts the configured width (thickness of a single line) into the CSS border-width.
* A double border is two lines of that thickness with an equal gap between them (the same model Word uses),
* so its CSS width is three times larger. Mirrors BorderType.toCssWidth() on the backend.
*/
export const borderCssWidth = (type: BorderType, lineWidth: number): number =>
type === BorderType.double ? lineWidth * 3 : lineWidth;
export interface TableReportCellSettings {
font?: Font;
color?: string;
backgroundColor?: string;
textAlignment?: alignment;
verticalAlignment?: alignment;
borderType?: BorderType;
borderColor?: string;
borderWidth?: number;
}
export interface TableReportColumnSettings extends ReportDataKeySettings {
@ -223,6 +252,43 @@ const tableReportCellSettings = (header = false): FormProperty[] => ([
}
],
default: 'middle'
},
{
id: 'borderWidth',
type: FormPropertyType.number,
name: '{i18n:report-template.border}',
subLabel: '{i18n:report-template.width}',
fieldSuffix: 'px',
min: 0,
step: 1,
default: null
},
{
id: 'borderType',
type: FormPropertyType.select,
name: '{i18n:report-template.border}',
subLabel: '{i18n:report-template.style}',
fieldClass: 'standard-width',
items: borderTypes.map(type => ({
label: `{i18n:${borderTypeTranslations.get(type)}}`,
value: type
})),
default: BorderType.solid
},
{
id: 'borderColor',
type: FormPropertyType.color,
name: '{i18n:report-template.border}',
default: null
},
{
id: 'doubleBorderHint',
type: FormPropertyType.htmlSection,
name: '',
htmlClassList: ['tb-form-hint', 'tb-primary-fill'],
htmlContent: '{i18n:report-template.double-border-width-hint}',
condition: `return model.borderType === '${BorderType.double}';`,
default: null
}
]);
@ -987,22 +1053,6 @@ export const borderLengthTranslations = new Map<BorderLength, string>(
]
);
export enum BorderType {
solid = 'solid',
dashed = 'dashed',
dotted = 'dotted'
}
export const borderTypes = Object.keys(BorderType) as BorderType[];
export const borderTypeTranslations = new Map<BorderType, string>(
[
[BorderType.solid, 'report-template.component.divider.line-type-solid'],
[BorderType.dashed, 'report-template.component.divider.line-type-dashed'],
[BorderType.dotted, 'report-template.component.divider.line-type-dotted']
]
);
export interface DividerReportComponentConfig extends LayoutReportComponentConfig {
length: BorderLength;
borderType: BorderType;

3
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -9210,6 +9210,7 @@
"bottom": "Bottom",
"background": "Background",
"border": "Border",
"double-border-width-hint": "Double draws two lines of this width with an equal gap between them, so the border is 3 times wider.",
"radius": "Radius",
"insert-update-image": "Insert/update image",
"edit-image": "Edit image",
@ -9217,6 +9218,7 @@
"image-size": "Image size",
"width": "Width",
"height": "Height",
"style": "Style",
"preserve-image-proportions": "Preserve image proportions",
"text-style": "Text style",
"background-color": "Background color",
@ -9257,6 +9259,7 @@
"line-type-solid": "Solid",
"line-type-dashed": "Dashed",
"line-type-dotted": "Dotted",
"line-type-double": "Double",
"line-width": "Line width"
},
"page-break": {

Loading…
Cancel
Save