Tweaks to asset listing

This commit is contained in:
2018-09-11 17:45:33 +02:00
parent c546dd2881
commit 3ae16d7750
8 changed files with 185 additions and 204 deletions

View File

@@ -1,26 +1,28 @@
| {% from '_macros/_asset_video_progress.html' import video_progress_bar %}
| {% from '_macros/_asset_list_item.html' import asset_list_item %}
include ../../../mixins/components
| {% block body %}
#node-container
section.px-3.pt-3.d-flex
h4 {{node.name}}
.ml-auto
.btn.btn-sm.btn-browsetoggle(
title="Toggle between list/grid view",
data-toggle="tooltip",
data-placement="top")
i.pi-list
section.d-flex
h4.p-4 {{node.name}}
| {% if node.description %}
section.node-details-description.p-3
section.node-details-description.px-4
| {{ node | markdowned('description') }}
| {% endif %}
section.container-fluid
| {% if children %}
+card-deck(4)(class="pr-3 pl-1")
.d-flex.justify-content-end.mb-2
button.btn.btn-sm.btn-outline-secondary(
class="js-btn-browsetoggle",
title="Toggle between list/grid view",
data-toggle="tooltip",
data-placement="top")
i.pi-list
+card-deck(class="px-2")
| {% for child in children %}
| {# Browse type: List #}
a(
@@ -73,30 +75,7 @@ include ../../../mixins/components
| {# Browse type: Icon #}
| {% set node_type = child.properties.content_type if child.properties.content_type else child.node_type %}
| {% if child.properties.content_type == 'video' %}
| {% set view_progress = current_user.nodes.view_progress %}
| {% if child._id in view_progress %}
| {% set progress = current_user.nodes.view_progress[child._id] %}
| {% set progress_in_percent = progress.progress_in_percent %}
| {% set progress_done = progress.done %}
| {% endif %}
| {% endif %}
+list-asset(
'{{ child.name }}',
'{{ url_for_node(node=child) }}',
"{% if child.picture %}{{ child.picture.thumbnail('m', api=api) }}{% endif %}",
"{{ node_type | undertitle }}",
"{{ child._created | pretty_date }}")(
class="js-item-open pr-0 mx-0 mb-2 {% if child.permissions.world %}free{% endif %}",
data-node_id="{{ child._id }}",
title="{{ child.name }}")
| {% if child.properties.content_type == 'video' %}
| {{ video_progress_bar(child, current_user) }}
| {% endif %}
| {{ asset_list_item(child, current_user) }}
| {% endfor %}
| {% else %}
@@ -138,13 +117,13 @@ include ../../../mixins/components
function projectBrowseTypeIcon() {
$(".list-node-children-item.browse-list").hide();
$(".list-node-children-item.browse-icon").show();
$(".btn-browsetoggle").html('<i class="pi-list"></i>');
$(".js-btn-browsetoggle").html('<i class="pi-list"></i> List View');
};
function projectBrowseTypeList() {
$(".list-node-children-item.browse-list").show();
$(".list-node-children-item.browse-icon").hide();
$(".btn-browsetoggle").html('<i class="pi-layout"></i>');
$(".js-btn-browsetoggle").html('<i class="pi-layout"></i> Grid View');
};
function projectBrowseTypeCheck(){
@@ -184,7 +163,7 @@ include ../../../mixins/components
}
}
$('.btn-browsetoggle').on('click', function (e) {
$('.js-btn-browsetoggle').on('click', function (e) {
e.preventDefault();
projectBrowseToggle();
});

View File

@@ -5,9 +5,8 @@
| {% block node_preview %}
| {% if node.picture %}
| {% if current_user.has_cap('subscriber') or node.permissions.world %}
section#node-preview.node-preview.image.js-node-preview-image
img.node-preview-thumbnail#node-preview-thumbnail(
src="{{ node.picture.thumbnail('l', api=api) }}")
section.node-preview.image.js-node-preview-image
img.node-preview-thumbnail(src="{{ node.picture.thumbnail('l', api=api) }}")
| {% else %}
| {% include 'nodes/custom/_node_preview_forbidden.html' %}
| {% endif %}
@@ -15,19 +14,20 @@
| {% endblock node_preview %}
| {% block node_details %}
section.node-details-container
| {# NAME #}
h4.pt-4.px-4 {{node.name}}
| {# NAME #}
section.px-4
h4.pt-4.mb-3 {{node.name}}
| {# DESCRIPTION #}
| {% if node.description %}
.node-details-description.px-4
.node-details-description
| {{ node | markdowned('description') }}
| {% endif %}
| {# LICENSE #}
| {# LICENSE #}
section
| {% if node.properties.license_type %}
a.node-details-license(
href="https://creativecommons.org/licenses/",
@@ -41,80 +41,80 @@
| {% endif %}
| {# DETAILS #}
.node-details-meta
ul
| {% if node.has_method('PUT') and (node.properties.status != 'published') %}
li(class="status-{{ node.properties.status }}")
| {{ node.properties.status | undertitle }}
| {% endif %}
| {# DETAILS #}
section.node-details-meta
ul
| {% if node.has_method('PUT') and (node.properties.status != 'published') %}
li(class="status-{{ node.properties.status }}")
| {{ node.properties.status | undertitle }}
| {% endif %}
li(title="Author")
| {{ node.user.full_name }}
li(title="Author")
| {{ node.user.full_name }}
li(
title="Created {{ node._created }} (updated {{ node._updated | pretty_date_time }})")
| {{ node._created | pretty_date }}
li(
title="Created {{ node._created }} (updated {{ node._updated | pretty_date_time }})")
| {{ node._created | pretty_date }}
| {% if node.short_link %}
li.shared
a(href="{{ node.short_link }}")
i.pi-share
| Shared
| {% endif %}
| {% if node.short_link %}
li.shared
a(href="{{ node.short_link }}")
i.pi-share
| Shared
| {% endif %}
li.left-side
li.left-side
| {% if node.file %}
li(title="File size")
| {{ node.file.length | filesizeformat }}
li.js-type(title="File format")
| {{ node.file.content_type }}
| {% endif %}
| {% if node.file %}
li(title="File size")
| {{ node.file.length | filesizeformat }}
li.js-type(title="File format")
| {{ node.file.content_type }}
| {% endif %}
| {% if node.permissions.world %}
li.public(
data-toggle="tooltip",
data-placement="bottom",
title="Anybody can download. Share it!")
i.pi-lock-open
span Public
| {% endif %}
| {% if node.permissions.world %}
li.public(
data-toggle="tooltip",
data-placement="bottom",
title="Anybody can download. Share it!")
i.pi-lock-open
span Public
| {% endif %}
| {% block node_details_meta_extra %}{% endblock %}
| {% block node_details_meta_extra %}{% endblock %}
li.download
| {% if (current_user.has_cap('subscriber') or node.permissions.world) and (node.file or node.properties.files) %}
| {% block node_download %}
a(
title="Download {{ node.properties.content_type | undertitle }}",
href="{{ node.file.link }}",
download="{{ node.file.filename }}")
button.btn.btn-sm.btn-outline-primary.px-3(type="button")
i.pi-download.pr-2
| Download
| {% endblock node_download %}
| {% elif current_user.has_cap('can-renew-subscription') %}
a.btn.btn-success(
title="Renew your subscription to download",
target="_blank",
href="/renew")
i.pi-heart
| Renew Subscription
| {% elif current_user.is_authenticated %}
.btn.disabled
i.pi-lock
li.download
| {% if (current_user.has_cap('subscriber') or node.permissions.world) and (node.file or node.properties.files) %}
| {% block node_download %}
a(
title="Download {{ node.properties.content_type | undertitle }}",
href="{{ node.file.link }}",
download="{{ node.file.filename }}")
button.btn.btn-sm.btn-outline-primary.px-3(type="button")
i.pi-download.pr-2
| Download
| {% endblock node_download %}
| {% else %}
a.btn(
title="Login to download {{ node.properties.content_type | undertitle }}",
href="{{ url_for('users.login') }}")
i.pi-lock
| Download
| {% endif %}
| {% elif current_user.has_cap('can-renew-subscription') %}
a.btn.btn-success(
title="Renew your subscription to download",
target="_blank",
href="/renew")
i.pi-heart
| Renew Subscription
| {% elif current_user.is_authenticated %}
.btn.disabled
i.pi-lock
| Download
| {% else %}
a.btn(
title="Login to download {{ node.properties.content_type | undertitle }}",
href="{{ url_for('users.login') }}")
i.pi-lock
| Download
| {% endif %}
| {% endblock node_details %}