mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 09:36:08 +08:00
ui: re-impl #1094
This commit is contained in:
3 files changed
+8
-3
No files matched your search
@@ -47,3 +47,8 @@ export function* paginate(page: number, numPages: number) {
|
||||
if (page < numPages - 1) yield ['last', numPages];
|
||||
}
|
||||
}
|
||||
|
||||
export function buildQueryString(obj: Record<string, any>) {
|
||||
return Object.entries(obj).filter(([key, value]) => value && !key.startsWith('__'))
|
||||
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`).join('&');
|
||||
}
|
||||
@@ -130,7 +130,7 @@ class Nunjucks extends nunjucks.Environment {
|
||||
this.addGlobal('instanceof', (a, b) => a instanceof b);
|
||||
this.addGlobal('paginate', misc.paginate);
|
||||
this.addGlobal('size', misc.size);
|
||||
this.addGlobal('utils', { status, getAlphabeticId });
|
||||
this.addGlobal('utils', { status, getAlphabeticId, buildQueryString: misc.buildQueryString });
|
||||
this.addGlobal('avatarUrl', avatar);
|
||||
this.addGlobal('formatSeconds', misc.formatSeconds);
|
||||
this.addGlobal('model', global.Hydro.model);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
{% if not pdocs.length %}
|
||||
{{ nothing.render('Sorry, there are no problems in the problem set.') }}
|
||||
{% else %}
|
||||
{{ paginator.render(page, ppcount, position='top', add_qs=('q=' + qs if qs else '')) }}
|
||||
{{ paginator.render(page, ppcount, position='top', add_qs=utils.buildQueryString(q=qs, sort='' if sort == 'default' else sort)) }}
|
||||
<table class="data-table hide-problem-tag">
|
||||
<colgroup>
|
||||
<col class="col--checkbox display-mode-hide">
|
||||
@@ -63,6 +63,6 @@
|
||||
{%- endfor -%}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ paginator.render(page, ppcount, add_qs=('q=' + qs if qs else '')) }}
|
||||
{{ paginator.render(page, ppcount, add_qs=utils.buildQueryString(q=qs, sort='' if sort == 'default' else sort)) }}
|
||||
{% endif %}
|
||||
</div>
|
||||
Reference in new issue
Block a user