Goals working well
This commit is contained in:
@@ -189,18 +189,83 @@
|
||||
<!-- Create Activity Form -->
|
||||
<div id="newActivityForm" class="card" style="display:none; margin-top: 2rem;">
|
||||
<h3>Create New Activity Category</h3>
|
||||
<form action="{{ url_for('add_activity') }}" method="POST">
|
||||
<form action="{{ url_for('add_activity') }}" method="POST" onsubmit="prepareTasksList()">
|
||||
<label>Name</label>
|
||||
<input type="text" name="name" required placeholder="e.g. Household">
|
||||
|
||||
<label>Color</label>
|
||||
<input type="color" name="color" value="#3498db" style="width:100%; height:40px; border:none;">
|
||||
|
||||
<label>Default Tasks (comma separated)</label>
|
||||
<input type="text" name="tasks" placeholder="e.g. Laundry, Dishes, Trash">
|
||||
<label>Default Tasks (Template)</label>
|
||||
<p style="font-size: 0.8rem; color: var(--text-secondary); margin-top: -10px;">
|
||||
These tasks will be created automatically every time you start this activity.
|
||||
</p>
|
||||
|
||||
<button type="submit" class="btn">Create</button>
|
||||
<button type="button" class="btn" style="background: #7f8c8d" onclick="this.parentElement.parentElement.style.display='none'">Cancel</button>
|
||||
<div style="display: flex; gap: 5px; margin-bottom: 10px;">
|
||||
<input type="text" id="newTaskInput" placeholder="Add task name..." style="margin-bottom: 0;">
|
||||
<button type="button" class="btn" style="background: #27ae60;" onclick="addNewTask()">Add</button>
|
||||
</div>
|
||||
|
||||
<ul id="newTasksListDisplay" style="list-style: none; padding: 0; margin-bottom: 1rem;">
|
||||
<!-- Items will be injected here -->
|
||||
</ul>
|
||||
|
||||
<input type="hidden" name="tasks_list_data" id="tasksListData">
|
||||
|
||||
<div style="margin-top: 1rem;">
|
||||
<button type="submit" class="btn">Create</button>
|
||||
<button type="button" class="btn" style="background: var(--text-secondary)" onclick="document.getElementById('newActivityForm').style.display='none'">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// Existing timer scripts...
|
||||
// ...existing code...
|
||||
|
||||
// New Task List Logic for Activity Creation
|
||||
let newActivityTasks = [];
|
||||
|
||||
function addNewTask() {
|
||||
const input = document.getElementById('newTaskInput');
|
||||
const val = input.value.trim();
|
||||
if (val) {
|
||||
newActivityTasks.push(val);
|
||||
input.value = '';
|
||||
renderNewActivityTasks();
|
||||
}
|
||||
}
|
||||
|
||||
function removeNewTask(index) {
|
||||
newActivityTasks.splice(index, 1);
|
||||
renderNewActivityTasks();
|
||||
}
|
||||
|
||||
function renderNewActivityTasks() {
|
||||
const list = document.getElementById('newTasksListDisplay');
|
||||
list.innerHTML = '';
|
||||
newActivityTasks.forEach((item, index) => {
|
||||
const li = document.createElement('li');
|
||||
li.style.background = '#f7f7f5';
|
||||
li.style.border = '1px solid var(--border-dim)';
|
||||
li.style.margin = '5px 0';
|
||||
li.style.padding = '8px';
|
||||
li.style.borderRadius = '4px';
|
||||
li.style.display = 'flex';
|
||||
li.style.justifyContent = 'space-between';
|
||||
li.style.alignItems = 'center';
|
||||
li.style.fontSize = '0.9rem';
|
||||
|
||||
li.innerHTML = `
|
||||
<span>${item}</span>
|
||||
<span onclick="removeNewTask(${index})" style="cursor: pointer; color: var(--danger-color); font-weight: bold; padding: 0 5px;">×</span>
|
||||
`;
|
||||
list.appendChild(li);
|
||||
});
|
||||
}
|
||||
|
||||
function prepareTasksList() {
|
||||
document.getElementById('tasksListData').value = newActivityTasks.join(',');
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user