Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Project taxonomy #1846

Merged
merged 7 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions indigo_api/migrations/0027_taxonomytopic_description.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.13 on 2023-10-10 03:59

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('indigo_api', '0026_taxonomy_topic'),
]

operations = [
migrations.AddField(
model_name='taxonomytopic',
name='description',
field=models.TextField(blank=True, null=True),
),
]
1 change: 1 addition & 0 deletions indigo_api/models/works.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ def get_topic(self, value):
class TaxonomyTopic(MP_Node):
name = models.CharField(max_length=512, null=False, blank=False)
slug = models.SlugField(max_length=512, null=False, unique=True, blank=False)
description = models.TextField(null=True, blank=True)
node_order_by = ['name']

class Meta:
Expand Down
4 changes: 2 additions & 2 deletions indigo_app/js/components/TaxonomyTOC.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default {
// Set expanded state of current item and its parents
function formatItem (x) {
const children = (x.children || []).map(y => formatItem(y));
x.expanded = x.data.slug === current || children.some(y => y.expanded);
x.expanded = x.selected || x.data.slug === current || children.some(y => y.expanded);
return x;
}
taxonomy.map(x => formatItem(x));
Expand All @@ -35,7 +35,7 @@ export default {
toc[0].addEventListener('itemRendered', (e) => {
const tocItem = e.target;
if (!tocItem) return;
if (this.current === tocItem.item.data?.slug) {
if (tocItem.item.selected || this.current === tocItem.item.data?.slug) {
tocItem.querySelector('.content__action__title').classList.add('active');
}
});
Expand Down
23 changes: 16 additions & 7 deletions indigo_app/templates/indigo_api/_task_card_single.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@
{% trans 'Approve' %}
</button>
{% endif %}
<button type="submit"
class="dropdown-item"
formaction="{% url 'workflow_remove_task' place=task.place.place_code pk=workflow.pk task_pk=task.pk %}"
data-confirm="{% trans 'Are you sure you want to remove this task?' %}">
{% trans 'Remove from project' %}
</button>
{% if workflow.pk %}
<button type="submit"
class="dropdown-item"
formaction="{% url 'workflow_remove_task' place=task.place.place_code pk=workflow.pk task_pk=task.pk %}"
data-confirm="{% trans 'Are you sure you want to remove this task?' %}">
{% trans 'Remove from project' %}
</button>
{% endif %}
goose-life marked this conversation as resolved.
Show resolved Hide resolved
</div>
</div>
</form>
Expand Down Expand Up @@ -93,11 +95,17 @@
<span class="badge badge-secondary mb-1" title="{{ label.description }}">{{ label.title }}</span>
{% endfor %}


{% if assigned and task.assigned_to %}
<div class="mb-1">
<div>
<i class="fas fa-user-tag fa-xs text-{{ task.state }}" title="{% trans 'Assigned to' %}"></i>
<small class="text-muted">{% user_profile task.assigned_to %}</small>
</div>
{% endif %}

{% if assign_controls %}
{% if assigned and task.assigned_to %}
<div class="mb-1">
<!-- assign button-->
{% if assign_button and perms.indigo_api.change_task %}
<form method="POST" class="assign-task-form" action="{% url 'assign_task' place=task.place.place_code pk=task.pk %}?next={{ request.get_full_path|urlencode }}#task-{{ task.id }}">
Expand Down Expand Up @@ -131,6 +139,7 @@
</form>
{% endif %}
{% endif %}
{% endif %}

{% if approved and task.reviewed_by_user %}
<div class="mb-1">
Expand Down
17 changes: 15 additions & 2 deletions indigo_app/templates/indigo_api/_task_filter_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@
</select>
</div>
{% endif %}

{% if show_country %}
<div class="mr-2 mb-2">
<select class="narrow selectpicker notooltip" multiple title="{% trans 'Country' %}" name="{{ form.country.name }}"
data-style="btn-outline-secondary" data-actions-box="true" data-live-search="true" data-size="7">
{% for country in form.fields.country.queryset %}
<option value="{{ country.pk }}" {% if country.pk|stringformat:"i" in form.country.value %}selected{% endif %}>{{ country.name }}</option>
{% endfor %}
</select>
</div>
{% endif %}
</div>

{% if format %}
Expand All @@ -81,8 +92,10 @@
</div>
{% endif %}

<!-- Hidden field to capture and preserve the taxonomy_topic parameter-->
{{ form.taxonomy_topic.as_hidden }}
{% if taxonomy %}
<!-- Hidden field to capture and preserve the taxonomy_topic parameter-->
{{ form.taxonomy_topic.as_hidden }}
{% endif %}

</div>
</form>
4 changes: 2 additions & 2 deletions indigo_app/templates/indigo_api/task_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<div>
<div class="d-flex">
<div class="flex-grow-1">
{% include 'indigo_api/_task_filter_form.html' with form=form format=True status=True %}
{% include 'indigo_api/_task_filter_form.html' with form=form format=True status=True taxonomy=True %}
</div>

<div class="pl-3 border-left">
Expand All @@ -40,7 +40,7 @@
{% if form.format.value == 'list' %}
{% include 'indigo_api/_task_list.html' with tasks=tasks selectable=True place=False %}
{% else %}
{% include 'indigo_api/_task_cards.html' with task_groups=task_groups selectable=True %}
{% include 'indigo_api/_task_cards.html' with task_groups=task_groups assign_controls=True selectable=True %}
{% endif %}

{% else %}
Expand Down
2 changes: 1 addition & 1 deletion indigo_app/templates/indigo_api/work_tasks.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<div class="card">
{% if tasks %}
{% include 'indigo_api/_task_cards.html' with task_groups=task_groups %}
{% include 'indigo_api/_task_cards.html' with assign_controls=True task_groups=task_groups %}
{% else %}
<div class="card-body">
<p class="text-center"><em>{% trans 'No tasks.' %}</em></p>
Expand Down
4 changes: 2 additions & 2 deletions indigo_app/templates/indigo_api/workflow_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ <h5>{{ workflow.title }}</h5>
</div>

<div class="card-header p-sticky-0">
{% include 'indigo_api/_task_filter_form.html' with form=form formats=False status=False %}
{% include 'indigo_api/_task_filter_form.html' with form=form formats=False status=False taxonomy=True %}
{% include 'indigo_api/_task_bulk_update_form.html' %}
</div>

{% if has_tasks %}
{% if tasks %}
{% include 'indigo_api/_task_cards.html' with task_groups=task_groups workflow_controls=True selectable=True %}
{% include 'indigo_api/_task_cards.html' with task_groups=task_groups workflow_controls=True assign_controls=True selectable=True %}
{% else %}
<div class="card-body text-center">
<p>{% trans 'No tasks match your filters.' %}</p>
Expand Down
190 changes: 101 additions & 89 deletions indigo_app/templates/indigo_app/tasks/available_tasks.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,108 +5,120 @@

{% block content %}
<div class="container-fluid mt-3">
{% if priority_workflows %}
<h4>{% trans "Priority projects" %}</h4>

<div class="mb-3 row">
{% for workflow in priority_workflows %}
<div class="col-4 mb-2">
<div class="card">
<div class="card-body">
<div class="mb-2">
<a href="{% url 'workflow_detail' place=workflow.place.place_code pk=workflow.pk %}">{{ workflow.title }}</a>
<span class="mr-3 text-warning text-nowrap"><i class="fas fa-exclamation-circle"></i> {% trans "Priority" %}</span>
</div>
<div class="row">
<div class="col-md-3">
<div class="card">
<div class="card-body">
<div data-vue-component="TaxonomyTOC"></div>
{{ taxonomy_toc|json_script:"taxonomy_toc" }}
</div>
</div>
</div>
<div class="col-md">
{% if priority_workflows %}
<h4>{% trans "Priority projects" %}</h4>
<div class="mb-3 row">
{% for workflow in priority_workflows %}
<div class="col-4 mb-2">
<div class="card">
<div class="card-body">
<div class="mb-2">
<a href="{% url 'workflow_detail' place=workflow.place.place_code pk=workflow.pk %}">{{ workflow.title }}</a>
<span class="mr-3 text-warning text-nowrap"><i class="fas fa-exclamation-circle"></i> {% trans "Priority" %}</span>
</div>

<div class="text-muted">
<span class="mr-2">{{ workflow.country.name }}{% if workflow.locality %} › {{ workflow.locality.name }}{% endif %}</span>
{% if workflow.due_date %}
{% trans "Due" %} {{ workflow.due_date|date:"Y-m-d" }}
{% if workflow.overdue %}
<i class="ml-3 fas fa-exclamation-triangle"></i> {% trans "Overdue" %}
{% endif %}
{% endif %}
</div>
<div class="text-muted">
<span class="mr-2">{{ workflow.country.name }}{% if workflow.locality %} › {{ workflow.locality.name }}{% endif %}</span>
{% if workflow.due_date %}
{% trans "Due" %} {{ workflow.due_date|date:"Y-m-d" }}
{% if workflow.overdue %}
<i class="ml-3 fas fa-exclamation-triangle"></i> {% trans "Overdue" %}
{% endif %}
{% endif %}
</div>

<div class="progress mt-2" style="height: 0.5rem">
<div class="progress-bar bg-success" role="progressbar" style="width: {{ workflow.pct_complete }}%"></div>
</div>
<div class="progress mt-2" style="height: 0.5rem">
<div class="progress-bar bg-success" role="progressbar" style="width: {{ workflow.pct_complete }}%"></div>
</div>

<div class="row">
{% for state, count, label in workflow.task_counts %}
{% if count %}
<div class="col-4 mt-1">
<i class="fas fa-sm fa-fw task-icon-{{ state }}" title="{{ state }}"></i>
<span class="text-muted">{{ count }} {{ label }}</span>
</div>
{% endif %}
{% endfor %}
<div class="row">
{% for state, count, label in workflow.task_counts %}
{% if count %}
<div class="col-4 mt-1">
<i class="fas fa-sm fa-fw task-icon-{{ state }}" title="{{ state }}"></i>
<span class="text-muted">{{ count }} {{ label }}</span>
</div>
{% endif %}
{% endfor %}
</div>
</div>
</div>
</div>
</div>
{% endfor %}
</div>
{% endfor %}
</div>
{% endif %}
{% endif %}

<h4>{% trans "Available tasks" %} <span class="badge badge-light">{{ paginator.count }}</span></h4>
<h4>{% trans "Available tasks" %} <span class="badge badge-light">{{ paginator.count }}</span></h4>

<div class="card">
<div class="card-header">
<form method="GET" id="task-filter-form" onchange="this.submit();">
<div class="d-flex">
<div class="card">
<div class="card-header">
<form method="GET" id="task-filter-form" onchange="this.submit();">
<div class="d-flex">

<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-outline-secondary {% if not form.state.value.0 %}active{% endif %}">
<input type="radio" name="{{ form.state.name }}" autocomplete="off" value="" {% if not form.state.value %}checked{% endif %}>
{% trans "Available tasks" %}
</label>
<label class="btn btn-outline-secondary {% if 'open' in form.state.value %}active{% endif %}">
<input type="radio" name="{{ form.state.name }}" autocomplete="off" value="open" {% if 'open' in form.state.value %}checked{% endif %}>
<i class="fas fa-sm fa-fw task-icon-open"></i>
{% trans "Open" %}
</label>
<label class="btn btn-outline-secondary {% if 'pending_review' in form.state.value %}active{% endif %}">
<input type="radio" name="{{ form.state.name }}" autocomplete="off" value="pending_review" {% if 'pending_review' in form.state.value %}checked{% endif %}>
<i class="fas fa-sm fa-fw task-icon-pending_review"></i>
{% trans "Pending review" %}
</label>
</div>
<select class="form-control selectpicker notooltip col-2 ml-2"
id="{{ form.type.id_for_label }}" name="{{ form.type.html_name }}"
data-style="btn-outline-success" title="Task type"
data-actions-box="true"
data-live-search="true" data-size="7" multiple>
{% for opt in form.type %}
{{ opt }}
{% endfor %}
</select>
<select class="form-control selectpicker notooltip col-2 ml-2"
id="{{ form.country.id_for_label }}" name="{{ form.country.html_name }}"
data-style="btn-outline-success" title="Country"
data-actions-box="true"
data-live-search="true" data-size="7" multiple>
{% for opt in form.country %}
{{ opt }}
{% endfor %}
</select>
<div class="btn-group btn-group-toggle" data-toggle="buttons">
<label class="btn btn-outline-secondary {% if not form.state.value.0 %}active{% endif %}">
<input type="radio" name="{{ form.state.name }}" autocomplete="off" value="" {% if not form.state.value %}checked{% endif %}>
{% trans "Available tasks" %}
</label>
<label class="btn btn-outline-secondary {% if 'open' in form.state.value %}active{% endif %}">
<input type="radio" name="{{ form.state.name }}" autocomplete="off" value="open" {% if 'open' in form.state.value %}checked{% endif %}>
<i class="fas fa-sm fa-fw task-icon-open"></i>
{% trans "Open" %}
</label>
<label class="btn btn-outline-secondary {% if 'pending_review' in form.state.value %}active{% endif %}">
<input type="radio" name="{{ form.state.name }}" autocomplete="off" value="pending_review" {% if 'pending_review' in form.state.value %}checked{% endif %}>
<i class="fas fa-sm fa-fw task-icon-pending_review"></i>
{% trans "Pending review" %}
</label>
</div>
<select class="form-control selectpicker notooltip col-2 ml-2"
id="{{ form.type.id_for_label }}" name="{{ form.type.html_name }}"
data-style="btn-outline-success" title="Task type"
data-actions-box="true"
data-live-search="true" data-size="7" multiple>
{% for opt in form.type %}
{{ opt }}
{% endfor %}
</select>
<select class="form-control selectpicker notooltip col-2 ml-2"
id="{{ form.country.id_for_label }}" name="{{ form.country.html_name }}"
data-style="btn-outline-success" title="Country"
data-actions-box="true"
data-live-search="true" data-size="7" multiple>
{% for opt in form.country %}
{{ opt }}
{% endfor %}
</select>
</div>
</form>
</div>
</form>
</div>

{% if tasks %}
{% include 'indigo_api/_task_list.html' with tasks=tasks selectable=False place=True %}
{% else %}
<div class="card-body">
<p class="text-center"><em>{% trans "No tasks found." %}</em></p>
{% if tasks %}
{% include 'indigo_api/_task_list.html' with tasks=tasks selectable=False place=True %}
{% else %}
<div class="card-body">
<p class="text-center"><em>{% trans "No tasks found." %}</em></p>
</div>
{% endif %}
</div>
{% endif %}
</div>

{% if is_paginated %}
<nav class="mt-4">
{% include 'indigo_app/_paginator.html' with params=form.data_as_url %}
</nav>
{% endif %}
{% if is_paginated %}
<nav class="mt-4">
{% include 'indigo_app/_paginator.html' with params=form.data_as_url %}
</nav>
{% endif %}
</div>
</div>
</div>
{% endblock %}
3 changes: 3 additions & 0 deletions indigo_app/templates/indigo_app/tasks/tabbed_layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<span class="badge badge-light">{{ tab_count }}</span>
{% endif %}
</a>
<a class="nav-item nav-link {% if view.tab == 'topics' %}active{% endif %}" href="{% url 'taxonomy_task_list' %}">
{% trans "Topics" %}
</a>
{% endblock %}
</nav>
</div>
Expand Down
Loading
Loading