70 lines
3.3 KiB
HTML
70 lines
3.3 KiB
HTML
<!--
|
|
Project Search Results Partial
|
|
Rendered by /api/projects/search endpoint for HTMX dropdown.
|
|
|
|
Variables:
|
|
- projects: List of project dicts with id, project_number, client_name, name, display, status
|
|
- query: The search query string
|
|
- show_create: Boolean - show "Create new project" option when no matches
|
|
-->
|
|
|
|
{% set picker_id = request.query_params.get('picker_id', '') %}
|
|
|
|
{% if projects %}
|
|
{% for project in projects %}
|
|
<div class="px-4 py-3 hover:bg-gray-100 dark:hover:bg-gray-700 cursor-pointer border-b border-gray-100 dark:border-gray-700 last:border-0 transition-colors"
|
|
onclick="selectProject('{{ project.id }}', '{{ project.display|e }}', '{{ picker_id }}')">
|
|
<div class="flex items-start justify-between gap-2">
|
|
<div class="flex-1 min-w-0">
|
|
<div class="font-medium text-gray-900 dark:text-white truncate">
|
|
{% if project.project_number %}
|
|
<span class="text-seismo-orange font-semibold">{{ project.project_number }}</span>
|
|
{% if project.client_name or project.name %}
|
|
<span class="text-gray-400 mx-1">-</span>
|
|
{% endif %}
|
|
{% endif %}
|
|
{% if project.client_name %}
|
|
<span>{{ project.client_name }}</span>
|
|
{% endif %}
|
|
</div>
|
|
{% if project.name %}
|
|
<div class="text-sm text-gray-500 dark:text-gray-400 truncate">
|
|
{{ project.name }}
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
{% if project.status == 'completed' %}
|
|
<span class="flex-shrink-0 text-xs px-2 py-0.5 bg-gray-100 dark:bg-gray-600 text-gray-600 dark:text-gray-300 rounded">
|
|
Completed
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
{% if show_create %}
|
|
<div class="px-4 py-3 hover:bg-green-50 dark:hover:bg-green-900/30 cursor-pointer border-t border-gray-200 dark:border-gray-600 transition-colors"
|
|
onclick="openCreateProjectModal('{{ query|e }}', '{{ picker_id }}')">
|
|
<div class="flex items-center gap-2 text-green-600 dark:text-green-400">
|
|
<svg class="w-5 h-5 flex-shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"></path>
|
|
</svg>
|
|
<span class="font-medium">Create new project "{{ query }}"</span>
|
|
</div>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400 mt-1 ml-7">
|
|
No matching projects found. Click to create a new one.
|
|
</p>
|
|
</div>
|
|
{% endif %}
|
|
|
|
{% if not projects and not show_create %}
|
|
<div class="px-4 py-6 text-center text-gray-500 dark:text-gray-400">
|
|
<svg class="w-8 h-8 mx-auto mb-2 text-gray-300 dark:text-gray-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"></path>
|
|
</svg>
|
|
<p class="text-sm">Start typing to search projects...</p>
|
|
<p class="text-xs mt-1">Search by project number, client name, or project name</p>
|
|
</div>
|
|
{% endif %}
|