EnVisageOnline/Main/Source/EnVisage/Views/WorkWeek/_editWorkWeek.cshtml

137 lines
5.3 KiB
Plaintext

@model EnVisage.Models.WorkWeekModel
@{
ViewBag.Title = Model != null ? "Edit " + Model.Name : "Add Work Week";
}
<script type="text/javascript">
var _wwDataChanged = false;
function onWWDataChanged() {
_wwDataChanged = true;
}
function resetWWDataChanged() {
_wwDataChanged = false;
}
function isWWDataChanged() {
return _wwDataChanged;
}
emulateNavUrl = "/WorkWeek";
var isActive = @(Model.Id != Guid.Empty && Model.IsDefault ? "true" : "false");
function initWW() {
@{if (Model.Id != Guid.Empty)
{
<text>
StartEdit('WorkWeek', '@Model.Id', "#btnDelete", "#btnsave", "erorMsgPlaceholder");
if (isActive) {
$('#isDefaultCheckBox').prop('disabled', true);
}
</text>
}
}
if (isActive)
$('#isDefaultCheckBox').prop('checked', true);
else
$('#isDefaultCheckBox').removeProp('checked');
$('#editWWForm').find('input[type=checkbox],input[type=text],select,textarea').on("change", function () {
if (typeof onWWDataChanged === 'function')
onWWDataChanged();
});
$.validator.unobtrusive.parseDynamicContent('form#editWWForm');
}
function wwSetAsDefault(ctrl) {
if (isActive || !ctrl)
return;
var isChecked = $(ctrl).prop("checked");
$('#@(Html.IdFor(model => model.IsDefault))').val(isChecked);
if (isChecked)
$("#wwActivationWarningMessage").show();
else
$("#wwActivationWarningMessage").hide();
}
function onFailure(xhr) {
showErrorModal();
}
function onSuccess(result) {
handleAjaxResponse(result, function () {
var href = document.location.href;
if (href.substr(href.length - 1) == '#')
href = href.substr(0, href.length - 1);
document.location.href = href;
}, null, null, $('#editWWForm'));
}
</script>
@using (Ajax.BeginForm("Edit", "WorkWeek", new AjaxOptions { HttpMethod = "Post", OnBegin = "blockUI", OnSuccess = "onSuccess", OnFailure = "onFailure(xhr)", OnComplete = "unblockUI" }, new { id = "editWWForm" }))
{
@Html.AntiForgeryToken()
@Html.HiddenFor(t => t.Id)
@Html.HiddenFor(t => t.IsSystem)
@Html.HiddenFor(t => t.IsDefault)
<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 Work Week")</h4>
</div>
<div class="modal-body">
<div id="erorMsgPlaceholder"></div>
<div id="wwActivationWarningMessage" class="alert alert-warning" style="display:none;">
Reminder: This Work Week will be set as default for all new created resources
</div>
<div class="row">
<div class="col-sm-12">
<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>
<div class="row">
<div class="col-sm-6">
<div class="form-group no-margin-hr select2-primary">
@Html.CheckBoxFor(model => model.Monday)
@Html.LabelFor(model => model.Monday, new { @class = "control-label" })
<br />
@Html.CheckBoxFor(model => model.Tuesday)
@Html.LabelFor(model => model.Tuesday, new { @class = "control-label" })
<br />
@Html.CheckBoxFor(model => model.Wednesday)
@Html.LabelFor(model => model.Wednesday, new { @class = "control-label" })
<br />
@Html.CheckBoxFor(model => model.Thursday)
@Html.LabelFor(model => model.Thursday, new { @class = "control-label" })
</div>
</div>
<div class="col-sm-6 ">
<div class="form-group no-margin-hr">
@Html.CheckBoxFor(model => model.Friday)
@Html.LabelFor(model => model.Friday, new { @class = "control-label" })
<br />
@Html.CheckBoxFor(model => model.Saturday)
@Html.LabelFor(model => model.Saturday, new { @class = "control-label" })
<br />
@Html.CheckBoxFor(model => model.Sunday)
@Html.LabelFor(model => model.Sunday, new { @class = "control-label" })
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="form-group no-margin-hr">
<input name="isDefaultCheckBox" id="isDefaultCheckBox" onclick="wwSetAsDefault(this);" type="checkbox" data-val-required="The Make Default Work Week field is required." data-val="true" value="false" />
<label class="control-label" for="isDefaultCheckBox">Make Default Work Week</label>
</div>
</div>
</div>
@Html.ValidationSummary(false, "The Work Week could not be saved due to the following errors:")
</div> <!-- / .modal-body -->
<div class="modal-footer">
<button type="submit" class="btn btn-success"><i class="fa fa-save"></i>&nbsp;Save</button>
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
}