EnVisageOnline/Main/Source/EnVisage/Views/NonProjectTimeCategory/Index.cshtml

131 lines
6.3 KiB
Plaintext

@using EnVisage.Code
@{
ViewBag.Title = "Non-Project Time Categories";
}
@section scripts
{
<script type="text/javascript">
init.push(function () {
$('#allocationCategories').dataTable({
"bProcessing": true,
"bServerSide": true,
"bAutoWidth": false,
"sAjaxSource": document.URL,
"sServerMethod": "POST",
"aoColumns": [
{ "mDataProp": "Name" },
{
"mDataProp": "Scheduled",
"sClass": "text-center"
},
{
"mData": function (data, type, full) {
@if (SecurityManager.CheckSecurityObjectPermission(Areas.RD_ResourceNPTAllocationCategory, AccessLevel.Write))
{
<text>
return ('<a id="btnEdit_rplcmnt_ onclick="return CheckLock(this.id, \'NonProjectTimeCategories\', \'_rplcmnt_\')" data-toggle="popover" data-placement="left" ' + 'class="btn btn-sm btn-primary popover-warning popover-dark" onclick="showEditNonProjectTimeCategoryWindow(\'_rplcmnt_\');"><i class="fa fa-edit"></i> Edit</a> ' +
'<a id="btnReallocate_rplcmnt_ onclick="return CheckLock(this.id, \'NonProjectTimeCategories\', \'_rplcmnt_\')" data-toggle="popover" data-placement="left" ' + 'class="btn btn-sm btn-warning popover-warning popover-dark" onclick="showReallocateNonProjectTimeCategoryWindow(\'_rplcmnt_\');"><i class="fa fa-arrow-right"></i> Reallocate </a> ' +
'<a id="btnDelete_rplcmnt_ onclick="return CheckLock(this.id, \'NonProjectTimeCategories\', \'_rplcmnt_\')" data-toggle="popover" data-placement="left" ' + 'class="btn btn-sm btn-danger popover-warning popover-dark" ' + (data.CanBeDeleted ? '' : 'disabled="disabled"') + ' onclick="deleteNonProjectTimeCategory(\'_rplcmnt_\');"' + ' ><i class="fa fa-trash-o"></i> Delete</a>')
.replace(/_rplcmnt_/g, data.Id);
</text>
}
else
{
<text>
return "";
</text>
}
},
"bSortable": false
}],
});
@if (SecurityManager.CheckSecurityObjectPermission(Areas.RD_ResourceNPTAllocationCategory, AccessLevel.Write))
{
<text>
$('#allocationCategories_wrapper .table-caption').html('<a class="btn btn-primary" onclick="showEditNonProjectTimeCategoryWindow(\'@Guid.Empty\');"><i class="fa fa-plus"></i> Add Allocation Category</a>');
</text>
}
$('#allocationCategories_wrapper .dataTables_filter input').attr('placeholder', 'Search...');
$('#allocationCategories_wrapper .dataTables_processing').addClass("table-caption");
$('#allocationCategories_wrapper .dataTables_processing').html('<span class="h3"><img class="valign-middle" src="../Content/images/loadFA.gif"/></span>');
});
function showEditNonProjectTimeCategoryWindow(categoryId) {
$.get('@Url.Action("Edit", "NonProjectTimeCategory")?id=' + categoryId, function (data) {
$('#divEditNonProjectTimeCategory').html(data);
$('#modalEditNonProjectTimeCategory').modal("show");
initNonProjectTimeCategory();
}).fail(function () {
showErrorModal('Oops...', 'An error occurred while processing your request. Please, try again later.');
});
};
function showReallocateNonProjectTimeCategoryWindow(categoryId) {
$.get('@Url.Action("Reallocate", "NonProjectTimeCategory")?id=' + categoryId, function (data) {
$('#divReallocateNonProjectTimeCategory').html(data);
$('#modalReallocateNonProjectTimeCategory').modal("show");
initNonProjectTimeCategory();
}).fail(function () {
showErrorModal('Oops...', 'An error occurred while processing your request. Please, try again later.');
});
};
function deleteNonProjectTimeCategory(categoryId) {
if (!categoryId)
return;
bootbox.confirm({
message: "Are you sure you want to delete this allocation category?",
callback: function (result) {
if (result) {
var text = "@Url.Action("Delete", "NonProjectTimeCategory", new { Id = "JSVar" })".replace("JSVar", categoryId);
$.post(text, function () {
blockUI();
refreshAllocationCategories();
}).fail(function () {
showErrorModal('Oops...', 'An error occurred while processing your request. Please, try again later.');
}).always(unblockUI);
}
},
className: "bootbox-sm"
});
};
function closeEditNonProjectTimeCategoryWindow() {
$('#modalEditNonProjectTimeCategory').modal("hide");
};
function closeReallocateNonProjectTimeCategoryWindow() {
$('#modalReallocateNonProjectTimeCategory').modal("hide");
};
function refreshAllocationCategories() {
blockUI();
$('#allocationCategories').DataTable().ajax.reload(unblockUI, false);
};
</script>
}
<div class="table-light table-responsive">
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="allocationCategories">
<thead>
<tr>
<th>
Allocation Category Name
</th>
<th style="width: 100px;">
# Scheduled
</th>
<th style="width:229px;"></th>
</tr>
</thead>
</table>
</div>
<div id="modalEditNonProjectTimeCategory" class="modal fade" data-width="600" tabindex="-1" role="dialog" style="display: none;" data-backdrop="static">
<div class="modal-dialog" id="divEditNonProjectTimeCategory">
</div> <!-- / .modal-dialog -->
</div> <!-- / .modal -->
<div id="modalReallocateNonProjectTimeCategory" class="modal fade" data-width="600" tabindex="-1" role="dialog" style="display: none;" data-backdrop="static">
<div class="modal-dialog" id="divReallocateNonProjectTimeCategory">
</div> <!-- / .modal-dialog -->
</div> <!-- / .modal -->