Fix PDF font color not reflecting system settings
Root cause: resolveFontPrefsForUser() uses `userRow ?? globalRow` precedence. When an admin saved font settings with scope="global", only the global row was updated. If the admin also had a user-scope row (created by prior saves with the default scope="user"), the user-scope row still overrode the global row during PDF generation, causing the PDF to show the old color. Backend fix (executive-meetings.ts): - When saving with scope="global", delete the current admin's user-scope row within the same transaction. This ensures global settings immediately apply to the admin who set them. Other users' personal rows are unaffected. Frontend fix (executive-meetings.tsx): - Pass both `globalFont` and effective `font` to FontSettingsSection. - When the scope dropdown changes, the form now loads the selected scope's actual saved values instead of always showing the effective (user-override) values. This prevents confusion where the admin edits "global" but sees their personal values in the form. Verified end-to-end: - PATCH font-settings with scope=user + fontColor=#ff0000 → DB updated → PDF uses red - PATCH font-settings with scope=global + fontColor=#0000ff → global updated, user-scope row deleted → PDF resolves to global blue - TypeScript compiles cleanly, e2e Playwright test passes
This commit is contained in:
@@ -2970,6 +2970,16 @@ const upsertFontSettingsHandler = async (
|
||||
});
|
||||
}
|
||||
}
|
||||
if (data.scope === "global") {
|
||||
await tx
|
||||
.delete(executiveMeetingFontSettingsTable)
|
||||
.where(
|
||||
and(
|
||||
eq(executiveMeetingFontSettingsTable.scope, "user"),
|
||||
eq(executiveMeetingFontSettingsTable.userId, userId),
|
||||
),
|
||||
);
|
||||
}
|
||||
await logAudit(tx, {
|
||||
action: existing ? "update" : "create",
|
||||
entityType: "font_settings",
|
||||
|
||||
Reference in New Issue
Block a user