144 lines
4.7 KiB
Plaintext
144 lines
4.7 KiB
Plaintext
@using EnVisage.Code
|
|
@using EnVisage.Code.HtmlHelpers
|
|
@using EnVisage.Models
|
|
@model ScenarioCopyModel
|
|
|
|
|
|
<script type="text/javascript">
|
|
var _copytoDataChanged = false;
|
|
function onCTDataChanged() {
|
|
_copytoDataChanged = true;
|
|
}
|
|
function resetCTDataChanged() {
|
|
_copytoDataChanged = false;
|
|
}
|
|
function isCTDataChanged() {
|
|
return _copytoDataChanged;
|
|
}
|
|
function switchStatusCB() {
|
|
var status = $("#@Html.ClientIdFor(x=>x.TargetStatus)").val();
|
|
if (status == "Active")
|
|
$("#@Html.ClientIdFor(x=>x.TargetStatus)").val("Inactive");
|
|
else
|
|
$("#@Html.ClientIdFor(x=>x.TargetStatus)").val("Active");
|
|
}
|
|
function switchCostSavingsCB() {
|
|
|
|
var status = $("#@Html.ClientIdFor(x=>x.includeCostSavings)").val();
|
|
if (status == "true")
|
|
$("#@Html.ClientIdFor(x=>x.includeCostSavings)").val(false);
|
|
else
|
|
$("#@Html.ClientIdFor(x=>x.includeCostSavings)").val(true);
|
|
}
|
|
|
|
init.push(function () {
|
|
initControls();
|
|
$('#copyToForm').find('input[type=checkbox],input[type=text],select,textarea').on("change", function () {
|
|
if (typeof onCTDataChanged === 'function')
|
|
onCTDataChanged();
|
|
});
|
|
});
|
|
|
|
function initControls() {
|
|
|
|
$("#@Html.ClientIdFor(model => model.TargetProjectId)").select2({
|
|
allowClear: true
|
|
}).on('select2-selecting', function (e) {
|
|
var $select = $(this);
|
|
if (e.val == '') {
|
|
e.preventDefault();
|
|
}
|
|
});
|
|
|
|
$('#chStatus').switcher({
|
|
on_state_content: 'Active',
|
|
off_state_content: 'Inactive'
|
|
});
|
|
$('#chStatus').parent().css("width", "90px");
|
|
|
|
|
|
$('#includeSav').switcher({
|
|
on_state_content: "Include",
|
|
off_state_content: "Exclude"
|
|
});
|
|
$('#includeSav').parent().css("width", "90px");
|
|
}
|
|
|
|
function CheckSelection() {
|
|
return true;
|
|
}
|
|
|
|
</script>
|
|
|
|
@using (Ajax.BeginForm("CopyTo", "Scenario", new AjaxOptions { HttpMethod = "Post", OnSuccess = "onCopyToSuccess", OnFailure = "onCopyToFailure", UpdateTargetId = "copyToModal", OnBegin = "return CheckSelection();" }, new { @id = "copyToForm" }))
|
|
{
|
|
<div class="modal-header">
|
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button>
|
|
<h4 class="modal-title">Copy To</h4>
|
|
</div>
|
|
<div class="modal-body" style="max-height:400px;overflow-y:auto;">
|
|
@Html.ValidationSummary(false, "The Scenario could not be copied due to the following errors:")
|
|
|
|
@Html.HiddenFor(model => model.ScenarioId)
|
|
@Html.HiddenFor(model => model.TargetStatus)
|
|
@Html.HiddenFor(model => model.includeCostSavings)
|
|
<div class="panel-body" style="border: 0;" id="copy-to-body">
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<div class="form-group no-margin-hr">
|
|
<div style="float:left;margin:3px 3px 10px 0px;">Copy as </div><input type="checkbox" onclick="switchStatusCB();" id="chStatus" name="chStatus" class="switcher" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row" style="display:@(Model.hasCostSavings? "block" : "none")">
|
|
<div class="col-sm-12">
|
|
<div class="form-group no-margin-hr">
|
|
<div style="float:left;margin:3px 3px 10px 0px;">Cost Savings </div>
|
|
<input type="checkbox" onclick="switchCostSavingsCB();" id="includeSav" name="includeSav" class="switcher" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<div class="form-group no-margin-hr">
|
|
@Html.LabelFor(model => model.TargetProjectId, new { @class = "control-label" })
|
|
<select class="form-control forselect2 type" data-val="true" data-val-required="Target Project is required." id="@Html.IdFor(m => m.TargetProjectId)" name="@EnVisage.Code.HtmlHelpers.HtmlExtensions.NameFor(Html, m => m.TargetProjectId)">
|
|
@{
|
|
bool openGroup = false;
|
|
foreach (var project in Utils.GetProjectsToScenarioCopy(Model.TargetProjectId, User.Identity.Name))
|
|
{
|
|
if (project.Value == "")
|
|
{
|
|
if (openGroup)
|
|
{
|
|
@Html.Raw("</optgroup>");
|
|
openGroup = false;
|
|
}
|
|
<text>
|
|
<optgroup label="@project.Text">
|
|
</text>
|
|
openGroup = true;
|
|
}
|
|
else
|
|
{
|
|
<text>
|
|
<option value="@project.Value">@project.Text</option>
|
|
</text>
|
|
}
|
|
}
|
|
}
|
|
</select>
|
|
@Html.ValidationMessageFor(model => model.TargetProjectId)
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div> <!-- / .modal-body -->
|
|
<div class="modal-footer">
|
|
<button type="submit" class="btn btn-primary" id="btnCopySubmit">OK</button>
|
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
|
<div class="spinner" style="display:none"></div>
|
|
</div>
|
|
} |