(core) Add cell formatting options to reference columns

Test Plan:
Tested manually by enabling/disabling wrapping and changing alignment on reference columns. Existing test updated to check that
reference columns have cell formatting options available.

Reviewers: dsagal

Reviewed By: dsagal

Differential Revision: https://phab.getgrist.com/D2853
This commit is contained in:
George Gevoian 2021-06-08 14:29:54 -07:00
parent 24dca831c0
commit 8bf26a4433
2 changed files with 14 additions and 5 deletions

View File

@ -58,6 +58,14 @@ export class Reference extends NTextBox {
} }
public buildConfigDom() { public buildConfigDom() {
return [
this.buildTransformConfigDom(),
cssLabel('CELL FORMAT'),
super.buildConfigDom()
];
}
public buildTransformConfigDom() {
return [ return [
cssLabel('SHOW COLUMN'), cssLabel('SHOW COLUMN'),
cssRow( cssRow(
@ -67,10 +75,6 @@ export class Reference extends NTextBox {
]; ];
} }
public buildTransformConfigDom() {
return this.buildConfigDom();
}
public buildDom(row: DataRowModel) { public buildDom(row: DataRowModel) {
const formattedValue = Computed.create(null, (use) => { const formattedValue = Computed.create(null, (use) => {
if (use(row._isAddRow) || this.isDisposed() || use(this.field.displayColModel).isDisposed()) { if (use(row._isAddRow) || this.isDisposed() || use(this.field.displayColModel).isDisposed()) {
@ -92,6 +96,8 @@ export class Reference extends NTextBox {
}); });
return dom('div.field_clip', return dom('div.field_clip',
dom.autoDispose(formattedValue), dom.autoDispose(formattedValue),
dom.style('text-align', this.alignment),
dom.cls('text_wrapping', this.wrapping),
cssRefIcon('FieldReference', cssRefIcon('FieldReference',
testId('ref-link-icon') testId('ref-link-icon')
), ),
@ -101,6 +107,7 @@ export class Reference extends NTextBox {
} }
const cssRefIcon = styled(icon, ` const cssRefIcon = styled(icon, `
float: left;
background-color: ${colors.slate}; background-color: ${colors.slate};
margin: -1px 2px 2px 0; margin: -1px 2px 2px 0;
`); `);

View File

@ -228,7 +228,9 @@ var typeDefs = {
cons: 'Reference', cons: 'Reference',
editCons: 'ReferenceEditor', editCons: 'ReferenceEditor',
icon: 'FieldReference', icon: 'FieldReference',
options: {} options: {
alignment: 'left'
}
} }
}, },
default: 'Reference' default: 'Reference'