Files
wekan/models/lib/attachmentTile.cjs
T
Lauri Ojansivu 2c520ef382 Declutter the opened card, attachments too, and fit Card Settings on the screen.
#6796: an opened card gave most of its height to controls with nothing in
them. Stickers, Location, Dependencies and List already have Show on Card
rows, and Date Format is in Member Settings; what was left:

- A field's add button sits on its title's line (Labels, Stickers,
  Location, the dates, Members, Assignee, Creator, Requested and Assigned
  By, Dependencies); what a field holds follows and wraps. Requested and
  Assigned By put their two buttons side by side.
- Checklists: the controls under the list share a line, and the bottom
  "+" is drawn once there is a checklist; before that it is the title
  line's.
- Attachments: the upload rules ("If filename is invalid, ...", size,
  types) are in the upload popup, not body text above every list. "+" is
  a small button. A file with nothing to preview gets a small file button
  that still opens the preview, instead of a 144x96 box with "txt" in it,
  and the name has a line of its own, so a long one is not hidden behind
  the buttons.
- Two new Board Settings / Card / Show on Card rows, Attachments: Preview
  and Attachments: Details (uploader and date), both on by default, built
  from existing translations.

Board Settings / Card is a centred panel as wide (up to 1800px) and tall
as the window, and each list spreads into as many 10em columns as fit,
read top to bottom: on 1920x1080 nothing is scrolled, on 1366x768 32px.

Its rows are dragged by the handle, the icon or the label when drag
handles are on, and by the icon or the label, with no handle drawn, when
they are off. With handles on only the handle dragged, and the rows were
locked to vertical moves, which the columns made unusable.

tests/declutterCard6796.test.cjs runs the tile decision and the popup
geometry, and checks the gates, the CSS and the drag wiring;
tests/playwright/specs/declutter-card-6796.e2e.js checks the add buttons
on their title's line, the compact attachment, the rules in the upload
popup, Attachments: Details, the new rows saving, no scroll at 1920x1080,
and a drag by label and handle with handles on and by label with them
off. cardSettingsCoverage and narrowWindowLayout follow the new rules.

Thanks to mueschel and xet7 !

Fixes #6796,
2026-10-22 19:15:36 +03:00

29 lines
1.2 KiB
JavaScript

'use strict';
// #6796: how big an attachment's tile is on the opened card
// (client/components/cards/attachments.jade, attachmentGallery).
//
// The full tile (144x96) is worth its space only when it SHOWS something - an
// image, an SVG, a video or audio player. A file with nothing to preview got the
// same box with its extension written in it ("txt"), which took more room than
// the file name did and pushed the name and its buttons out of the card. Such a
// file now gets a small file button, and so does every attachment when Board
// Settings / Card / Show on Card / Attachments: Preview is off. The small button
// still opens the preview, as the tile does.
const PREVIEW_EXTENSIONS = new Set(['svg', 'mp3', 'ogg', 'webm', 'mp4']);
function attachmentHasVisualPreview({ isImage, extension, hasLink } = {}) {
if (!hasLink) return false;
if (isImage) return true;
return PREVIEW_EXTENSIONS.has(String(extension || '').toLowerCase());
}
// previewsOn: the board's allowsAttachmentPreviewsOnCard (unset means on).
function attachmentTileCompact(file = {}, previewsOn) {
if (previewsOn === false) return true;
return !attachmentHasVisualPreview(file);
}
module.exports = { attachmentHasVisualPreview, attachmentTileCompact, PREVIEW_EXTENSIONS };