2020-01-15 07:04:22 +00:00
|
|
|
{% macro create_album_card(album, view="grid", unlink_parent=none, draggable=false) %}
|
|
|
|
{% set id = "album_card_root" if album == "root" else "album_card_" + album.id %}
|
2018-12-23 23:51:38 +00:00
|
|
|
{% set view = (view if view in ("list", "grid") else "grid") %}
|
2018-11-13 06:15:59 +00:00
|
|
|
{% set viewparam = "?view=list" if view == "list" else "" %}
|
2020-01-15 07:04:22 +00:00
|
|
|
<div
|
|
|
|
id="{{id}}"
|
|
|
|
class="album_card album_card_{{view}}"
|
2020-09-20 19:20:36 +00:00
|
|
|
data-id="{{'root' if album == 'root' else album.id}}"
|
2020-09-11 23:03:15 +00:00
|
|
|
ondragstart="return on_album_drag_start(event);"
|
|
|
|
ondragend="return on_album_drag_end(event);"
|
|
|
|
ondragover="return on_album_drag_over(event);"
|
|
|
|
ondrop="return on_album_drag_drop(event);"
|
2020-01-15 07:04:22 +00:00
|
|
|
{% if album != "root" and draggable %}
|
|
|
|
draggable=true
|
|
|
|
{% endif %}
|
|
|
|
>
|
2019-12-21 09:48:36 +00:00
|
|
|
{% if album == "root" %}
|
2020-01-12 02:05:44 +00:00
|
|
|
<a class="album_card_thumbnail" href="/albums{{viewparam}}">
|
2019-12-21 09:48:36 +00:00
|
|
|
{% else %}
|
2020-01-12 02:05:44 +00:00
|
|
|
<a class="album_card_thumbnail" href="/album/{{album.id}}{{viewparam}}">
|
2019-12-21 09:48:36 +00:00
|
|
|
{% endif %}
|
2021-01-19 18:35:58 +00:00
|
|
|
{% if album.thumbnail_photo %}
|
|
|
|
{% set thumbnail_src = "/thumbnail/" + album.thumbnail_photo.id + ".jpg" %}
|
|
|
|
{% else %}
|
|
|
|
{% set thumbnail_src = "/static/basic_thumbnails/album.png" %}
|
|
|
|
{% endif %}
|
|
|
|
<img src="{{thumbnail_src}}"/>
|
2020-01-12 02:05:44 +00:00
|
|
|
</a>
|
2019-12-21 09:48:36 +00:00
|
|
|
|
|
|
|
<div class="album_card_tools">
|
|
|
|
{% if unlink_parent is not none %}
|
|
|
|
<button
|
|
|
|
class="remove_child_button button_with_confirm red_button"
|
2020-11-07 05:42:28 +00:00
|
|
|
data-onclick="return api.albums.remove_child('{{unlink_parent.id}}', '{{album.id}}', common.refresh_or_alert);"
|
2019-12-21 09:48:36 +00:00
|
|
|
data-prompt="Remove child?"
|
|
|
|
data-holder-class="remove_child_button"
|
|
|
|
data-confirm-class="red_button"
|
|
|
|
data-cancel-class="gray_button"
|
|
|
|
>Unlink
|
|
|
|
</button>
|
|
|
|
{% endif %}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="album_card_title">
|
2019-12-21 09:47:33 +00:00
|
|
|
{% if album == "root" %}
|
2019-12-21 09:48:36 +00:00
|
|
|
<a href="/albums{{viewparam}}">Albums</a>
|
2019-12-21 09:47:33 +00:00
|
|
|
{% else %}
|
2019-12-21 09:48:36 +00:00
|
|
|
<a href="/album/{{album.id}}{{viewparam}}">{{album.display_name}}</a>
|
2019-12-21 09:47:33 +00:00
|
|
|
{% endif %}
|
2019-12-21 09:48:36 +00:00
|
|
|
</div>
|
2019-12-21 09:47:33 +00:00
|
|
|
|
2019-12-21 09:48:36 +00:00
|
|
|
<div class="album_card_metadata">
|
|
|
|
{% if album == "root" %}
|
|
|
|
{% else %}
|
2021-01-08 03:23:12 +00:00
|
|
|
{% set child_count = album.sum_children(recurse=False) %}
|
2019-12-21 09:48:36 +00:00
|
|
|
{% set photo_count = album.sum_photos(recurse=False) %}
|
2020-07-27 02:18:27 +00:00
|
|
|
<span class="album_card_child_count" title="{{child_count}} child albums">{{child_count}}</span>
|
2019-12-21 09:48:36 +00:00
|
|
|
{{-' | '-}}
|
|
|
|
<span class="album_card_photo_count" title="{{photo_count}} photos">{{photo_count}}</span>
|
|
|
|
{% endif %}
|
2018-12-23 23:51:38 +00:00
|
|
|
</div>
|
2019-12-21 09:48:36 +00:00
|
|
|
</div>
|
2018-11-13 06:15:59 +00:00
|
|
|
{% endmacro %}
|