core&ui: fix sidebar preview (#491)

Co-authored-by: panda <panda_dtdyy@outlook.com>
This commit is contained in:
undefinedandpanda authored and GitHub committed 2023-01-18 18:32:04 +08:00
1 parent feb3b5cecb
commit feb5180476
19 files changed
+152 -244

No files matched your search

@@ -1,7 +1,7 @@
<div class="section__body typo" data-fragment-id="problem-description">
{% if not pdoc.data.length and not pdoc.reference %}
<blockquote class="warn">
<p>{{ _('No testdata at current.') }}</p>
<p>{{ _('No {0} at current.').format(_("testdata")) }}</p>
</blockquote>
{% endif %}
{% if typeof(pdoc.config) == 'string' %}
@@ -1,40 +0,0 @@
{% import "components/nothing.html" as nothing with context %}
<div class="section__body no-padding problem-files-additional_file" data-fragment-id="problem-files-additional_file">
{% if additional_file.length %}
<table class="data-table">
<colgroup>
<col class="col--checkbox">
<col class="col--name">
<col class="col--size">
</colgroup>
<thead>
<tr>
<th class="col--checkbox">
<label class="compact checkbox">
<input type="checkbox" name="select_all" data-checkbox-toggle="additional_file">
</label>
</th>
<th class="col--name">{{ _('Filename') }}</th>
<th class="col--size">{{ _('Size') }}</th>
</tr>
</thead>
<tbody>
{%- for file in additional_file -%}
<tr data-filename="{{ file.name }}" data-size="{{ file.size }}">
<td class="col--checkbox">
<label class="compact checkbox">
<input type="checkbox" data-checkbox-group="additional_file" data-checkbox-range>
</label>
</td>
<td class="col--name" data-preview="additional_file">
<a href="{{ url('problem_file_download', {pid: pdoc.docId, filename: file.name}) }}">{{ file.name }}</a>
</td>
<td class="col--size">{{ size(file.size) }}</td>
</tr>
{%- endfor -%}
</tbody>
</table>
{% else %}
{{ nothing.render('No additional file at current.') }}
{% endif %}
</div>
@@ -1,48 +0,0 @@
{% import "components/nothing.html" as nothing with context %}
<div class="section__body no-padding problem-files-testdata" data-fragment-id="problem-files-testdata">
{% if reference %}
<blockquote class="note">
<p>{{ _('This is a copy of another problem.') }}</p>
</blockquote>
{% elif testdata.length %}
<table class="data-table">
<colgroup>
<col class="col--checkbox">
<col class="col--name">
<col class="col--size">
</colgroup>
<thead>
<tr>
<th class="col--checkbox">
<label class="compact checkbox">
<input type="checkbox" name="select_all" data-checkbox-toggle="testdata">
</label>
</th>
<th class="col--name">{{ _('Filename') }}</th>
<th class="col--size">{{ _('Size') }}</th>
</tr>
</thead>
<tbody>
{%- for file in testdata -%}
<tr data-filename="{{ file.name }}" data-size="{{ file.size }}">
<td class="col--checkbox">
<label class="compact checkbox">
<input type="checkbox" data-checkbox-group="testdata" data-checkbox-range>
</label>
</td>
<td class="col--name" data-preview="testdata">
{% if handler.user.own(pdoc) or handler.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA) or handler.user.hasPerm(perm.PERM_READ_PROBLEM_DATA) %}
<a href="{{ url('problem_file_download', {pid: pdoc.docId, filename: file.name, query:{type:'testdata'} }) }}">{{ file.name }}</a>
{% else %}
<p>{{ file.name }}</p>
{% endif %}
</td>
<td class="col--size">{{ size(file.size) }}</td>
</tr>
{%- endfor -%}
</tbody>
</table>
{% else %}
{{ nothing.render('No testdata at current.') }}
{% endif %}
</div>
@@ -0,0 +1,59 @@
{% import "components/nothing.html" as nothing with context %}
{% set _files = testdata if filetype == 'testdata' else additional_file %}
<div class="section__body no-padding problem-{{ 'sidebar' if sidebar else 'files' }}-{{ filetype }}" data-fragment-id="problem-files-{{ filetype }}"
{% if sidebar %}data-type="{{ filetype }}" data-sidebar{% endif %}>
{% if reference %}
<blockquote class="note">
<p>{{ _('This is a copy of another problem.') }}</p>
</blockquote>
{% elif _files.length %}
<table class="data-table {{ filetype }}-table">
<colgroup>
{% if not sidebar %}<col class="col--checkbox">{% endif %}
<col class="col--name">
<col class="col--size">
{% if sidebar %}<col class="col--operation">{% endif %}
</colgroup>
<thead>
<tr>
{% if not sidebar %}
<th class="col--checkbox">
<label class="compact checkbox">
<input type="checkbox" name="select_all" data-checkbox-toggle="{{ filetype }}">
</label>
</th>
{% endif %}
<th class="col--name">{{ _('Filename') }}</th>
<th class="col--size">{{ _('Size') }}</th>
{% if sidebar %}<th class="col--operation"><span class="icon icon-wrench"></span></th>{% endif %}
</tr>
</thead>
<tbody>
{%- for file in _files -%}
<tr data-filename="{{ file.name }}" data-size="{{ file.size }}">
{% if not sidebar %}
<td class="col--checkbox">
<label class="compact checkbox">
<input type="checkbox" data-checkbox-group="{{ filetype }}" data-checkbox-range>
</label>
</td>
{% endif %}
<td class="col--name" data-preview="{{ filetype }}">
{% if filetype != 'testdata' or handler.user.own(pdoc) or handler.user.hasPriv(PRIV.PRIV_READ_PROBLEM_DATA) or handler.user.hasPerm(perm.PERM_READ_PROBLEM_DATA) %}
<a href="{{ url('problem_file_download', {pid: pdoc.docId, filename: file.name, query:{type:filetype} }) }}">{{ file.name }}</a>
{% else %}
<p>{{ file.name }}</p>
{% endif %}
</td>
<td class="col--size">{{ size(file.size) }}</td>
{% if sidebar %}
<td class="col--operation"><a href="javascript:;" name="{{ filetype }}__delete"><span class="icon icon-delete"></span></a></td>
{% endif %}
</tr>
{%- endfor -%}
</tbody>
</table>
{% else %}
{{ nothing.render('No {0} at current.', compact=sidebar, args=[_(filetype)]) }}
{% endif %}
</div>
@@ -1,48 +0,0 @@
{% import "components/nothing.html" as nothing with context %}
{% import "components/problem.html" as problem with context %}
<div class="section side section--problem-sidebar-additional_file">
<div class="section__header">
<h1 class="section__title">{{ additional_file.length|default(0) }} {{_('Additional File')}}</h1>
</div>
<ol class="menu">
<li class="menu__item flex-row">
<a class="menu__link half" href="javascript:;" name="additional_file__upload">
<span class="icon icon-upload"></span> {{ _('Upload') }}
</a>
<a class="menu__link half" href="javascript:;" name="additional_file__download">
<span class="icon icon-download"></span> {{ _('Download All') }}
</a>
</li>
</ol>
<div class="section__body no-padding problem-sidebar-additional_file__detail" data-fragment-id="problem-sidebar-additional_file">
{% if additional_file.length %}
<table class="data-table additionalfile-table">
<colgroup>
<col class="col--name">
<col class="col--size">
<col class="col--operation">
</colgroup>
<thead>
<tr>
<th class="col--name">{{ _('Filename') }}</th>
<th class="col--size">{{ _('Size') }}</th>
<th class="col--operation"><span class="icon icon-wrench"></span></th>
</tr>
</thead>
<tbody>
{%- for file in additional_file -%}
<tr data-filename="{{ file.name }}" data-size="{{ file.size }}">
<td class="col--name" title="{{ file.name }}" data-preview="additional_file">
<a href="{{ url('problem_file_download', {pid: pdoc.docId, filename: file.name}) }}">{{ file.name }}</a>
</td>
<td class="col--size">{{ size(file.size) }}</td>
<td class="col--operation"><a href="javascript:;"name="additional_file__delete"><span class="icon icon-delete"></span></a></td>
</tr>
{%- endfor -%}
</tbody>
</table>
{% else %}
{{ nothing.render('No additional file at current.',compact = true) }}
{% endif %}
</div>
</div>
@@ -1,47 +0,0 @@
{% import "components/nothing.html" as nothing with context %}
{% import "components/problem.html" as problem with context %}
<div class="section side section--problem-sidebar-testdata">
<div class="section__header">
<h1 class="section__title">{{ testdata.length if testdata.length else 0 }} {{_('Testdata')}}</h1>
</div>
<ol class="menu">
<li class="menu__item flex-row">
<a class="menu__link half" href="javascript:;" name="testdata__upload">
<span class="icon icon-upload"></span> {{ _('Upload') }}
</a>
<a class="menu__link half" href="javascript:;" name="testdata__download__all">
<span class="icon icon-download"></span> {{ _('Download All') }}
</a>
</li>
<li class="menu__seperator"></li>
</ol>
<div class="section__body no-padding problem-sidebar-testdata__detail" data-fragment-id="problem-sidebar-testdata">
{% if testdata.length %}
<table class="data-table testdata-table">
<colgroup>
<col class="col--name">
<col class="col--size">
<col class="col--operation">
</colgroup>
<thead>
<tr>
<th class="col--name">{{ _('Filename') }}</th>
<th class="col--size">{{ _('Size') }}</th>
<th class="col--operation"><span class="icon icon-wrench"></span></th>
</tr>
</thead>
<tbody>
{%- for file in testdata -%}
<tr data-filename="{{ file.name }}" data-size="{{ file.size }}">
<td class="col--name" title="{{ file.name }}" data-preview="testdata"><a href="{{ url('problem_file_download', {pid: pdoc.docId, filename: file.name, query:{type:'testdata'} }) }}">{{ file.name }}</a></td>
<td class="col--size">{{ size(file.size) }}</td>
<td class="col--operation"><a href="javascript:;" name="testdata__delete"><span class="icon icon-delete"></span></a></td>
</tr>
{%- endfor -%}
</tbody>
</table>
{% else %}
{{ nothing.render('No testdata at current.', compact = true) }}
{% endif %}
</div>
</div>