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

Commit 2954092

Browse files
committed
Merge branch 'master' into 377-bug-when-using-the-data-view-query-as-source-you-cant-seem-to-add-existing-columns
2 parents 1b1b5d7 + 05ea752 commit 2954092

File tree

13 files changed

+121
-21
lines changed

13 files changed

+121
-21
lines changed

src/cdm/FolderModel.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export interface ConfigColumn {
3939
media_width: number;
4040
media_height: number;
4141
isInline: boolean;
42-
content_alignment: string;
42+
content_alignment?: string;
4343
task_hide_completed?: boolean;
4444
formula_query?: string;
4545
persist_formula?: boolean;

src/cdm/SettingsModel.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export interface LocalSettings {
4141
formula_folder_path: string;
4242
inline_default: boolean;
4343
inline_new_position: string;
44+
date_format: string;
45+
datetime_format: string;
4446
}
4547

4648
export interface FilterSettings {

src/components/cellTypes/FormulaCell.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CellComponentProps } from "cdm/ComponentsModel";
22
import { TableColumn } from "cdm/FolderModel";
33
import { renderMarkdown } from "components/obsidianArq/MarkdownRenderer";
4-
import { c } from "helpers/StylesHelper";
4+
import { c, getAlignmentClassname } from "helpers/StylesHelper";
55
import React, { useEffect, useRef } from "react";
66

77
const FormulaCell = (mdProps: CellComponentProps) => {
@@ -46,7 +46,9 @@ const FormulaCell = (mdProps: CellComponentProps) => {
4646
return (
4747
<span
4848
ref={formulaRef}
49-
className={`${c("md_cell " + tableColumn.config.content_alignment)}`}
49+
className={`${c(
50+
"md_cell " + getAlignmentClassname(tableColumn.config.content_alignment)
51+
)}`}
5052
key={`formula_${cell.id}`}
5153
/>
5254
);

src/components/cellTypes/NumberCell.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { CellComponentProps } from "cdm/ComponentsModel";
22
import { TableColumn } from "cdm/FolderModel";
3-
import { c } from "helpers/StylesHelper";
3+
import { c, getAlignmentClassname } from "helpers/StylesHelper";
44
import React, {
55
ChangeEventHandler,
66
KeyboardEventHandler,
@@ -61,11 +61,11 @@ const NumberCell = (props: CellComponentProps) => {
6161
onChange={handleOnChange}
6262
onKeyDown={handleKeyDown}
6363
onBlur={handleOnBlur}
64-
className={c(tableColumn.config.content_alignment)}
64+
className={c(getAlignmentClassname(tableColumn.config.content_alignment))}
6565
/>
6666
) : (
6767
<span
68-
className={c(tableColumn.config.content_alignment)}
68+
className={c(getAlignmentClassname(tableColumn.config.content_alignment))}
6969
onClick={handleEditableOnclick}
7070
style={{ width: column.getSize() }}
7171
>

src/components/cellTypes/TextCell.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import React, { MouseEventHandler, useEffect, useRef } from "react";
44
import { useState } from "react";
55
import EditorCell from "components/cellTypes/EditorCell";
66
import { TableColumn } from "cdm/FolderModel";
7-
import { c } from "helpers/StylesHelper";
7+
import { c, getAlignmentClassname } from "helpers/StylesHelper";
88

99
const TextCell = (props: CellComponentProps) => {
1010
const { defaultCell } = props;
@@ -73,7 +73,7 @@ const TextCell = (props: CellComponentProps) => {
7373
ref={containerCellRef}
7474
onClick={handleEditableOnclick}
7575
style={{ width: column.getSize() }}
76-
className={c(tableColumn.config.content_alignment)}
76+
className={c(getAlignmentClassname(tableColumn.config.content_alignment))}
7777
/>
7878
);
7979
};

src/components/portals/CalendarPortal.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ const CalendarPortal = (calendarProps: CellComponentProps) => {
6969
style={{ width: column.getSize() }}
7070
>
7171
{DateTime.isDateTime(calendarValue)
72-
? (calendarValue as unknown as DateTime).toFormat("yyyy-MM-dd")
72+
? (calendarValue as unknown as DateTime).toFormat(
73+
configInfo.getLocalSettings().date_format
74+
)
7375
: null}
7476
</span>
7577
);

src/components/portals/CalendarTimePortal.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const CalendarTimePortal = (calendarTimeProps: CellComponentProps) => {
5050
(tableColumn.isMetadata === undefined || !tableColumn.isMetadata) ? (
5151
<div className="calendar-time">
5252
<DatePicker
53-
dateFormat="yyyy-MM-dd h:mm aa"
53+
dateFormat={configInfo.getLocalSettings().datetime_format}
5454
selected={
5555
DateTime.isDateTime(calendarTimeState)
5656
? (calendarTimeState as unknown as DateTime).toJSDate()
@@ -72,7 +72,9 @@ const CalendarTimePortal = (calendarTimeProps: CellComponentProps) => {
7272
<div onClick={handleSpanOnClick}>
7373
<span className="calendar-time" style={{ width: column.getSize() }}>
7474
{DateTime.isDateTime(calendarTimeState)
75-
? (calendarTimeState as DateTime).toFormat("yyyy-MM-dd h:mm a")
75+
? (calendarTimeState as DateTime).toFormat(
76+
configInfo.getLocalSettings().datetime_format
77+
)
7678
: null}
7779
</span>
7880
</div>

src/helpers/Constants.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ export const DEFAULT_COLUMN_CONFIG: ConfigColumn = Object.freeze({
8686
media_width: 100,
8787
media_height: 100,
8888
isInline: false,
89-
task_hide_completed: true,
90-
content_alignment: COLUMN_ALIGNMENT_OPTIONS.LEFT,
89+
task_hide_completed: true
9190
});
9291

9392
export const MetadataDatabaseColumns: MetadataColumnsModel = Object.freeze({
@@ -370,6 +369,8 @@ export const DEFAULT_SETTINGS: DatabaseSettings = {
370369
formula_folder_path: '/',
371370
inline_default: false,
372371
inline_new_position: INLINE_POSITION.TOP,
372+
date_format: 'yyyy-MM-dd',
373+
datetime_format: 'yyyy-MM-dd HH:mm:ss',
373374
}
374375
};
375376
/******************************************************************************

src/helpers/StylesHelper.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ export function getLabelHeader(input: string) {
3939
}
4040
});
4141
return labelCandidate === undefined ? input : labelCandidate[1];
42+
}
43+
44+
export function getAlignmentClassname(alignment: string) {
45+
return alignment === undefined ? COLUMN_ALIGNMENT_OPTIONS.LEFT : alignment;
4246
}

src/parsers/handlers/marshall/MarshallColumnsHandler.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,6 @@ export class MarshallColumnsHandler extends AbstractYamlHandler {
6868
if (column.config.isInline === undefined) {
6969
column.config.isInline = DEFAULT_COLUMN_CONFIG.isInline;
7070
}
71-
if (column.config.content_alignment === undefined) {
72-
column.config.content_alignment = DEFAULT_COLUMN_CONFIG.content_alignment;
73-
}
7471
column = marshallParticularConfigInfo(column);
7572
}
7673
// Update mashaller response

0 commit comments

Comments
 (0)