tasks for specific sub categories
This commit is contained in:
@@ -60,6 +60,11 @@
|
||||
<a href="{{ url_for('task_detail', task_id=task._id) }}" class="task-name-link" style="text-decoration: none; color: var(--text-primary); font-weight: 500; {% if task.status == 'completed' %}text-decoration: line-through; color: var(--text-secondary);{% endif %}">
|
||||
{{ task.name }}
|
||||
</a>
|
||||
{% if task.subcategory %}
|
||||
<span style="font-size: 0.75rem; color: #555; background: #eee; padding: 2px 6px; border-radius: 4px;">
|
||||
{{ task.subcategory }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if task.due_date %}
|
||||
<span style="font-size: 0.75rem; color: var(--text-secondary); background: var(--bg-input); padding: 2px 6px; border-radius: 4px;">
|
||||
{{ task.due_date.strftime('%d. %b %H:%M') }}
|
||||
@@ -108,6 +113,11 @@
|
||||
<a href="{{ url_for('task_detail', task_id=task._id) }}" style="text-decoration: none; color: var(--text-primary); font-weight: 500; {% if task.status == 'completed' %}text-decoration: line-through; color: var(--text-secondary);{% endif %}">
|
||||
{{ task.name }}
|
||||
</a>
|
||||
{% if task.subcategory %}
|
||||
<span style="font-size: 0.75rem; color: #555; background: #eee; padding: 2px 6px; border-radius: 4px;">
|
||||
{{ task.subcategory }}
|
||||
</span>
|
||||
{% endif %}
|
||||
{% if task.due_date %}
|
||||
<span style="font-size: 0.75rem; color: var(--text-secondary); background: var(--bg-input); padding: 2px 6px; border-radius: 4px;">
|
||||
{{ task.due_date.strftime('%d. %b %H:%M') }}
|
||||
@@ -156,13 +166,20 @@
|
||||
<input type="text" name="name" id="modalInputName" required placeholder="What needs to be done?" autocomplete="off">
|
||||
|
||||
<label>Activity</label>
|
||||
<select name="activity_id" id="modalSelectActivity">
|
||||
<select name="activity_id" id="modalSelectActivity" onchange="updateModalSubcategories()">
|
||||
<option value="">-- No Activity --</option>
|
||||
{% for act in activities %}
|
||||
<option value="{{ act._id }}">{{ act.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
|
||||
<div id="modalSubcatWrapper" style="display:none;">
|
||||
<label>Subcategory</label>
|
||||
<select name="subcategory" id="modalSelectSubcategory">
|
||||
<option value="">-- None --</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<label>Due Date</label>
|
||||
<input type="datetime-local" name="due_date">
|
||||
|
||||
@@ -184,6 +201,39 @@
|
||||
|
||||
<!-- Scripts removed dead macros -->
|
||||
<script>
|
||||
// Prepare Data for JS
|
||||
const activitiesList = [
|
||||
{% for act in activities %}
|
||||
{
|
||||
id: "{{ act._id }}",
|
||||
subcategories: {{ act.subcategories|default([])|tojson }}
|
||||
},
|
||||
{% endfor %}
|
||||
];
|
||||
|
||||
function updateModalSubcategories() {
|
||||
const actSelect = document.getElementById('modalSelectActivity');
|
||||
const subWrapper = document.getElementById('modalSubcatWrapper');
|
||||
const subSelect = document.getElementById('modalSelectSubcategory');
|
||||
|
||||
const selectedId = actSelect.value;
|
||||
const activity = activitiesList.find(a => a.id === selectedId);
|
||||
|
||||
subSelect.innerHTML = '<option value="">-- None --</option>';
|
||||
|
||||
if (activity && activity.subcategories && activity.subcategories.length > 0) {
|
||||
subWrapper.style.display = 'block';
|
||||
activity.subcategories.forEach(sub => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = sub;
|
||||
opt.innerText = sub;
|
||||
subSelect.appendChild(opt);
|
||||
});
|
||||
} else {
|
||||
subWrapper.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
function openTaskModal(activityId) {
|
||||
const modal = document.getElementById('taskModal');
|
||||
const select = document.getElementById('modalSelectActivity');
|
||||
@@ -195,6 +245,9 @@
|
||||
select.value = "";
|
||||
}
|
||||
|
||||
// Trigger subcategory update based on pre-selection
|
||||
updateModalSubcategories();
|
||||
|
||||
modal.classList.add('show');
|
||||
nameInput.focus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user