Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit c9d4731

Browse files
committed
now options are persisted
1 parent 4adc964 commit c9d4731

File tree

6 files changed

+19
-13
lines changed

6 files changed

+19
-13
lines changed

src/cdm/RowSelectModel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ActionType } from "react-table";
22
import NoteInfo from "services/NoteInfo";
3-
import { TableDataType } from "cdm/FolderModel";
3+
import { TableColumn, TableDataType } from "cdm/FolderModel";
44

55
export type RowSelectOption = {
66
backgroundColor: string,
@@ -9,7 +9,7 @@ export type RowSelectOption = {
99
export type PopperProps = {
1010
dispatch: (action: ActionType) => void;
1111
row: any;
12-
column: any;
12+
column: TableColumn;
1313
columns: any;
1414
note: NoteInfo;
1515
state: TableDataType;

src/components/Cell.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export default function DefaultCell(cellProperties: Cell) {
170170
<PopperSelectPortal
171171
dispatch={dataDispatch}
172172
row={cellProperties.row}
173-
column={cellProperties.column}
173+
column={cellProperties.column as unknown as TableColumn}
174174
columns={columns}
175175
note={note}
176176
state={(cellProperties as any).initialState}

src/components/Columns.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ function columnOptions(
7575
): TableColumn {
7676
LOGGER.debug(`=> columnOptions. column: ${JSON.stringify(column)}`);
7777
const options: RowSelectOption[] = column.options ?? [];
78-
7978
if (Object.values(DataTypes).includes(column.input)) {
8079
LOGGER.debug(`<= columnOptions`, `return ${column.input} column`);
8180
return {

src/components/Header.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,17 @@ import { DatabaseHeaderProps } from "cdm/FolderModel";
1919
import ReactDOM from "react-dom";
2020
import { c } from "helpers/StylesHelper";
2121
import { HeaderContext } from "components/contexts/HeaderContext";
22+
import { RowSelectOption } from "cdm/RowSelectModel";
2223

24+
/**
25+
* Generate column Options with Select type
26+
* @param options
27+
* @param rows
28+
* @param columnId
29+
* @returns
30+
*/
2331
function setOptionsOfSelectDataType(
24-
options: any[],
32+
options: RowSelectOption[],
2533
rows: any,
2634
columnId: string
2735
): any[] {

src/components/portals/PopperSelectPortal.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const PopperSelectPortal = (popperProps: PopperProps) => {
3939
dispatch({
4040
type: ActionTypes.UPDATE_OPTION_CELL,
4141
file: note.getFile(),
42-
key: (column as any).key,
42+
key: column.key,
4343
value: option.label,
4444
row: row,
4545
columnId: column.id,
@@ -53,7 +53,7 @@ const PopperSelectPortal = (popperProps: PopperProps) => {
5353
type: ActionTypes.ADD_OPTION_TO_COLUMN,
5454
option: e.target.value,
5555
backgroundColor: randomColor(),
56-
columnId: (column as any).id,
56+
columnId: column.id,
5757
});
5858
}
5959
setShowAdd(false);
@@ -70,7 +70,7 @@ const PopperSelectPortal = (popperProps: PopperProps) => {
7070
columns: columns,
7171
option: e.target.value,
7272
backgroundColor: randomColor(),
73-
columnId: (column as any).id,
73+
columnId: column.id,
7474
type: ActionTypes.ADD_OPTION_TO_COLUMN,
7575
});
7676
}
@@ -79,8 +79,8 @@ const PopperSelectPortal = (popperProps: PopperProps) => {
7979
}
8080

8181
function getColor() {
82-
const match = (column as any).options.find(
83-
(option: { label: any }) => option.label === contextValue.value
82+
const match = column.options.find(
83+
(option: { label: string }) => option.label === contextValue.value
8484
);
8585
return (match && match.backgroundColor) || grey(200);
8686
}

src/parsers/handlers/unmarshall/UnmarshallColumnsHandler.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { DatabaseColumn } from "cdm/DatabaseModel";
22
import { DiskHandlerResponse } from "cdm/MashallModel";
33
import { DataTypes, YAML_INDENT } from "helpers/Constants";
4-
import { Literal } from "obsidian-dataview/lib/data-model/value";
54
import { AbstractDiskHandler } from "parsers/handlers/unmarshall/AbstractDiskPropertyHandler";
65

76
export class UnmarshallColumnsHandler extends AbstractDiskHandler {
@@ -46,8 +45,8 @@ function unmarshallParticularInputInfo(column: DatabaseColumn): string[] {
4645
if (column.options && Array.isArray(column.options)) {
4746
particularInputString.push(`${YAML_INDENT.repeat(2)}options:`);
4847
column.options.forEach(option => {
49-
particularInputString.push(`${YAML_INDENT.repeat(3)}- {label: ${option.label}, backgroundColor: ${option
50-
.backgroundColor.toString()}}`);
48+
particularInputString.push(`${YAML_INDENT.repeat(3)}- { label: "${option.label}", backgroundColor: "${option
49+
.backgroundColor}"}`);
5150
});
5251
}
5352
}

0 commit comments

Comments
 (0)