mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(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:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user