321 lines
11 KiB
HTML
321 lines
11 KiB
HTML
{% extends "layouts/base.html" %}
|
|
{% load i18n %}
|
|
|
|
{% block title %}{% if source %}{% trans "Edit Source" %}{% else %}{% trans "Create Source" %}{% endif %} - PX360{% endblock %}
|
|
|
|
{% block extra_css %}
|
|
<style>
|
|
:root {
|
|
--hh-navy: #005696;
|
|
--hh-blue: #007bbd;
|
|
--hh-light: #eef6fb;
|
|
--hh-slate: #64748b;
|
|
--hh-success: #10b981;
|
|
--hh-warning: #f59e0b;
|
|
}
|
|
|
|
.form-card {
|
|
background: white;
|
|
border-radius: 1rem;
|
|
border: 1px solid #e2e8f0;
|
|
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
|
|
transition: all 0.3s ease;
|
|
}
|
|
|
|
.card-header {
|
|
background: linear-gradient(135deg, var(--hh-light), #e0f2fe);
|
|
padding: 1.25rem 1.75rem;
|
|
border-bottom: 1px solid #bae6fd;
|
|
border-radius: 1rem 1rem 0 0;
|
|
}
|
|
|
|
.form-group {
|
|
margin-bottom: 1.5rem;
|
|
}
|
|
|
|
.form-label {
|
|
display: block;
|
|
margin-bottom: 0.5rem;
|
|
font-weight: 600;
|
|
color: var(--hh-navy);
|
|
font-size: 0.9rem;
|
|
}
|
|
|
|
.form-input {
|
|
width: 100%;
|
|
padding: 0.75rem 1rem;
|
|
border: 2px solid #cbd5e1;
|
|
border-radius: 0.75rem;
|
|
font-size: 0.95rem;
|
|
transition: all 0.2s;
|
|
background: white;
|
|
color: #1e293b;
|
|
font-family: 'Inter', sans-serif;
|
|
}
|
|
|
|
.form-input:focus {
|
|
outline: none;
|
|
border-color: var(--hh-blue);
|
|
box-shadow: 0 0 0 4px rgba(0, 123, 189, 0.1);
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.form-input[readonly] {
|
|
background: #f1f5f9;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
textarea.form-input {
|
|
resize: vertical;
|
|
min-height: 120px;
|
|
}
|
|
|
|
.btn-primary {
|
|
background: linear-gradient(135deg, var(--hh-navy) 0%, var(--hh-blue) 100%);
|
|
color: white;
|
|
padding: 0.75rem 1.5rem;
|
|
border-radius: 0.75rem;
|
|
font-weight: 600;
|
|
border: none;
|
|
cursor: pointer;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.btn-primary:hover {
|
|
transform: translateY(-2px);
|
|
box-shadow: 0 8px 16px rgba(0, 86, 150, 0.3);
|
|
}
|
|
|
|
.btn-secondary {
|
|
background: white;
|
|
color: #475569;
|
|
padding: 0.75rem 1.5rem;
|
|
border-radius: 0.75rem;
|
|
font-weight: 600;
|
|
border: 2px solid #e2e8f0;
|
|
cursor: pointer;
|
|
transition: all 0.3s ease;
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 0.5rem;
|
|
text-decoration: none;
|
|
}
|
|
|
|
.btn-secondary:hover {
|
|
background: #f1f5f9;
|
|
border-color: #cbd5e1;
|
|
transform: translateY(-1px);
|
|
}
|
|
|
|
.checkbox-wrapper {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 0.75rem;
|
|
padding: 1rem;
|
|
background: var(--hh-light);
|
|
border-radius: 0.75rem;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
.checkbox-wrapper:hover {
|
|
background: #e0f2fe;
|
|
}
|
|
|
|
.checkbox-wrapper input[type="checkbox"] {
|
|
width: 1.25rem;
|
|
height: 1.25rem;
|
|
cursor: pointer;
|
|
}
|
|
|
|
@keyframes fadeIn {
|
|
from { opacity: 0; transform: translateY(20px); }
|
|
to { opacity: 1; transform: translateY(0); }
|
|
}
|
|
|
|
.animate-in {
|
|
animation: fadeIn 0.5s ease-out forwards;
|
|
}
|
|
</style>
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
<div class="px-4 py-6">
|
|
<!-- Breadcrumb -->
|
|
<nav class="mb-4 animate-in">
|
|
<ol class="flex items-center gap-2 text-sm text-slate">
|
|
<li><a href="{% url 'px_sources:source_list' %}" class="text-blue hover:text-navy font-medium">{% trans "PX Sources" %}</a></li>
|
|
<li><i data-lucide="chevron-right" class="w-4 h-4 text-slate"></i></li>
|
|
<li class="text-navy font-semibold">
|
|
{% if source %}{% trans "Edit Source" %}{% else %}{% trans "Create Source" %}{% endif %}
|
|
</li>
|
|
</ol>
|
|
</nav>
|
|
|
|
<!-- Page Header -->
|
|
<div class="flex flex-wrap justify-between items-center gap-4 mb-6 animate-in">
|
|
<div>
|
|
<h1 class="text-2xl font-bold text-navy flex items-center gap-3">
|
|
<div class="w-10 h-10 bg-blue/10 rounded-xl flex items-center justify-center">
|
|
<i data-lucide="{% if source %}edit{% else %}plus-circle{% endif %}" class="w-5 h-5 text-blue"></i>
|
|
</div>
|
|
{% if source %}{% trans "Edit Source" %}{% else %}{% trans "Create Source" %}{% endif %}
|
|
</h1>
|
|
{% if source %}
|
|
<p class="text-slate mt-1">{{ source.name_en }} <span class="text-slate-400">({{ source.code }})</span></p>
|
|
{% endif %}
|
|
</div>
|
|
<a href="{% url 'px_sources:source_list' %}"
|
|
class="btn-secondary">
|
|
<i data-lucide="arrow-left" class="w-4 h-4"></i>
|
|
{% trans "Back to List" %}
|
|
</a>
|
|
</div>
|
|
|
|
<!-- Form Card -->
|
|
<div class="form-card max-w-4xl animate-in">
|
|
<div class="card-header">
|
|
<h2 class="text-lg font-bold text-navy flex items-center gap-2 m-0">
|
|
<i data-lucide="file-text" class="w-5 h-5"></i>
|
|
{% trans "Source Information" %}
|
|
</h2>
|
|
</div>
|
|
<div class="p-6">
|
|
<form method="post">
|
|
{% csrf_token %}
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-5 mb-5">
|
|
<div class="md:col-span-1">
|
|
<label for="code" class="form-label">
|
|
{% trans "Source Code" %}
|
|
</label>
|
|
<input type="text" id="code" name="code"
|
|
value="{{ source.code|default:'' }}"
|
|
placeholder="{% trans 'Auto-generated' %}"
|
|
class="form-input"
|
|
{% if source %}readonly{% endif %}>
|
|
{% if not source %}
|
|
<p class="text-xs text-slate mt-1">{% trans "Auto-generated from name if left blank" %}</p>
|
|
{% endif %}
|
|
</div>
|
|
<div class="md:col-span-2">
|
|
<label for="name_en" class="form-label">
|
|
{% trans "Name (English)" %} <span class="text-red-500">*</span>
|
|
</label>
|
|
<input type="text" id="name_en" name="name_en"
|
|
value="{{ source.name_en|default:'' }}" required
|
|
placeholder="{% trans 'e.g., Patient Portal' %}"
|
|
class="form-input">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-5 mb-5">
|
|
<div>
|
|
<label for="name_ar" class="form-label">
|
|
{% trans "Name (Arabic)" %}
|
|
</label>
|
|
<input type="text" id="name_ar" name="name_ar"
|
|
value="{{ source.name_ar|default:'' }}"
|
|
placeholder="{% trans 'e.g., بوابة المريض' %}"
|
|
dir="rtl"
|
|
class="form-input">
|
|
</div>
|
|
<div>
|
|
<label for="source_type" class="form-label">
|
|
{% trans "Source Type" %}
|
|
</label>
|
|
<select id="source_type" name="source_type" class="form-input">
|
|
{% for value, label in source_types %}
|
|
<option value="{{ value }}" {% if source.source_type == value %}selected{% endif %}>
|
|
{{ label }}
|
|
</option>
|
|
{% endfor %}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="description" class="form-label">
|
|
{% trans "Description" %}
|
|
</label>
|
|
<textarea id="description" name="description" rows="4"
|
|
placeholder="{% trans 'Enter source description...' %}"
|
|
class="form-input">{{ source.description|default:'' }}</textarea>
|
|
</div>
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-5 mb-5">
|
|
<div>
|
|
<label for="contact_email" class="form-label">
|
|
{% trans "Contact Email" %}
|
|
</label>
|
|
<input type="email" id="contact_email" name="contact_email"
|
|
value="{{ source.contact_email|default:'' }}"
|
|
placeholder="contact@example.com"
|
|
class="form-input">
|
|
</div>
|
|
<div>
|
|
<label for="contact_phone" class="form-label">
|
|
{% trans "Contact Phone" %}
|
|
</label>
|
|
<input type="text" id="contact_phone" name="contact_phone"
|
|
value="{{ source.contact_phone|default:'' }}"
|
|
placeholder="+966 XX XXX XXXX"
|
|
class="form-input">
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label class="checkbox-wrapper">
|
|
<input type="checkbox" id="is_active" name="is_active" value="true"
|
|
{% if source.is_active|default_if_none:True %}checked{% endif %}>
|
|
<div>
|
|
<span class="text-navy font-semibold">{% trans "Active" %}</span>
|
|
<p class="text-slate text-sm m-0">{% trans "Source is available for selection" %}</p>
|
|
</div>
|
|
</label>
|
|
</div>
|
|
|
|
<div class="mt-8 pt-6 border-t border-slate-200 flex gap-3">
|
|
<button type="submit" class="btn-primary">
|
|
<i data-lucide="save" class="w-4 h-4"></i>
|
|
{% if source %}{% trans "Save Changes" %}{% else %}{% trans "Create Source" %}{% endif %}
|
|
</button>
|
|
<a href="{% url 'px_sources:source_list' %}" class="btn-secondary">
|
|
{% trans "Cancel" %}
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
lucide.createIcons();
|
|
|
|
// Auto-generate code preview from name
|
|
const nameEnInput = document.getElementById('name_en');
|
|
const codeInput = document.getElementById('code');
|
|
|
|
if (nameEnInput && codeInput && !codeInput.value) {
|
|
nameEnInput.addEventListener('blur', function() {
|
|
const name = this.value.trim().toUpperCase();
|
|
if (name && !codeInput.value) {
|
|
const words = name.split(' ');
|
|
let code;
|
|
if (words.length >= 2) {
|
|
code = words.slice(0, 3).map(w => w.substring(0, 4)).join('-');
|
|
} else {
|
|
code = name.substring(0, 10).replace(' ', '-');
|
|
}
|
|
codeInput.value = code;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
{% endblock %}
|