mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
The Dashboard view's By Assignee/By Label bars grouped a card with no
assignee or label under the literal English word "none" - untranslated in
every language, on the live chart, the data table, and the PDF/Excel
export alike (models/lib/chartCalculations.js's computeDashboardGroups
hardcoded {key: 'none', label: 'none'}). Two sentinel keys
(NO_ASSIGNEE_GROUP/NO_LABEL_GROUP) plus a shared translateGroupLabel()
replace it with a real "No assignee"/"No label", translated into all 245
locales directly (not left as English placeholders), everywhere that group
label is rendered: server/lib/boardChartData.js (the server chart-data
loader both the live view and the exporters read from),
models/lib/chartExportRows.js (the shared PDF/Excel/data-table shape), and
client/components/boards/charts/boardCharts.js (the live Chart.js bars).
Also fixes a board report chart (reported: Burndown) rendering its export
buttons and table but no visible chart: the `<canvas>` boardCharts.js draws
into only exists once isLoading/hasNoData flip Blaze's jade conditional to
its "else" branch - a sibling reactive change driven by the SAME chartData
update the chart-building autorun also depends on, with no guaranteed
ordering between the two Tracker computations. The very first successful
data load could run the chart-building body before Blaze patched the DOM;
templateInstance.find() silently returned null, no chart was ever built,
and nothing triggered a retry. The canvas lookup is now deferred with
Tracker.afterFlush so it always runs after the DOM has actually been
patched.
Also removes three dead <link> tags in gantt.jade pointing at
gantt.css/ganttCard.css/boardCharts.css's raw source path - all three are
already loaded through the normal bundler import (client/features/gantt.js,
client/features/boards.js), and the runtime <link> to the unserved source
path 404'd as text/html, pure console noise on every Gantt page load.
Thanks to xet7 !
40 lines
2.2 KiB
JavaScript
40 lines
2.2 KiB
JavaScript
'use strict';
|
|
|
|
// The 10 board report chart views (client/components/boards/charts/
|
|
// boardCharts.js) draw into a `<canvas>` that only exists in the DOM once
|
|
// isLoading/hasNoData flip Blaze's jade conditional to the "else" branch - a
|
|
// sibling reactive change driven by the SAME chartData ReactiveVar this
|
|
// autorun also depends on, with no guaranteed ordering between the two
|
|
// Tracker computations. Without deferring past that DOM patch, the very
|
|
// first successful data load could run the chart-building body before the
|
|
// canvas existed: templateInstance.find() silently returned null, no chart
|
|
// was ever built, and nothing triggered a retry - a chart view (reported:
|
|
// Burndown) rendered its export buttons and empty table but no visible
|
|
// chart at all.
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const path = require('node:path');
|
|
const root = path.join(__dirname, '..');
|
|
const read = file => fs.readFileSync(path.join(root, file), 'utf8');
|
|
|
|
const source = read('client/components/boards/charts/boardCharts.js');
|
|
|
|
// The canvas lookup and chart construction must be deferred with
|
|
// Tracker.afterFlush, INSIDE the autorun, so it runs after Blaze has
|
|
// patched the DOM for whatever reactive change just fired.
|
|
const autorunIndex = source.indexOf('templateInstance.autorun(() => {');
|
|
assert.ok(autorunIndex !== -1, 'the chart-building autorun exists');
|
|
const afterFlushIndex = source.indexOf('Tracker.afterFlush(() => {', autorunIndex);
|
|
assert.ok(afterFlushIndex !== -1, 'the canvas lookup is deferred with Tracker.afterFlush');
|
|
const canvasLookupIndex = source.indexOf("templateInstance.find('.js-chart-canvas')", autorunIndex);
|
|
assert.ok(canvasLookupIndex > afterFlushIndex,
|
|
'the canvas lookup happens INSIDE the afterFlush callback, not before it (negative: would still race)');
|
|
|
|
// A destroyed template must not build a chart into a canvas that is about to
|
|
// be torn down (the afterFlush callback can fire after the template is gone).
|
|
const afterFlushBody = source.slice(afterFlushIndex, source.indexOf("if (!canvas) return;", afterFlushIndex));
|
|
assert.match(afterFlushBody, /if \(templateInstance\.destroyed\) return;/);
|
|
|
|
console.log('chartCanvasRaceFix: the chart canvas is looked up after Blaze finishes patching the DOM, not before');
|