Merge Core main into sameh/core-vue

railCardBlocks.js is the Vue wrapper on this branch, so main's verbatim
legend units move into RailCardBlocks.vue.
This commit is contained in:
Sameh Khamis committed 2026-11-01 17:37:56 -08:00
commit 5605fdc60a
33 files changed
+1498 -84

No files matched your search

+5 -1
View File
@@ -574,7 +574,11 @@ export class LayerPanel {
const stats = layer.stats || {};
const feedState = layerFeedState(stats);
const stateLabel = t(FEED_STATE_LABEL_KEYS[feedState]);
const source = sourceLabel(stats.source || layer.source);
// A layer marks source text that is data rather than a catalog name.
const source =
stats.sourceVerbatim === true && stats.source
? stats.source
: sourceLabel(stats.source || layer.source);
const lifecycleState =
layer.lifecycleState || (layer.enabled ? 'enabled' : 'disabled');
if (lifecycleState === 'enabling' || lifecycleState === 'disabling') {
+18
View File
@@ -87,3 +87,21 @@ for (const locale of ['es', 'ru']) {
}
});
}
test('a source a layer marks as data is shown untranslated in the row', () => {
setLocale('ru');
try {
const row = (stats) =>
LayerPanel.prototype._buildMetaText({
id: 'weather-lightning',
enabled: true,
stats: { count: 1, lastUpdate: Date.now(), ...stats },
});
assert.match(row({ source: 'Local ADS-B' }), /Локальный ADS-B/);
const verbatim = row({ source: 'Local ADS-B', sourceVerbatim: true });
assert.match(verbatim, /Local ADS-B/);
assert.doesNotMatch(verbatim, /Локальный/);
} finally {
setLocale('en');
}
});
+10 -4
View File
@@ -31,9 +31,10 @@ const rootTag = (block) =>
block.type === 'list' ? 'ol' : block.type === 'actions' ? 'footer' : 'div';
const lines = (block) => block.lines || [{ id: block.id, text: block.text }];
// "960 — 1050+ гПа": the unit stays with the last number.
function scaleText(low, high, units) {
const unit = unitLabel(units);
// "960 — 1050+ гПа": the unit stays with the last number. Units a source
// supplied as data are shown as given.
function scaleText(low, high, units, verbatim) {
const unit = verbatim ? units || '' : unitLabel(units);
const range = `${formatScaleLabel(low)} — ${formatScaleLabel(high)}`;
return unit ? `${range} ${unit}` : range;
}
@@ -63,7 +64,12 @@ function legendView(legend) {
? `left: ${(legend.zeroIndex / (colors.length - 1)) * 100}%`
: undefined,
scale: visible
? scaleText(legend.labels[0], legend.labels.at(-1), legend.units)
? scaleText(
legend.labels[0],
legend.labels.at(-1),
legend.units,
legend.unitsVerbatim === true,
)
: '',
labels: legend?.labels || [],
};
+1
View File
@@ -199,6 +199,7 @@ export function createWeatherPanel({
colors: legend.map(({ color }) => color),
labels: legend.map(({ label }) => label),
units: categorical ? '' : summary.units,
...(summary.unitsVerbatim === true ? { unitsVerbatim: true } : {}),
zeroIndex: legend.findIndex(({ label }) => label === '0'),
},
};
+24
View File
@@ -760,3 +760,27 @@ test('air-quality readout renders its band legend, Canada coverage and worst-fir
view.destroy();
layer.destroy();
});
test('source-supplied legend units are shown as given; catalog units are translated', () => {
setLocale('ru');
try {
const f = fixture();
const view = createWeatherPanel(f);
const row = (summary) => ({
...radar,
summary: { ...radar.summary, units: 'km/h', ...summary },
legend: [
{ label: '1', color: '#000000' },
{ label: '2', color: '#ffffff' },
],
});
const scale = () =>
f.find((n) => n.className === 'rail-card-scale').textContent;
view.update([row()]);
assert.equal(scale(), '1 — 2 км/ч');
view.update([row({ unitsVerbatim: true })]);
assert.equal(scale(), '1 — 2 km/h');
view.destroy();
} finally {
setLocale('en');
}
});