mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) move client code to core
Summary: This moves all client code to core, and makes minimal fix-ups to get grist and grist-core to compile correctly. The client works in core, but I'm leaving clean-up around the build and bundles to follow-up. Test Plan: existing tests pass; server-dev bundle looks sane Reviewers: dsagal Reviewed By: dsagal Differential Revision: https://phab.getgrist.com/D2627
This commit is contained in:
60
app/client/ui/GridOptions.ts
Normal file
60
app/client/ui/GridOptions.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
import { ViewSectionRec } from "app/client/models/DocModel";
|
||||
import { KoSaveableObservable, setSaveValue } from "app/client/models/modelUtil";
|
||||
import { cssLabel, cssRow } from "app/client/ui/RightPanel";
|
||||
import { squareCheckbox } from "app/client/ui2018/checkbox";
|
||||
import { testId } from "app/client/ui2018/cssVars";
|
||||
import { Computed, Disposable, dom, IDisposableOwner, styled } from "grainjs";
|
||||
|
||||
/**
|
||||
* Builds the grid options.
|
||||
*/
|
||||
export class GridOptions extends Disposable {
|
||||
|
||||
constructor(private _section: ViewSectionRec) {
|
||||
super();
|
||||
}
|
||||
|
||||
public buildDom() {
|
||||
const section = this._section;
|
||||
return [
|
||||
cssLabel('Grid Options'),
|
||||
dom('div', [
|
||||
cssRow(
|
||||
checkbox(setSaveValueFromKo(this, section.optionsObj.prop('verticalGridlines'))),
|
||||
'Vertical Gridlines',
|
||||
testId('v-grid-button')
|
||||
),
|
||||
|
||||
cssRow(
|
||||
checkbox(setSaveValueFromKo(this, section.optionsObj.prop('horizontalGridlines'))),
|
||||
'Horizontal Gridlines',
|
||||
testId('h-grid-button')
|
||||
),
|
||||
|
||||
cssRow(
|
||||
checkbox(setSaveValueFromKo(this, section.optionsObj.prop('zebraStripes'))),
|
||||
'Zebra Stripes',
|
||||
testId('zebra-stripe-button')
|
||||
),
|
||||
|
||||
testId('grid-options')
|
||||
]),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Returns a grainjs observable that reflects the value of obs a knockout saveable observable. The
|
||||
// returned observable will set and save obs to the given value when written. If the obs.save() call
|
||||
// fails, then it gets reset to its previous value.
|
||||
function setSaveValueFromKo<T>(owner: IDisposableOwner, obs: KoSaveableObservable<T>) {
|
||||
const ret = Computed.create(null, (use) => use(obs));
|
||||
ret.onWrite(async (val) => {
|
||||
await setSaveValue(obs, val);
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
const checkbox = styled(squareCheckbox, `
|
||||
margin-right: 8px;
|
||||
`);
|
||||
Reference in New Issue
Block a user