mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
d1be2d2131714d023a22a6ffc0a94de651dc7f4e
7
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
278db0ada3 |
Write dates as real date cells in every Excel export.
Reported directly, with a LibreOffice screenshot: the Frappe Gantt view's
Excel export showed Start/Due/End as ISO text ("2026-09-23T09:00:00.000Z").
ExporterChartExcel wrote cell.toISOString() into the cell. A date is now a
real date cell with a date number format (yyyy-mm-dd hh:mm), so the
spreadsheet shows it in its own date format, sorts it as a date and can do
arithmetic on it; the "-" placeholder for an unset date stays text. Every
chart export (Gantt, Time, the report charts) shares this exporter.
The follow-up ask - every other Excel export too:
- The board and card Excel exports draw the shared card document
(models/lib/cardDocument.js), whose meta pairs were pre-formatted text
(fmtDate), so Created/Received/Start/Due/End/Last activity were text
there as well. A date pair now carries the raw Date as a third element
([label, text, Date]); renderCardDocumentExcel writes that as a date cell
and the PDF keeps printing the text. ExporterExcelBoard's own
Created/Modified lines get the same treatment.
- The legacy whole-board Excel export (ExporterExcel.js) already wrote Date
values into numFmt columns; nothing to change, pinned as such.
tests/chartExcelDateCells.test.cjs drives the chart row-writing branch
against a stand-in worksheet and pins the other exporters' shapes;
tests/pdfExport.test.cjs updated for add()'s third argument.
Thanks to xet7 !
|
||
|
|
0885b9a10b | Share one card document adapter across PDF and Excel exports. | ||
|
|
57c806705c | Order detailed exports by board hierarchy. | ||
|
|
f6e3144452 |
Step 4: the PDF draws the shared card document, so both formats have one layout.
"PDF export layout should be like Excel layout", and "export board, swimlane,
list, card to Excel and PDF should have same layout like export card to Excel" -
with markdown rendered and only the fields that have data.
The PDF laid a card out itself: a hundred and sixty lines that had to be kept in
step with the Excel exporter's layout by hand, and were not. The Excel export
drew sections under filled headers with label/value columns; the PDF drew a flat
list of monospaced lines. Both ask models/lib/cardDocument.js for the layout now
and only the drawing differs, so a section added to one is in the other.
WHAT A PAGE MAKES OF THE DOCUMENT, in pdfDocument.js: a section is a filled grey
bar, a meta block is a row of label/value columns with the labels in bold, text
is markdown wrapped and styled, a list keeps its marker, a comment keeps its
date and its author. The bars are real rectangles - drawn outside BT/ET, because
a PDF text object may not contain a path - and the y of each line is known from
its index, so it needs no layout pass.
What is left in the exporter is the MAPPING: Meteor documents, user ids and
dates turned into the plain names and strings the document takes. That is the
only part that knows a Mongo document from a string.
FOUR REGRESSIONS THE EXISTING GUARDS CAUGHT, every one a field that would have
gone missing from the file:
* requested by / assigned by - a card's own record of who asked for it, and a
suite exists precisely because they have been lost from an export before;
* card number, last activity, spent time and overtime;
* the labels and the dates, which two suites check by name;
* and every label's English fallback. The document was passing keys without
one, so a missing translation would have printed "card-due" on the page.
The words live in one table now, which also stops a PDF saying "Due" where
a spreadsheet says "Due date".
The guards themselves follow the layout to where it went: they read the exporter
AND the document, because a field is now carried by the pair, and reading only
the exporter would report a field as lost when it had merely moved to where both
formats take it from.
Verified as far as this sandbox allows: the mapping is extracted from the file
and executed against a stand-in exporter (tests/pdfDrawsTheDocument.test.cjs),
the document it builds is checked section by section, and the bytes are checked
to be a PDF whose xref offset points at its table. There is no PDF viewer here,
so how the page LOOKS is still to be checked by eye.
Thanks to Heart1010 and xet7 !
Fixes #6586,
|
||
|
|
bd009cf601 |
Export a board, a swimlane or a list, in the card export's own layout,
with a popup for what to include. #1173 "Add Feature: Print Board with Params" has been open since 2017, and two things were missing. There was no CHOICE of what to print. The board's Excel and PDF exports took everything they knew how to render and nothing else, while the card export already had a popup with a checkbox per section. And they did not LOOK like the card export: the board's Excel export was a spreadsheet table, one row per card and eighteen columns, which is a data dump rather than a printed board. Both now render a board as its own header followed by every card as the CARD export's block, drawn by the card export's own code - cardBlockLines() for the PDF, ExporterExcelCard.renderCardBlock() for the Excel one. A card looks the same whether it was exported alone or inside its board, and the two cannot drift into two layouts again. Each card starts on its own page in the Excel export, because a printed board is read a card at a time. The swimlane and list menus offer the same export, which is the board export with one query parameter saying which cards are in scope. They sit beside "Copy link" rather than under the permission checks, because exporting is reading, and the file is named for what was exported - a PDF titled with the board that holds one list is a file nobody can place afterwards. The selection is one popup body used by all three menus, and one list: models/lib/exportFields.js, imported by the exporters and by every popup. The card export's list used to live twice, in the server and in cardDetails.js under a comment reading "Must match ALL_FIELDS ..." - which is a comment, not a mechanism, and a section added on one side is either a checkbox that does nothing or a section nobody can turn off. The same ?fields= now gates the same sections in both formats; the card popup's checkboxes used to say "fields to include in Excel export" and did nothing to the PDF. A card block cannot be streamed - it merges cells, styles them and returns to earlier rows - and models/server/ExporterExcel.js streams on purpose, after the in-memory version ate gigabytes on boards with thousands of cards. That exporter is still there and still reachable: unticking "Card details" asks for it. A checkbox, not a silent fallback. A board's per-card data is read once per collection and grouped by card. The card export's own per-card queries would be fifteen hundred round trips on a board of three hundred cards. tests/boardExportScope.test.cjs pins the shared block, the shared list, the gating, the three menus and the streaming exporter still being reachable. Two guards moved rather than being deleted: they pinned the board PDF building its own labels and the server's own copy of the field list, which is the behaviour that deliberately changed. Thanks to xet7 ! Fixes #1173, |
||
|
|
698e980e27 |
Card PDF and Excel exports say the same thing, in the reader's language,
format and time zone. #6586 was reopened for what the first fix left, and every point of it was a symptom of one thing: the PDF export of a card had grown separately from the Excel export of the same card. "Assignee, Labels, due,... these titels should be in the user set language" - the labels were hard-coded English, and not even consistent with each other: the card export wrote "Due: " while the board export wrote "due" with no colon. Both exports now build every label from the same i18n keys, in the language the request carries, through one field() helper that writes every "Label: value" - so the two cannot drift apart again. Every key carries its English text as the fallback, so a missing translation shows the word and never the key. "I think all those other things we set in a card should be also present" - both exports now carry title, labels, creator, assignees, members, board, swimlane, list, card number, requested by, assigned by, the six dates, spent time, description, custom fields, checklists, subtasks, comments, attachments, voting and Planning Poker, in that order. Custom fields, voting and poker are new on BOTH sides; they are appended to ALL_FIELDS rather than inserted, so a saved ?fields= link still asks for what it always asked for, and they are checkboxes in the export popup like the rest. "the time is not in the user set timezone (-2h wrong for Europe/Berlin)" - it was worse than -2h: the PDF printed UTC and the Excel export printed whatever zone the server was started in. Dates are stored in UTC and a profile carries no zone, so the export links now send the browser's IANA zone and the date format the OPENED CARD is showing - which for a logged-out reader lives in localStorage, where no server-side lookup reaches it. Both exports format through formatDateByUserPreference, which gained an optional zone; without one it still renders in the process zone, which is what every client-side caller wants. A server-built export given no zone renders UTC and says UTC. Verified: 12:00Z prints 14:00 for Europe/Berlin, 00:00 on the 15th for Pacific/Auckland, and an unknown zone falls back instead of failing. "would it make sense to support markdown formated text in description" - a description is now cut into runs and drawn in the four base-14 Courier faces, so **bold**, *italic* and ***both*** are bold, italic and both. Consecutive Tj operators continue at the current text position, so a font switch needs no glyph measuring. Strikethrough and inline code keep their words and lose their markers - a Type1 base-14 font has no strike and there is no fifth face for code - and an underscore inside a word stays an underscore. tests/cardExportParity.test.cjs pins the shared field list, keys, formatter and request params; tests/pdfExport.test.cjs gains the runs, the wrapping and the four declared faces. Two of its guards moved rather than being deleted: they pinned the hard-coded English "Labels: " and "due", which is the behaviour that deliberately changed, and they now pin that both come from the same keys. Thanks to Heart1010 and xet7 ! Fixes #6586, |
||
|
|
eb14168893 |
Fix #6586: the PDF export writes umlauts, not question marks.
"When using Board settings » Export board » export / PDF we get a pdf file but the umlauts (german, ä, ü, ö,...) are corrupt", "all the text in this PDF file is markdown formatted - this doesn't make sense in a pdf file, does it?", and "I can't see in which swimlane a card is in that export, no tags". The umlauts were removed on purpose, one line before anything was written: .replace(/[^\x20-\x7E\n]/g, '?') so "Grüße" left the server as "Gr??e". That line was a workaround for the real problem rather than a choice: text in a PDF is BYTES PLUS AN ENCODING, and the exporter declared neither. A `(...)` string in a content stream is read through the font's encoding; no /Encoding was given, so a viewer used the font's built-in one, where the bytes above 127 are not the Latin-1 letters - and the file was assembled as a UTF-8 string, so one "ü" would have arrived as two bytes and drawn as two wrong glyphs. With no encoding to write into, erasing the letters was the only thing left that did not corrupt the file. So the font declares /WinAnsiEncoding - Windows-1252, which every viewer has for the base-14 fonts - the text is encoded to those single bytes, and the file is assembled as binary. The xref offsets are measured in bytes for the same reason: measured as UTF-8, every offset after the first accented character is wrong, and some viewers refuse the file outright. What Windows-1252 does not have is transliterated rather than erased: a Latin letter loses its mark (ā -> a, ź -> z, Ł -> L) and keeps its word. Only a script the base-14 fonts cannot draw at all - Cyrillic, Greek, Hebrew, Arabic, CJK, emoji - still falls back to '?', because the fix for those is an embedded Unicode font and that is a font binary this repository does not carry. It is in TODO Later. Markdown is flattened instead of printed. `**bold**` in a PDF is four asterisks, and the board export was itself emitting markdown - "## List (3)", "- Card" - into a file that has no markdown in it. The structure is drawn now: headings and titles in Courier-Bold, cards as bullets, and a card's own markdown reduced to its words (links keep their text and their URL). Emphasis underscores only count at a word boundary, so `snake_case` and `file_name_here` are left alone - markdown treats them the same way. And the board export says what it was missing: swimlanes (walked swimlane by swimlane when a board has more than the one every board is created with, and not mentioned at all when it does not), labels, members, assignees and the dates. The PDF itself - encoding, flattening, wrapping, pagination - moves to models/lib/pdfDocument.js, which is pure, so tests/pdfExport.test.cjs reads the BYTES that come out: that ü is 0xFC and ß is 0xDF, that the euro sign is 0x80, which Latin-1 does not have at all, that every xref row points at the object it claims, and that the bold font is selected only where a heading asks for it. Its negative half is the part worth keeping: junk never throws, an empty board still produces a file that opens, `2 * 3 * 4` and `a_b_c` are not emphasis, and a Japanese title degrades to '?' without ever emitting a byte above 0xFF into the stream. Verified by running the suite and the whole node suite (378 suites, 0 failed). Not verified against a PDF viewer: this sandbox has none, so the bytes are checked against the PDF specification's own rules instead. Thanks to Heart1010 and xet7 ! Fixes #6586. |