You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gristlabs_grist-core/app/client/components/DataTables.ts

33 lines
1.0 KiB

import {GristDoc} from 'app/client/components/GristDoc';
import {buildViewSectionDom, ViewSectionHelper} from 'app/client/components/ViewLayout';
import {ViewSectionRec} from 'app/client/models/DocModel';
import {Disposable, dom, domComputed} from 'grainjs';
export class DataTables extends Disposable {
constructor(private _gristDoc: GristDoc) {
super();
}
public buildDom() {
return [
dom(
'ul',
this._gristDoc.docModel.allTables.all().map(t => dom(
'li', t.rawViewSection().title() || t.tableId(),
dom.on('click', () => this._gristDoc.viewModel.activeSectionId(t.rawViewSection.peek().getRowId())),
))
),
domComputed<ViewSectionRec>(
this._gristDoc.viewModel.activeSection,
(viewSection) => {
if (!viewSection.getRowId()) {
return;
}
ViewSectionHelper.create(this, this._gristDoc, viewSection);
return buildViewSectionDom(this._gristDoc, viewSection.getRowId());
}
)
];
}
}