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

Commit 717d38d

Browse files
committed
Merge branch '801-bug-using-dataview-query-with-use-all-fields-causes-an-error'
2 parents 9d12dc7 + 5b7ff13 commit 717d38d

27 files changed

+476
-214
lines changed

src/Settings.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { App, Modal, PluginSettingTab } from "obsidian";
22
import { add_setting_header } from 'settings/SettingsComponents';
33
import DBFolderPlugin from 'main';
4-
import { DatabaseView } from "views/DatabaseView";
54
import { LOGGER } from "services/Logger";
65
import columns_settings_section from "settings/ColumnsSection";
76
import { folder_settings_section } from "settings/FolderSection";

src/cdm/DatabaseModel.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Literal } from "obsidian-dataview/lib/data-model/value";
44
import { TableOptions } from "@tanstack/react-table";
55
import { BaseColumn, RowDataType } from "cdm/FolderModel";
66
import { SMarkdownPage } from "obsidian-dataview";
7+
import en from "lang/locale/en";
78

89
/** database column */
910
export interface DatabaseColumn extends BaseColumn {
@@ -44,4 +45,6 @@ export type TableOptionsResponse = {
4445

4546
export type NoteInfoPage = Omit<SMarkdownPage, "file"> & {
4647
file: Pick<SMarkdownPage["file"], "link" | "path" | "ctime" | "mtime" | "tasks" | "outlinks" | "inlinks" | "folder">
47-
};
48+
};
49+
50+
export type LocaleDict = keyof typeof en;

src/cdm/FolderModel.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ export interface ConfigColumn {
4747
// Text
4848
link_alias_enabled?: boolean;
4949
custom_link_alias?: string;
50+
// Selects & Tags
51+
option_source?: string;
52+
formula_option_source?: string;
5053
// Tasks
5154
task_hide_completed?: boolean;
5255
// Formulas

src/cdm/ModalsModel.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { RowDataType, TableColumn } from "cdm/FolderModel";
2-
import { ColumnsState, ConfigState, DataState, RowTemplateState } from "cdm/TableStateInterface";
2+
import { AutomationState, ColumnsState, ConfigState, DataState, RowTemplateState } from "cdm/TableStateInterface";
33
import { ColumnSettingsManager } from "components/modals/columnSettings/ColumnSettingsModal";
44
import { AddColumnModalManager } from "components/modals/newColumn/addColumnModal";
55
import { FiltersModalManager } from "components/modals/filters/FiltersModal";
@@ -18,8 +18,8 @@ export type BaseColumnModalProps = {
1818
dataState: Pick<DataState, "actions">,
1919
columnState: Pick<ColumnsState, "info" | "actions">,
2020
configState: Pick<ConfigState, "info">,
21-
view: CustomView,
22-
//headerMenuProps: HeaderMenuProps
21+
automationState: Pick<AutomationState, "info">,
22+
view: CustomView
2323
}
2424
/***************************************
2525
* COLUMN SETTINGS MODAL

src/cdm/TableStateInterface.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ export type AutomationStateActions = {
158158

159159
export type AutomationStateInfo = {
160160
getFormula: (name: string) => unknown;
161+
getFormulas: () => { [key: string]: unknown };
161162
runFormula: (input: string, row: RowDataType, dbInfo: DbInfo) => Literal;
162163
dispatchFooter: (column: TableColumn, colValues: Literal[]) => Literal;
163164
dispatchRollup: (configColumn: ConfigColumn, relation: Literal) => Literal;

src/components/DefaultHeader.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function DefaultHeader(headerProps: DatabaseHeaderProps) {
4242
const columnsInfo = tableState.columns((state) => state.info);
4343
const columnActions = tableState.columns((state) => state.actions);
4444
const dataActions = tableState.data((state) => state.actions);
45-
45+
const automationInfo = tableState.automations((state) => state.info);
4646
const areColumnsFilterable = tableState.configState(
4747
(state) => state.ephimeral.enable_columns_filter
4848
);
@@ -124,6 +124,7 @@ export default function DefaultHeader(headerProps: DatabaseHeaderProps) {
124124
actions: columnActions,
125125
},
126126
configState: { info: configInfo },
127+
automationState: { info: automationInfo },
127128
view: table.options.meta.view,
128129
};
129130
new AddColumnModal(table.options.meta.view, addColumnProps).open();

src/components/HeaderMenu.tsx

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { StyleVariables } from "helpers/Constants";
2-
import { dbTrim, c, getLabelHeader } from "helpers/StylesHelper";
2+
import { dbTrim, c } from "helpers/StylesHelper";
33
import AdjustmentsIcon from "components/img/AdjustmentsIcon";
44
import React, { FocusEventHandler, useState } from "react";
55
import Popper from "@mui/material/Popper";
@@ -18,15 +18,18 @@ import { dynamic_t, t } from "lang/helpers";
1818
const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
1919
const { table, column } = headerMenuProps.headerProps;
2020

21-
const [columnsInfo, columnActions] = table.options.meta.tableState.columns(
22-
(state) => [state.info, state.actions]
23-
);
24-
const dataActions = table.options.meta.tableState.data(
25-
(state) => state.actions
26-
);
27-
const configInfo = table.options.meta.tableState.configState(
28-
(state) => state.info
29-
);
21+
const { tableState } = table.options.meta;
22+
23+
const [columnsInfo, columnActions] = tableState.columns((state) => [
24+
state.info,
25+
state.actions,
26+
]);
27+
28+
const dataActions = tableState.data((state) => state.actions);
29+
30+
const configInfo = tableState.configState((state) => state.info);
31+
32+
const automationInfo = tableState.automations((state) => state.info);
3033

3134
/** Header props */
3235
const { propertyIcon, menuEl, setMenuEl, labelState, setLabelState } =
@@ -238,6 +241,7 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
238241
actions: columnActions,
239242
},
240243
configState: { info: configInfo },
244+
automationState: { info: automationInfo },
241245
view: table.options.meta.view,
242246
tableColumn: column.columnDef as TableColumn,
243247
}).open();

src/components/cellTypes/FormulaCell.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ const FormulaCell = (mdProps: CellComponentProps) => {
3333
})
3434
.toString();
3535

36-
// If the formula cell is the same as the rendered formula, do nothing
37-
if (cell.getValue() === formulaResponse) return;
38-
3936
await MarkdownService.renderMarkdown(
4037
defaultCell,
4138
formulaResponse,

src/components/cellTypes/RelationCell.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,11 @@ const RelationCell = (mdProps: CellComponentProps) => {
112112
? relationCell.map((link: Link, index) => (
113113
<Relationship
114114
key={`relation-${index}-${tableColumn.key}-${link.path}`}
115-
value={link.markdown()}
116-
backgroundColor={tableColumn.config.relation_color || grey(300)}
115+
option={{
116+
value: link.markdown(),
117+
label: link.markdown(),
118+
color: tableColumn.config.relation_color || grey(300),
119+
}}
117120
view={view}
118121
/>
119122
))

src/components/modals/columnSettings/ColumnSections.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import { add_setting_header } from "settings/SettingsComponents";
33
import { MediaDimensionsHandler } from "./handlers/media/MediaDimensionsHandler";
44
import { MediaToggleHandler } from "./handlers/media/MediaToggleHandler";
55
import { InlineToggleHandler } from "./handlers/InlineToggleHandler";
6+
import { OptionSourceDropdownHandler } from "./handlers/selects/OptionSourceDropdownHandler";
67
import { AddOptionHandler } from "./handlers/selects/AddOptionHandler";
7-
import { SelectedColumnOptionsHandler } from "./handlers/selects/SelectedColumnOptionsHandler";
8+
import { ManualColumnOptionsHandler } from "./handlers/selects/ManualColumnOptionsHandler";
89
import { HideCompletedTaskToggleHandler } from "./handlers/tasks/HideCompletedTaskToggleHandler";
910
import { LinkAliasToggleHandler } from "./handlers/media/LinkAliasToggleHandler";
1011
import { FormulaInputHandler } from "./handlers/automations/FormulaInputHandler";
@@ -20,6 +21,7 @@ import { RollupPersistToggleHandler } from "./handlers/rollups/RollupPersistTogg
2021
import { RollupFormulaHandler } from "./handlers/rollups/RollupFormulaHandler";
2122
import { BidirectionalRelationToggleHandler } from "./handlers/relations/BidirectionalRelationToggleHandler";
2223
import { RelationColorSelectorHandler } from "./handlers/relations/RelationColorSelectorHandler";
24+
import { FormulaColumnOptionsHandler } from "./handlers/selects/FormulaColumnOptionsHandler";
2325
import { InputType } from "helpers/Constants";
2426
import { AbstractChain } from "patterns/chain/AbstractFactoryChain";
2527
import { AbstractHandler } from "patterns/chain/AbstractHandler";
@@ -135,8 +137,10 @@ class ParticularSetttingsSection extends AbstractChain<ColumnSettingsHandlerResp
135137
break;
136138
case InputType.SELECT:
137139
case InputType.TAGS:
140+
particularHandlers.push(new OptionSourceDropdownHandler());
138141
particularHandlers.push(new AddOptionHandler());
139-
particularHandlers.push(new SelectedColumnOptionsHandler());
142+
particularHandlers.push(new ManualColumnOptionsHandler());
143+
particularHandlers.push(new FormulaColumnOptionsHandler());
140144
break;
141145
case InputType.TASK:
142146
particularHandlers.push(new HideCompletedTaskToggleHandler());

0 commit comments

Comments
 (0)