Skip to content

Commit

Permalink
finalize badge update (#1299, #1300)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkonie committed Oct 18, 2023
1 parent 4d6c0aa commit 86b0370
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 103 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,21 @@ Changelog for the **SODAR Core** Django app package. Loosely follows the
Unreleased
==========

Added
-----

- **Projectroles**
- ``_project_badge.html`` template (#1300)

Changed
-------

- **Appalerts**
- Use projectroles project badge templage (#1300)
- **Timeline**
- Truncate long project titles in badge (#1299)
- Use projectroles project badge templage (#1300)

Fixed
-----

Expand All @@ -17,6 +32,12 @@ Fixed
- **Timeline**
- ``get_timestamp()`` template tag crash from missing ``ProjectEventStatus`` (#1297)

Removed
-------

- **Timeline**
- ``_project_badge.html`` template (#1300)


v0.13.2 (2023-09-21)
====================
Expand Down
23 changes: 3 additions & 20 deletions appalerts/templates/appalerts/alert_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,7 @@ <h2>
</div>
<div class="col pl-0">
{% if a.project %}
{% include 'projectroles/_project_badge.html' with project=a.project badge_color=a.level can_view=can_view_project %}
{% comment %}
<span class="badge sodar-app-alert-project-badge mr-1
badge-{% if not a.project or can_view_project %}{{ a.level | lower }}{% else %}secondary{% endif %}"
title="{% get_display_name a.project.type title=True %}: {{ a.project.title }}"
data-toggle="tooltip" data-placement="top">
<i class="iconify"
data-icon="{% if a.project.type == 'PROJECT' %}mdi:cube{% else %}mdi:rhombus-split{% endif %}">
</i>
{% if can_view_project %}
<a href="{% url 'projectroles:detail' project=a.project.sodar_uuid %}">
{{ a.project.title }}
</a>
{% else %}
{{ a.project.title }}
{% endif %}
</span>
{% endcomment %}
{% include 'projectroles/_project_badge.html' with project=a.project color=a.level can_view=can_view_project %}
{% endif %}
{{ a.message | safe }}
</div>
Expand Down Expand Up @@ -210,15 +193,15 @@ <h2>
showCancelLink: true
});
}
if ($('.sodar-app-alert-project-badge').length) {
if ($('.sodar-project-badge').length) {
tour.addStep('alert', {
title: 'Alert {% get_display_name 'PROJECT' title=True %} or ' +
'{% get_display_name 'CATEGORY' title=True %}',
text: 'This badge links to the ' +
'{% get_display_name 'PROJECT' %} or ' +
'{% get_display_name 'CATEGORY' %} to which the alerted ' +
'activity is related.',
attachTo: '.sodar-app-alert-project-badge top',
attachTo: '.sodar-project-badge top',
advanceOn: '.docs-link click',
showCancelLink: true
});
Expand Down
156 changes: 91 additions & 65 deletions docs/source/dev_resource.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,97 @@ will disable the button after the initial click while the form is submitted.
This is especially recommended for forms responsible for creating objects.


Template Includes and Helpers
=============================

This section details general template includes and helpers provided by SODAR
Core. Unless otherwise mentioned, these can be imported from the projectroles
app.

For common template tags, see :ref:`app_projectroles_api_django_tags`.

Pagination Template
-------------------

A common template for adding navigation for list pagination can be found in
``projectroles/_pagination.html``. This can be included to any Django
``ListView`` template which provides the ``paginate_by`` definition, enabling
pagination. If a smaller layout is desired, the ``pg_small`` argument can be
used. An example can be seen below:

.. code-block:: django
{% include 'projectroles/_pagination.html' with pg_small=True %}
Project Badge
-------------

Projectroles provides a project badge which can be used to display a fixed-size
link to a category or a project among text. It can be included in your template
as follows:

.. code-block:: django
{% include 'projectroles/_project_badge.html' with project=project color='info' can_view=True %}
The following arguments are expected:

``project``
Project object for the related project or category.
``color``
String for the badge color (must correspond to bootstrap classes, e.g.
"info" or "success").
``can_view``
Boolean for whether the current user should have access to view the project.

Tour Help
---------

SODAR Core uses `Shepherd <https://shipshapecode.github.io/shepherd/docs/welcome/>`_
to present an optional interactive tour for a rendered page. To enable the tour
in your template, set it up inside the ``javascript`` template block. Within an
inline javascript structure, set the ``tourEnabled`` variable to ``true`` and
add steps according to the
`Shepherd documentation <https://shipshapecode.github.io/shepherd>`_.

Example:

.. code-block:: django
{% block javascript %}
{{ block.super }}
{# Tour content #}
<script type="text/javascript">
tourEnabled = true;
/* Normal step */
tour.addStep('id_of_step', {
title: 'Step Title',
text: 'Description of the step',
attachTo: '#some-element top',
advanceOn: '.docs-link click',
showCancelLink: true
});
/* Conditional step */
if ($('.potentially-existing-element').length) {
tour.addStep('id_of_another_step', {
title: 'Another Title',
text: 'Another description here',
attachTo: '.potentially-existing-element right',
advanceOn: '.docs-link click',
showCancelLink: true
});
}
</script>
{% endblock javascript %}
.. warning::

Make sure you call ``{{ block.super }}`` at the start of the declared
``javascript`` block or you will overwrite the site's default Javascript
setup!


App Settings
============

Expand Down Expand Up @@ -251,71 +342,6 @@ the Django database:
$ ./manage.py cleanappsettings
Pagination Template
===================

A common template for adding navigation for list pagination can be found in
``projectroles/_pagination.html``. This can be included to any Django
``ListView`` template which provides the ``paginate_by`` definition, enabling
pagination. If a smaller layout is desired, the ``pg_small`` argument can be
used. An example can be seen below:

.. code-block:: django
{% include 'projectroles/_pagination.html' with pg_small=True %}
Tour Help
=========

SODAR Core uses `Shepherd <https://shipshapecode.github.io/shepherd/docs/welcome/>`_
to present an optional interactive tour for a rendered page. To enable the tour
in your template, set it up inside the ``javascript`` template block. Within an
inline javascript structure, set the ``tourEnabled`` variable to ``true`` and add
steps according to the `Shepherd documentation <https://shipshapecode.github.io/shepherd>`_.

Example:

.. code-block:: django
{% block javascript %}
{{ block.super }}
{# Tour content #}
<script type="text/javascript">
tourEnabled = true;
/* Normal step */
tour.addStep('id_of_step', {
title: 'Step Title',
text: 'Description of the step',
attachTo: '#some-element top',
advanceOn: '.docs-link click',
showCancelLink: true
});
/* Conditional step */
if ($('.potentially-existing-element').length) {
tour.addStep('id_of_another_step', {
title: 'Another Title',
text: 'Another description here',
attachTo: '.potentially-existing-element right',
advanceOn: '.docs-link click',
showCancelLink: true
});
}
</script>
{% endblock javascript %}
.. warning::

Make sure you call ``{{ block.super }}`` at the start of the declared
``javascript`` block or you will overwrite the site's default Javascript
setup!


Project Modifying API
=====================

Expand Down
1 change: 1 addition & 0 deletions docs/source/major_changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ releases, see the :ref:`full changelog<changelog>`.
v0.13.3 (WIP)
*************

- Add common project badge template
- Fix hidden JSON project setting reset on non-superuser project update
- General bug fixes and minor updates

Expand Down
5 changes: 3 additions & 2 deletions projectroles/templates/projectroles/_project_badge.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{# Badge to display a project/category link #}
{# Parameters: #}
{# project (Project object) #}
{# badge_color (string) #}
{# color (string) #}
{# can_view (boolean) #}
<span class="badge sodar-project-badge mr-1
badge-{% if not can_view %}secondary{% else %}{{ badge_color|lower }}{% endif %}">
badge-{% if not can_view %}secondary{% else %}{{ color|lower }}{% endif %}"
title="{{ project.full_title }}" data-toggle="tooltip" data-delay="500">
<i class="iconify"
data-icon="{% if project.type == 'PROJECT' %}mdi:cube{% else %}mdi:rhombus-split{% endif %}">
</i>
Expand Down
4 changes: 1 addition & 3 deletions timeline/templates/timeline/_list_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
</td>
<td class="sodar-tl-item-desc">
{% if event.project and user.is_superuser and timeline_mode == 'admin' %}
{% include 'projectroles/_project_badge.html' with project=event.project badge_color='info' can_view=True %}
{# include 'timeline/_project_badge.html' #}
{% include 'projectroles/_project_badge.html' with project=event.project color='info' can_view=True %}
{% endif %}
{% get_event_description event plugin_lookup request as event_desc %}
{{ event_desc|safe }}
Expand Down Expand Up @@ -74,4 +73,3 @@
{{ event.get_status.status_type }}
</td>
</tr>

4 changes: 2 additions & 2 deletions timeline/templates/timeline/_list_tour.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
showCancelLink: true
});
}
if ($('.sodar-tl-item-project-badge').length) {
if ($('.sodar-project-badge').length) {
tour.addStep('event_desc', {
title: '{% get_display_name 'PROJECT' title=True %} Badge',
text: 'This badge links to the {% get_display_name 'PROJECT' %} to ' +
'which the event is related.',
attachTo: '.sodar-tl-item-project-badge top',
attachTo: '.sodar-project-badge top',
advanceOn: '.docs-link click',
showCancelLink: true
});
Expand Down
11 changes: 0 additions & 11 deletions timeline/templates/timeline/_project_badge.html

This file was deleted.

0 comments on commit 86b0370

Please sign in to comment.