136 lines
5.3 KiB
Plaintext
136 lines
5.3 KiB
Plaintext
@using EnVisage.Code
|
||
@model EnVisage.Models.CompanyModel
|
||
|
||
@{
|
||
ViewBag.Title = Model.Id != Guid.Empty ? "Edit " + Model.Name : "Add New Company";
|
||
var availableUsers = Utils.GetUsers(false);
|
||
}
|
||
|
||
@section Scripts
|
||
{
|
||
<script type="text/javascript">
|
||
emulateNavUrl = "/Company";
|
||
</script>
|
||
@if (Model.Id != Guid.Empty)
|
||
{
|
||
<script type="text/javascript">
|
||
init.push(function() {
|
||
StartEdit('Company', '@Model.Id', "#btnDelete", "#btnsave", "erorMsgPlaceholder");
|
||
@if (Model.ClientId != null)
|
||
{
|
||
foreach(var clientId in Model.ClientId)
|
||
{
|
||
@:$("#clientId_@clientId")[0].checked = true;
|
||
}
|
||
}
|
||
@if (Model.ViewId != null)
|
||
{
|
||
foreach (var viewId in Model.ViewId)
|
||
{
|
||
@:$("#ViewId_@viewId")[0].checked = true;
|
||
}
|
||
}
|
||
|
||
$('#@Html.IdFor(model => model.Watchers)').select2();
|
||
$('#@Html.IdFor(model => model.Contributors)').select2();
|
||
|
||
var selectedWatchersAsText = '@Model.WatchersAsText';
|
||
var selectedContributorsAsText = '@Model.ContributorsAsText';
|
||
|
||
var watchersAsArray = selectedWatchersAsText.split(',');
|
||
var contributorsAsArray = selectedContributorsAsText.split(',');
|
||
|
||
$('#@Html.IdFor(model => model.Watchers)').select2('val', watchersAsArray);
|
||
$('#@Html.IdFor(model => model.Contributors)').select2('val', contributorsAsArray);
|
||
|
||
$('#btnsave').buttonLocker({
|
||
click: saveCompany
|
||
});
|
||
$('#btnDelete').buttonLocker({
|
||
click: deleteCompany
|
||
});
|
||
});
|
||
|
||
function deleteCompany() {
|
||
blockUI();
|
||
var url = "@Url.Action("Delete", "Company", new {id = Model.Id})";
|
||
document.location.href = url;
|
||
}
|
||
|
||
function saveCompany() {
|
||
var form = $('#btnsave').parents('form');
|
||
|
||
if (form.valid()) {
|
||
blockUI();
|
||
form.submit();
|
||
}
|
||
}
|
||
</script>
|
||
}
|
||
}
|
||
|
||
<div id="erorMsgPlaceholder"></div>
|
||
|
||
@using (Html.BeginForm("Edit", "Company", FormMethod.Post, new { @class = "panel form-horizontal innerForm" }))
|
||
{
|
||
@Html.AntiForgeryToken()
|
||
@Html.HiddenFor(model => model.Id)
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||
<h4 class="modal-title">@ViewBag.Title</h4>
|
||
</div>
|
||
<div class="modal-body">
|
||
<div class="form-group">
|
||
@Html.LabelFor(model => model.Name, new { @class = "col-sm-2 control-label" })
|
||
<div class="col-sm-10">
|
||
@Html.TextBoxFor(model => model.Name, new { @class = "form-control", id = "IDDDD" })
|
||
@Html.ValidationMessageFor(model => model.Name)
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
@Html.LabelFor(model => model.ParentCompanyId, "Company", new { @class = "control-label col-sm-2" })
|
||
<div class="col-sm-10">
|
||
@Html.DropDownListFor(model => model.ParentCompanyId, Utils.GetParentCompanies(), new { @class = "form-control disabled" })
|
||
@Html.ValidationMessageFor(model => model.ParentCompanyId)
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">Clients</label>
|
||
<div class="col-sm-10">
|
||
@Html.Partial("_clients", Utils.GetClients())
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">Views</label>
|
||
<div class="col-sm-10">
|
||
@Html.Partial("_views", Utils.GetAllViews())
|
||
</div>
|
||
</div>
|
||
<div class="form-group select2-primary">
|
||
@Html.LabelFor(model => model.Watchers, new { @class = "col-sm-2 control-label" })
|
||
<div class="col-sm-10">
|
||
@Html.DropDownListFor(model => model.Watchers, availableUsers, new { @class = "form-control", @multiple = "multiple" })
|
||
</div>
|
||
</div>
|
||
<div class="form-group select2-primary">
|
||
@Html.LabelFor(model => model.Contributors, new { @class = "col-sm-2 control-label" })
|
||
<div class="col-sm-10">
|
||
@Html.DropDownListFor(model => model.Contributors, availableUsers, new { @class = "form-control", @multiple = "multiple" })
|
||
</div>
|
||
</div>
|
||
@Html.ValidationSummary(false, "The company could not be saved due to the following errors:")
|
||
<div class="modal-footer" style="margin-bottom: 0;">
|
||
<div class="col-sm-offset-2 col-sm-10">
|
||
@*<a class="btn btn-primary" href="@Url.Action("Index", "Company")"><i class="fa fa-backward"></i> Back to list</a>*@
|
||
<button type="button" class="btn btn-success" id="btnsave"><i class="fa fa-save"></i> Save</button>
|
||
@if ((Model != null) && (Model.Id != Guid.Empty) && ((Model.ProjectsCount + Model.CompaniesCount + Model.TeamsCount) < 1))
|
||
{
|
||
<button type="button" id="btnDelete" class="btn btn-danger disabled"><i class="fa fa-trash-o"></i> Delete</button>
|
||
}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
}
|