TitleButton

Title buttons are individual elements or modules that make up the profile. These can include various functionalities or data points that contribute to the profile’s overall purpose.


TitleButton Database Table Structure

The TitleButton model represents interactive buttons that allow users to perform specific actions related to records within the profile. These actions can include creating, downloading or accessing other functionalities.

The PostgreSQL table TitleButton consists of the following fields:

  • id (Integer):

    The primary key and unique identifier for each title button

  • name (String):

    The internal name of the title button used to identify the title button. It is often used in the code to refer to the button

  • template (String):

    The HTML template string used to render the button. It includes various HTML attributes such as style, title, CSS classes and icon elements

  • additional_attr (String):

    Any additional attributes required for the button. It is often used to store URLs or other necessary data for the button’s functionality

Hint

Click the collapsible-item-arrow button below to view the contents

TitleButton database fields
 id |                name                |                                                                                                                        template                                                                                                                         |     additional_attr
----+------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+--------------------------
  1 | new_component_template             | <button title="Add new profile record"             class="big circular ui icon primary button new-component-template copo-tooltip">         <i class="icon add sign"></i>     </button>                                                                 |
  2 | quick_tour_template                | <button title="Quick tour"             class="big circular ui icon orange button takeatour quick-tour-template copo-tooltip">         <i class="icon lightbulb"></i>     </button>                                                                      |
  3 | new_samples_spreadsheet_template   | <button   title="Add Sample(s) from Spreadsheet"             class="big circular ui icon button new-samples-spreadsheet-template copo-tooltip">         <i class="icon table sign"></i>     </button>                                                   |
  4 | new_reads_spreadsheet_template     | <button style="display: inline" title="Add Read(s) from Read Spreadsheet"             class="big circular ui icon button new-reads-spreadsheet-template copo-tooltip">         <i class="icon table sign"></i>     </button>                            |
  5 | new_local_file                     | <button title="Add new file by browsing local file system"             class="big circular ui icon primary button new-local-file copo-tooltip">         <i class="icon desktop sign"></i>     </button>                                                 |
  6 | new_terminal_file                  | <button title="Add new file by terminal"             class="big circular ui icon primary button new-terminal-file copo-tooltip">         <i class="icon terminal sign"></i>     </button>                                                               |
  7 | new_taggedseq_spreadsheet_template | <button style="display: inline" title="Add Tagged Sequence (s) from Tagged Sequence Spreadsheet"             class="big circular ui icon button new-taggedseq-spreadsheet-template copo-tooltip">         <i class="icon table sign"></i>     </button> |
  8 | download_blank_manifest_template   | <a  title="Download Blank Manifest Template"             class="big circular ui icon brown button download-blank-manifest-template copo-tooltip" target="_blank">         <i class="icon download sign"></i>     </a>                                   | href:#blank_manifest_url
  9 | download_sop                       | <a title="Download Standard Operating Procedure (SOP)"         class="big circular ui icon yellow button download-sop copo-tooltip" target="_blank">         <i class="icon download sign"></i>     </a>                                                | href:#sop_url
 10 | accept_reject_samples              | <button style="display: none" title="Accept/Reject TOL Samples"             class="big circular ui icon teal button accept_reject_samples copo-tooltip">         <i class="icon tasks sign"></i>     </button>                                          |
 11 | tol_inspect                        | <button style="display: none" title="Inspect TOL"             class="big circular ui icon yellow button tol_inspect copo-tooltip">         <i class="icon clipboard list"></i>     </button>                                                            |
 12 | tol_inspect_gal                    | <button class="big circular ui icon green button tol_inspect_gal copo-tooltip" title="Inspect TOL by GAL">         <i class="icon building"></i>     </button>                                                                                          |
 13 | copo_accessions                    | <button style="display: none" title="View Accessions Dashboard"             class="big circular ui icon pink button copo_accessions copo-tooltip">         <i class="icon sitemap"></i>     </button>                                                   |


Description of each TitleButton record
  • new_component_template: Button to add a new profile record. It is styled with a primary colour and an icon of an add sign

  • quick_tour_template: Button to start a quick tour. It is styled with an orange colour and an icon of a lightbulb

  • new_samples_spreadsheet_template: Button to add samples from a spreadsheet template. It is styled with a teal colour and an icon of a table sign

  • new_reads_spreadsheet_template: Button to add reads from a spreadsheet template. It is styled with a teal colour and an icon of a table sign

  • new_local_file: Button to add a new file by browsing the local file system. It is styled with a primary colour and an icon of a desktop sign

    📖 Section on Button Usage in the Project

  • new_terminal_file: Button to add a new file by terminal. It is styled with a primary colour and an icon of a terminal sign

    📖 Section on Button Usage in the Project

  • new_taggedseq_spreadsheet_template: Button to add tagged sequences from a spreadsheet template. It is styled with a teal colour and an icon of a table sign

    📖 Section on Button Usage in the Project

    🌐 Associated web page

  • download_blank_manifest_template: Button to download a blank manifest template. It is styled with a brown colour and an icon of a download sign

  • download_sop: Button to download the :abbr:SOP (Standard Operating Procedure). It is styled with a yellow colour and an icon of a download sign

  • accept_reject_samples: Button to accept or reject ToL samples. It is styled with a teal colour and an icon of tasks

    📖 Section on Button Usage in the Project

    🌐 Associated web page

    🌐 Django Admin UI

  • tol_inspect: Button to inspect the ToL samples. It is styled with a yellow colour and an icon of a clipboard list

    📖 Section on Button Usage in the Project

    🌐 Associated web page

  • tol_inspect_gal: Button to inspect the ToL by Genome Acquisition Lab (GAL). It is styled with a green colour and an icon of a building

    📖 Section on Button Usage in the Project

    🌐 Associated web page

  • copo_accessions: Button to access the Accessions Dashboard. It is styled with a pink colour and an icon of a sitemap


Referencing Created TitleButton in Project

Note

  • Ensure that a Django app is created to manage the TitleButton Django model and render the buttons in the template.

    Refer to the Creation of Component section which explains how to create a Django app for a component

  • Ensure that static files like CSS and JS files are correctly configured in the Django project settings.py file

    # settings.py
    STATIC_URL = '/static/'
    STATICFILES_DIRS = [BASE_DIR / 'static']
    

Hint

Click the collapsible-item-arrow button below to view the contents

See also

COPO Project Application Structure section which explains the structure of a Django project.

Define views that render the template containing the buttons in views.py
# myapp/views.py
from django.shortcuts import render
from django.views import View
from .models import TitleButton

class TitleButtonView(View):
    def get(self, request):
        my_models = TitleButton.objects.all()
        return render(request, 'myapp/myapp.html', {'title_button_def': my_models})
Configure URL routing to the view defined above in the urls.py
# myapp/urls.py
from django.urls import path
from .views import TitleButtonView

urlpatterns = [
    path('title-buttons/', TitleButtonView.as_view(), name='title_buttons'),
]

  • In the template HTML file (myapp.html), reference each element from the TitleButton table.

TitleButton example template
<!-- myapp/templates/myapp/title_button.html -->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title Buttons</title>
    <link rel="stylesheet" href="{% static 'your_app/css/styles.css' %}">
    <script src="{% static 'your_app/js/title_buttons.js' %}"></script>
    <script>
        const component_def = {
          {% for component in component_def %}
            {{ component.name|lower }}:  {
              component: '{{ component.name }}',
              title: '{{ component.title }}',
              {% if component.subtitle %}
              subtitle: '{{ component.subtitle }}',
              {% endif %}
              iconClass: '{{ component.widget_icon_class }}',
              semanticIcon: '{{ component.widget_icon }}',
              buttons: [ {% for button in component.title_buttons.all %} '{{ button.name }}', {% endfor %} ],
              sidebarPanels: ['copo-sidebar-info'],
              colorClass: '{{ component.widget_colour_class }}',
              color: '{{ component.widget_colour }}',
              tableID: '{{ component.table_id }}',
              recordActions: [ {% for button in component.recordaction_buttons.all %} '{{ button.name }}', {% endfor %} ],
              url: "{% if component.reverse_url %}{% url component.reverse_url profile_id='999' %}{% endif %}",
            },
          {% endfor %}
        }

        const title_button_def = {
          {% autoescape off %}
          {% for button in title_button_def %}
            {{ button.name  }} : {
              template: `{{ button.template }}`,
              additional_attr: '{{ button.additional_attr }}',
              },
          {% endfor  %}
          {% endautoescape %}
        }
    </script>
</head>
<body>
    <ul>
        <li>
            <button title="Add new profile record" class="big circular ui icon primary button new-component-template copo-tooltip">
                <i class="icon add sign"></i>
            </button>
        </li>
        <li>
            <button title="Quick tour" class="big circular ui icon orange button takeatour quick-tour-template copo-tooltip">
                <i class="icon lightbulb"></i>
            </button>
        </li>
        <li>
            <button title="Add Sample(s) from Spreadsheet" class="big circular ui icon button new-samples-spreadsheet-template copo-tooltip">
                <i class="icon table sign"></i>
            </button>
        </li>
        <li>
            <button title="Add Read(s) from Read Spreadsheet" class="big circular ui icon button new-reads-spreadsheet-template copo-tooltip">
                <i class="icon table sign"></i>
            </button>
        </li>
        <li>
            <button title="Add new file by browsing local file system" class="big circular ui icon primary button new-local-file copo-tooltip">
                <i class="icon desktop sign"></i>
            </button>
        </li>
        <li>
            <button title="Add new file by terminal" class="big circular ui icon primary button new-terminal-file copo-tooltip">
                <i class="icon terminal sign"></i>
            </button>
        </li>
        <li>
            <button title="Add Tagged Sequence (s) from Tagged Sequence Spreadsheet" class="big circular ui icon button new-taggedseq-spreadsheet-template copo-tooltip">
                <i class="icon table sign"></i>
            </button>
        </li>
        <li>
            <a title="Download Blank Manifest Template" class="big circular ui icon brown button download-blank-manifest-template copo-tooltip" target="_blank" href="#blank_manifest_url">
                <i class="icon download sign"></i>
            </a>
        </li>
        <li>
            <a title="Download Standard Operating Procedure (SOP)" class="big circular ui icon yellow button download-sop copo-tooltip" target="_blank" href="#sop_url">
                <i class="icon download sign"></i>
            </a>
        </li>
        <li>
            <button style="display: none" title="Accept/Reject TOL Samples" class="big circular ui icon teal button accept_reject_samples copo-tooltip">
                <i class="icon tasks sign"></i>
            </button>
        </li>
        <li>
            <button style="display: none" title="Inspect TOL" class="big circular ui icon yellow button tol_inspect copo-tooltip">
                <i class="icon clipboard list"></i>
            </button>
        </li>
        <li>
            <button class="big circular ui icon green button tol_inspect_gal copo-tooltip" title="Inspect TOL by GAL">
                <i class="icon building"></i>
            </button>
        </li>
        <li>
            <button style="display: none" title="View Accessions Dashboard" class="big circular ui icon pink button copo_accessions copo-tooltip">
                <i class="icon sitemap"></i>
            </button>
        </li>
    </ul>
</body>
</html>

  • Handle any JavaScript functionality needed for the buttons in the JS file (myapp.js)

Title button example javascript
// myapp/static/myapp/js/title_button.js
$(document).ready(function () {
    var componentName = $('#nav_component_name').val();

    // 'component_def' is defined in the 'title_button.html' file
    var componentMeta = null;
    componentMeta = component_def[componentName]

    // 'get_component_meta' reference
    var component = componentMeta;

    // Ignored obsolete code about creating page title and adding
    // it to the page 'buttonsSpan'

    // Create buttons
    var buttonsSpan = $('<span/>', {style: 'white-space:nowrap;'});

    if (component.buttons) {
        component.buttons.forEach(function (item) {
            button_str = title_button_def[item.split('|')[0]].template
            additional_attr = title_button_def[item.split('|')[0]].additional_attr
            button = $(button_str);

            if (additional_attr != undefined) {
                attrs = additional_attr.split(',');
                for (var i = 0; i < attrs.length; ++i) {
                    if (attrs[i].indexOf(':') > -1) {
                        key = attrs[i].split(':')[0];
                        value = attrs[i].split(':')[1];
                        if (value.indexOf('#') > -1 || value.indexOf('.') > -1) {
                            button.attr(key, $(value).val());
                        } else {
                            button.attr(key, value);
                        }
                    }
                }
            }
            buttonsSpan
                .append(button)
                .append("<span style='display: inline;'>&nbsp;</span>");
        });
    }
});

Visualisation of TitleButton in Project

Visual representation of 'new component' title button on 'Work Profiles' web page

Work Profiles web page: Visual representation of ‘new component’ title button

  • new_component_template button is labelled Add new profile record. It is the add-profile-button button indicated by the blue arrow in the image above.


Visual representation of 'quick tour', 'new samples spreadsheet', 'download blank manifest ', 'download SOP' and 'accept/reject' title buttons on Samples web page

Samples web page: Visual representation of ‘quick tour’, ‘new samples spreadsheet’, ‘download blank manifest’, ‘download SOP’ and ‘accept/reject’ title buttons

  • quick_tour_template button is labelled Quick tour. It is the quick-tour-button button indicated by the orange arrow in the image above.

  • new_samples_spreadsheet_template button is labelled Add Sample(s) from Spreadsheet. It is the add-dtol-manifest-button button indicated by the green arrow.

    The colour of this button may differ based on the profile type. For example, it can be add-asg-manifest-button for ASG profile, add-erga-manifest-button for ERGA profile or add-reads-manifest-button for Genomics profile.

  • download_blank_manifest_template button is labelled Download Blank Manifest Template. It is the blank-manifest-download-button button indicated by the brown arrow.

  • download_sop: button is labelled Download Standard Operating Procedure (SOP). It is the sop-download-button button indicated by the yellow arrow.

  • accept_reject_samples button is labelled Accept/Reject TOL Samples. It is the accept-reject-samples-navigation-button button indicated by the teal arrow.