-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.html
142 lines (126 loc) · 3.94 KB
/
app.html
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
<!DOCTYPE html>
<html>
<head>
<title>Application</title>
<link href="assets/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<script src="assets/js/libs/jquery.min.js"></script>
<script src="assets/js/libs/handlebars.js"></script>
<script src="assets/js/libs/bootstrap.min.js"></script>
<script src="assets/js/models/student.model.js"></script>
<script src="assets/js/services/student.service.js"></script>
</head>
<body>
<div class="container">
<div class="page-title">
<h1>Student Management System</h1>
</div>
<div class="pull-right">
<p>
<a href="javascript:void(0)" class="btn btn-primary btn-sm" id="add-btn">
<span class="glyphicon glyphicon-plus"></span>
</a>
</p>
</div>
<table id="student-table" class="table table-bordered table-hover table-striped">
<tr>
<th><input type="checkbox" id="check-all"/></th>
<th>Id</th>
<th>Name</th>
<th>Email</th>
<th>Contact No</th>
<th>Status</th>
<th>Action</th>
</tr>
</table>
<div id="student-dialog" style="display:none">
<form role="form">
<div class="form-group">
<label>First Name</label>
<input type="text" id="fname" name="first_name" required="required" placeholder="Enter First Name" class="form-control"/>
</div>
<div class="form-group">
<label>Last Name</label>
<input type="text" id="lname" name="last_name" required="required" placeholder="Enter Last Name" class="form-control"/>
</div>
<div class="form-group">
<label>Email</label>
<input type="email" id="email" name="email" required="required" placeholder="Enter Email" class="form-control"/>
</div>
<div class="form-group">
<label>Contact No</label>
<input type="text" id="contact_no" name="contact_no" required="required" placeholder="Enter Contact No" class="form-control"/>
</div>
<div class="checkbox">
<label><input type="checkbox" id="status"/>Status</label>
</div>
<button type="submit" class="btn btn-success btn-sm" id="save-btn">Save</button>
<a href="javascript:void(0)" id="cancel-btn" class="btn btn-danger btn-sm">
Cancel
</a>
</form>
</div>
<script id="student-data-template" type="text/x-handlebars-template">
{{#each students}}
<tr>
<td><input type="checkbox" class="select-all"/></td>
<td>{{this.id}}</td>
<td>{{this.firstName}} {{this.lastName}}</td>
<td>{{this.email}}</td>
<td>{{this.contactNo}}</td>
<td>{{this.status}}</td>
<td>
<a href="javascript:void(0)" class="btn btn-success btn-sm" >
<span class="glyphicon glyphicon-pencil"></span>
</a>
<a href="javascript:void(0)" class="btn btn-danger btn-sm">
<span class="glyphicon glyphicon-trash"></span>
</a>
</td>
</tr>
{{/each}}
</script>
</div>
<script>
var counter=1;
var stdService=new StudentService();
$(document).on("ready",function(){
$("#check-all").on("click",function(){
var $this=$(this);
$(".select-all").prop("checked",$this.is(":checked"));
});
$("#add-btn").on("click",function(){
$("#student-table").hide();
$("#student-dialog").slideToggle();
});
$("#save-btn").on("click",function(){
var student=new Student();
student.id=counter;
student.firstName=$("#fname").val();
student.lastName=$("#lname").val();
student.email=$("#email").val();
student.contactNo=$("#contact_no").val();
student.status=$("#status").is(":checked");
//console.log(student);
stdService.add(student);
counter++;
$("#cancel-btn").click();
reload();
return false;
});
$("#cancel-btn").on("click",function(){
$("#student-dialog").slideToggle('auto',function(){
$("#student-table").show();
});
});
});
function reload(){
var source = $("#student-data-template").html();
var template = Handlebars.compile(source);
var context = {students:stdService.getAll()};
var html = template(context);
$("#student-table").append(html);
}
</script>
</body>
</html>