Deepak3635 commited on
Commit
16e5118
·
verified ·
1 Parent(s): 07992ae

admin can delete the tasks

Browse files
Files changed (1) hide show
  1. script.js +7 -4
script.js CHANGED
@@ -496,10 +496,14 @@ const UI = {
496
  // This would open an edit modal in full implementation
497
  this.showToast('Edit functionality would open here', 'info');
498
  },
499
-
500
  // Delete task (admin)
501
  deleteTask(taskId) {
502
- if (confirm('Are you sure you want to delete this task?')) {
 
 
 
 
 
503
  DataStore.deleteTask(taskId);
504
  this.hideTaskDetail();
505
  this.renderTasks();
@@ -507,8 +511,7 @@ const UI = {
507
  this.showToast('Task deleted successfully', 'success');
508
  }
509
  },
510
-
511
- // Update task progress (member)
512
  updateTaskProgress(taskId, progress) {
513
  DataStore.updateTask(taskId, { progress: parseInt(progress) });
514
  document.getElementById('taskDetailProgressBar').style.width = `${progress}%`;
 
496
  // This would open an edit modal in full implementation
497
  this.showToast('Edit functionality would open here', 'info');
498
  },
 
499
  // Delete task (admin)
500
  deleteTask(taskId) {
501
+ if (!DataStore.isAdmin()) {
502
+ this.showToast('Only administrators can delete tasks', 'error');
503
+ return;
504
+ }
505
+
506
+ if (confirm('Are you sure you want to delete this task? This action cannot be undone.')) {
507
  DataStore.deleteTask(taskId);
508
  this.hideTaskDetail();
509
  this.renderTasks();
 
511
  this.showToast('Task deleted successfully', 'success');
512
  }
513
  },
514
+ // Update task progress (member)
 
515
  updateTaskProgress(taskId, progress) {
516
  DataStore.updateTask(taskId, { progress: parseInt(progress) });
517
  document.getElementById('taskDetailProgressBar').style.width = `${progress}%`;