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

Commit 4bb6cff

Browse files
committed
Merge branch '161-update-values-when-switching-property-type'
2 parents 502b1d5 + 700e026 commit 4bb6cff

File tree

8 files changed

+33
-38
lines changed

8 files changed

+33
-38
lines changed

docs/docs/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
- Now you can hide completed task on task column type [ISSUE#111](https://github.com/RafaelGB/obsidian-db-folder/issues/111)
88
### No longer broken
99
- If you modify the label of a column, now exist an onMouseLeave event to blur the input and be more frieldly to the user interact with the next action without a double click (once for onBlur label edition and another for your next interaction) [ISSUE#114](https://github.com/RafaelGB/obsidian-db-folder/issues/114)
10-
## 1.7.2
10+
- Change the type of the column to checkbox respects the value `1` as marked and will not mark as `0` all by default[ISSUE#161](https://github.com/RafaelGB/obsidian-db-folder/issues/161)
1111
### No longer broken
1212
- add new rows hotfix. Was broken in 1.7.1 with refactor of datadispatch
1313
## 1.7.1

src/__tests__/IO/settings.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { YamlHandlerResponse } from "cdm/MashallModel";
2+
import { mockReset, mockDeep, DeepMockProxy } from "jest-mock-extended";
23
import { parseYamlMock } from "mock/mockObsidianUtils";
34
import DatabaseStringToYamlParser from "parsers/DatabaseStringToYamlParser";
45

@@ -8,12 +9,20 @@ jest.mock("obsidian",
89
return {
910
parseYaml: jest.fn(() => {
1011
return parseYamlMock(1, 1);
11-
}
12-
),
12+
}),
1313
};
1414
}
1515
);
1616
describe("Settings", () => {
17+
// @ts-ignore
18+
const mockGlobalApp: DeepMockProxy<App> = mockDeep<App>();
19+
/**
20+
* Run this before each test.
21+
*/
22+
beforeAll(() => {
23+
mockReset(mockGlobalApp);
24+
global.app = mockGlobalApp;
25+
});
1726
/** Parse string YAML */
1827
test("Parse Database string to Yaml", () => {
1928
const yamlResponse: YamlHandlerResponse = DatabaseStringToYamlParser("test");

src/components/modals/handlers/tasks/HideCompletedTaskToggleHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export class HideCompletedTaskToggleHandler extends AbstractColumnHandler {
66
handle(columnHandlerResponse: ColumnHandlerResponse): ColumnHandlerResponse {
77
const { column, containerEl, view } = columnHandlerResponse;
88
const inline_togle_promise = async (value: boolean): Promise<void> => {
9-
column.config.isInline = value;
9+
column.config.task_hide_completed = value;
1010
// Persist value
1111
await view.diskConfig.updateColumnConfig(column.key, {
1212
task_hide_completed: value

src/helpers/Constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ export function getOperatorFilterValue(keyToFind: string): string {
242242
}
243243

244244
export const MarkdownBreakerRules = Object.freeze({
245-
INIT_CHARS: ['`', '\"', '[', '{', '*'],
245+
INIT_CHARS: ['`', '"', '[', '{', '*'],
246246
BETWEEN_CHARS: [':'],
247247
UNIQUE_CHARS: ['?'],
248248
})

src/helpers/VaultManagement.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,12 @@ export async function sourceDataviewPages(folderPath: string, dbYaml: DatabaseYa
9898
pagesResult = DataviewService.getDataviewAPI().pages(`outgoing([[${dbYaml.config.source_form_result}]])`);
9999
break;
100100
case SourceDataTypes.QUERY:
101-
const query = generateDataviewTableQuery(
102-
dbYaml.columns,
103-
dbYaml.config.source_form_result)
104-
pagesResult = await obtainQueryResult(query, folderPath);
101+
pagesResult = await obtainQueryResult(
102+
generateDataviewTableQuery(
103+
dbYaml.columns,
104+
dbYaml.config.source_form_result),
105+
folderPath
106+
);
105107
break;
106108
default:
107109
pagesResult = DataviewService.getDataviewAPI().pages(`"${folderPath}"`);
@@ -129,7 +131,7 @@ async function obtainQueryResult(query: string, folderPath: string): Promise<Dat
129131
const msg = `Error obtaining query result: "${query}", current folder loaded instead`;
130132
LOGGER.error(msg, error);
131133
new Notice(msg, 10000);
132-
return DataviewService.getDataviewAPI().pages(`"${folderPath}"`);;
134+
return DataviewService.getDataviewAPI().pages(`"${folderPath}"`);
133135
}
134136
}
135137

src/mock/mockObsidianUtils.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,13 @@
1-
import { parseYaml } from "obsidian";
1+
import { generateYamlColumns } from "mock/mockTableUtils";
2+
import { DEFAULT_SETTINGS } from "helpers/Constants";
23

34
/** Mock parseYaml returning YamlHandlerResponse object */
45
export const parseYamlMock = (numOfColumns: number, numberOfFilters: number) => {
56
return {
67
name: "Test",
78
description: "Test",
8-
columns: {
9-
"test": {
10-
input: "text",
11-
accessor: "test",
12-
label: "test",
13-
key: "test",
14-
position: 1,
15-
isMetadata: true,
16-
skipPersist: false,
17-
csvCandidate: true,
18-
isInline: false
19-
}
20-
},
21-
config: {
22-
enable_show_state: false,
23-
group_folder_column: "test"
24-
},
9+
columns: generateYamlColumns(numOfColumns),
10+
config: DEFAULT_SETTINGS.local_settings,
2511
filters: [
2612
{
2713
field: "test",

src/mock/mockTableUtils.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import faker from "@faker-js/faker";
33
import React, { useRef, useLayoutEffect } from "react";
44
import { randomColor } from "helpers/Colors";
5-
import { DataTypes } from "helpers/Constants";
5+
import { DataTypes, DEFAULT_COLUMN_CONFIG } from "helpers/Constants";
66
import { TableDataType, TableColumn, RowDataType } from "cdm/FolderModel";
77
import { DatabaseColumn } from "cdm/DatabaseModel";
88
import { obtainColumnsFromFolder } from "components/Columns";
@@ -36,7 +36,6 @@ export async function makeData(count: number): Promise<TableDataType> {
3636
skipReset: false,
3737
view: null,
3838
stateManager: null,
39-
cellSize: "normal",
4039
};
4140
}
4241

@@ -60,12 +59,7 @@ export const generateYamlColumns = (
6059
isMetadata: false,
6160
skipPersist: true,
6261
csvCandidate: false,
63-
config: {
64-
enable_media_view: true,
65-
media_width: 100,
66-
media_height: 100,
67-
isInline: false,
68-
},
62+
config: DEFAULT_COLUMN_CONFIG,
6963
};
7064
}
7165
return yamlColumns;

src/services/DataviewService.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,12 @@ class DataviewProxy {
152152
}
153153

154154
private parseToNumber(wrapped: WrappedLiteral): number {
155-
const adjustedValue = this.getDataviewAPI().value.toString(wrapped.value);
156-
return wrapped.type === 'number' ? wrapped.value : Number(adjustedValue);
155+
if (wrapped.type === 'number') {
156+
return wrapped.value;
157+
} else {
158+
const adjustedValue = this.getDataviewAPI().value.toString(wrapped.value);
159+
return Number(adjustedValue);
160+
}
157161
}
158162

159163
private parseToMarkdown(wrapped: WrappedLiteral, localSettings: LocalSettings, isInline: boolean): string {

0 commit comments

Comments
 (0)