openvibers/openvibe.trade Commits
Trade: an empty instruments list draws the kit's empty state (#264)
Changes
@@@ -124,7 +124,7 @@ function createPages(ctx) {common.page(req, res, {title: pageNo === 1 ? 'Companies and currencies' : `Companies and currencies, page ${pageNo}`, canonical: urls.abs(path), decision: listing(path),description: 'US-listed companies from the SEC\'s list and euro reference currencies, the newest filing or figure first, each with its source and time.',-- feeds: FEEDS, body: views.instrumentsPage({ page, urls, pager, ...await headlines(page.instruments, ctx.store.now()) }),++ feeds: FEEDS, styles: ['kit.css'], body: views.instrumentsPage({ page, urls, pager, ...await headlines(page.instruments, ctx.store.now()) }),});});@@@ -180,7 +180,7 @@ function instrumentsPage({ page, urls, pager, latest, latestDocs }) {<input id="q" name="q" type="search" maxlength="200" required><button type="submit">Find</button></form>--${page.instruments.length ? html`${instrumentsTable({ instruments: page.instruments, latest, latestDocs, urls })}${raw(paginationHtml(pager))}` : html`<p class="empty">No instruments have been added yet.</p>`}`;++${page.instruments.length ? html`${instrumentsTable({ instruments: page.instruments, latest, latestDocs, urls })}${raw(paginationHtml(pager))}` : raw(kit.empty({ icon: 'list', title: 'No instruments have been added yet', text: 'Companies and currencies appear once a source has reported them.', action: { href: '/sources', label: 'See the sources', icon: 'live' } }))}`;}/** One filing as a list line: company, form (with its plain name), title, published and retrieved. */@@@ -220,6 +220,14 @@ const WORDS = (n) => Array.from({ length: n }, (_, i) => `word${i}`).join(' ');assert.ok(body.includes('Frankfurter (ECB data)'));});++ await check('an empty instruments list draws the kit empty state and one button', () => {++ const views = require('../server/render/views');++ const body = String(views.instrumentsPage({ page: { instruments: [], total: 0 }, urls: {}, pager: {} }));++ assert.match(body, /class="ovk-empty"/, 'the kit empty state is used, not a bare sentence');++ assert.match(body, /No instruments have been added yet/);++ assert.match(body, /class="ovk-btn[^"]*" href="\/sources"/, 'the empty state offers one button forward');++ });++await t.close();done();})();
@@ -124,7 +124,7 @@ function createPages(ctx) {
@@ -124,7 +124,7 @@ function createPages(ctx) {
common.page(req, res, {
common.page(req, res, {
title: pageNo === 1 ? 'Companies and currencies' : `Companies and currencies, page ${pageNo}`, canonical: urls.abs(path), decision: listing(path),
title: pageNo === 1 ? 'Companies and currencies' : `Companies and currencies, page ${pageNo}`, canonical: urls.abs(path), decision: listing(path),
description: 'US-listed companies from the SEC\'s list and euro reference currencies, the newest filing or figure first, each with its source and time.',
description: 'US-listed companies from the SEC\'s list and euro reference currencies, the newest filing or figure first, each with its source and time.',
- feeds: FEEDS, body: views.instrumentsPage({ page, urls, pager, ...await headlines(page.instruments, ctx.store.now()) }),
+ feeds: FEEDS, styles: ['kit.css'], body: views.instrumentsPage({ page, urls, pager, ...await headlines(page.instruments, ctx.store.now()) }),
});
});
});
});
@@ -180,7 +180,7 @@ function instrumentsPage({ page, urls, pager, latest, latestDocs }) {
@@ -180,7 +180,7 @@ function instrumentsPage({ page, urls, pager, latest, latestDocs }) {
<input id="q" name="q" type="search" maxlength="200" required>
<input id="q" name="q" type="search" maxlength="200" required>
<button type="submit">Find</button>
<button type="submit">Find</button>
</form>
</form>
-${page.instruments.length ? html`${instrumentsTable({ instruments: page.instruments, latest, latestDocs, urls })}${raw(paginationHtml(pager))}` : html`<p class="empty">No instruments have been added yet.</p>`}`;
+${page.instruments.length ? html`${instrumentsTable({ instruments: page.instruments, latest, latestDocs, urls })}${raw(paginationHtml(pager))}` : raw(kit.empty({ icon: 'list', title: 'No instruments have been added yet', text: 'Companies and currencies appear once a source has reported them.', action: { href: '/sources', label: 'See the sources', icon: 'live' } }))}`;
}
}
/** One filing as a list line: company, form (with its plain name), title, published and retrieved. */
/** One filing as a list line: company, form (with its plain name), title, published and retrieved. */
@@ -220,6 +220,14 @@ const WORDS = (n) => Array.from({ length: n }, (_, i) => `word${i}`).join(' ');
@@ -220,6 +220,14 @@ const WORDS = (n) => Array.from({ length: n }, (_, i) => `word${i}`).join(' ');
assert.ok(body.includes('Frankfurter (ECB data)'));
assert.ok(body.includes('Frankfurter (ECB data)'));
});
});
+ await check('an empty instruments list draws the kit empty state and one button', () => {
+ const views = require('../server/render/views');
+ const body = String(views.instrumentsPage({ page: { instruments: [], total: 0 }, urls: {}, pager: {} }));
+ assert.match(body, /class="ovk-empty"/, 'the kit empty state is used, not a bare sentence');
+ assert.match(body, /No instruments have been added yet/);
+ assert.match(body, /class="ovk-btn[^"]*" href="\/sources"/, 'the empty state offers one button forward');
+ });
+
await t.close();
await t.close();
done();
done();
})();
})();