140 lines
5.8 KiB
Plaintext
140 lines
5.8 KiB
Plaintext
@model EnVisage.Models.UserQuickLinkModel
|
|
@using EnVisage.Code.HtmlHelpers
|
|
@using EnVisage.Code
|
|
@{
|
|
ViewBag.Title = Model != null ? "Edit " + Model.Name : "Add QuickLink";
|
|
}
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
</script>
|
|
|
|
<script type="text/javascript">
|
|
var _qlDataChanged = false;
|
|
function onQLDataChanged() {
|
|
_qlDataChanged = true;
|
|
}
|
|
function resetQLDataChanged() {
|
|
_qlDataChanged = false;
|
|
}
|
|
function isQLDataChanged() {
|
|
return _qlDataChanged;
|
|
}
|
|
//init.push(function () {
|
|
function initQuickLink() {
|
|
|
|
StartEdit('UserQuickLink', '@Model.Id', "#btnDelete", "#btnsave", "erorMsgPlaceholder");
|
|
|
|
|
|
@if (Model.Id != Guid.Empty)
|
|
{
|
|
<text>
|
|
StartEdit('UserQuickLink', '@Model.Id', "#btnDelete", "#btnsave", "erorMsgPlaceholder");
|
|
</text>
|
|
}
|
|
else
|
|
{
|
|
<text>
|
|
console.log(document.title);
|
|
$('#editUserQuickLinkForm #Name').val(document.title.replace(' - Prevu', ''));
|
|
$('#@Html.ClientIdFor(m => m.UserId)').val('@User.Identity.GetID()');
|
|
var href = document.location.href;
|
|
if (href.substr(href.length - 1) == '#')
|
|
href = href.substr(0, href.length - 1);
|
|
href = URI(href).removeQuery("linkId");
|
|
$('#@Html.ClientIdFor(m => m.Url)').val(href);
|
|
var data = {};
|
|
$("*[data-section]").each(function (i, elem) {
|
|
var section = $(elem).attr('data-section');
|
|
data[section] = loadUserPreferences(section);
|
|
});
|
|
$('#@Html.ClientIdFor(m => m.PageState)').val(JSON.stringify(data));
|
|
</text>
|
|
}
|
|
|
|
$('#btnsave').click(function () {
|
|
if ($(this).parents('form').valid())
|
|
blockUI();
|
|
});
|
|
|
|
$('#editUserQuickLinkForm').find('input[type=checkbox],input[type=text],select,textarea').on("change", function () {
|
|
if (typeof onQLDataChanged === 'function')
|
|
onQLDataChanged();
|
|
});
|
|
$(document).ready(function () {
|
|
$.validator.unobtrusive.parse($(this));
|
|
|
|
});
|
|
}
|
|
|
|
function onFailure(xhr) {
|
|
unblockUI();
|
|
$('#editReload').html(xhr.responseText);
|
|
initQuickLink();
|
|
}
|
|
function onSuccess(data) {
|
|
unblockUI();
|
|
var href = document.location.href;
|
|
if (href.substr(href.length - 1) == '#')
|
|
href = href.substr(0, href.length - 1);
|
|
{
|
|
if ($('li #' + data.Id).length > 0)
|
|
{
|
|
var li = '<a href="javascript:void(\'' + data.Url + '\');">' +
|
|
'<span class="mm-text" title="' + data.Name + '" onclick="linkTo(event, \'' + data.Url + '\', \'' + data.Id + '\');">' + ((data.Name.length < 19) ? data.Name : data.Name.substring(0, 17) + "...") + '</span>' +
|
|
'<span class="label label-danger" onclick="LoadDeleteQLModal(\'' + data.Id + '\');"><i class="fa fa-trash-o"></i></span>' +
|
|
'<span class="label label-info" onclick="editQuickLink(event, \'@User.Identity.GetID()\', \'' + data.Id + '\');"><i class="fa fa-edit"></i></span>' +
|
|
'</a>';
|
|
$('li #' + data.Id).html(li);
|
|
$('#editQuickLink').modal('hide');
|
|
}
|
|
else if ($('#quicklinksContainer').length > 0) {
|
|
var li = '<li id=\'' + data.Id + '\'>' +
|
|
'<a href="javascript:void(\'' + data.Url + '\');">' +
|
|
'<span class="mm-text" title="' + data.Name + '" onclick="linkTo(event, \'' + data.Url + '\', \'' + data.Id + '\');">' + ((data.Name.length < 19) ? data.Name : data.Name.substring(0, 17) + "...") + '</span>' +
|
|
'<span class="label label-danger" onclick="LoadDeleteQLModal(\'' + data.Id + '\');"><i class="fa fa-trash-o"></i></span>' +
|
|
'<span class="label label-info" onclick="editQuickLink(event, \'@User.Identity.GetID()\', \'' + data.Id + '\');"><i class="fa fa-edit"></i></span>' +
|
|
'</a>' +
|
|
'</li>';
|
|
$('#quicklinksContainer').append(li);
|
|
$('#editQuickLink').modal('hide');
|
|
}
|
|
else document.location.href = href;
|
|
}
|
|
}
|
|
</script>
|
|
|
|
|
|
<div id="erorMsgPlaceholder"></div>
|
|
|
|
@using (Ajax.BeginForm("Edit", "UserQuickLink", new AjaxOptions { HttpMethod = "Post", OnSuccess = "onSuccess", OnFailure = "onFailure(xhr)", UpdateTargetId = "editReloadQL" }, new { @id = "editUserQuickLinkForm" }))
|
|
{
|
|
@Html.AntiForgeryToken()
|
|
@Html.HiddenFor(model => model.Id)
|
|
@Html.HiddenFor(model => model.UserId);
|
|
@Html.HiddenFor(model => model.Url);
|
|
@Html.HiddenFor(model => model.PageState);
|
|
<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 QuickLink")</h4>
|
|
</div>
|
|
<div class="modal-body">
|
|
<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>
|
|
@Html.ValidationSummary(false, "The Quick Link could not be saved due to the following errors:")
|
|
</div> <!-- / .modal-body -->
|
|
<div class="modal-footer">
|
|
<button type="submit" class="btn btn-success" id="btnsave"><i class="fa fa-save"></i> Save</button>
|
|
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
|
|
</div>
|
|
} |