mirror of
https://github.com/taskgenius/taskgenius-plugin.git
synced 2026-07-22 06:40:25 +00:00
feat(gantt): add config override support for Bases integration
- Add setConfigOverride method to GanttComponent - Add getEffectiveGanttConfig to merge base config with overrides - Add applyEffectiveConfig to update internal config object - Apply effective config in onload and when override changes - Support showTaskLabels and useMarkdownRenderer overrides This completes config override support across all view components (calendar, forecast, kanban, quadrant, and gantt), enabling Bases plugin to customize view-specific settings independently.
This commit is contained in:
parent
227f85d793
commit
11a8d5a071
1 changed files with 42 additions and 0 deletions
|
|
@ -22,6 +22,8 @@ import { ActiveFilter, FilterCategory } from "@/components/features/task/filter/
|
|||
import { ScrollToDateButton } from '@/components/features/task/filter/in-view/custom/scroll-to-date-button';
|
||||
import { PRIORITY_MAP } from "@/common/default-symbol";
|
||||
|
||||
import { GanttSpecificConfig } from "@/common/setting-definition";
|
||||
|
||||
// Define the PRIORITY_MAP here as well, or import it if moved to a shared location
|
||||
// This is needed to convert filter value (icon/text) back to number for comparison
|
||||
|
||||
|
|
@ -132,6 +134,10 @@ export class GanttComponent extends Component {
|
|||
// Helpers
|
||||
private dateHelper = new DateHelper();
|
||||
|
||||
// Per-view override from Bases
|
||||
private configOverride: Partial<GanttSpecificConfig> | null = null;
|
||||
|
||||
|
||||
private config = {
|
||||
showDependencies: false,
|
||||
taskColorBy: "status",
|
||||
|
|
@ -192,6 +198,9 @@ export class GanttComponent extends Component {
|
|||
this.renderInternal,
|
||||
this.config.debounceRenderMs
|
||||
);
|
||||
|
||||
|
||||
|
||||
// Debounce header updates triggered by scroll
|
||||
this.debouncedHeaderUpdate = debounce(
|
||||
this.updateHeaderComponent,
|
||||
|
|
@ -201,6 +210,8 @@ export class GanttComponent extends Component {
|
|||
|
||||
onload() {
|
||||
console.log("GanttComponent loaded.");
|
||||
this.applyEffectiveConfig();
|
||||
|
||||
this.createBaseSVG(); // Creates SVG and groups
|
||||
|
||||
// Instantiate Child Components
|
||||
|
|
@ -220,6 +231,9 @@ export class GanttComponent extends Component {
|
|||
],
|
||||
},
|
||||
this.plugin
|
||||
|
||||
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
|
|
@ -249,6 +263,8 @@ export class GanttComponent extends Component {
|
|||
this.registerDomEvent(this.containerEl, "wheel", this.handleWheel, {
|
||||
passive: false,
|
||||
});
|
||||
this.applyEffectiveConfig();
|
||||
|
||||
// Initial render is triggered by updateTasks or refresh
|
||||
}
|
||||
|
||||
|
|
@ -277,6 +293,32 @@ export class GanttComponent extends Component {
|
|||
this.preparedTasks = [];
|
||||
}
|
||||
|
||||
public setConfigOverride(override: Partial<GanttSpecificConfig> | null): void {
|
||||
this.configOverride = override ?? null;
|
||||
this.applyEffectiveConfig();
|
||||
// Re-render with new settings
|
||||
this.debouncedRender();
|
||||
}
|
||||
|
||||
private getEffectiveGanttConfig(): Partial<GanttSpecificConfig> {
|
||||
const view = this.plugin.settings.viewConfiguration.find(v => v.id === this.viewId);
|
||||
let base: Partial<GanttSpecificConfig> = {};
|
||||
if (view && view.specificConfig && view.specificConfig.viewType === "gantt") {
|
||||
base = view.specificConfig as GanttSpecificConfig;
|
||||
} else {
|
||||
const def = this.plugin.settings.viewConfiguration.find(v => v.id === "gantt");
|
||||
base = (def?.specificConfig as GanttSpecificConfig) || ({} as any);
|
||||
}
|
||||
return { ...(base ?? {}), ...(this.configOverride ?? {}) };
|
||||
}
|
||||
|
||||
private applyEffectiveConfig(): void {
|
||||
const eff = this.getEffectiveGanttConfig();
|
||||
if (typeof eff.showTaskLabels === "boolean") this.config.showTaskLabels = eff.showTaskLabels;
|
||||
if (typeof eff.useMarkdownRenderer === "boolean") this.config.useMarkdownRenderer = eff.useMarkdownRenderer;
|
||||
}
|
||||
|
||||
|
||||
setTasks(newTasks: Task[]) {
|
||||
this.preparedTasks = []; // Clear prepared tasks
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue