mirror of
https://github.com/wekan/wekan.git
synced 2026-11-26 14:45:11 -05:00
attachments. Two things, one commit each would have been two lines apart in the same files. THE X. Clicking a card's title opens the title editor in place of the card header - and the header is where the card's own close X lives, so the X disappeared the moment you started editing and Save became the only visible way out. Escape still worked; nothing on the screen said so. The editor draws the X itself now, reusing .close-card-details, the header button's own class, so it is the same size in the same place and does not jump as the editor opens and closes. That class floats to inline-end - the right in English, the left in Arabic - so the RTL mirroring needs no direction branch, and a negative test says it must not grow one. It is an <a> and not a <button>, because a button inside the form would submit it, and the click reaches the shared inlinedForm handler by bubbling. The same one-line omission was in the Requested by and Assigned by editors below it: the close anchor was there and its icon was not, so the click target existed and was invisible. Ten more of those exist in other files and are left for their own change. THE ATTACHMENTS. The scoped import was half a round trip: a card imported from a swimlane, list or card menu arrived with its checklists and comments and without its files. A .json export carries each attachment as base64, and ScopedImporter writes them the way the board import always has - the server-side Meteor-Files writeAsync, one at a time. A .zip carries them as files named attachments/<id>-<name>; the archive is unpacked in the browser and each file is put back on the metadata row its id names, so the server sees the same document either way and there is ONE import path rather than one per container. The whole-board import on the import page now takes a .json or a .zip through that same reader, which is the case the .zip exists for. An attachment lands where its CARD landed - the list and swimlane it is in now, not the ones it was exported from. One unreadable file is warned about and skipped rather than losing the rest of the import, an empty one is not written as a zero-byte attachment, and a `url` attachment from an older export still goes through the downloader that validates and pins every hop, so FollowBleed stays fixed on this path too. The tradeoff worth knowing: the archive is unpacked in the browser and sent as base64, so a .zip full of large attachments costs memory on the way in. It is the shape the board import has always used, and it is written down where the unpacking happens. Thanks to xet7 !
108 lines
4.9 KiB
JavaScript
108 lines
4.9 KiB
JavaScript
'use strict';
|
|
|
|
// Editing a card's title keeps the X that closes it.
|
|
// Run: node tests/cardTitleEditClose.test.cjs
|
|
//
|
|
// The card header carries the card's own close X. Opening the title editor
|
|
// REPLACES that header - `+inlinedForm(classNames="js-card-details-title")`
|
|
// renders `editCardTitleForm` in its place - so the X vanished the moment you
|
|
// clicked the title, and Save was the only way out of the editor. Escape worked,
|
|
// and nothing on the screen said so.
|
|
//
|
|
// The editor now draws the X itself, in the same place: it reuses
|
|
// `.close-card-details`, the class the header's own X uses, so the button does
|
|
// not move or change size as the editor opens and closes. That class floats to
|
|
// `inline-end` - the right in English, the left in Arabic - which is why there
|
|
// is no RTL branch here and must not become one.
|
|
//
|
|
// The click is handled by the generic `Template.inlinedForm` events in
|
|
// client/lib/inlinedform.js, which the anchor's `js-close-inlined-form` class
|
|
// reaches by bubbling. That is also why an <a> and not a <button>: a button
|
|
// inside the form would submit it.
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const ROOT = path.join(__dirname, '..');
|
|
const read = rel => fs.readFileSync(path.join(ROOT, rel), 'utf8');
|
|
|
|
const jade = read('client/components/cards/cardDetails.jade');
|
|
const css = read('client/components/cards/cardDetails.css');
|
|
const inlinedForm = read('client/lib/inlinedform.js');
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
|
|
function template(name) {
|
|
const start = jade.indexOf(`template(name="${name}")`);
|
|
assert.ok(start !== -1, `missing template: ${name}`);
|
|
const next = jade.indexOf('\ntemplate(name="', start + 1);
|
|
return jade.slice(start, next === -1 ? undefined : next);
|
|
}
|
|
|
|
console.log('cardTitleEditClose:');
|
|
|
|
test('the title editor has a close X, not just Save', () => {
|
|
const form = template('editCardTitleForm');
|
|
assert.ok(/a\.close-card-details\.js-close-inlined-form/.test(form),
|
|
'the editor draws a close button of its own');
|
|
assert.ok(/i\.fa\.fa-times-thin/.test(form),
|
|
'with the X icon in it - an empty anchor is a click target nobody can see');
|
|
assert.ok(/js-submit-edit-card-title-form/.test(form), 'and Save is still there');
|
|
});
|
|
|
|
test('it is in the same place as the header X it replaces', () => {
|
|
const form = template('editCardTitleForm');
|
|
// Same class as the card's own close button, so it does not jump when the
|
|
// editor opens.
|
|
assert.ok(/close-card-details/.test(form), 'it reuses the header button class');
|
|
// The selector list this rule shares is long; take it to its closing brace
|
|
// rather than guessing a character count.
|
|
const from = css.indexOf('.card-details .card-details-header .close-card-details,');
|
|
const rule = css.slice(from, css.indexOf('}', from));
|
|
assert.ok(/float:\s*inline-end/.test(rule),
|
|
'which floats to the inline end');
|
|
// And it is FIRST in the form, so it is at the top rather than under the text.
|
|
assert.ok(form.indexOf('close-card-details') < form.indexOf('textarea'),
|
|
'above the textarea, which is what puts it at the top of the editor');
|
|
});
|
|
|
|
test('RTL mirrors by itself, with no second rule (negative)', () => {
|
|
// `float: inline-end` is already the left in a right-to-left language. A
|
|
// `float: right` or a direction branch would pin it to one side in both.
|
|
const from = css.indexOf('.card-details .card-details-header .close-card-details,');
|
|
const rule = css.slice(from, css.indexOf('}', from));
|
|
assert.ok(!/float:\s*right/.test(rule), 'no physical float on the header controls');
|
|
const form = template('editCardTitleForm');
|
|
assert.ok(!/rtl|dir="rtl"/.test(form), 'and no direction branch in the editor');
|
|
});
|
|
|
|
test('the click closes the form through the shared handler', () => {
|
|
assert.ok(/'click \.js-close-inlined-form'/.test(inlinedForm),
|
|
'inlinedForm handles the class, and the click bubbles to it');
|
|
const form = template('editCardTitleForm');
|
|
assert.ok(!/button[^\n]*js-close-inlined-form/.test(form),
|
|
'an <a>, not a <button> - a button inside the form would submit it');
|
|
});
|
|
|
|
test('the other card editors show their X too', () => {
|
|
// The same one-line omission: the anchor was there, the icon was not, so the
|
|
// close was invisible in these as well.
|
|
for (const name of ['editCardRequesterForm', 'editCardAssignerForm']) {
|
|
const form = template(name);
|
|
assert.ok(/js-close-inlined-form\n\s+i\.fa\.fa-times-thin/.test(form),
|
|
`${name} has a visible close`);
|
|
}
|
|
});
|
|
|
|
test('the title editor keeps exactly one close anchor (negative)', () => {
|
|
// Two would both fire on the programmatic `.js-close-inlined-form` clicks
|
|
// other components make.
|
|
const form = template('editCardTitleForm');
|
|
const anchors = form.match(/js-close-inlined-form/g) || [];
|
|
assert.strictEqual(anchors.length, 1, 'one close anchor in the title editor');
|
|
});
|
|
|
|
console.log(`\ncardTitleEditClose: ${passed} tests passed`);
|