my $cols = "ref, array_to_string(form || alt, '/'), prio, id, sub";
%rows = $db->select(_word => $cols, \%filter)->map_arrays;
defined $_->[-1] or pop @$_ for values %rows;
+ $rows{''} = [
+ (undef) x 3,
+ [$db->select(word => 'id', {cat => undef, ref => undef})->flat]
+ ];
say pp \%rows
=~ s/\\x\{([0-9A-F]+)\}/chr hex $1/ger;
exit;
let ids = new Set(Object.keys(json));
const selection = {...json}; // clone
+ for (let cat of selection[''][3]) {
+ if (selection[cat])
+ selection[cat][1] = 0; // keep root categories
+ }
+
if (this.preset.cat !== undefined) {
ids.clear();
let children = [this.preset.cat];
selection[id][3] = function subresolve(subs) {
//console.log(subs);
return (subs || []).flatMap(sub =>
- sub in selection ? [sub] : subresolve(json[sub][3])
+ sub in selection ? [sub] : json[sub] ? subresolve(json[sub][3]) : []
);
}(selection[id][3]);
}