forked from JohanGriesel/Stratusolve-Exercise
-
Notifications
You must be signed in to change notification settings - Fork 35
/
index.php
108 lines (103 loc) · 3.92 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
/**
* Created by PhpStorm.
* User: johangriesel
* Date: 13052016
* Time: 08:48
* @package ${NAMESPACE}
* @subpackage ${NAME}
* @author johangriesel <[email protected]>
*/
?>
<!DOCTYPE html>
<html>
<head>
<title>Basic Task Manager</title>
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.min.css">
</head>
<body>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<form action="update_task.php" method="post">
<div class="row">
<div class="col-md-12" style="margin-bottom: 5px;;">
<input id="InputTaskName" type="text" placeholder="Task Name" class="form-control">
</div>
<div class="col-md-12">
<textarea id="InputTaskDescription" placeholder="Description" class="form-control"></textarea>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button id="deleteTask" type="button" class="btn btn-danger">Delete Task</button>
<button id="saveTask" type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row">
<div class="col-md-3">
</div>
<div class="col-md-6">
<h2 class="page-header">Task List</h2>
<!-- Button trigger modal -->
<button id="newTask" type="button" class="btn btn-primary btn-lg" style="width:100%;margin-bottom: 5px;" data-toggle="modal" data-target="#myModal">
Add Task
</button>
<div id="TaskList" class="list-group">
<!-- Assignment: These are simply dummy tasks to show how it should look and work. You need to dynamically update this list with actual tasks -->
</div>
</div>
<div class="col-md-3">
</div>
</div>
</div>
</body>
<script type="text/javascript" src="assets/js/jquery-1.12.3.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap.min.js"></script>
<script type="text/javascript">
var currentTaskId = -1;
$('#myModal').on('show.bs.modal', function (event) {
var triggerElement = $(event.relatedTarget); // Element that triggered the modal
var modal = $(this);
if (triggerElement.attr("id") == 'newTask') {
modal.find('.modal-title').text('New Task');
$('#deleteTask').hide();
currentTaskId = -1;
} else {
modal.find('.modal-title').text('Task details');
$('#deleteTask').show();
currentTaskId = triggerElement.attr("id");
console.log('Task ID: '+triggerElement.attr("id"));
}
});
$('#saveTask').click(function() {
//Assignment: Implement this functionality
alert('Save... Id:'+currentTaskId);
$('#myModal').modal('hide');
updateTaskList();
});
$('#deleteTask').click(function() {
//Assignment: Implement this functionality
alert('Delete... Id:'+currentTaskId);
$('#myModal').modal('hide');
updateTaskList();
});
function updateTaskList() {
$.post("list_tasks.php", function( data ) {
$( "#TaskList" ).html( data );
});
}
updateTaskList();
</script>
</html>