(core) Convert a few widgets to typescript and grainjs.

Summary:
No behavior changes.
Diff includes an intermediate commit with only renames, for easier review.

Test Plan: Existing tests should pass.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2669
This commit is contained in:
Dmitry S
2020-10-07 17:58:43 -04:00
parent f24a82e8d4
commit 4539521dff
13 changed files with 298 additions and 387 deletions

View File

@@ -5,7 +5,7 @@ import {cssRow} from 'app/client/ui/RightPanel';
import {alignmentSelect, makeButtonSelect} from 'app/client/ui2018/buttonSelect';
import {testId} from 'app/client/ui2018/cssVars';
import {NewAbstractWidget} from 'app/client/widgets/NewAbstractWidget';
import {Computed, dom, Observable} from 'grainjs';
import {dom, DomContents, fromKo, Observable} from 'grainjs';
/**
* TextBox - The most basic widget for displaying text information.
@@ -18,27 +18,15 @@ export class NTextBox extends NewAbstractWidget {
super(field);
this.alignment = fromKoSave<string>(this.options.prop('alignment'));
const wrap = this.options.prop('wrap');
this.wrapping = Computed.create(this, (use) => {
const w = use(wrap);
if (w === null || w === undefined) {
// When user has yet to specify a desired wrapping state, GridView and DetailView have
// different default states. GridView defaults to wrapping disabled, while DetailView
// defaults to wrapping enabled.
return (this.field.viewSection().parentKey() === 'record') ? false : true;
} else {
return w;
}
});
this.wrapping = fromKo(this.field.wrapping);
this.autoDispose(this.wrapping.addListener(() => {
this.field.viewSection().events.trigger('rowHeightChange');
}));
}
public buildConfigDom() {
return dom('div',
public buildConfigDom(): DomContents {
return [
cssRow(
alignmentSelect(this.alignment),
dom('div', {style: 'margin-left: 8px;'},
@@ -46,7 +34,7 @@ export class NTextBox extends NewAbstractWidget {
testId('tb-wrap-text')
)
)
);
];
}
public buildDom(row: DataRowModel) {