05/19 Implement Changing QR code name when editing

This commit is contained in:
2026-05-19 16:18:31 -04:00
parent 0a85fa8fe3
commit f81e3cea7f
+159 -92
View File
@@ -4,10 +4,7 @@
{% block extra_head %} {% block extra_head %}
<style> <style>
/* Photo Verification Toggle */ /* Photo Verification Toggle */
#photo_verification_enabled:checked+.toggle-slider { #photo_verification_enabled:checked + .toggle-slider { background: var(--success-color, #10b981); }
background: var(--success-color, #10b981);
}
.toggle-slider::before { .toggle-slider::before {
content: ""; content: "";
position: absolute; position: absolute;
@@ -20,10 +17,7 @@
transition: 0.3s; transition: 0.3s;
box-shadow: 0 1px 3px rgba(0,0,0,0.2); box-shadow: 0 1px 3px rgba(0,0,0,0.2);
} }
#photo_verification_enabled:checked + .toggle-slider::before { transform: translateX(24px); }
#photo_verification_enabled:checked+.toggle-slider::before {
transform: translateX(24px);
}
</style> </style>
<style> <style>
:root { :root {
@@ -602,17 +596,9 @@
} }
@keyframes pulse { @keyframes pulse {
0% { 0% { transform: scale(1); }
transform: scale(1); 50% { transform: scale(1.05); }
} 100% { transform: scale(1); }
50% {
transform: scale(1.05);
}
100% {
transform: scale(1);
}
} }
/* Toast notification styles */ /* Toast notification styles */
@@ -661,15 +647,27 @@
<div class="form-group"> <div class="form-group">
<label for="name"> <label for="name">
<i class="fas fa-tag"></i> <i class="fas fa-tag"></i>
QR Code Name <span style="color: var(--error-color)">*</span> QR Code Name
<span style="color: var(--secondary-color); font-size: 0.75rem; font-weight: 400; margin-left: 0.4rem;">
<i class="fas fa-lock"></i> Cannot be changed
</span>
</label> </label>
<input type="text" id="name" name="name" required value="{{ qr_code.name }}" <input
data-original="{{ qr_code.name }}" placeholder="e.g., Main Office Entrance, Conference Room A" type="text"
maxlength="100" /> id="name"
<small class="form-help">A unique name to identify this QR code</small> name="name"
<div class="character-counter"> required
<span id="nameCounter">{{ qr_code.name|length }}/100</span> value="{{ qr_code.name }}"
</div> data-original="{{ qr_code.name }}"
placeholder="e.g., Main Office Entrance, Conference Room A"
maxlength="100"
readonly
style="background: var(--gray-100, #f1f5f9); cursor: not-allowed; color: var(--gray-700, #334155);"
/>
<small class="form-help">
<i class="fas fa-info-circle"></i>
QR code name cannot be changed after creation as it is linked to the QR URL.
</small>
</div> </div>
<!-- ===== ADDED: QR Code Type selector ===== --> <!-- ===== ADDED: QR Code Type selector ===== -->
@@ -680,10 +678,8 @@
<span style="color: var(--error-color)">*</span> <span style="color: var(--error-color)">*</span>
</label> </label>
<select id="qr_type" name="qr_type" class="form-control" onchange="toggleQRTypeSection()"> <select id="qr_type" name="qr_type" class="form-control" onchange="toggleQRTypeSection()">
<option value="standard" {% if qr_code.qr_type !='dynamic' %}selected{% endif %}>Standard — Fixed Location <option value="standard" {% if qr_code.qr_type != 'dynamic' %}selected{% endif %}>Standard — Fixed Location</option>
</option> <option value="dynamic" {% if qr_code.qr_type == 'dynamic' %}selected{% endif %}>Dynamic — Employee Selects Location</option>
<option value="dynamic" {% if qr_code.qr_type=='dynamic' %}selected{% endif %}>Dynamic — Employee Selects
Location</option>
</select> </select>
<small class="form-help"> <small class="form-help">
<strong>Standard:</strong> employee checks in at one fixed location.<br> <strong>Standard:</strong> employee checks in at one fixed location.<br>
@@ -699,15 +695,22 @@
<i class="fas fa-map-marker-alt"></i> <i class="fas fa-map-marker-alt"></i>
Location Name <span style="color: var(--error-color)">*</span> Location Name <span style="color: var(--error-color)">*</span>
</label> </label>
<input type="text" id="location" name="location" {% if qr_code.qr_type !='dynamic' %}required{% endif %} <input
type="text"
id="location"
name="location"
{% if qr_code.qr_type != 'dynamic' %}required{% endif %}
value="{{ qr_code.location if qr_code.qr_type != 'dynamic' else '' }}" value="{{ qr_code.location if qr_code.qr_type != 'dynamic' else '' }}"
data-original="{{ qr_code.location }}" placeholder="e.g., Corporate Headquarters, Branch Office" data-original="{{ qr_code.location }}"
maxlength="100" /> placeholder="e.g., Corporate Headquarters, Branch Office"
<small class="form-help">The name of the physical location where this QR code will be maxlength="100"
used</small> />
<small class="form-help"
>The name of the physical location where this QR code will be
used</small
>
<div class="character-counter"> <div class="character-counter">
<span id="locationCounter">{{ qr_code.location|length if qr_code.qr_type != 'dynamic' else '0' <span id="locationCounter">{{ qr_code.location|length if qr_code.qr_type != 'dynamic' else '0' }}/100</span>
}}/100</span>
</div> </div>
</div> </div>
</div><!-- end standardLocationNameGroup --> </div><!-- end standardLocationNameGroup -->
@@ -717,8 +720,7 @@
<i class="fas fa-folder"></i> <i class="fas fa-folder"></i>
Project (Optional) Project (Optional)
</label> </label>
<select id="project_id" name="project_id" class="form-select" <select id="project_id" name="project_id" class="form-select" data-original="{{ qr_code.project_id or '' }}">
data-original="{{ qr_code.project_id or '' }}">
<option value="">Select a project (Optional)</option> <option value="">Select a project (Optional)</option>
{% for project in projects %} {% for project in projects %}
<option value="{{ project.id }}" {% if qr_code.project_id == project.id %}selected{% endif %}> <option value="{{ project.id }}" {% if qr_code.project_id == project.id %}selected{% endif %}>
@@ -750,12 +752,19 @@
Complete Address Complete Address
<span style="color: var(--error-color)">*</span> <span style="color: var(--error-color)">*</span>
</label> </label>
<textarea id="location_address" name="location_address" required <textarea
id="location_address"
name="location_address"
required
data-original="{{ qr_code.location_address }}" data-original="{{ qr_code.location_address }}"
placeholder="Enter the full address including street, city, state, and ZIP code" rows="3" placeholder="Enter the full address including street, city, state, and ZIP code"
maxlength="500">{{ qr_code.location_address }}</textarea> rows="3"
<small class="form-help">Include all address details for accurate location maxlength="500"
identification</small> >{{ qr_code.location_address }}</textarea>
<small class="form-help"
>Include all address details for accurate location
identification</small
>
<div class="character-counter"> <div class="character-counter">
<span id="addressCounter">{{ qr_code.location_address|length }}/500</span> <span id="addressCounter">{{ qr_code.location_address|length }}/500</span>
</div> </div>
@@ -792,12 +801,20 @@
</div> </div>
<div class="coordinates-actions"> <div class="coordinates-actions">
<button type="button" class="btn-coordinate" id="geocodeBtn"> <button
type="button"
class="btn-coordinate"
id="geocodeBtn"
>
<i class="fas fa-search-location"></i> <i class="fas fa-search-location"></i>
{% if qr_code.has_coordinates %}Update{% else %}Get{% endif %} Coordinates {% if qr_code.has_coordinates %}Update{% else %}Get{% endif %} Coordinates
</button> </button>
<button type="button" class="btn-coordinate" id="clearCoordinatesBtn" <button
style="display: {% if qr_code.has_coordinates %}inline-flex{% else %}none{% endif %};"> type="button"
class="btn-coordinate"
id="clearCoordinatesBtn"
style="display: {% if qr_code.has_coordinates %}inline-flex{% else %}none{% endif %};"
>
<i class="fas fa-times"></i> <i class="fas fa-times"></i>
Clear Clear
</button> </button>
@@ -819,14 +836,20 @@
Event or Purpose Event or Purpose
<span style="color: var(--error-color)">*</span> <span style="color: var(--error-color)">*</span>
</label> </label>
<select id="location_event" name="location_event" required class="form-control" <select
data-original="{{ qr_code.location_event }}"> id="location_event"
name="location_event"
required
class="form-control"
data-original="{{ qr_code.location_event }}"
>
<option value="">Select Event Type</option> <option value="">Select Event Type</option>
<option value="Check In" {% if qr_code.location_event == 'Check In' %}selected{% endif %}>Check In</option> <option value="Check In" {% if qr_code.location_event == 'Check In' %}selected{% endif %}>Check In</option>
<option value="Check Out" {% if qr_code.location_event=='Check Out' %}selected{% endif %}>Check Out <option value="Check Out" {% if qr_code.location_event == 'Check Out' %}selected{% endif %}>Check Out</option>
</option>
</select> </select>
<small class="form-help">Select the event type for this QR code</small> <small class="form-help"
>Select the event type for this QR code</small
>
</div> </div>
</div> </div>
@@ -842,26 +865,21 @@
<p>Require a photo when employee check-in location is too far from the QR code</p> <p>Require a photo when employee check-in location is too far from the QR code</p>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="toggle-label" for="photo_verification_enabled" <label class="toggle-label" for="photo_verification_enabled" style="display:flex;align-items:center;gap:0.75rem;cursor:pointer;">
style="display:flex;align-items:center;gap:0.75rem;cursor:pointer;"> <div class="toggle-switch" id="photoVerifyToggle" style="position:relative;display:inline-block;width:52px;height:28px;">
<div class="toggle-switch" id="photoVerifyToggle" <input type="checkbox" id="photo_verification_enabled" name="photo_verification_enabled" value="1"
style="position:relative;display:inline-block;width:52px;height:28px;"> {% if qr_code.photo_verification_enabled != False %}checked{% endif %}
<input type="checkbox" id="photo_verification_enabled" name="photo_verification_enabled" value="1" {% if
qr_code.photo_verification_enabled !=False %}checked{% endif %}
style="opacity:0;width:0;height:0;position:absolute;"> style="opacity:0;width:0;height:0;position:absolute;">
<span class="toggle-slider" <span class="toggle-slider" style="position:absolute;cursor:pointer;inset:0;background:#cbd5e1;border-radius:28px;transition:0.3s;"></span>
style="position:absolute;cursor:pointer;inset:0;background:#cbd5e1;border-radius:28px;transition:0.3s;"></span>
</div> </div>
<span id="photoVerifyLabel" <span id="photoVerifyLabel" style="font-weight:600;font-size:0.875rem;
style="font-weight:600;font-size:0.875rem;
{% if qr_code.photo_verification_enabled != False %}color:var(--success-color,#10b981){% else %}color:var(--error-color,#ef4444){% endif %}"> {% if qr_code.photo_verification_enabled != False %}color:var(--success-color,#10b981){% else %}color:var(--error-color,#ef4444){% endif %}">
{% if qr_code.photo_verification_enabled != False %}Enabled{% else %}Disabled{% endif %} {% if qr_code.photo_verification_enabled != False %}Enabled{% else %}Disabled{% endif %}
</span> </span>
</label> </label>
<input type="hidden" name="photo_verification_enabled" id="photo_verification_hidden" <input type="hidden" name="photo_verification_enabled" id="photo_verification_hidden"
value="{% if qr_code.photo_verification_enabled != False %}1{% else %}0{% endif %}"> value="{% if qr_code.photo_verification_enabled != False %}1{% else %}0{% endif %}">
<small class="form-help">When disabled, photo verification is skipped for this QR code regardless of <small class="form-help">When disabled, photo verification is skipped for this QR code regardless of distance</small>
distance</small>
</div> </div>
</div> </div>
@@ -884,9 +902,13 @@
<select id="style_id" name="style_id" onchange="applyStylePreset()"> <select id="style_id" name="style_id" onchange="applyStylePreset()">
<option value="">Custom Style</option> <option value="">Custom Style</option>
{% for style in styles %} {% for style in styles %}
<option value="{{ style.id }}" {% if qr_code.style_id==style.id %}selected{% endif %} <option
data-fill="{{ style.fill_color }}" data-back="{{ style.back_color }}" value="{{ style.id }}"
data-box-size="{{ style.box_size }}" data-border="{{ style.border }}" {% if qr_code.style_id == style.id %}selected{% endif %}
data-fill="{{ style.fill_color }}"
data-back="{{ style.back_color }}"
data-box-size="{{ style.box_size }}"
data-border="{{ style.border }}"
data-error-correction="{{ style.error_correction }}"> data-error-correction="{{ style.error_correction }}">
{{ style.name }} {{ style.name }}
</option> </option>
@@ -903,10 +925,21 @@
QR Code Color QR Code Color
</label> </label>
<div class="color-input-group"> <div class="color-input-group">
<input type="color" id="fill_color" name="fill_color" value="{{ qr_code.fill_color or '#000000' }}" <input
onchange="updatePreview()" /> type="color"
<input type="text" id="fill_color_text" value="{{ qr_code.fill_color or '#000000' }}" id="fill_color"
pattern="^#[0-9A-Fa-f]{6}$" placeholder="#000000" onchange="syncColorInput('fill')" /> name="fill_color"
value="{{ qr_code.fill_color or '#000000' }}"
onchange="updatePreview()"
/>
<input
type="text"
id="fill_color_text"
value="{{ qr_code.fill_color or '#000000' }}"
pattern="^#[0-9A-Fa-f]{6}$"
placeholder="#000000"
onchange="syncColorInput('fill')"
/>
</div> </div>
<span class="form-help">Color of the QR code modules</span> <span class="form-help">Color of the QR code modules</span>
</div> </div>
@@ -917,10 +950,21 @@
Background Color Background Color
</label> </label>
<div class="color-input-group"> <div class="color-input-group">
<input type="color" id="back_color" name="back_color" value="{{ qr_code.back_color or '#FFFFFF' }}" <input
onchange="updatePreview()" /> type="color"
<input type="text" id="back_color_text" value="{{ qr_code.back_color or '#FFFFFF' }}" id="back_color"
pattern="^#[0-9A-Fa-f]{6}$" placeholder="#FFFFFF" onchange="syncColorInput('back')" /> name="back_color"
value="{{ qr_code.back_color or '#FFFFFF' }}"
onchange="updatePreview()"
/>
<input
type="text"
id="back_color_text"
value="{{ qr_code.back_color or '#FFFFFF' }}"
pattern="^#[0-9A-Fa-f]{6}$"
placeholder="#FFFFFF"
onchange="syncColorInput('back')"
/>
</div> </div>
<span class="form-help">Background color of the QR code</span> <span class="form-help">Background color of the QR code</span>
</div> </div>
@@ -934,8 +978,15 @@
Module Size Module Size
</label> </label>
<div class="range-input-group"> <div class="range-input-group">
<input type="range" id="box_size" name="box_size" min="5" max="20" value="{{ qr_code.box_size or 10 }}" <input
oninput="updateRangeValue('box_size'); updatePreview()" /> type="range"
id="box_size"
name="box_size"
min="5"
max="20"
value="{{ qr_code.box_size or 10 }}"
oninput="updateRangeValue('box_size'); updatePreview()"
/>
<span class="range-value" id="box_size_value">{{ qr_code.box_size or 10 }}px</span> <span class="range-value" id="box_size_value">{{ qr_code.box_size or 10 }}px</span>
</div> </div>
<span class="form-help">Size of each QR code module (affects overall size)</span> <span class="form-help">Size of each QR code module (affects overall size)</span>
@@ -947,8 +998,15 @@
Border Size Border Size
</label> </label>
<div class="range-input-group"> <div class="range-input-group">
<input type="range" id="border" name="border" min="1" max="10" value="{{ qr_code.border or 4 }}" <input
oninput="updateRangeValue('border'); updatePreview()" /> type="range"
id="border"
name="border"
min="1"
max="10"
value="{{ qr_code.border or 4 }}"
oninput="updateRangeValue('border'); updatePreview()"
/>
<span class="range-value" id="border_value">{{ qr_code.border or 4 }} modules</span> <span class="range-value" id="border_value">{{ qr_code.border or 4 }} modules</span>
</div> </div>
<span class="form-help">White border around the QR code</span> <span class="form-help">White border around the QR code</span>
@@ -964,8 +1022,7 @@
<select id="error_correction" name="error_correction" onchange="updatePreview()"> <select id="error_correction" name="error_correction" onchange="updatePreview()">
<option value="L" {% if qr_code.error_correction == 'L' %}selected{% endif %}>Low (7% recovery)</option> <option value="L" {% if qr_code.error_correction == 'L' %}selected{% endif %}>Low (7% recovery)</option>
<option value="M" {% if qr_code.error_correction == 'M' %}selected{% endif %}>Medium (15% recovery)</option> <option value="M" {% if qr_code.error_correction == 'M' %}selected{% endif %}>Medium (15% recovery)</option>
<option value="Q" {% if qr_code.error_correction=='Q' %}selected{% endif %}>Quartile (25% recovery) <option value="Q" {% if qr_code.error_correction == 'Q' %}selected{% endif %}>Quartile (25% recovery)</option>
</option>
<option value="H" {% if qr_code.error_correction == 'H' %}selected{% endif %}>High (30% recovery)</option> <option value="H" {% if qr_code.error_correction == 'H' %}selected{% endif %}>High (30% recovery)</option>
</select> </select>
<span class="form-help">Higher levels allow QR code to work even if partially damaged</span> <span class="form-help">Higher levels allow QR code to work even if partially damaged</span>
@@ -1001,12 +1058,24 @@
</div> </div>
<!-- Hidden coordinate fields for form submission --> <!-- Hidden coordinate fields for form submission -->
<input type="hidden" id="address_latitude" name="address_latitude" <input
value="{% if qr_code.has_coordinates %}{{ qr_code.address_latitude }}{% endif %}" /> type="hidden"
<input type="hidden" id="address_longitude" name="address_longitude" id="address_latitude"
value="{% if qr_code.has_coordinates %}{{ qr_code.address_longitude }}{% endif %}" /> name="address_latitude"
<input type="hidden" id="coordinate_accuracy" name="coordinate_accuracy" value="{% if qr_code.has_coordinates %}{{ qr_code.address_latitude }}{% endif %}"
value="{% if qr_code.has_coordinates %}{{ qr_code.coordinate_accuracy }}{% endif %}" /> />
<input
type="hidden"
id="address_longitude"
name="address_longitude"
value="{% if qr_code.has_coordinates %}{{ qr_code.address_longitude }}{% endif %}"
/>
<input
type="hidden"
id="coordinate_accuracy"
name="coordinate_accuracy"
value="{% if qr_code.has_coordinates %}{{ qr_code.coordinate_accuracy }}{% endif %}"
/>
<!-- Form Actions --> <!-- Form Actions -->
<div class="form-actions"> <div class="form-actions">
@@ -1091,11 +1160,9 @@
<div class="detail-row"> <div class="detail-row">
<strong>Colors:</strong> <strong>Colors:</strong>
<span> <span>
<span <span style="display: inline-block; width: 12px; height: 12px; background: {{ qr_code.fill_color or '#000000' }}; border-radius: 2px; margin-right: 4px;"></span>
style="display: inline-block; width: 12px; height: 12px; background: {{ qr_code.fill_color or '#000000' }}; border-radius: 2px; margin-right: 4px;"></span>
on on
<span <span style="display: inline-block; width: 12px; height: 12px; background: {{ qr_code.back_color or '#FFFFFF' }}; border: 1px solid #ccc; border-radius: 2px; margin-left: 4px;"></span>
style="display: inline-block; width: 12px; height: 12px; background: {{ qr_code.back_color or '#FFFFFF' }}; border: 1px solid #ccc; border-radius: 2px; margin-left: 4px;"></span>
</span> </span>
</div> </div>
</div> </div>