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

Commit 498c7fb

Browse files
committed
action to change column inline property
1 parent c6af021 commit 498c7fb

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

src/components/HeaderMenu.tsx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
6868
useState(null);
6969
const [settingsPopperElement, setSettingsPopperElement] = useState(null);
7070
const [showSettings, setShowSettings] = useState(false);
71+
const [toggleInlineFrontmatter, setToggleInlineFrontmatter] = useState(
72+
headerMenuProps.column.isInline
73+
);
74+
7175
useEffect(() => {
7276
if (created) {
7377
setExpanded(true);
@@ -256,6 +260,15 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
256260
return { name: columnName, position: columnNumber, label: columnLabel };
257261
}
258262

263+
function handleChangeToggleInlineFrontmatter(e: any) {
264+
setToggleInlineFrontmatter(e.target.checked);
265+
dispatch({
266+
type: ActionTypes.TOGGLE_INLINE_FRONTMATTER,
267+
columnId: id,
268+
isInline: e.target.checked,
269+
});
270+
}
271+
259272
return (
260273
<div>
261274
{expanded && (
@@ -405,7 +418,12 @@ const HeaderMenu = (headerMenuProps: HeaderMenuProps) => {
405418
<FormGroup>
406419
<FormControlLabel
407420
control={
408-
<Checkbox checked={headerMenuProps.column.isInline} />
421+
<Checkbox
422+
checked={toggleInlineFrontmatter}
423+
onChange={(event) => {
424+
handleChangeToggleInlineFrontmatter(event);
425+
}}
426+
/>
409427
}
410428
label="Inline"
411429
/>

src/components/reducers/DatabaseDispatch.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,13 @@ export function databaseReducer(state: TableDataType, action: ActionType) {
406406
*/
407407
case ActionTypes.ENABLE_RESET:
408408
return update(state, { skipReset: { $set: false } });
409+
410+
case ActionTypes.TOGGLE_INLINE_FRONTMATTER:
411+
// Update configuration & row files on disk
412+
state.view.diskConfig.updateColumnProperties(action.columnId, {
413+
isInline: action.isInline,
414+
});
415+
return state;
409416
default:
410417
LOGGER.warn(`<=> databaseReducer: unknown action ${action.type}`);
411418
}

src/helpers/Constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export const ActionTypes = Object.freeze({
1111
DELETE_COLUMN: 'delete_column',
1212
ENABLE_RESET: 'enable_reset',
1313
SETTINGS_COLUMN: 'settings_column',
14+
TOGGLE_INLINE_FRONTMATTER: 'toggle_inline_frontmatter',
1415
});
1516

1617
/** Flavours of data types */

0 commit comments

Comments
 (0)