EnVisageOnline/Main/Source/EnVisage/Views/PeopleResource/_reassignResource.cshtml

126 lines
6.4 KiB
Plaintext

@using EnVisage.Code.HtmlHelpers
@using EnVisage.Models
@model PeopleResourceReassignModel
@{
ViewBag.Title = "Reassign Resource Allocations";
}
<style>
.special-select-item {
border-bottom: solid 1px #e4e4e4;
}
.multiline-label {
display: inline-block;
white-space: normal;
vertical-align: top;
}
</style>
<script type="text/javascript">
// Note! datePickerOptions variable must be initialized in the host-page for this form
var C_EDIT_ACTION_DEACTIVATION_UNASSIGN = 1;
var C_EDIT_ACTION_DEACTIVATION_REASSIGN = 2
var C_EDIT_ACTION_TEAM_CHANGING = 3;
var C_EDIT_ACTION_EDIT_PROPS = 4;
function initReasourceReassignForm(formRootElement, formDisplayMode) {
formRootElement.find(".forselect2").select2({
allowClear: true,
});
formRootElement.find(".forselect2").css("width", "96%");
formRootElement.find("input[type=radio]").on("change", function (item) {
if (!item || !item.target)
return;
var val = $(item.target).val();
var setSelectEnabled = (val == '@(PeopleResourceReassignmentModel.MoveAction.MoveToResource)');
var selectControl = $(item.target).parents("div.form-group").find("select");
if (setSelectEnabled)
selectControl.select2("enable");
else
selectControl.select2("disable");
});
if (formDisplayMode == C_EDIT_ACTION_DEACTIVATION_REASSIGN) {
// Hide some form elements
formRootElement.find('input[type=radio][value=@(PeopleResourceReassignmentModel.MoveAction.MoveToResource)]')
.prop("checked", true).change().hide();
formRootElement.find('input[type=radio][value=@(PeopleResourceReassignmentModel.MoveAction.MoveToNewTeam)]')
.parent("div.row").hide();
}
$('#btn-reassignResource').on('click', submitReassign);
};
function submitReassign(e) {
var reassignmentPlan = $(this).closest('form').serializeArray();
savePeopleResource(reassignmentPlan);
}
</script>
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
<h4 class="modal-title">@ViewBag.Title</h4>
</div>
<form>
<div class="modal-body" style="padding: 0 15px;">
<div class="panel-body form-horizontal">
<div class="alert alert-warning">
Reminder: PREVU works on weekly assignments for your team members. This change will be effective at the start of the next work week on @Model.EffectiveChangeDate.ToShortDateString()
</div>
<div class="form-inline">
<p>
This People Resource has future assignments in one or more projects. Please choose what we need to do with these assignments:
</p>
@for (int pIndex = 0; pIndex < Model.AllocationsReassignmentPlan.Count; pIndex++)
{
<text>
<div class="form-group" style="width: 100%; padding-bottom: 8px;">
<div class="radio-group-sigle-line">
@Html.HiddenFor(model => Model.AllocationsReassignmentPlan[pIndex].ProjectId)
<label class="col-sm-5 control-label">@Model.AllocationsReassignmentPlan[pIndex].ProjectName</label>
<div class="col-sm-7">
<div class="row" style="white-space:nowrap;">
@Html.RadioButtonFor(model => Model.AllocationsReassignmentPlan[pIndex].Action, PeopleResourceReassignmentModel.MoveAction.MoveToNewTeam, new { @class = "form-control" })
<span class="radio-gap" />
<span class="radio-label">
@(Model.AllocationsReassignmentPlan[pIndex].ProjectHasDestTeam ?
"Leave Resource's current assignment in new team" :
"Assign Resource's new team to the project and leave current assignment")
</span>
</div>
<div class="row" style="white-space:nowrap;">
@Html.RadioButtonFor(model => Model.AllocationsReassignmentPlan[pIndex].Action, PeopleResourceReassignmentModel.MoveAction.MoveToResource, new { @class = "form-control" })
<span class="radio-gap" />&nbsp;
<select class="form-control forselect2" name="AllocationsReassignmentPlan[@pIndex].DestResource" disabled>
<option class="special-select-item" value="@Guid.Empty.ToString()" selected>Drop assignments</option>
@for (int tIndex = 0; tIndex < Model.AllocationsReassignmentPlan[pIndex].SubstitutionOptions.Count; tIndex++)
{
<text>
<optgroup label="@Model.AllocationsReassignmentPlan[pIndex].SubstitutionOptions[tIndex].TeamName">
@for (int rIndex = 0; rIndex < Model.AllocationsReassignmentPlan[pIndex].SubstitutionOptions[tIndex].Resources.Count; rIndex++)
{
<text>
<option value="@Model.AllocationsReassignmentPlan[pIndex].SubstitutionOptions[tIndex].Resources[rIndex].Value">@Model.AllocationsReassignmentPlan[pIndex].SubstitutionOptions[tIndex].Resources[rIndex].Text</option>
</text>
}
</optgroup>
</text>
}
</select>
</div>
</div>
</div>
</div>
</text>
}
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" id="btn-reassignResource">Ok</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
</div>
</form>