EnVisageOnline/Main-RMO/Source/EnVisage/Views/StrategicGoal/Index.cshtml

236 lines
7.7 KiB
Plaintext

@using EnVisage.Code.HtmlHelpers
@using Microsoft.AspNet.Identity
@using EnVisage.Code
@{
ViewBag.Title = "Strategic Goals";
}
@section scripts
{
<script src="@Url.Content("~/Scripts/jquery.unobtrusive-ajax.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.collapsiblepanel.js")" type="text/javascript"></script>
<script type="text/javascript">
function formatFDDate(jsonDate) {
if (jsonDate == null || jsonDate == "")
return "";
var dt = new Date(parseInt(jsonDate.replace("/Date(", "").replace(")/", ""), 10));
return (dt.getMonth() + 1) + "/" + dt.getDate() + "/" + dt.getFullYear();
}
var ctr = 0;
var GroupArr = new Array();
init.push(function () {
$('#goals').dataTable({
"bProcessing": true,
"bServerSide": true,
"bAutoWidth": false,
"sAjaxSource": document.URL,
"sServerMethod": "POST",
"aoColumns": [
{ "mDataProp": "Name" },
{"mDataProp": "NbrProjects"},
{
"mData": function (data, type, full) {
return formatFDDate(data.StartDate);
}
},
{
"mData": function (data, type, full) {
return formatFDDate(data.EndDate);
}
},
//{ "mDataProp": "Color" },
//{
// "mData": function (data, type, full) {
// var retVal = "";
// for (var i=0; i < data.Companies.length; i++)
// {
// retVal += data.Companies[i].Name + ", ";
// }
// if (retVal.length > 1)
// {
// return retVal.substr(0, retVal.length - 2);
// }
// return retVal;
// }
//},
{
"mData": function (data, type, full) {
@if (SecurityManager.CheckSecurityObjectPermission(Areas.StrategicGoals, AccessLevel.Write))
{
<text>
ctr++;
return ('<a id="btnEdit' + ctr + '" onclick="return editGoal(this.id, \'_rplcmnt_\')" data-toggle="popover" data-placement="left" ' + 'class="btn btn-sm btn-primary popover-warning popover-dark"><i class="fa fa-edit"></i> Edit</a> ' +
'<a id="btnDelete' + ctr + '" onclick="return deleteGoal(this.id, \'_rplcmnt_\', \'_rplcmnt1_\')" data-toggle="popover" data-placement="left" ' + 'class="btn btn-sm btn-danger popover-warning popover-dark"><i class="fa fa-trash-o"></i> Delete</a>')
.replace(/_rplcmnt_/g, data.Id).replace(/_rplcmnt1_/g, data.Name);
</text>
}
else
{
<text>
return "";
</text>
}
}
}],
})
@if (SecurityManager.CheckSecurityObjectPermission(Areas.ProjectClassifications, AccessLevel.Write))
{
<text>
$('#goals_wrapper .table-caption').html('<a class="btn btn-primary" onclick="return editGoal(this.id, null);"><i class="fa fa-plus"></i> Add Strategic Goal</a>');
</text>
}
$('#goals_wrapper .dataTables_processing').addClass("table-caption");
$('#goals_wrapper .dataTables_processing').html('<span class="h3"><img class="valign-middle" src="../Content/images/loadFA.gif"/></span>');
});
function loadSG(sgId) {
blockUI();
var url = "";
var isNew = true;
if (sgId && (sgId != null) && (sgId.length > 0) && (sgId != '@Guid.Empty')) {
url = "?Id=" + sgId;
isNew = false;
}
$('#editReload').html("");
$.ajax({
url: '@Url.Action("Edit", "StrategicGoal")' + url,
cache: false,
dataType: "html",
success: function (data) {
$('#editReload').html(data);
initGoal();
$('#editStrategicGoal')
.on('hidden.bs.modal', function () {
if (!isNew) {
StopEdit();
RemoveLock('StrategicGoal', sgId);
}
})
.modal('show');
unblockUI();
}
});
}
function editGoal(aId, Id) {
if (Id && (Id != null) && (Id.length > 0) && (Id != '@Guid.Empty'))
if (!CheckLock(aId, 'StrategicGoal', Id))
return false;
loadSG(Id);
return true;
}
function deleteGoal(aId, Id, name) {
if (Id && (Id != null) && (Id.length > 0) && (Id != '@Guid.Empty')) {
if (!CheckLock(aId, 'StrategicGoal', Id))
return false;
StartEdit('StrategicGoal', Id, null, null, 'errorsMessagesPlaceholder');
}
else
// Id not specified
return false;
$("#deleteStrategicGoalId").val(Id);
$("#deleteSGCaption").text("Do you want to delete \"" + name + "\" stgrategic goal?");
$('#modal-warning').on('hidden.bs.modal', function () {
StopEdit();
RemoveLock('StrategicGoal', Id);
}).modal('show');
return true;
}
$(document).on('hide.bs.modal', '#editStrategicGoal', function (e) {
// skip modal hide event from datepickers
if ($(e.target).attr('id') != 'editStrategicGoal')
return true; // close modal form
// check that form has been changed
if (typeof isSGDataChanged === 'function')
// if form has been changed
if (isSGDataChanged()) {
// ask user for confirmation of form close
if (confirm("Strategic Goal editing form contains unsaved changes, do you really want to close the form?")) {
// reset change indicator
if (typeof resetSGDataChanged === 'function') {
resetSGDataChanged();
}
return true; // close modal form
};
return false; // DO NOT close modal form
}
return true; // close modal form
});
</script>
}
<div id="errorsMessagesPlaceholder"></div>
<div class="table-light table-responsive">
<table cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered" id="goals">
<thead>
<tr>
<th>Goal
</th>
<th>
Number of Projects
</th>
<th>Start Date
</th>
<th>End Date
</th>
@*<th>
Color
</th>
<th>
Companies
</th>*@
<th></th>
</tr>
</thead>
</table>
</div>
<!-- Modal -->
<div id="editStrategicGoal" class="modal fade" tabindex="-1" role="dialog" style="display: none;" data-backdrop="static">
<div class="modal-dialog">
<div class="modal-content" id="editReload">
</div>
<!-- / .modal-content -->
</div>
<!-- / .modal-dialog -->
</div>
<!-- /.modal -->
<!-- / Modal -->
<!-- Warning modal alert -->
<div id="modal-warning" class="modal fade" tabindex="-1" role="dialog" style="display: none;">
<div class="modal-dialog">
@using (Html.BeginForm("Delete", "StrategicGoal"))
{
@Html.AntiForgeryToken()
<input type="hidden" id="deleteStrategicGoalId" name="deleteStrategicGoalId" />
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h4 class="modal-title">Delete Strategic Goal</h4>
</div>
<div class="modal-title"></div>
<div class="modal-body"><strong id="deleteSGCaption"></strong></div>
<div class="modal-footer">
<button type="submit" class="btn btn-danger" data-dismiss="modal" onclick="blockUI()">OK</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</div> <!-- / .modal-content -->
}
</div>
<!-- / .modal-dialog -->
</div>
<!-- / .modal -->
<!-- Modal -->