Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wiring together calculated column pieces #931

Merged
merged 3 commits into from
Oct 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import {
buildColumnMap,
ColumnMap,
EventEmitter,
getAddedItems,
getMissingItems,
getSelectionStatus,
KeySet,
logger,
Expand Down Expand Up @@ -57,7 +59,6 @@ export interface ArrayDataSourceConstructorProps
data: Array<VuuRowDataItemType[]>;
rangeChangeRowset?: "delta" | "full";
}

const { debug } = logger("ArrayDataSource");

const { RENDER_IDX, SELECTED } = metadataKeys;
Expand Down Expand Up @@ -148,6 +149,10 @@ export class ArrayDataSource
}: ArrayDataSourceConstructorProps) {
super();

console.log(`ArrayDataSource`, {
columnDescriptors,
});

if (!data || !columnDescriptors) {
throw Error(
"ArrayDataSource constructor called without data or without columnDescriptors"
Expand Down Expand Up @@ -293,6 +298,10 @@ export class ArrayDataSource
return this.processedData ?? this.#data;
}

get table() {
return this.tableSchema.table;
}

get config() {
return this.#config;
}
Expand Down Expand Up @@ -434,6 +443,17 @@ export class ArrayDataSource
}

set columns(columns: string[]) {
const addedColumns = getAddedItems(this.config.columns, columns);
if (addedColumns.length > 0) {
const columnsWithoutDescriptors = getMissingItems(
this.columnDescriptors,
addedColumns,
(col) => col.name
);
console.log(`columnsWithoutDescriptors`, {
columnsWithoutDescriptors,
});
}
this.config = {
...this.#config,
columns,
Expand Down
3 changes: 2 additions & 1 deletion vuu-ui/packages/vuu-data/src/data-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const equivalentColumns: DataConfigPredicate = (
(cols1 === undefined && cols2?.length === 0) ||
(cols2 === undefined && cols1?.length === 0);

const columnsChanged: DataConfigPredicate = (config, newConfig) => {
export const columnsChanged: DataConfigPredicate = (config, newConfig) => {
const { columns: cols1 } = config;
const { columns: cols2 } = newConfig;

Expand Down Expand Up @@ -510,6 +510,7 @@ export interface DataSource extends EventEmitter<DataSourceEvents> {
props: SubscribeProps,
callback: SubscribeCallback
) => Promise<void>;
table?: VuuTable;
title?: string;
unsubscribe: () => void;
viewport?: string;
Expand Down
Loading
Loading