mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 20:45:00 -05:00
The opened card's title was split like a minicard's: the leading half opened the editor and the trailing half dragged the window, so clicking the right of the title, or beside a short last line, did not edit. Now all of the title edits. With drag handles off, the window is moved from the empty space of its header row above the title - between the collapse caret and the menu; with drag handles on, only by the drag handle. A reader who may not edit has no edit zone and still drags by the title. Every popup now moves the same way - by its title bar with drag handles off, by the handle before its title alone with them on - where only the Drawing, Board View and Board Card settings popups and the date popups moved before. A dragged popup is kept inside the window as it grows. The drag pins a popup where it is before moving it: one placed from the right edge (the member menu) jumped across the window, and one with a margin by that margin, as the drag began. card-title-edit-and-move-6839.e2e.js, in Chromium and WebKit: a two-line title edits from its right, middle and left; the empty header row moves the window by exactly the drag with handles off and not at all with them on, when the handle does; and the card menu, Labels and the member menu move by their title bar, or with handles on by the handle alone. titleClickToEdit, popupMoveMaximize and popupBounds pin it. Thanks to mimZD and xet7 ! Fixes #6839,
82 lines
4.4 KiB
JavaScript
82 lines
4.4 KiB
JavaScript
'use strict';
|
|
|
|
// The card's Drawing popup moves like the opened card - by its title bar or a
|
|
// drag handle - and has the opened card's maximize / minimize button. The
|
|
// shared popup offers both by name, so other popups can join with one line.
|
|
// Run: node tests/popupMoveMaximize.test.cjs
|
|
|
|
const assert = require('assert');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const read = p => fs.readFileSync(path.join(__dirname, '..', p), 'utf8');
|
|
const js = read('client/components/main/popup.js');
|
|
const jade = read('client/components/main/popup.tpl.jade');
|
|
const css = read('client/components/main/popup.css');
|
|
const en = JSON.parse(read('imports/i18n/data/en.i18n.json'));
|
|
|
|
let passed = 0;
|
|
function test(name, fn) { fn(); passed += 1; console.log(' ok -', name); }
|
|
|
|
const setOf = name => {
|
|
const m = js.match(new RegExp(`const ${name} = new Set\\(\\[([^\\]]*)\\]\\)`));
|
|
assert.ok(m, name);
|
|
return m[1].split(',').map(s => s.trim().replace(/^'|'$/g, '')).filter(Boolean);
|
|
};
|
|
|
|
console.log('popupMoveMaximize:');
|
|
|
|
test('the Drawing popup is movable and maximizable; Board View settings stays movable', () => {
|
|
assert.ok(setOf('MOVABLE_POPUPS').includes('cardDrawingPopup'));
|
|
assert.ok(setOf('MOVABLE_POPUPS').includes('boardViewSettingsPopup'));
|
|
assert.ok(setOf('MAXIMIZABLE_POPUPS').includes('cardDrawingPopup'));
|
|
// The opened card's "+ Add" popup (docs/Features/Cards/Card-Fields.md).
|
|
assert.ok(setOf('MOVABLE_POPUPS').includes('boardCardSettingsPopup'), 'Board Settings / Card, also the opened card\'s + Add');
|
|
assert.ok(setOf('MAXIMIZABLE_POPUPS').includes('boardCardSettingsPopup'));
|
|
});
|
|
|
|
test('the header has the drag handle and the maximize / minimize button, only where enabled', () => {
|
|
// The handle only while drag handles are on, as on the opened card; the
|
|
// title bar drags either way.
|
|
assert.match(jade, /if popupMovable\n\s+if isTouchScreenOrShowDesktopDragHandles\n\s+span\.popup-drag-handle\.js-popup-drag-handle/);
|
|
assert.match(jade, /if popupMaximizable\n\s+if popupMaximized\n\s+a\.popup-maximize-btn\.js-popup-minimize/);
|
|
assert.match(jade, /a\.popup-maximize-btn\.js-popup-maximize[^\n]*maximize-window/);
|
|
for (const key of ['drag-to-move', 'maximize-window', 'minimize-window']) assert.ok(en[key], key);
|
|
});
|
|
|
|
// #6839: every popup is movable now, like the opened card - by its title bar
|
|
// while drag handles are off, by its handle alone while they are on. The
|
|
// allow-list that remains is of popups kept inside the window as they grow.
|
|
test('every popup drags, by the handle alone when there is one, and never a maximized one', () => {
|
|
const down = js.slice(js.indexOf("'pointerdown .header'"), js.indexOf("'pointermove .header'"));
|
|
assert.match(down, /classList\.contains\('pop-over--maximized'\)/);
|
|
assert.match(down, /\(handle && !evt\.target\.closest\('\.js-popup-drag-handle'\)\)/);
|
|
assert.doesNotMatch(down, /MOVABLE_POPUPS/, 'negative: no allow-list decides which popup moves');
|
|
assert.match(js, /popupMovable\(\) \{\n\s+return true;/);
|
|
assert.doesNotMatch(js, /element\.dataset\.popup !== 'boardViewSettingsPopup'/, 'the old one-popup check');
|
|
});
|
|
|
|
test('maximizing keeps the dragged place to restore, and the drawing takes the window', () => {
|
|
assert.match(js, /dataset\.restoreStyle = element\.getAttribute\('style'\)/);
|
|
assert.match(js, /element\.setAttribute\('style', element\.dataset\.restoreStyle/);
|
|
assert.match(css, /\.pop-over\.pop-over--maximized \{[^}]*inset: 8px !important/);
|
|
// d5d027a6f2: maximized, the drawing takes the window (cardDrawing.js sizes it
|
|
// to its stage); the 800 x 500 shape this pinned drew it 784px wide.
|
|
assert.doesNotMatch(css.replace(/\/\*[\s\S]*?\*\//g, ''), /\.pop-over--maximized \.card-drawing-surface \{/);
|
|
});
|
|
|
|
test('negative: every locale has the three new strings, none left in English but English', () => {
|
|
const dir = path.join(__dirname, '..', 'imports/i18n/data');
|
|
for (const f of fs.readdirSync(dir)) {
|
|
const j = JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8'));
|
|
for (const key of ['drag-to-move', 'maximize-window', 'minimize-window']) {
|
|
assert.ok(j[key], `${f} ${key}`);
|
|
if (!f.startsWith('en')) assert.notStrictEqual(j[key], en[key], `${f} ${key} is still English`);
|
|
}
|
|
const keys = Object.keys(j);
|
|
assert.strictEqual(keys.indexOf('maximize-window'), keys.indexOf('minimize-card') + 1, `${f}: key order`);
|
|
}
|
|
});
|
|
|
|
console.log(`popupMoveMaximize: ${passed} passed`);
|