initial add
This commit is contained in:
103
Fab2ApprovalSystem-Copy/Views/Admin/TrainingGroups.cshtml
Normal file
103
Fab2ApprovalSystem-Copy/Views/Admin/TrainingGroups.cshtml
Normal file
@ -0,0 +1,103 @@
|
||||
@model IEnumerable<Fab2ApprovalSystem.Models.TrainingGroup>
|
||||
<p>
|
||||
<input type="button" value="Add Training Group" class="btn btn-success btn-xs" id="AddTrainingGroup" />
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
Group Name:
|
||||
</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.TrainingGroupName)
|
||||
</td>
|
||||
<td>
|
||||
<a href="~/Admin/ViewTrainingGroup?TrainingGroupID=@item.TrainingGroupID" class="btn btn-default">View/Edit Group</a>
|
||||
@*<input type="button" class="btn btn-default" value="View/Edit Group" />*@
|
||||
<input type="button" class="btn btn-default" value="Delete" onclick="DeleteGroup('@item.TrainingGroupID')" />
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
</table>
|
||||
<div class="modal fade" id="AddGroup" tabindex="0" role="dialog" aria-hidden="true" data-backdrop="static">
|
||||
<div class="modal-dialog modal-lg" style="width:500px;">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header" style="background-color: #fce0a3;">
|
||||
<h3 class="modal-title">Add Training Group</h3>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
|
||||
<p>New Group Name: </p>
|
||||
<input type="text" id="GroupName" />
|
||||
<input type="button" value="Save" onclick="SaveGroup()" />
|
||||
|
||||
</div>
|
||||
<div class="modal-footer" style="background-color: #fce0a3; ">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
//RefreshGroups();
|
||||
});
|
||||
function SaveGroup() {
|
||||
groupName = document.getElementById('GroupName').value;
|
||||
alert('test');
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Admin/AddNewTrainingGroup",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: '{"groupName":"' + groupName + '"}',
|
||||
dataType: "json",
|
||||
success: function () {
|
||||
RefreshGroups();
|
||||
},
|
||||
error: function (req, status, error) {
|
||||
alert(error);
|
||||
}
|
||||
});
|
||||
$("#AddGroup").modal('hide');
|
||||
|
||||
}
|
||||
|
||||
$('#AddTrainingGroup').on('click', function () {
|
||||
$("#AddGroup").modal('show');
|
||||
return false;
|
||||
})
|
||||
function DeleteGroup(groupID) {
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/Admin/DeleteTrainingGroup",
|
||||
contentType: "application/json; charset=utf-8",
|
||||
data: '{"groupID":"' + groupID + '"}',
|
||||
dataType: "json",
|
||||
success: function () {
|
||||
RefreshGroups();
|
||||
},
|
||||
error: function (req, status, error) {
|
||||
alert(error);
|
||||
}
|
||||
});
|
||||
}
|
||||
function RefreshGroups() {
|
||||
$.ajax({
|
||||
url: '@Url.Action("TrainingGroups", "Admin")',
|
||||
type: 'POST',
|
||||
success: function(data) {
|
||||
if (data) { // check if data is defined
|
||||
$("#GroupsDisplay").html(data);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user