149 lines
6.7 KiB
Plaintext
149 lines
6.7 KiB
Plaintext
@model EnVisage.Models.UDFModel
|
|
@using EnVisage.Code
|
|
|
|
<script type="text/javascript">
|
|
var _saveSuccessCallbackFn;
|
|
function initUdf(callbackFn) {
|
|
|
|
$("#@Html.IdFor(model => model.Type)").select2({
|
|
placeholder: "Select Field Type"
|
|
});
|
|
$("#@Html.IdFor(model => model.DomainId)").select2({
|
|
placeholder: "Select area for field"
|
|
});
|
|
$('input.switcher').switcher({
|
|
on_state_content: 'Yes',
|
|
off_state_content: 'No'
|
|
}).parent().css("width", "80px");
|
|
|
|
@if (Model.Id != Guid.Empty)
|
|
{
|
|
<text>
|
|
StartEdit('UDF', '@Model.Id', null, "#btnsaveudf", "erorMsgPlaceholder");
|
|
</text>
|
|
}
|
|
$('#btnsaveudf').on('click', function () {
|
|
$.validator.unobtrusive.parseDynamicContent('#edit-udf-form');
|
|
var isValid = $('#edit-udf-form').valid();
|
|
if (isValid)
|
|
$('#edit-udf-form').submit();
|
|
});
|
|
$('#btnCancelUdf').on('click', function () {
|
|
|
|
onUdfCancel();
|
|
});
|
|
_saveSuccessCallbackFn = callbackFn;
|
|
}
|
|
function onUdfCancel() {
|
|
if (!!_saveSuccessCallbackFn && typeof _saveSuccessCallbackFn === 'function') {
|
|
_saveSuccessCallbackFn(null, callBackId);
|
|
return true;
|
|
} else {
|
|
closeEditUdfWindow();
|
|
unblockUI();
|
|
}
|
|
}
|
|
function onUdfEditSuccess(data) {
|
|
if (!!_saveSuccessCallbackFn && typeof _saveSuccessCallbackFn === 'function') {
|
|
_saveSuccessCallbackFn(data, callBackId);
|
|
return true;
|
|
} else {
|
|
closeEditUdfWindow();
|
|
refreshUdfs();
|
|
unblockUI();
|
|
}
|
|
}
|
|
function onUdfEditFailure(xhr) {
|
|
showErrorModal('Oops...', 'An error occurred while processing your request. Please, try again later.');
|
|
unblockUI();
|
|
}
|
|
</script>
|
|
<style>
|
|
textarea.description {
|
|
resize: none;
|
|
}
|
|
</style>
|
|
@using (Ajax.BeginForm("Edit", "UDF", new AjaxOptions { HttpMethod = "Post", Url = Url.Action("Edit", "UDF"), OnSuccess = "onUdfEditSuccess", OnFailure = "onUdfEditFailure", OnBegin = "blockUI" }, new { @class = "form-horizontal", @id = "edit-udf-form" }))
|
|
{
|
|
@Html.AntiForgeryToken()
|
|
@Html.HiddenFor(m => m.Id)
|
|
<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">@(Model.Id != Guid.Empty ? "Edit " + Model.Name : "Add User Defined Field")</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div id="erorMsgPlaceholder"></div>
|
|
<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.Label, new { @class = "control-label" })
|
|
@Html.TextBoxFor(model => model.Label, new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.Label)
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-sm-5">
|
|
<div class="form-group no-margin-hr select2-primary">
|
|
@Html.LabelFor(model => model.Type, new { @class = "control-label" })
|
|
@Html.DropDownListFor(model => model.Type, Utils.GetEnumList(typeof(UserDefinedFieldType), true), new { @class = "form-control forselect2" })
|
|
@Html.ValidationMessageFor(model => model.Type)
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-5">
|
|
<div class="form-group no-margin-hr select2-primary">
|
|
@Html.LabelFor(model => model.DomainId, new { @class = "control-label" })
|
|
@Html.DropDownListFor(model => model.DomainId, Utils.GetEnumList(typeof(UserDefinedFieldDomain), true), new { @class = "form-control forselect2" })
|
|
@Html.ValidationMessageFor(model => model.DomainId)
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-sm-3 ">
|
|
<div class="form-group no-margin-hr">
|
|
@Html.LabelFor(model => model.Status, new { @class = "control-label" })
|
|
@Html.CheckBoxFor(model => model.Status, new { @class = "switcher form-control" })
|
|
@Html.ValidationMessageFor(model => model.Status)
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-3 ">
|
|
<div class="form-group no-margin-hr">
|
|
@Html.LabelFor(model => model.Required, new { @class = "control-label" })
|
|
@Html.CheckBoxFor(model => model.Required, new { @class = "switcher form-control" })
|
|
@Html.ValidationMessageFor(model => model.Required)
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<div class="form-group no-margin-hr">
|
|
@Html.LabelFor(model => model.DefaultValue, new { @class = "control-label" })
|
|
@Html.TextBoxFor(model => model.DefaultValue, new { @class = "form-control" })
|
|
@Html.ValidationMessageFor(model => model.DefaultValue)
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col-sm-12">
|
|
<div class="form-group no-margin-hr">
|
|
@Html.LabelFor(model => model.Description, new { @class = "control-label" })
|
|
@Html.TextAreaFor(model => model.Description, new { @class = "form-control description" })
|
|
@Html.ValidationMessageFor(model => model.Description)
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@Html.ValidationSummary(false, "The User Defined Field could not be saved due to the following errors:")
|
|
</div> <!-- / .modal-body -->
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-success" id="btnsaveudf"><i class="fa fa-save"></i>Save</button>
|
|
<button type="button" class="btn btn-default" id="btnCancelUdf" data-dismiss="modal">Cancel</button>
|
|
</div>
|
|
</div>
|
|
}
|