core&ui: user_detail: show solutions (#414)
parent
e3dd65c690
commit
6ed4d74210
@ -1,23 +0,0 @@
|
||||
import Clipboard from 'clipboard';
|
||||
import $ from 'jquery';
|
||||
import Notification from 'vj/components/notification';
|
||||
import { NamedPage } from 'vj/misc/Page';
|
||||
import base64 from 'vj/utils/base64';
|
||||
import i18n from 'vj/utils/i18n';
|
||||
import substitute from 'vj/utils/substitute';
|
||||
|
||||
const page = new NamedPage('user_detail', () => {
|
||||
$('[data-copy]').get().forEach((el) => {
|
||||
const data = $(el).attr('data-copy');
|
||||
const decoded = base64.decode(data);
|
||||
const clip = new Clipboard(el, { text: () => decoded });
|
||||
clip.on('success', () => {
|
||||
Notification.success(substitute(i18n('"{data}" copied to clipboard!'), { data: decoded }), 2000);
|
||||
});
|
||||
clip.on('error', () => {
|
||||
Notification.error(substitute(i18n('Copy "{data}" failed :('), { data: decoded }));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
export default page;
|
@ -0,0 +1,29 @@
|
||||
{% if psdocs %}
|
||||
<li class="section__tab-item">
|
||||
<h1 class="section__tab-title">{{ _('Recent solutions') }}</h1>
|
||||
<div class="section__tab-main">
|
||||
{% if not psdocs.length %}
|
||||
{{ nothing.render("This person is lazy and wrote any solution") }}
|
||||
{% else %}
|
||||
<div class="section__body typo no-media">
|
||||
<div class="typo section__body">
|
||||
{% set _mark = Math.ceil(psdocs.length/4) %}
|
||||
{% macro col(psdocs) %}
|
||||
<div class="medium-3 columns"><ul>
|
||||
{% for psdoc in psdocs %}
|
||||
<li><a href="{{ url('problem_solution_detail', pid=psdoc.parentId, sid=psdoc._id) }}">{{ pdict[psdoc.parentId].title|default(psdoc._id) }}</a></li>
|
||||
{% endfor %}
|
||||
</ul></div>
|
||||
{% endmacro %}
|
||||
<div class="row">
|
||||
{{ col(psdocs.slice(0, _mark)) }}
|
||||
{{ col(psdocs.slice(_mark, _mark*2)) }}
|
||||
{{ col(psdocs.slice(_mark*2, _mark*3)) }}
|
||||
{{ col(psdocs.slice(_mark*3)) }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</li>
|
||||
{% endif %}
|
Loading…
Reference in New Issue