contentdb/app/templates/packages/screenshots.html

101 lines
2.9 KiB
HTML
Raw Normal View History

2021-05-04 04:15:26 +02:00
{% extends "packages/package_base.html" %}
2020-12-06 04:35:25 +01:00
{% block title %}
2022-01-08 00:27:00 +01:00
{{ _("Screenshots") }} - {{ package.title }}
2020-12-06 04:35:25 +01:00
{% endblock %}
{% block content %}
{% if package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
2021-07-24 05:30:14 +02:00
<a href="{{ package.getURL("packages.create_screenshot") }}" class="btn btn-primary float-right">
2021-05-04 04:15:26 +02:00
<i class="fas fa-plus mr-1"></i>
2020-12-06 04:35:25 +01:00
{{ _("Add Image") }}
</a>
{% endif %}
2022-01-08 00:27:00 +01:00
<h2 class="mt-0">{{ _("Screenshots") }}</h2>
2020-12-06 04:35:25 +01:00
<p class="mb-4">
{{ _("Topmost screenshot will be used as the package thumbnail.") }}
</p>
2020-12-06 04:35:25 +01:00
<ul class="list-group sortable">
{% for ss in package.screenshots %}
{% if ss.approved or package.checkPerm(current_user, "ADD_SCREENSHOTS") %}
<li class="list-group-item" data-id="{{ ss.id }}">
<div class="row">
<div class="col-auto text-muted pr-2">
<i class="fas fa-bars"></i>
</div>
<div class="col-auto">
<img class="img-fluid" style="max-height: 64px;"
src="{{ ss.getThumbnailURL() }}" alt="{{ ss.title }}" />
</div>
<div class="col">
2020-12-06 04:35:25 +01:00
{{ ss.title }}
{% if not ss.approved %}
<div class="text-muted">
{{ _("Awaiting approval") }}
</div>
{% endif %}
</div>
2020-12-06 05:30:47 +01:00
<form action="{{ ss.getDeleteURL() }}" method="POST" class="col-auto text-right" role="form">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
2020-12-06 04:35:25 +01:00
<a class="btn btn-sm btn-primary" href="{{ ss.getEditURL() }}">
2021-02-28 06:16:15 +01:00
<i class="fas fa-pen"></i>
2020-12-06 04:35:25 +01:00
</a>
2020-12-06 05:30:47 +01:00
<button type="submit" class="btn btn-sm btn-danger ml-2">
<i class="fas fa-trash"></i>
</button>
</form>
2020-12-06 04:35:25 +01:00
</div>
</li>
{% endif %}
2020-12-06 05:07:51 +01:00
{% else %}
<li class="list-group-item">
2022-01-08 00:27:00 +01:00
<i>{{ _("No screenshots.") }}</i>
2020-12-06 05:07:51 +01:00
</li>
2020-12-06 04:35:25 +01:00
{% endfor %}
</ul>
<form action="" method="POST" class="form mt-4" role="form">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}" />
<input type="hidden" name="order" value="" />
2022-01-08 00:27:00 +01:00
<input type="submit" value="{{ _('Save Order') }}" class="btn btn-primary">
2020-12-06 04:35:25 +01:00
</form>
<noscript>
<p class="alert alert-warning mt-5">
{{ _("Reordering requires JavaScript.") }}
</p>
</noscript>
<h2>{{ _("Cover Image") }}</h2>
{% from "macros/forms.html" import render_submit_field, render_field %}
<form action="" method="POST" class="form" role="form">
{{ form.hidden_tag() }}
{{ render_field(form.cover_image, tabindex=220) }}
{{ render_submit_field(form.submit, tabindex=280) }}
</form>
2020-12-06 04:35:25 +01:00
{% endblock %}
{% block scriptextra %}
2021-02-05 17:19:34 +01:00
<script src="/static/libs/jquery-ui.min.js"></script>
2020-12-06 04:35:25 +01:00
<script>
function update() {
const elements = Array.from(document.getElementsByClassName("sortable")[0].children);
const ids = elements.map(x => x.dataset.id).filter(x => x);
$("input[name='order']").val(ids.join(","))
}
update();
$(function() {
$(".sortable").sortable({
update: update
});
});
</script>
{% endblock %}