Database-BI
view release on metacpan or search on metacpan
# ---------------------------------------------------------------------------
# Phase 3.2 -- the size menu: a preset width per card, chosen without a drag
# ---------------------------------------------------------------------------
subtest '3.2: each card has a size menu that sets its width without a drag' => sub {
my $sales_path = $t->app->home->child('data/sales.csv')->to_string;
plan skip_all => 'data/sales.csv not found' unless -f $sales_path;
my $spec = {
name => 'SizeMenu',
datasets => [ { spec => "path:$sales_path", alias => 'left' } ],
visuals => [
{ kind => 'table', encode => {}, title => 'Left' },
{ kind => 'table', encode => {}, title => 'Right' },
],
};
my $cid = $t->post_ok('/api/analyses',
{ 'Content-Type' => 'application/json' },
encode_json($spec)
)->status_is(201)->tx->res->json->{id};
'width and height together';
# The menu and the corner grip are two ways to the same write.
like $b, qr/function commitSize\(card, w, h\)/,
'a chosen width and height are applied by commitSize';
like $b, qr/h = clampSpan\(h, 1, MAX_ROW_SPAN\);/, 'the height within the row limit';
like $b, qr/var isRow = raw\.charAt\(0\) === 'h';/,
'a prefixed value is a height, a bare one a width';
like $b, qr/if \(isRow\) commitSize\(card, st\.w, value\);/, 'a height keeps the width';
like $b, qr/else commitSize\(card, value, st\.h\);/, 'a width keeps the height';
like $b, qr/function initSizeMenus/,
'each menu is wired up';
like $b, qr/^\s*initSizeMenus\(\);\r?$/m, 'at load';
like $b, qr/function updateSizeSelect/,
'the menu shows the size the card actually is';
like $b, qr/function updateSizeBadge\(card, state\)/,
'and the card shows it too, rather than only the menu';
like $b, qr/option\[data-current="1"\]/,
'and the option that says what the card is is found by its own marker';
like $b, qr/id="size-help"[^>]*>[^<]*height to one, two, three or six rows/s,
'the help says the menu sets the height as well';
like $b, qr/badge\.textContent = st\.w \+ ' \\u00D7 ' \+ st\.h;/,
'as the two numbers the menu spells out in words';
templates/web/en-us/canvas.html.tt view on Meta::CPAN
* Each entry is a width in grid columns or a height in grid rows, applied
* through commitSize, so the menu and the corner grip end in the same layout
* and the same PATCH. Focus stays on the menu after a choice, which is where
* the reader already is: the size can be changed again, or tabbed away from,
* without hunting for the card again. The first option is not a choice but
* the size the card is; it is what the menu shows when the size came from
* somewhere else (a drag, an arrow key, a reload), while a choice made here
* stays selected, so the arrow keys walk the entries one after another
* instead of being pulled back to the top after every one.
*/
function initSizeMenus(root) {
if (!grid || !anaId) return;
(root || grid).querySelectorAll('.visual-size-select').forEach(function (sel) {
var card = sel.closest('.visual-card');
if (!card) return;
updateSizeControls(card);
sel.addEventListener('change', function () {
var raw = sel.value;
var index = sel.selectedIndex;
templates/web/en-us/canvas.html.tt view on Meta::CPAN
else commitSize(card, value, st.h);
/* The entry that was chosen stays chosen: the commit re-selects the
* summary, and a reader stepping down the list with the arrow keys
* would otherwise be pulled back to the top after every change. */
sel.selectedIndex = index;
});
});
}
initSizeMenus();
/* ---- cross-filter (3.3 URL-stage) ----
*
* Semantics: self-highlighting.
* - Clicking a mark on visual N navigates to ?cf=col:eq:val&cv=N.
* - On reload the server filters every visual except the source (cv=N).
* - The source card gets a blue border (.cf-source) to show it is the
* filter origin and is intentionally shown unfiltered.
* - Multi-select not supported: each click replaces any prior cross-filter.
* - Cross-filter respects each visual's own saved filters because the
templates/web/en-us/canvas.html.tt view on Meta::CPAN
});
}
function appendCard(json) {
var card = buildCard(json);
grid.appendChild(card);
fitTextRows();
initMoveHandles(card);
initResizeHandles(card);
initSizeMenus(card);
updateVisualCount();
var title = json.title || ('Visual ' + (json.visual + 1));
var count = grid.querySelectorAll('.visual-card').length;
card.focus();
announce((KIND_NAMES[json.kind] || 'Visual') + ' "' + title
+ '" added at the end of the canvas. ' + count + ' visual'
+ (count === 1 ? '' : 's') + ' on the canvas.');
var lib = drawLib(json.kind);
templates/web/en/canvas.html.tt view on Meta::CPAN
* Each entry is a width in grid columns or a height in grid rows, applied
* through commitSize, so the menu and the corner grip end in the same layout
* and the same PATCH. Focus stays on the menu after a choice, which is where
* the reader already is: the size can be changed again, or tabbed away from,
* without hunting for the card again. The first option is not a choice but
* the size the card is; it is what the menu shows when the size came from
* somewhere else (a drag, an arrow key, a reload), while a choice made here
* stays selected, so the arrow keys walk the entries one after another
* instead of being pulled back to the top after every one.
*/
function initSizeMenus(root) {
if (!grid || !anaId) return;
(root || grid).querySelectorAll('.visual-size-select').forEach(function (sel) {
var card = sel.closest('.visual-card');
if (!card) return;
updateSizeControls(card);
sel.addEventListener('change', function () {
var raw = sel.value;
var index = sel.selectedIndex;
templates/web/en/canvas.html.tt view on Meta::CPAN
else commitSize(card, value, st.h);
/* The entry that was chosen stays chosen: the commit re-selects the
* summary, and a reader stepping down the list with the arrow keys
* would otherwise be pulled back to the top after every change. */
sel.selectedIndex = index;
});
});
}
initSizeMenus();
/* ---- cross-filter (3.3 URL-stage) ----
*
* Semantics: self-highlighting.
* - Clicking a mark on visual N navigates to ?cf=col:eq:val&cv=N.
* - On reload the server filters every visual except the source (cv=N).
* - The source card gets a blue border (.cf-source) to show it is the
* filter origin and is intentionally shown unfiltered.
* - Multi-select not supported: each click replaces any prior cross-filter.
* - Cross-filter respects each visual's own saved filters because the
templates/web/en/canvas.html.tt view on Meta::CPAN
});
}
function appendCard(json) {
var card = buildCard(json);
grid.appendChild(card);
fitTextRows();
initMoveHandles(card);
initResizeHandles(card);
initSizeMenus(card);
updateVisualCount();
var title = json.title || ('Visual ' + (json.visual + 1));
var count = grid.querySelectorAll('.visual-card').length;
card.focus();
announce((KIND_NAMES[json.kind] || 'Visual') + ' "' + title
+ '" added at the end of the canvas. ' + count + ' visual'
+ (count === 1 ? '' : 's') + ' on the canvas.');
var lib = drawLib(json.kind);
( run in 3.194 seconds using v1.01-cache-2.11-cpan-60884a8df76 )