Vaihe 1/4: asiakastyöt (numerointi, tagit, linkit, jäsenet, muutoshistoria)

- Uusi jobs-moduuli: asiakastyön kentät ilman rahakenttiä, juokseva
  vuosinumero VVVV-NNNN (laskuririvi lukitaan), tagit, linkit dialogissa,
  jäsenet ja muutoshistoria nimiarvoineen.
- Tilojen oikeudet: lasku luotu / laskutettu johto tai työn laskuttaja,
  arkistointi vain johto; alihankkija näkee vain jäsenyystyönsä eikä muokkaa.
- Lista ja haku (numero, nimi, asiakas), suodattimet, omat työt oletuksena,
  arkistoidut piilossa, myöhässä tekstinä ja kuvakkeena.
- Asiakasvalitsin hakuineen ja pikalisäyksineen (myös pikavastaanottoa varten).
- Asiakkaan sivulle asiakastyöt-osio; valikkoon Asiakastyöt.
- Lukurajapinnat muihin moduuleihin: UserQueries.choices,
  CustomerQueries.summaries, CatalogQueries.service_units; jobs.*-oikeudet.
- Import-linter-sopimukset, käännökset, testit (domain, application,
  integraatio, selain) sekä määrittelyn ja CLAUDE.md:n päivitys.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-29 14:38:42 +02:00
co-authored by Claude Opus 5.5
parent 679bf57eb4
commit 1ca03137fd
72 changed files with 4907 additions and 44 deletions
@@ -0,0 +1,86 @@
{% extends "base.html" %}{% load jobs_tags %}
{% block title %}{{ job.number }} {{ job.name }}{% endblock %}
{% block content %}
<nav class="breadcrumbs text-sm" aria-label="{% translate 'Breadcrumbs' %}">
<ul><li><a href="{% url 'jobs:list' %}">{% translate "Customer jobs" %}</a></li><li aria-current="page">{{ job.number }}</li></ul>
</nav>
<div class="flex flex-wrap items-start justify-between gap-2 mb-4">
<div class="min-w-0">
<p class="text-sm">{{ job.number }}</p>
<h1 class="text-2xl font-bold break-words">{{ job.name }}</h1>
<div class="flex flex-wrap gap-1 mt-2">
{% include "jobs/partials/status_badge.html" with status=job.status %}
{% include "jobs/partials/priority_badge.html" with priority=job.priority %}
{% if job.is_late %}{% include "jobs/partials/late_badge.html" %}{% endif %}
</div>
</div>
{% if can_edit %}<a href="{% url 'jobs:edit' job.id %}" class="btn">{% translate "Edit" %}</a>{% endif %}
</div>
<div class="grid gap-4 lg:grid-cols-2">
<section class="card bg-base-100 shadow-sm" aria-labelledby="basic-heading">
<div class="card-body">
<h2 id="basic-heading" class="card-title">{% translate "Basic information" %}</h2>
<dl class="grid gap-x-6 gap-y-2 sm:grid-cols-[max-content_1fr]">
<dt class="font-semibold">{% translate "Customer" %}</dt>
<dd>{% if can_see_customer %}<a class="link" href="{% url 'customers:detail' job.customer.id %}">{{ job.customer.name }}</a>{% else %}{{ job.customer.name }}{% endif %}</dd>
<dt class="font-semibold">{% translate "Service units" %}</dt>
<dd>{% for u in job.service_units %}{{ u.name }}{% if not forloop.last %}, {% endif %}{% empty %}–{% endfor %}</dd>
<dt class="font-semibold">{% translate "Kind" %}</dt><dd>{{ job.kind|kind_label }}</dd>
<dt class="font-semibold">{% translate "Payment basis" %}</dt><dd>{{ job.payment_basis|payment_basis_label }}</dd>
<dt class="font-semibold">{% translate "Estimated hours" %}</dt><dd>{% if job.estimated_hours is not None %}{{ job.estimated_hours }} h{% else %}–{% endif %}</dd>
<dt class="font-semibold">{% translate "Customer reference (PO)" %}</dt><dd>{{ job.customer_reference|default:"–" }}</dd>
<dt class="font-semibold">{% translate "Tags" %}</dt>
<dd>{% if job.tags %}<ul class="flex flex-wrap gap-1" aria-label="{% translate 'Tags' %}">{% for t in job.tags %}<li class="badge badge-outline">{{ t }}</li>{% endfor %}</ul>{% else %}–{% endif %}</dd>
<dt class="font-semibold">{% translate "Created" %}</dt>
<dd>{{ job.created_at|date:"SHORT_DATE_FORMAT" }}{% if job.created_by %}, {{ job.created_by.name }}{% endif %}</dd>
</dl>
</div>
</section>
<section class="card bg-base-100 shadow-sm" aria-labelledby="schedule-heading">
<div class="card-body">
<h2 id="schedule-heading" class="card-title">{% translate "Schedule" %}</h2>
<dl class="grid gap-x-6 gap-y-2 sm:grid-cols-[max-content_1fr]">
<dt class="font-semibold">{% translate "Start date" %}</dt><dd>{{ job.starts_on|date:"SHORT_DATE_FORMAT"|default:"–" }}</dd>
<dt class="font-semibold">{% translate "Due date" %}</dt>
<dd>{{ job.due_on|date:"SHORT_DATE_FORMAT"|default:"–" }}{% if job.is_late %} {% include "jobs/partials/late_badge.html" %}{% endif %}</dd>
<dt class="font-semibold">{% translate "Planned schedule" %}</dt>
<dd>{% if job.planned_from or job.planned_to %}{{ job.planned_from|date:"SHORT_DATE_FORMAT"|default:"…" }} – {{ job.planned_to|date:"SHORT_DATE_FORMAT"|default:"…" }}{% else %}–{% endif %}</dd>
</dl>
</div>
</section>
<section class="card bg-base-100 shadow-sm" aria-labelledby="people-heading">
<div class="card-body">
<h2 id="people-heading" class="card-title">{% translate "People and invoicing" %}</h2>
<dl class="grid gap-x-6 gap-y-2 sm:grid-cols-[max-content_1fr]">
<dt class="font-semibold">{% translate "Responsible person" %}</dt><dd>{{ job.responsible.name|default:"–" }}</dd>
<dt class="font-semibold">{% translate "Contact person" %}</dt><dd>{{ job.contact_user.name|default:"–" }}</dd>
<dt class="font-semibold">{% translate "Customer's contact" %}</dt><dd>{{ job.customer_contact.name|default:"–" }}</dd>
<dt class="font-semibold">{% translate "Biller" %}</dt><dd>{{ job.biller.name|default:"–" }}</dd>
<dt class="font-semibold">{% translate "Billing unit" %}</dt><dd>{{ job.billing_unit.name|default:"–" }}</dd>
<dt class="font-semibold">{% translate "Other members" %}</dt>
<dd>{% for m in job.members %}{{ m.name }}{% if not forloop.last %}, {% endif %}{% empty %}–{% endfor %}</dd>
</dl>
</div>
</section>
{% include "jobs/partials/links.html" %}
<section class="card bg-base-100 shadow-sm lg:col-span-2" aria-labelledby="description-heading">
<div class="card-body">
<h2 id="description-heading" class="card-title">{% translate "Description" %}</h2>
<p class="whitespace-pre-line break-words">{{ job.description|default:"–" }}</p>
<h2 class="card-title mt-2">{% translate "Instructions" %}</h2>
<p class="whitespace-pre-line break-words">{{ job.instructions|default:"–" }}</p>
</div>
</section>
</div>
<div class="mt-4">{% include "jobs/partials/history.html" %}</div>
<dialog id="item-dialog" class="modal" aria-labelledby="item-dialog-title">
<div class="modal-box" id="item-dialog-body"></div>
</dialog>
{% endblock %}
@@ -0,0 +1,73 @@
{% extends "base.html" %}
{% block title %}{% if job %}{% translate "Edit job" %}{% else %}{% translate "New job" %}{% endif %}{% endblock %}
{% block content %}
<nav class="breadcrumbs text-sm" aria-label="{% translate 'Breadcrumbs' %}">
<ul>
<li><a href="{% url 'jobs:list' %}">{% translate "Customer jobs" %}</a></li>
{% if job %}<li><a href="{% url 'jobs:detail' job.id %}">{{ job.number }}</a></li>{% endif %}
<li aria-current="page">{% if job %}{% translate "Edit" %}{% else %}{% translate "New job" %}{% endif %}</li>
</ul>
</nav>
<h1 class="text-2xl font-bold mb-4">{% if job %}{% blocktranslate with number=job.number %}Edit job {{ number }}{% endblocktranslate %}{% else %}{% translate "New job" %}{% endif %}</h1>
<form method="post" novalidate class="space-y-4 max-w-4xl">
{% csrf_token %}
{% include "components/non_field_errors.html" %}
<section class="card bg-base-100 shadow-sm" aria-labelledby="form-basic-heading">
<div class="card-body">
<h2 id="form-basic-heading" class="card-title">{% translate "Basic information" %}</h2>
{% include "jobs/partials/customer_picker.html" %}
{{ form.name.as_field_group }}
{{ form.description.as_field_group }}
{{ form.service_units.as_field_group }}
<div class="grid gap-x-4 sm:grid-cols-2">
{{ form.status.as_field_group }}
{{ form.priority.as_field_group }}
{{ form.kind.as_field_group }}
{{ form.payment_basis.as_field_group }}
{{ form.estimated_hours.as_field_group }}
{{ form.customer_reference.as_field_group }}
</div>
{% include "jobs/partials/tags_input.html" %}
</div>
</section>
<section class="card bg-base-100 shadow-sm" aria-labelledby="form-schedule-heading">
<div class="card-body">
<h2 id="form-schedule-heading" class="card-title">{% translate "Schedule" %}</h2>
<div class="grid gap-x-4 sm:grid-cols-2">
{{ form.starts_on.as_field_group }}
{{ form.due_on.as_field_group }}
{{ form.planned_from.as_field_group }}
{{ form.planned_to.as_field_group }}
</div>
</div>
</section>
<section class="card bg-base-100 shadow-sm" aria-labelledby="form-people-heading">
<div class="card-body">
<h2 id="form-people-heading" class="card-title">{% translate "People and invoicing" %}</h2>
<div class="grid gap-x-4 sm:grid-cols-2">
{{ form.responsible_user.as_field_group }}
{{ form.contact_user.as_field_group }}
{{ form.biller_user.as_field_group }}
</div>
<div id="customer-fields">{% include "jobs/partials/customer_fields.html" %}</div>
{{ form.members.as_field_group }}
</div>
</section>
<section class="card bg-base-100 shadow-sm" aria-labelledby="form-instructions-heading">
<div class="card-body">
<h2 id="form-instructions-heading" class="card-title">{% translate "Instructions" %}</h2>
{{ form.instructions.as_field_group }}
</div>
</section>
<div class="flex justify-end gap-2">
<a href="{% if job %}{% url 'jobs:detail' job.id %}{% else %}{% url 'jobs:list' %}{% endif %}" class="btn">{% translate "Cancel" %}</a>
<button type="submit" class="btn btn-primary">{% translate "Save" %}</button>
</div>
</form>
{% endblock %}
@@ -0,0 +1,15 @@
{% extends "base.html" %}
{% block title %}{{ job.number }} {{ job.name }}{% endblock %}
{% block content %}
<nav class="breadcrumbs text-sm" aria-label="{% translate 'Breadcrumbs' %}">
<ul>
<li><a href="{% url 'jobs:list' %}">{% translate "Customer jobs" %}</a></li>
<li><a href="{% url 'jobs:detail' job.id %}">{{ job.number }}</a></li>
</ul>
</nav>
<div class="card bg-base-100 shadow-sm max-w-2xl">
<div class="card-body">
{% include "jobs/partials/link_form.html" %}
</div>
</div>
{% endblock %}
@@ -0,0 +1,29 @@
{% extends "base.html" %}{% load users_tags %}
{% block title %}{% translate "Customer jobs" %}{% endblock %}
{% block content %}
<div class="flex flex-wrap items-center justify-between gap-2 mb-4">
<h1 class="text-2xl font-bold">{% translate "Customer jobs" %}</h1>
{% if request.user|can:"jobs.edit" %}
<a href="{% url 'jobs:create' %}" class="btn btn-primary">{% translate "New job" %}</a>
{% endif %}
</div>
<form method="get" role="search" aria-label="{% translate 'Filter jobs' %}"
class="card bg-base-100 shadow-sm mb-4"
hx-get="{% url 'jobs:list' %}" hx-target="#job-table" hx-push-url="true"
hx-trigger="input changed delay:300ms from:input[name='q'], change from:select, change from:input[type='checkbox'], submit">
<div class="card-body grid gap-2 sm:grid-cols-2 lg:grid-cols-3 py-4">
{{ filters.q.as_field_group }}
{{ filters.scope.as_field_group }}
{{ filters.status.as_field_group }}
{{ filters.priority.as_field_group }}
{{ filters.service_unit.as_field_group }}
<div class="self-end">{{ filters.archived.as_field_group }}</div>
<noscript><button type="submit" class="btn">{% translate "Filter" %}</button></noscript>
</div>
</form>
<div id="job-table">
{% include "jobs/partials/job_table.html" %}
</div>
{% endblock %}
@@ -0,0 +1,5 @@
{# Contact and billing unit of the chosen customer (reloaded when the customer changes). #}
<div class="grid gap-x-4 sm:grid-cols-2">
{{ form.customer_contact.as_field_group }}
{{ form.billing_unit.as_field_group }}
</div>
@@ -0,0 +1,24 @@
{# The customer page's job list; loaded into the customers module's page. #}
<section id="customer-jobs" class="card bg-base-100 shadow-sm mt-4" aria-labelledby="customer-jobs-heading">
<div class="card-body">
<div class="flex flex-wrap items-center justify-between gap-2">
<h2 id="customer-jobs-heading" class="card-title">{% translate "Customer jobs" %}</h2>
{% if can_edit %}<a href="{% url 'jobs:create' %}?customer={{ customer.id }}" class="btn btn-sm">{% translate "New job" %}</a>{% endif %}
</div>
{% if jobs %}
<ul class="divide-y divide-base-300">
{% for j in jobs %}
<li class="py-2 flex flex-wrap items-center justify-between gap-2">
<span class="min-w-0"><span class="text-sm">{{ j.number }}</span> <a class="link break-words" href="{% url 'jobs:detail' j.id %}">{{ j.name }}</a></span>
<span class="flex flex-wrap gap-1">
{% include "jobs/partials/status_badge.html" with status=j.status %}
{% if j.is_late %}{% include "jobs/partials/late_badge.html" %}{% endif %}
</span>
</li>
{% endfor %}
</ul>
{% else %}
<p>{% translate "The customer has no jobs yet." %}</p>
{% endif %}
</div>
</section>
@@ -0,0 +1,16 @@
{# Customer picker: search, choose a result (radio buttons named "customer") or add one by name. #}
<fieldset id="customer-picker" class="fieldset"
{% if form.customer.errors %}aria-describedby="customer-picker-error"{% endif %}>
<legend class="fieldset-legend text-sm">
{% translate "Customer" %} <span aria-hidden="true">*</span><span class="sr-only">{% translate "(required)" %}</span>
</legend>
{% include "jobs/partials/customer_search_input.html" %}
<div id="customer-results"
hx-get="{% url 'jobs:customer_fields' %}" hx-trigger="change[event.target.name === 'customer']"
hx-target="#customer-fields" hx-include="[name='customer']:checked">
{% include "jobs/partials/customer_results.html" with term="" results=None %}
</div>
{% if form.customer.errors %}
<p class="text-error text-sm" id="customer-picker-error">{% for error in form.customer.errors %}{{ error }} {% endfor %}</p>
{% endif %}
</fieldset>
@@ -0,0 +1,45 @@
{# Results of the customer search. The selected customer always stays first and checked. #}
{% if term %}
<p class="sr-only" role="status">{% blocktranslate count counter=results|length %}{{ counter }} customer found{% plural %}{{ counter }} customers found{% endblocktranslate %}</p>
{% endif %}
{% if selected_customer or results %}
<ul class="space-y-1 mt-1" aria-label="{% translate 'Customers' %}">
{% if selected_customer %}
<li><label class="label cursor-pointer justify-start gap-3 text-base-content whitespace-normal">
<input type="radio" class="radio" name="customer" value="{{ selected_customer.id }}" checked{% if oob %} data-autofocus{% endif %}>
<span>{{ selected_customer.name }}{% if selected_customer.business_id %} <span class="text-sm">({{ selected_customer.business_id }})</span>{% endif %}</span>
</label></li>
{% endif %}
{% for c in results %}
<li><label class="label cursor-pointer justify-start gap-3 text-base-content whitespace-normal">
<input type="radio" class="radio" name="customer" value="{{ c.id }}">
<span>{{ c.name }}{% if c.business_id %} <span class="text-sm">({{ c.business_id }})</span>{% endif %}</span>
</label></li>
{% endfor %}
</ul>
{% elif term %}
<p class="text-sm mt-1">{% translate "No customers found." %}</p>
{% else %}
<p class="text-sm mt-1">{% translate "Type to search. If the customer is not found, you can add it by name." %}</p>
{% endif %}
{% if term and can_add_customer %}
<div class="flex flex-wrap items-end gap-2 mt-2 p-2 rounded-box border border-base-300">
<fieldset>
<legend class="text-sm">{% blocktranslate %}Add “{{ term }}” as a new customer{% endblocktranslate %}</legend>
<div class="flex flex-wrap gap-x-4">
<label class="label cursor-pointer gap-2 text-base-content"><input type="radio" class="radio radio-sm" name="new_customer_type" value="company" checked> {% translate "Company" %}</label>
<label class="label cursor-pointer gap-2 text-base-content"><input type="radio" class="radio radio-sm" name="new_customer_type" value="consumer"> {% translate "Consumer" %}</label>
</div>
</fieldset>
<button type="button" class="btn btn-sm"
hx-post="{% url 'jobs:customer_add' %}" hx-target="#customer-results"
hx-include="#customer-search, [name='new_customer_type']:checked, [name='customer']:checked">
{% translate "Add customer" %}</button>
</div>
{% endif %}
{% if add_error %}<p class="text-error text-sm mt-1" role="alert">{{ add_error }}</p>{% endif %}
{% if oob %}
{# A customer was just added: clear the search and empty the contact and billing unit choices. #}
{% include "jobs/partials/customer_search_input.html" %}
<div id="customer-fields" hx-swap-oob="true">{% include "jobs/partials/customer_fields.html" %}</div>
{% endif %}
@@ -0,0 +1,8 @@
<div id="customer-search-field"{% if oob %} hx-swap-oob="true"{% endif %}>
<label class="text-sm" for="customer-search">{% translate "Search customer by name or business ID" %}</label>
<input type="search" id="customer-search" name="customer_q" class="input w-full" autocomplete="off"
{% if form.customer.errors %}aria-invalid="true" aria-describedby="customer-picker-error"{% endif %}
hx-get="{% url 'jobs:customer_search' %}" hx-trigger="input changed delay:300ms, search"
hx-target="#customer-results" hx-include="this, [name='customer']:checked" hx-sync="this:replace"
hx-on:keydown="if (event.key === 'Enter') { event.preventDefault(); htmx.trigger(this, 'search'); }">
</div>
@@ -0,0 +1,24 @@
{% load jobs_tags %}
<section id="history-section" class="card bg-base-100 shadow-sm" aria-labelledby="history-heading"{% if oob %} hx-swap-oob="true"{% endif %}>
<div class="card-body">
<h2 id="history-heading" class="card-title">{% translate "Change history" %}</h2>
{% if changes %}
<ol class="divide-y divide-base-300">
{% for c in changes %}
<li class="py-2">
<p class="text-sm"><time datetime="{{ c.created_at|date:'c' }}">{{ c.created_at|date:"SHORT_DATETIME_FORMAT" }}</time> · {{ c.user_name }}</p>
<p class="font-semibold">{{ c.field|change_field_label }}</p>
<div class="grid gap-x-4 sm:grid-cols-[max-content_1fr] text-sm">
<span>{% translate "Before" %}:</span>
<span class="whitespace-pre-line break-words">{% change_value c.field c.old_value as old %}{{ old|default:"–" }}</span>
<span>{% translate "After" %}:</span>
<span class="whitespace-pre-line break-words">{% change_value c.field c.new_value as new %}{{ new|default:"–" }}</span>
</div>
</li>
{% endfor %}
</ol>
{% else %}
<p>{% translate "No changes since the job was created." %}</p>
{% endif %}
</div>
</section>
@@ -0,0 +1,70 @@
<p class="sr-only" role="status">{% blocktranslate count counter=page.paginator.count %}{{ counter }} job found{% plural %}{{ counter }} jobs found{% endblocktranslate %}</p>
{% if page.object_list %}
{# Wide screens: a table. Narrow screens: one card per job (no horizontal scrolling). #}
<div class="hidden md:block card bg-base-100 shadow-sm overflow-x-auto">
<table class="table">
<caption class="sr-only">{% translate "Customer jobs" %}</caption>
<thead>
<tr>
<th scope="col">{% translate "Number" %}</th>
<th scope="col">{% translate "Name" %}</th>
<th scope="col">{% translate "Customer" %}</th>
<th scope="col">{% translate "Status" %}</th>
<th scope="col">{% translate "Priority" %}</th>
<th scope="col">{% translate "Due date" %}</th>
<th scope="col">{% translate "Responsible person" %}</th>
</tr>
</thead>
<tbody>
{% for j in page.object_list %}
<tr>
<td class="whitespace-nowrap">{{ j.number }}</td>
<td>
<a class="link" href="{% url 'jobs:detail' j.id %}">{{ j.name }}</a>
{% if j.service_units %}<p class="text-sm">{{ j.service_units|join:", " }}</p>{% endif %}
</td>
<td>{{ j.customer.name }}</td>
<td>{% include "jobs/partials/status_badge.html" with status=j.status %}</td>
<td>{% include "jobs/partials/priority_badge.html" with priority=j.priority %}</td>
<td class="whitespace-nowrap">
{{ j.due_on|date:"SHORT_DATE_FORMAT"|default:"–" }}
{% if j.is_late %}<br>{% include "jobs/partials/late_badge.html" %}{% endif %}
</td>
<td>{{ j.responsible.name|default:"–" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<ul class="md:hidden space-y-2">
{% for j in page.object_list %}
<li class="card bg-base-100 shadow-sm">
<div class="card-body p-4 gap-1">
<p class="text-sm">{{ j.number }} · {{ j.customer.name }}</p>
<a class="link font-semibold break-words" href="{% url 'jobs:detail' j.id %}">{{ j.name }}</a>
<div class="flex flex-wrap gap-1">
{% include "jobs/partials/status_badge.html" with status=j.status %}
{% include "jobs/partials/priority_badge.html" with priority=j.priority %}
{% if j.is_late %}{% include "jobs/partials/late_badge.html" %}{% endif %}
</div>
{% if j.due_on %}<p class="text-sm">{% translate "Due date" %}: {{ j.due_on|date:"SHORT_DATE_FORMAT" }}</p>{% endif %}
</div>
</li>
{% endfor %}
</ul>
{% else %}
<div class="card bg-base-100 shadow-sm"><div class="card-body"><p>{% translate "No jobs match the filters." %}</p></div></div>
{% endif %}
{% if page.paginator.num_pages > 1 %}
<nav aria-label="{% translate 'Pages' %}" class="join mt-4">
{% if page.has_previous %}
<a class="join-item btn" href="?{{ query }}{% if query %}&amp;{% endif %}page={{ page.previous_page_number }}"
hx-get="?{{ query }}{% if query %}&amp;{% endif %}page={{ page.previous_page_number }}" hx-target="#job-table" hx-push-url="true">{% translate "Previous" %}</a>
{% endif %}
<span class="join-item btn btn-disabled" aria-current="page">{% blocktranslate with n=page.number total=page.paginator.num_pages %}Page {{ n }} / {{ total }}{% endblocktranslate %}</span>
{% if page.has_next %}
<a class="join-item btn" href="?{{ query }}{% if query %}&amp;{% endif %}page={{ page.next_page_number }}"
hx-get="?{{ query }}{% if query %}&amp;{% endif %}page={{ page.next_page_number }}" hx-target="#job-table" hx-push-url="true">{% translate "Next" %}</a>
{% endif %}
</nav>
{% endif %}
@@ -0,0 +1 @@
<span class="badge badge-error badge-soft gap-1 whitespace-nowrap"><svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path fill-rule="evenodd" d="M10 18a8 8 0 1 0 0-16 8 8 0 0 0 0 16zm.75-12.5a.75.75 0 0 0-1.5 0V10c0 .2.08.39.22.53l2.5 2.5a.75.75 0 1 0 1.06-1.06l-2.28-2.28V5.5z" clip-rule="evenodd"/></svg>{% translate "Late" %}</span>
@@ -0,0 +1,17 @@
{% if link_id %}
{% url 'jobs:link_edit' job.id link_id as action_url %}
{% else %}
{% url 'jobs:link_create' job.id as action_url %}
{% endif %}
<h2 id="item-dialog-title" class="text-lg font-bold">
{% if link_id %}{% translate "Edit link" %}{% else %}{% translate "Add link" %}{% endif %}
</h2>
<form method="post" action="{{ action_url }}" novalidate class="space-y-1 mt-2"
hx-post="{{ action_url }}" hx-target="#item-dialog-body">
{% csrf_token %}
{{ form }}
<div class="modal-action">
<button type="button" class="btn" onclick="this.closest('dialog') ? this.closest('dialog').close() : history.back()">{% translate "Cancel" %}</button>
<button type="submit" class="btn btn-primary">{% translate "Save" %}</button>
</div>
</form>
@@ -0,0 +1,38 @@
<section id="links-section" class="card bg-base-100 shadow-sm" aria-labelledby="links-heading">
<div class="card-body">
<div class="flex flex-wrap items-center justify-between gap-2">
<h2 id="links-heading" class="card-title" tabindex="-1">{% translate "Links" %}</h2>
{% if can_edit %}
<a href="{% url 'jobs:link_create' job.id %}" class="btn btn-sm"
hx-get="{% url 'jobs:link_create' job.id %}" hx-target="#item-dialog-body"
hx-on::after-request="document.getElementById('item-dialog').showModal()">{% translate "Add link" %}</a>
{% endif %}
</div>
{% if links %}
<ul class="divide-y divide-base-300">
{% for link in links %}{% with id_str=link.id|stringformat:"s" %}
<li class="py-2 flex flex-wrap justify-between gap-2">
<a class="link break-all" href="{{ link.url }}" target="_blank" rel="noopener noreferrer">{{ link.title }}<span class="sr-only"> {% translate "(opens in a new tab)" %}</span></a>
{% if can_edit %}
<div class="flex gap-1 items-start">
<a class="btn btn-sm btn-ghost" href="{% url 'jobs:link_edit' job.id link.id %}"
hx-get="{% url 'jobs:link_edit' job.id link.id %}" hx-target="#item-dialog-body"
hx-on::after-request="document.getElementById('item-dialog').showModal()">
{% translate "Edit" %}<span class="sr-only">: {{ link.title }}</span></a>
<button type="button" class="btn btn-sm btn-ghost" onclick="document.getElementById('confirm-delete-link-{{ link.id }}').showModal()">
{% translate "Delete" %}<span class="sr-only">: {{ link.title }}</span></button>
{% url 'jobs:link_delete' job.id link.id as delete_url %}
{% blocktranslate with title=link.title asvar dialog_title %}Delete link {{ title }}?{% endblocktranslate %}
{% translate "The link is removed from the job. The file itself is not touched." as dialog_body %}
{% translate "Delete" as dialog_confirm %}
{% with dialog_id="confirm-delete-link-"|add:id_str %}{% include "components/confirm_dialog.html" with id=dialog_id title=dialog_title body=dialog_body action_url=delete_url confirm_label=dialog_confirm hx_target="#links-section" %}{% endwith %}
</div>
{% endif %}
</li>
{% endwith %}{% endfor %}
</ul>
{% else %}
<p>{% translate "No links yet." %}</p>
{% endif %}
</div>
</section>
@@ -0,0 +1 @@
{% load jobs_tags %}<span class="badge {{ priority|priority_class }} gap-1 whitespace-nowrap"><svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><path d="M4 2a1 1 0 0 1 1 1v.5h9.4a1 1 0 0 1 .8 1.6L13.3 8l1.9 2.9a1 1 0 0 1-.8 1.6H5V18a1 1 0 1 1-2 0V3a1 1 0 0 1 1-1z"/></svg><span class="sr-only">{% translate "Priority" %}: </span>{{ priority|priority_label }}</span>
@@ -0,0 +1 @@
{% load jobs_tags %}<span class="badge badge-outline gap-1 whitespace-nowrap"><svg xmlns="http://www.w3.org/2000/svg" class="h-3 w-3" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true"><circle cx="10" cy="10" r="5"/></svg><span class="sr-only">{% translate "Status" %}: </span>{{ status|status_label }}</span>
@@ -0,0 +1,43 @@
{# Tag editor: choose from the list or type a new tag; each tag becomes a hidden input "tags". #}
{{ form.tags.value|default_if_none:""|json_script:"tags-initial" }}
{% translate "Tag added" as added_label %}{% translate "Tag removed" as removed_label %}{% translate "Remove tag" as remove_label %}
<div class="fieldset" data-added="{{ added_label }}" data-removed="{{ removed_label }}" data-remove="{{ remove_label }}"
x-data="{
tags: JSON.parse(document.getElementById('tags-initial').textContent) || [],
draft: '',
add() {
const added = [];
this.draft.split(',').map(t => t.trim().replace(/\s+/g, ' ')).filter(Boolean).forEach(t => {
if (!this.tags.some(x => x.toLowerCase() === t.toLowerCase())) { this.tags.push(t); added.push(t); }
});
this.draft = '';
if (added.length) window.notify(this.$root.dataset.added + ': ' + added.join(', '));
},
remove(i) {
const [t] = this.tags.splice(i, 1);
window.notify(this.$root.dataset.removed + ': ' + t);
this.$refs.input.focus();
}
}">
<label class="fieldset-legend text-sm" for="tag-input">{% translate "Tags" %}</label>
<ul class="flex flex-wrap gap-1" aria-label="{% translate 'Chosen tags' %}" x-show="tags.length" x-cloak>
<template x-for="(tag, i) in tags" :key="tag">
<li class="badge badge-outline gap-1 h-auto py-1">
<span x-text="tag"></span>
<button type="button" class="btn btn-ghost btn-xs min-h-6 min-w-6 px-1" @click="remove(i)"
:aria-label="$root.dataset.remove + ' ' + tag"><span aria-hidden="true">✕</span></button>
<input type="hidden" name="tags" :value="tag">
</li>
</template>
</ul>
<div class="join w-full">
<input id="tag-input" x-ref="input" type="text" class="input join-item w-full" list="tag-options"
maxlength="50" autocomplete="off" x-model="draft" @keydown.enter.prevent="add()"
aria-describedby="tag-input_helptext{% if form.tags.errors %} tag-input_error{% endif %}"
{% if form.tags.errors %}aria-invalid="true"{% endif %}>
<button type="button" class="btn join-item" @click="add()">{% translate "Add tag" %}</button>
</div>
<datalist id="tag-options">{% for t in tag_options %}<option value="{{ t }}"></option>{% endfor %}</datalist>
<p class="label text-sm whitespace-normal" id="tag-input_helptext">{% translate "Choose from the list or type a new tag and press Enter." %}</p>
{% if form.tags.errors %}<p class="text-error text-sm" id="tag-input_error">{% for e in form.tags.errors %}{{ e }} {% endfor %}</p>{% endif %}
</div>