Skip to content

Commit

Permalink
Add board custom card order (marcusolsson#586, marcusolsson#652)
Browse files Browse the repository at this point in the history
  • Loading branch information
st4ng committed Feb 13, 2024
1 parent ce48eb1 commit 5aa1451
Show file tree
Hide file tree
Showing 26 changed files with 1,012 additions and 675 deletions.
4 changes: 4 additions & 0 deletions src/customViewApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type { ProjectDefinition, ViewId } from "./settings/settings";

export interface DataQueryResult {
data: DataFrame;
hasSort: boolean;
hasFilter: boolean;
}

/**
Expand All @@ -18,6 +20,8 @@ export interface ProjectViewProps<T = Record<string, any>> {
viewApi: ViewApi;
readonly: boolean;
getRecordColor: (record: DataRecord) => string | null;
sortRecords: (records: ReadonlyArray<DataRecord>) => DataRecord[];
getRecord: (id: string) => DataRecord | undefined;
}

/**
Expand Down
14 changes: 14 additions & 0 deletions src/lib/datasources/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ export function parseRecords(
return records;
}

/**
* Copies a data record and merges values.
*
* @param {Readonly<DataRecord>} record - the original data record
* @param {Readonly<DataRecord["values"]>} values - the values to merge into the original record
* @return {DataRecord} a new data record with the merged values
*/
export function copyRecordWithValues(
record: Readonly<DataRecord>,
values: Readonly<DataRecord["values"]>
): DataRecord {
return { ...record, values: { ...record.values, ...values } };
}

export function detectFields(records: DataRecord[]): DataField[] {
const valuesByField: Record<string, Optional<DataValue>[]> = {};

Expand Down
13 changes: 13 additions & 0 deletions src/lib/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { get } from "svelte/store";

import { app } from "src/lib/stores/obsidian";
import type { ProjectDefinition, ViewDefinition } from "src/settings/settings";
import { getContext, setContext } from "svelte";
import type { DataField } from "./dataframe/dataframe";

/**
Expand Down Expand Up @@ -88,3 +89,15 @@ export function getNameFromPath(path: string) {
const end: number = path.lastIndexOf(".");
return path.substring(start, end);
}

export type Context<T> = Readonly<{
get: () => T;
set: (value: T) => void;
}>;
export function makeContext<T>(): Context<T> {
const key = Symbol();
return {
get: () => getContext(key),
set: (value: T) => setContext(key, value),
};
}
Loading

0 comments on commit 5aa1451

Please sign in to comment.