Skip to content

Commit

Permalink
modify homework_main list to table
Browse files Browse the repository at this point in the history
  • Loading branch information
Wotagei committed Sep 6, 2023
1 parent 7eee840 commit 0d4654f
Show file tree
Hide file tree
Showing 3 changed files with 146 additions and 36 deletions.
22 changes: 21 additions & 1 deletion packages/ui-default/pages/homework_main.page.styl
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,24 @@ $highlight-button-color = #F6DF45
white-space: nowrap

.filter-form
display: inline-block
display: inline-block

.search
width: 50%

.search-input
padding: 10px
padding-left: 36px
border-radius: 43px
background: #fff
border: 1px solid #ccc
outline: none

& .show_all_homework
margin-bottom: 0

.border-none
border: none !important

.text-center
text-align: center
6 changes: 3 additions & 3 deletions packages/ui-default/templates/homework_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
<div class="row">
<div class="medium-9 columns">
<div class="section">
<div class="section__header">
{# <div class="section__header">
<h1 class="section__title">{{ _('Homework Introduction') }}</h1>
</div>
</div> #}
<div class="section__body typo">
{{ tdoc['content']|markdown|safe }}
</div>
</div>
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('Problem') }}</h1>
<h1 class="section__title font-bold">{{ _('Problem') }}</h1>
</div>
{% if pdict %}
<div class="section__body no-padding">
Expand Down
154 changes: 122 additions & 32 deletions packages/ui-default/templates/homework_main.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,66 @@
<div class="row">
<div class="medium-12 columns">
<div class="section">
<div class="section__header">
<h1 class="section__title">{{ _('All Homeworks') }}</h1>
<div class="section__tools">
<span class="nojs--hide">
{{ _('View') }}:
<select class="inline compact select" name="homework_display">
<option value="calendar">{{ _('Calendar View') }}</option>
<option value="list" selected>{{ _('List View') }}</option>
</select>
</span>
{% if groups.length %}
<form method="get" class="filter-form" name="filter-form">
{{ _('Show') }}:
<select class="inline compact select" name="group">
<option value=""{% if not group %} selected{% endif %}>{{ _('All') }}</option>
{%- for g in groups -%}
<option value="{{ g }}"{% if group == g %} selected{% endif %}>{{ g }}</option>
{%- endfor -%}
{%- if not groups|length -%}
<option disabled>{{ _('No group available') }}</option>
{%- endif -%}
</select>
<button type="submit" class="compact button hasjs--hide">
{{ _('Search') }}
</button>

<div class="section__header">
{# <h1 class="section__title">{{ _('All Homeworks') }}</h1> #}
<div class="section__tools">
{# <span class="nojs--hide">
{{ _('View') }}:
<select class="inline compact select" name="homework_display">
<option value="calendar">{{ _('Calendar View') }}</option>
<option value="list" selected>{{ _('List View') }}</option>
</select>
</span>
{% if groups.length %}
<form method="get" class="filter-form" name="filter-form">
{{ _('Show') }}:
<select class="inline compact select" name="group">
<option value=""{% if not group %} selected{% endif %}>{{ _('All') }}</option>
{%- for g in groups -%}
<option value="{{ g }}"{% if group == g %} selected{% endif %}>{{ g }}</option>
{%- endfor -%}
{%- if not groups|length -%}
<option disabled>{{ _('No group available') }}</option>
{%- endif -%}
</select>
<button type="submit" class="compact button hasjs--hide">
{{ _('Search') }}
</button>
</form>
{% endif %} #}
{% if handler.user.hasPerm(perm.PERM_CREATE_HOMEWORK) %}
<a class="rounded-lg button border-none" href="{{ url('homework_create') }}">{{ _('Create Homework') }}</a>
{% endif %}
</div>
</div>


<div class="section__body no-padding">
<form class="flex items-center justify-start medium-6" method="get" id="searchForm" action="{{ url('homework_main') }}">
<div class="search items-center flex-1 mr-2">
<input class="search-input" name="q" type="text" value="{{ qs }}" placeholder="比赛名...">
{# {% include "partials/homework.html" %} #}
<button type="submit">
{# <span class="icon icon-search search-icon"></span> #}
<img src="{{ UiContext.cdn_prefix }}img/icon_search.svg" width="20" height="20">
</button>
</div>
<button type="submit" class="button rounded-lg border-none show_all_homework">
显示所有作业比赛
</button>
</form>
{% endif %}
{% if handler.user.hasPerm(perm.PERM_CREATE_HOMEWORK) %}
<a class="compact button" href="{{ url('homework_create') }}">{{ _('Create Homework') }}</a>
{% endif %}
</div>
</div>

{{ paginator.render(page, tpcount, add_qs=qs) }}



<div class="section__body no-padding">
{% if not tdocs.length %}
{{ nothing.render('There is no homework so far ╰(*°▽°*)╯') }}
{% else %}
<ol class="section__list homework__list">
{# <ol class="section__list homework__list">
{%- for tdoc in tdocs -%}
<li class="section__list__item homework__item">
<div class="media">
Expand All @@ -62,13 +85,80 @@ <h1 class="homework__title"><a href="{{ url('homework_detail', tid=tdoc.docId) }
{{ _('Deadline') }}: {{ datetimeSpan(tdoc['penaltySince'])|safe }}
{% endif %}
</li>
<li>{{ _('Hidden') }}: {{ tdoc.hidden }}</li>
<li>{{ _('Owner') }}: {{ tdoc.owner }}</li>
</ul>
</div>
</div>
</li>
{%- endfor -%}
</ol>
{{ paginator.render(page, tpcount, add_qs=qs) }}
#}

<table class="data-table hide-problem-tag">
<colgroup>
<col class="col--checkbox display-mode-hide">
<col class="col--pid display-mode-hide">
{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<col class="col--status edit-mode-hide">
{% endif %}
<col class="col--name">
<col class="col--ac-tried">
<col class="col--difficulty">
</colgroup>

<thead>
<tr>
{# <th class="col--pid display-mode-hide">{{ _('ID') }}</th> #}
<th class="text-center medium-3 text-black font-medium text-md">{{ _('Homework') }}</th>
{#{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<th class="col--status record-status--border edit-mode-hide">{{ _('Status') }}</th>
{% endif %}#}
<th class="text-center medium-5 text-black font-medium text-md">{{ _('Time') }}</th>
{# <th class="col--open">{{ _('Open') }}</th> #}
<th class="text-center medium-4 text-black font-medium text-md">{{ _('Owner') }}</th>
</tr>
</thead>
<tbody>
{%- for tdoc in tdocs -%}
{#{% set psdoc = psdict[pdoc.domainId + '#' + pdoc.docId] %}#}
{% set owner_udoc = udict[tdoc.owner] %}
<tr data-pid="{{ tdoc._id }}">
{# <td class="col--pid display-mode-hide">{{ tdoc.docId }}</td> #}

{#{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
{% if psdoc['rid'] %}
{{ record.render_status_td(psdoc, rid_key='rid', class="edit-mode-hide", allDomain=pdoc.domainId!==handler.args.domainId) }}
{% else %}
<td class="col--status record-status--border edit-mode-hide"></td>
{% endif %}
{% endif %}#}

<td class="col--name col--problem-name text-center medium-3">
{#{% if handler.user.hasPriv(PRIV.PRIV_USER_PROFILE) %}
<form class="form--inline" action="{{ url('problem_main', domainId = pdoc.domainId) }}" method="post">
<input type="hidden" name="pid" value="{{ pdoc.docId }}">
<input type="hidden" name="operation" value="{{ "star" if not psdoc.star else "unstar" }}">
<button class="star{% if psdoc.star %} activated{% endif %}" type="submit">
<span class="starred--hide"><span class="icon icon-star--outline" data-tooltip="{{ _('Star') }}"></span></span>
<span class="starred--show"><span class="icon icon-star" data-tooltip="{{ _('Unstar') }}"></span></span>
</button>
</form>
{% endif %}#}
<a href="{{ url('homework_detail', tid=tdoc.docId) }}" data-emoji-enabled>{{ tdoc.title }}</a>
</td>
<td class="text-center medium-5">{{ _(model.contest.statusText(tdoc))}} {{ _('Open Since') }}: {{ datetimeSpan(tdoc['beginAt'])|safe }}
{% if model.contest.isExtended(tdoc) or model.contest.isDone(tdoc) %}
{{ _('Hard Deadline') }}: {{ datetimeSpan(tdoc['endAt'])|safe }}
{% else %}
{{ _('Deadline') }}: {{ datetimeSpan(tdoc['penaltySince'])|safe }}
{% endif %}</td>
<td class="text-center medium-4">{{ tdoc.owner }}</td>
</tr>
{%- endfor -%}
</tbody>
</table>

<div name="calendar_entry"></div>
{% endif %}
</div>
Expand Down

0 comments on commit 0d4654f

Please sign in to comment.