gristlabs_grist-core/app/client/models/Styles.ts
Jarosław Sadziński 8be920dd25 (core) Multi-column configuration
Summary:
Creator panel allows now to edit multiple columns at once
for some options that are common for them. Options that
are not common are disabled.

List of options that can be edited for multiple columns:
- Column behavior (but limited to empty/formula columns)
- Alignment and wrapping
- Default style
- Number options (for numeric columns)
- Column types (but only for empty/formula columns)

If multiple columns of the same type are selected, most of
the options are available to change, except formula, trigger formula
and conditional styles.

Editing column label or column id is disabled by default for multiple
selection.

Not related: some tests were fixed due to the change in the column label
and id widget in grist-core (disabled attribute was replaced by readonly).

Test Plan: Updated and new tests.

Reviewers: georgegevoian

Reviewed By: georgegevoian

Differential Revision: https://phab.getgrist.com/D3598
2022-10-17 09:51:19 +02:00

36 lines
1.4 KiB
TypeScript

export interface Style {
textColor?: string|undefined; // this can be string, undefined or an absent key.
fillColor?: string|undefined;
fontBold?: boolean|undefined;
fontUnderline?: boolean|undefined;
fontItalic?: boolean|undefined;
fontStrikethrough?: boolean|undefined;
}
export class CombinedStyle implements Style {
public readonly textColor?: string;
public readonly fillColor?: string;
public readonly fontBold?: boolean;
public readonly fontUnderline?: boolean;
public readonly fontItalic?: boolean;
public readonly fontStrikethrough?: boolean;
constructor(rules: (Style|undefined|null)[], flags: any[]) {
for (let i = 0; i < rules.length; i++) {
if (flags[i]) {
const textColor = rules[i]?.textColor;
const fillColor = rules[i]?.fillColor;
const fontBold = rules[i]?.fontBold;
const fontUnderline = rules[i]?.fontUnderline;
const fontItalic = rules[i]?.fontItalic;
const fontStrikethrough = rules[i]?.fontStrikethrough;
this.textColor = textColor || this.textColor;
this.fillColor = fillColor || this.fillColor;
this.fontBold = fontBold || this.fontBold;
this.fontUnderline = fontUnderline || this.fontUnderline;
this.fontItalic = fontItalic || this.fontItalic;
this.fontStrikethrough = fontStrikethrough || this.fontStrikethrough;
}
}
}
}