EnVisageOnline/Main/Source/EnVisage/Views/Team/_editTeam.cshtml

237 lines
11 KiB
Plaintext

@model EnVisage.Models.TeamModel
@using EnVisage.Code
@{
ViewBag.Title = Model != null ? "Edit " + Model.Name : "Add Team";
var contributors = string.Join("','", Model.UserId ?? new List<Guid>());
contributors = "'" + contributors + "'";
}
<script type="text/javascript">
var _teamDataChanged = false;
function onTeamDataChanged() {
_teamDataChanged = true;
}
function resetTeamDataChanged() {
_teamDataChanged = false;
}
function isTeamDataChanged() {
return _teamDataChanged;
}
emulateNavUrl = "/Team";
function fillSelect2(multik, preselected) {
var selected = [];
if (preselected != null)
selected = preselected;
multik.select2('val', selected);
}
</script>
<script type="text/javascript">
function initTeam() {
StartEdit('Team', '@Model.Id', "#btnDelete", "#btnsave", "erorMsgPlaceholder");
$("#@Html.IdFor(model=>model.ReportToId)").select2({
allowClear: true,
placeholder: "Select"
});
$("#@Html.IdFor(model=>model.CompanyId)").select2({
allowClear: true,
placeholder: "Select"
}).on('change', function () {
$.ajax({
url: "@Url.Action("LoadExternalContacts", "Project")",
data: { clientId: $("#@Html.IdFor(model=>model.CompanyId)").val(), selectControlId: $("#@Html.IdFor(model=>model.CompanyId)").id },
success: function (dt) {
var data = dt.contacts;
var markup = "<option value=''></option>";
for (var i = 0; i < data.length; i++) {
markup += "<option value=" + data[i].Id + ">" + data[i].FirstName + " " + data[i].LastName + "</option>";
}
$("#@Html.IdFor(model=>model.ReportToId)").html(markup);
$("#@Html.IdFor(model=>model.ReportToId)").select2("val", $("#" + dt.selectControlId).parents('.pm-container').data('ecurrentContacts'));
},
error: function (reponse) {
showErrorModal('Error.', reponse);
}
});
});
$("#@Html.IdFor(model=>model.CostCenterId)").select2({
allowClear: true,
placeholder: "Select"
});
$("#@Html.IdFor(model=>model.UserId)").select2({
allowClear: true,
placeholder: "Select contributors"
});
$("#@Html.IdFor(model=>model.WorkFlowContacts)").select2({
allowClear: true,
placeholder: "Select Workflow Contacts"
});
$("#@Html.IdFor(model=>model.NotificationContacts)").select2({
allowClear: true,
placeholder: "Select notification Contacts"
});
$("#@Html.IdFor(model=>model.NotificationWorkFlowStates)").select2({
allowClear: true,
placeholder: "Select Workflow states"
});
var contributors = [@Html.Raw(contributors)];
fillSelect2($("#@Html.IdFor(model=>model.UserId)"), contributors);
$(".select2-input").css("min-width", "200px");
@if (Model.Id != Guid.Empty)
{
<text>
StartEdit('Team', '@Model.Id', "#btnDelete", "#btnsave", "erorMsgPlaceholder");
</text>
}
$('#editTeamForm').find('input[type=checkbox],input[type=text],select,textarea').on("change", function () {
if (typeof onTeamDataChanged === 'function')
onTeamDataChanged();
});
@if (!Model.ProjectAddNotification)
{
<text>
$('#NotificationContactsDiv').hide();
</text>
}
else
{
<text>
$('#NotificationContactsDiv').show();
</text>
}
$('.projectaddnotification_sw').switcher({
on_state_content: 'Notify on Add',
off_state_content: 'Ignore Add'
}).change(function () {
if ($(this).is(':checked')) {
$('#NotificationContactsDiv').show();
} else {
$('#NotificationContactsDiv').hide();
}
}).switcher().parent().css("width", "200px");
$.validator.unobtrusive.parseDynamicContent('form#editTeamForm');
}
function onFailureEditTeam(xhr) {
showErrorModal();
}
function onSuccessEditTeam(result) {
handleAjaxResponse(result, function () {
// TODO: change to reloadDataTable function when issue with confirm dialog is fixed
reloadPage();
}, null, null, $('#editTeamForm'));
}
</script>
<div id="erorMsgPlaceholder"></div>
@using (Ajax.BeginForm("Edit", "Team", new AjaxOptions { HttpMethod = "Post", OnBegin = "blockUI", OnSuccess = "onSuccessEditTeam", OnFailure = "onFailureEditTeam(xhr)", OnComplete = "unblockUI" }, new { id = "editTeamForm" }))
{
@Html.AntiForgeryToken()
@Html.HiddenFor(t => t.Id)
@Html.HiddenFor(model => model.ActualCapacityScenarioId);
@Html.HiddenFor(model => model.PlannedCapacityScenarioId);
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h4 class="modal-title">@(Model.Id != Guid.Empty ? "Edit " + Model.Name : "Add Team")</h4>
</div>
<div class="modal-body">
<div class="row">
<div class="col-sm-6">
<div class="form-group no-margin-hr">
@Html.LabelFor(model => model.Name, new { @class = "control-label" })
@Html.TextBoxFor(model => model.Name, new { @class = "form-control" })
@Html.ValidationMessageFor(model => model.Name)
</div>
</div>
<div class="col-sm-6">
<div class="form-group no-margin-hr">
@Html.LabelFor(model => model.ReportToId, new { @class = "control-label" })
@Html.DropDownListFor(model => model.ReportToId, Utils.GetTeamContacts(Model.CompanyId), new { @class = "form-control forselect2" })
@Html.ValidationMessageFor(model => model.ReportToId)
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group no-margin-hr">
@Html.LabelFor(model => model.CostCenterId, new { @class = "control-label" })
@Html.DropDownListFor(model => model.CostCenterId, Utils.GetCreditDepartments(true), new { @class = "form-control forselect2" })
@Html.ValidationMessageFor(model => model.CostCenterId)
</div>
</div>
<div class="col-sm-6">
<div class="form-group no-margin-hr">
@Html.LabelFor(model => model.CompanyId, new { @class = "control-label" })
@Html.DropDownListFor(model => model.CompanyId, Utils.GetAllCompanies(true), new { @class = "form-control forselect2" })
@Html.ValidationMessageFor(model => model.CompanyId)
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6 ">
<div class="form-group no-margin-hr select2-primary">
@Html.LabelFor(model => model.UserId, new { @class = "control-label" })
@Html.EditorFor(model => model.UserId, string.Empty, new { List = Model.Users.OrderBy(x => x.LastName).Select(x => new SelectListItem() { Value = x.Id.ToLower(), Text = x.FirstName + " " + x.LastName }).ToList() })
@Html.ValidationMessageFor(model => model.UserId)
</div>
</div>
<div class="col-sm-6">
<div class="form-group no-margin-hr select2-primary">
@Html.LabelFor(model => model.WorkFlowContacts, new { @class = "control-label" })
@Html.ListBoxFor(model => model.WorkFlowContacts, EnVisage.Code.Utils.GetWorkFlowContacts(Model.Id), new { @class = "int-workflowcontacts form-control forselect2" })
@Html.ValidationMessageFor(model => model.WorkFlowContacts)
</div>
</div>
</div>
<div class="row">
<div class="form-group">
@Html.LabelFor(model => model.ProjectAddNotification, new { @class = "col-lg-9 control-label" })
<div class="col-sm-10">
@Html.CheckBoxFor(model => model.ProjectAddNotification, new { @class = "control-label projectaddnotification_sw" })
@Html.ValidationMessageFor(model => model.ProjectAddNotification)
</div>
</div>
</div>
<div class="row" id="NotificationContactsDiv">
<div class="row ">
<div class="col-lg-12">
<div class="form-group no-margin-hr select2-primary">
@Html.LabelFor(model => model.NotificationContacts, new { @class = "control-label" })
@Html.ListBoxFor(model => model.NotificationContacts, EnVisage.Code.Utils.GetWorkFlowContacts(Model.Id), new { @class = "int-workflowcontacts form-control forselect2" })
@Html.ValidationMessageFor(model => model.NotificationContacts)
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="form-group no-margin-hr select2-primary">
@Html.LabelFor(model => model.NotificationWorkFlowStates, new { @class = "control-label" })
@Html.ListBoxFor(model => model.NotificationWorkFlowStates, Utils.GetAllWorkFlowStates(), new { @class = "int-workflowcontacts form-control forselect2" })
@Html.ValidationMessageFor(model => model.NotificationWorkFlowStates)
</div>
</div>
</div>
</div>
@Html.ValidationSummary(false, "The Team could not be saved due to the following errors:")
</div> <!-- / .modal-body -->
<div class="modal-footer">
<button type="submit" class="btn btn-success" id="btnsave"><i class="fa fa-save"></i> Save</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
}