mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Reported directly: the Frappe Gantt view (and the DHTMLX Gantt, WeKan Gantt, Time and the ten report-chart views) each showed two untranslated "Export to PDF" / "Export to Excel" links. They now share one translated "Export" button that opens a new exportChartPopup - the same pop-over list of formats the board/swimlane/list/card export popup uses, offering PDF and Excel with the same icons and labels. The URL is built in exactly one place, client/components/boards/charts/exportChart.js's chartExportUrl(); the five per-view copies of that helper (gantt.js, frappeGantt.js, dhtmlxGantt.js, timeView.js, boardCharts.js) are gone. One delegated click handler opens the popup with the view's data-chart-key as its data context. The popup's title, exportChartPopup-title, is added to every locale from that locale's existing "export" translation - no new words to translate. Also from the same report: Frappe Gantt's own chrome was English in every language. Its view-mode dropdown prints each mode's `name` and looks modes up by it, so it now receives translated copies of Frappe's default modes (GanttLib.VIEW_MODE) - Day/Week/Month from the existing keys, and four new keys (gantt-view-hour, -quarter-day, -half-day, -year) added to every locale as English placeholders to be filled next. Its hardcoded "Today" button and "Mode" placeholder are rebuilt on every view change, so a MutationObserver re-translates them (existing "today" key; new gantt-view-mode), disconnected in onDestroyed. tests/chartExportPopup.test.cjs pins all of it; boardViewMenu, reportChartLibraries and timeViewReportAndExport updated from the old per-view links to the shared button/builder. Thanks to xet7 !
64 lines
3.9 KiB
JavaScript
64 lines
3.9 KiB
JavaScript
'use strict';
|
|
|
|
// #812 ("Add feature: Timesheet / Time Tracking"): the community discussion
|
|
// (39 comments) repeatedly asked for external integrations (Kimai, Harvest,
|
|
// Titra) that were never resourced (the maintainer's own 2021 comment quoted
|
|
// a ~1000 EUR / 4-month estimate for a Kimai sync and it was shelved). What
|
|
// the thread DID converge on that fits inside WeKan itself, without an
|
|
// external service: "reporting total hours by resource and task type"
|
|
// (the issue's own words) and export "like other chart views" - this file
|
|
// pins exactly those two additions to the Time board view.
|
|
|
|
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');
|
|
|
|
// --- 'time' is a real, exportable chartKey, alongside every other board
|
|
// report chart - not a second, parallel export pipeline just for Time.
|
|
const exportCharts = read('models/exportCharts.js');
|
|
// Match 'time' anywhere inside the Set literal - not necessarily last, since
|
|
// later chart keys (e.g. 'pulse') are appended after it.
|
|
assert.match(exportCharts, /const CHART_KEYS = new Set\(\[[\s\S]*?'time'[\s\S]*?\]\);/);
|
|
|
|
// --- server/lib/boardChartData.js answers 'time' with an assignee
|
|
// breakdown (hours, not card counts) and a per-card breakdown, scoped to
|
|
// non-archived cards (matching the existing Time summary's own scope).
|
|
const boardChartData = read('server/lib/boardChartData.js');
|
|
assert.match(boardChartData, /chartKey === 'time'/);
|
|
assert.match(boardChartData, /computeTimeByGroup\(activeCards, card =>/);
|
|
assert.match(boardChartData, /computeTimeByCard\(activeCards\)/);
|
|
assert.match(boardChartData, /const activeCards = allCards\.filter\(card => !card\.archived\);/);
|
|
assert.match(boardChartData, /NO_ASSIGNEE_GROUP/, 'the empty-assignee bucket is the real translated sentinel, not a hardcoded "none"');
|
|
|
|
// --- models/lib/chartExportRows.js turns that into the same
|
|
// {title, headers, rows} table shape the PDF/Excel exporters already share
|
|
// with every other chart, and gives it a real title.
|
|
const chartExportRows = read('models/lib/chartExportRows.js');
|
|
assert.match(chartExportRows, /time: \['board-view-time', 'Time'\]/);
|
|
assert.match(chartExportRows, /chartKey === 'time'/);
|
|
assert.match(chartExportRows, /translateGroupLabel\(group\.label, translate\)/);
|
|
|
|
// --- the live Time view calls the SAME boardChartData method (chartKey
|
|
// 'time') as every chart view, and offers PDF/Excel export through the SAME
|
|
// /api/boards/:boardId/charts/:chartKey/export* routes - "like other chart
|
|
// views", not a bespoke Time-only export.
|
|
const timeViewJs = read('client/components/boards/timeView.js');
|
|
assert.match(timeViewJs, /Meteor\.call\('boardChartData', boardId, 'time'/);
|
|
// The export URL is built in the one shared place every chart view uses
|
|
// (exportChart.js, chartKey from the view's Export button); the Time view
|
|
// names its chart key there. tests/chartExportPopup.test.cjs covers the popup.
|
|
assert.doesNotMatch(timeViewJs, /timeExportUrl\(format\)/, 'no Time-only export URL builder');
|
|
assert.match(read('client/components/boards/charts/exportChart.js'), /\/api\/boards\/\$\{boardId\}\/charts\/\$\{chartKey\}\/\$\{path\}/);
|
|
|
|
const timeViewJade = read('client/components/boards/timeView.jade');
|
|
assert.match(timeViewJade, /a\.chart-export-button\.js-export-chart\(href="#" data-chart-key="time"\)/);
|
|
// Negative: the original 3-row summary is kept exactly as it was (this is
|
|
// additive - #812's asks are new sections alongside it, not a replacement).
|
|
assert.match(timeViewJade, /\{\{_ 'board-status-time-spent-total'\}\}/);
|
|
assert.match(timeViewJade, /\{\{_ 'board-status-cards-with-time'\}\}/);
|
|
assert.match(timeViewJade, /\{\{_ 'board-status-overtime-cards'\}\}/);
|
|
|
|
console.log('timeViewReportAndExport: Time view now reports hours by assignee/card and exports like every other chart view');
|