security: use more antiforgery tokens
This commit is contained in:
@@ -185,7 +185,7 @@
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('__RequestVerificationToken', self.$host.find('input[name="__RequestVerificationToken"]').val());
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
const result = await fetch(onlineUploadUrl, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
@@ -359,7 +359,7 @@
|
||||
.append($('<span>').text('Uploading: ' + fileName))
|
||||
.appendTo(self.uploadProgressContainer);
|
||||
|
||||
formData.append('__RequestVerificationToken', self.$host.find('input[name="__RequestVerificationToken"]').val());
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
formData.append('comments', comments);
|
||||
formData.append('file', fileData, fileName);
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
+2
-2
@@ -185,7 +185,7 @@
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('__RequestVerificationToken', self.$host.find('input[name="__RequestVerificationToken"]').val());
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
const result = await fetch(onlineUploadUrl, {
|
||||
method: 'POST',
|
||||
body: formData
|
||||
@@ -359,7 +359,7 @@
|
||||
.append($('<span>').text('Uploading: ' + fileName))
|
||||
.appendTo(self.uploadProgressContainer);
|
||||
|
||||
formData.append('__RequestVerificationToken', self.$host.find('input[name="__RequestVerificationToken"]').val());
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
formData.append('comments', comments);
|
||||
formData.append('file', fileData, fileName);
|
||||
|
||||
|
||||
@@ -13,30 +13,25 @@
|
||||
let lastTemplateId = null;
|
||||
|
||||
const downloadPdf = function (templateId) {
|
||||
|
||||
let url;
|
||||
if (templateId.lastIndexOf('Package:', 0) === 0)
|
||||
url = generatePackageUrl + templateId.substring(8);
|
||||
else
|
||||
url = generatePdfUrl + templateId;
|
||||
url = url + '?TargetId=' + targetId;
|
||||
|
||||
if ($.connection && $.connection.hub && $.connection.hub.transport &&
|
||||
$.connection.hub.transport.name == 'foreverFrame') {
|
||||
// SignalR active with foreverFrame transport - use popup window
|
||||
window.open(url, '_blank', 'height=150,width=250,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
|
||||
} else {
|
||||
// use iFrame
|
||||
if (!$generationHost) {
|
||||
$generationHost = $('<iframe>')
|
||||
.attr({ 'src': url, 'title': 'Document Generation Host' })
|
||||
.addClass('hidden')
|
||||
.appendTo('body')
|
||||
.contents();
|
||||
} else {
|
||||
$generationHost[0].location.href = url;
|
||||
}
|
||||
let action = generatePdfUrl;
|
||||
if (templateId.lastIndexOf('Package:', 0) === 0) {
|
||||
templateId + templateId.substring(8);
|
||||
action = generatePackageUrl;
|
||||
}
|
||||
|
||||
if (!$generationHost) {
|
||||
$generationHost = $('<iframe>')
|
||||
.attr('title', 'Document Generation Host')
|
||||
.addClass('hidden')
|
||||
.appendTo('body')
|
||||
.contents();
|
||||
$generationHost[0].body.innerHTML = '<form method="post"><input type="hidden" name="__RequestVerificationToken" value="' + document.body.dataset.antiforgery + '"><input type="hidden" name="id"><input type="hidden" name="targetId"></form>';
|
||||
}
|
||||
const form = $generationHost[0].forms[0];
|
||||
form.action = action;
|
||||
form.id.value = templateId;
|
||||
form.targetId.value = targetId;
|
||||
form.submit();
|
||||
}
|
||||
|
||||
const updateHandlers = function (templateId) {
|
||||
@@ -47,6 +42,7 @@
|
||||
$loadingUi.show();
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
formData.append('templateId', decodeURI(templateId));
|
||||
formData.append('targetId', decodeURI(targetId));
|
||||
fetch(handlersUrl, {
|
||||
@@ -59,7 +55,7 @@
|
||||
$('<div class="handler">').text(h.Title).attr({
|
||||
'data-id': h.Id,
|
||||
'data-uiurl': h.UiUrl
|
||||
}).prepend($('<i class="fa fa-fw fa-lg">').addClass('fa-'+h.Icon)).appendTo($handlerPicker);
|
||||
}).prepend($('<i class="fa fa-fw fa-lg">').addClass('fa-' + h.Icon)).appendTo($handlerPicker);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -106,7 +102,12 @@
|
||||
$Document_Generation_Dialog_HandlerUI.empty();
|
||||
$Document_Generation_Dialog_HandlerUI.show();
|
||||
const uiurl = $this.attr('data-uiurl');
|
||||
fetch(uiurl, { method: 'POST' })
|
||||
const formData = new FormData();
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
fetch(uiurl, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
.then(r => r.text())
|
||||
.then(html => {
|
||||
$Document_Generation_Dialog_HandlerUI.html(html);
|
||||
|
||||
@@ -1 +1 @@
|
||||
(function(n,t,i){i(function(){let f=null;const r=i("#Document_Generation_Container"),u=r.find("#Document_Generate"),e=r.attr("data-targetid"),y=r.attr("data-targettype"),h=r.attr("data-generatepdfurl"),c=r.attr("data-generatepackageurl"),l=r.attr("data-handlerspresent")==="true",a=r.attr("data-handlersurl");let t=null,o=null;const s=function(t){let r;r=t.lastIndexOf("Package:",0)===0?c+t.substring(8):h+t;r=r+"?TargetId="+e;i.connection&&i.connection.hub&&i.connection.hub.transport&&i.connection.hub.transport.name=="foreverFrame"?n.open(r,"_blank","height=150,width=250,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no"):f?f[0].location.href=r:f=i("<iframe>").attr({src:r,title:"Document Generation Host"}).addClass("hidden").appendTo("body").contents()},v=function(n){const u=t.find(".handlerPicker"),f=t.find("#Document_Generation_Dialog_Handlers_Loading");u.find("div.handler").remove();f.show();var r=new FormData;r.append("templateId",decodeURI(n));r.append("targetId",decodeURI(e));fetch(a,{method:"POST",body:r}).then(n=>n.json()).then(n=>{f.hide(),i.each(n.Handlers,(n,t)=>{i('<div class="handler">').text(t.Title).attr({"data-id":t.Id,"data-uiurl":t.UiUrl}).prepend(i('<i class="fa fa-fw fa-lg">').addClass("fa-"+t.Icon)).appendTo(u)})})};u.change(function(){var n=u.val();if(n){if(o=n,l){if(!t){t=r.find("#Document_Generation_Dialog");t.dialog({width:750,height:500,resizable:!1,modal:!0,autoOpen:!1,buttons:{Cancel:function(){i(this).dialog("close")}}});t.find("#Document_Generation_Dialog_Download").click(n=>(n.preventDefault(),s(o),t.dialog("close"),!1));const u=t.find(".handlerPicker"),f=t.find("#Document_Generation_Dialog_Download_Container"),n=t.find("#Document_Generation_Dialog_HandlerUI");u.on("click","div[data-id]",t=>{u.find("div").removeClass("selected");const r=i(t.currentTarget);r.addClass("selected");const e=r.attr("data-id");if(e==="download")f.show(),n.hide(),n.empty();else{f.hide();n.empty();n.show();const t=r.attr("data-uiurl");fetch(t,{method:"POST"}).then(n=>n.text()).then(t=>{n.html(t)})}})}const f=t.find(".handlerPicker"),h=t.find("#Document_Generation_Dialog_Download_Container"),e=t.find("#Document_Generation_Dialog_HandlerUI");f.find("div").removeClass("selected");f.find("div[data-id=download]").addClass("selected");h.show();e.hide();e.empty();t.dialog("option","title","Generate Document: "+u[0].selectedOptions[0].label);t.dialog("open");v(n)}else s(n);u.val("").blur()}})})})(window,document,$);
|
||||
(function(n,t,i){i(function(){let u=null;const r=i("#Document_Generation_Container"),f=r.find("#Document_Generate"),e=r.attr("data-targetid"),y=r.attr("data-targettype"),h=r.attr("data-generatepdfurl"),c=r.attr("data-generatepackageurl"),l=r.attr("data-handlerspresent")==="true",a=r.attr("data-handlersurl");let n=null,o=null;const s=function(n){let f=h;n.lastIndexOf("Package:",0)===0&&(n+n.substring(8),f=c);u||(u=i("<iframe>").attr("title","Document Generation Host").addClass("hidden").appendTo("body").contents(),u[0].body.innerHTML='<form method="post"><input type="hidden" name="__RequestVerificationToken" value="'+t.body.dataset.antiforgery+'"><input type="hidden" name="id"><input type="hidden" name="targetId"><\/form>');const r=u[0].forms[0];r.action=f;r.id.value=n;r.targetId.value=e;r.submit()},v=function(r){const f=n.find(".handlerPicker"),o=n.find("#Document_Generation_Dialog_Handlers_Loading");f.find("div.handler").remove();o.show();var u=new FormData;u.append("__RequestVerificationToken",t.body.dataset.antiforgery);u.append("templateId",decodeURI(r));u.append("targetId",decodeURI(e));fetch(a,{method:"POST",body:u}).then(n=>n.json()).then(n=>{o.hide(),i.each(n.Handlers,(n,t)=>{i('<div class="handler">').text(t.Title).attr({"data-id":t.Id,"data-uiurl":t.UiUrl}).prepend(i('<i class="fa fa-fw fa-lg">').addClass("fa-"+t.Icon)).appendTo(f)})})};f.change(function(){var u=f.val();if(u){if(o=u,l){if(!n){n=r.find("#Document_Generation_Dialog");n.dialog({width:750,height:500,resizable:!1,modal:!0,autoOpen:!1,buttons:{Cancel:function(){i(this).dialog("close")}}});n.find("#Document_Generation_Dialog_Download").click(t=>(t.preventDefault(),s(o),n.dialog("close"),!1));const f=n.find(".handlerPicker"),e=n.find("#Document_Generation_Dialog_Download_Container"),u=n.find("#Document_Generation_Dialog_HandlerUI");f.on("click","div[data-id]",n=>{f.find("div").removeClass("selected");const r=i(n.currentTarget);r.addClass("selected");const o=r.attr("data-id");if(o==="download")e.show(),u.hide(),u.empty();else{e.hide();u.empty();u.show();const i=r.attr("data-uiurl"),n=new FormData;n.append("__RequestVerificationToken",t.body.dataset.antiforgery);fetch(i,{method:"POST",body:n}).then(n=>n.text()).then(n=>{u.html(n)})}})}const e=n.find(".handlerPicker"),c=n.find("#Document_Generation_Dialog_Download_Container"),h=n.find("#Document_Generation_Dialog_HandlerUI");e.find("div").removeClass("selected");e.find("div[data-id=download]").addClass("selected");c.show();h.hide();h.empty();n.dialog("option","title","Generate Document: "+f[0].selectedOptions[0].label);n.dialog("open");v(u)}else s(u);f.val("").blur()}})})})(window,document,$);
|
||||
+26
-25
@@ -13,30 +13,25 @@
|
||||
let lastTemplateId = null;
|
||||
|
||||
const downloadPdf = function (templateId) {
|
||||
|
||||
let url;
|
||||
if (templateId.lastIndexOf('Package:', 0) === 0)
|
||||
url = generatePackageUrl + templateId.substring(8);
|
||||
else
|
||||
url = generatePdfUrl + templateId;
|
||||
url = url + '?TargetId=' + targetId;
|
||||
|
||||
if ($.connection && $.connection.hub && $.connection.hub.transport &&
|
||||
$.connection.hub.transport.name == 'foreverFrame') {
|
||||
// SignalR active with foreverFrame transport - use popup window
|
||||
window.open(url, '_blank', 'height=150,width=250,location=no,menubar=no,resizable=no,scrollbars=no,status=no,toolbar=no');
|
||||
} else {
|
||||
// use iFrame
|
||||
if (!$generationHost) {
|
||||
$generationHost = $('<iframe>')
|
||||
.attr({ 'src': url, 'title': 'Document Generation Host' })
|
||||
.addClass('hidden')
|
||||
.appendTo('body')
|
||||
.contents();
|
||||
} else {
|
||||
$generationHost[0].location.href = url;
|
||||
}
|
||||
let action = generatePdfUrl;
|
||||
if (templateId.lastIndexOf('Package:', 0) === 0) {
|
||||
templateId + templateId.substring(8);
|
||||
action = generatePackageUrl;
|
||||
}
|
||||
|
||||
if (!$generationHost) {
|
||||
$generationHost = $('<iframe>')
|
||||
.attr('title', 'Document Generation Host')
|
||||
.addClass('hidden')
|
||||
.appendTo('body')
|
||||
.contents();
|
||||
$generationHost[0].body.innerHTML = '<form method="post"><input type="hidden" name="__RequestVerificationToken" value="' + document.body.dataset.antiforgery + '"><input type="hidden" name="id"><input type="hidden" name="targetId"></form>';
|
||||
}
|
||||
const form = $generationHost[0].forms[0];
|
||||
form.action = action;
|
||||
form.id.value = templateId;
|
||||
form.targetId.value = targetId;
|
||||
form.submit();
|
||||
}
|
||||
|
||||
const updateHandlers = function (templateId) {
|
||||
@@ -47,6 +42,7 @@
|
||||
$loadingUi.show();
|
||||
|
||||
var formData = new FormData();
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
formData.append('templateId', decodeURI(templateId));
|
||||
formData.append('targetId', decodeURI(targetId));
|
||||
fetch(handlersUrl, {
|
||||
@@ -59,7 +55,7 @@
|
||||
$('<div class="handler">').text(h.Title).attr({
|
||||
'data-id': h.Id,
|
||||
'data-uiurl': h.UiUrl
|
||||
}).prepend($('<i class="fa fa-fw fa-lg">').addClass('fa-'+h.Icon)).appendTo($handlerPicker);
|
||||
}).prepend($('<i class="fa fa-fw fa-lg">').addClass('fa-' + h.Icon)).appendTo($handlerPicker);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -106,7 +102,12 @@
|
||||
$Document_Generation_Dialog_HandlerUI.empty();
|
||||
$Document_Generation_Dialog_HandlerUI.show();
|
||||
const uiurl = $this.attr('data-uiurl');
|
||||
fetch(uiurl, { method: 'POST' })
|
||||
const formData = new FormData();
|
||||
formData.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
fetch(uiurl, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
})
|
||||
.then(r => r.text())
|
||||
.then(html => {
|
||||
$Document_Generation_Dialog_HandlerUI.html(html);
|
||||
|
||||
@@ -24,24 +24,34 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
|
||||
fieldValue = changedValue;
|
||||
if (fieldChangeToken)
|
||||
window.clearTimeout(fieldChangeToken);
|
||||
fieldChangeToken = window.setTimeout(function () {
|
||||
fieldChangeToken = window.setTimeout(async function () {
|
||||
$ajaxLoading.show();
|
||||
if (!data) {
|
||||
data = {};
|
||||
}
|
||||
data[updatePropertyName] = fieldValue;
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
|
||||
$.getJSON(updateUrl, data, function (response, result) {
|
||||
if (result != 'success' || response != 'OK') {
|
||||
alert('Unable to change property "' + updatePropertyName + '":\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
if (!data) {
|
||||
for (const prop in data) {
|
||||
body.append(prop, data[prop]);
|
||||
}
|
||||
}).fail(function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to change property "' + updatePropertyName + '":\n' + errorThrown);
|
||||
}
|
||||
body.append(updatePropertyName, fieldValue);
|
||||
|
||||
try {
|
||||
const response = await fetch(updateUrl, {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to change property "' + updatePropertyName + '":\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Unable to change property "' + updatePropertyName + '":\n' + e);
|
||||
$ajaxLoading.hide();
|
||||
})
|
||||
}
|
||||
fieldChangeToken = null;
|
||||
}, 500);
|
||||
};
|
||||
@@ -59,11 +69,11 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
|
||||
$(this).blur();
|
||||
}
|
||||
})
|
||||
.blur(function () {
|
||||
$ajaxSave.hide();
|
||||
}).focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
.blur(function () {
|
||||
$ajaxSave.hide();
|
||||
}).focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
if (fieldWatermark) {
|
||||
propertyField.watermark(fieldWatermark);
|
||||
}
|
||||
@@ -91,19 +101,31 @@ if (!document.DiscoFunctions.DateChangeUserHelper) {
|
||||
dateFieldValue = dateText;
|
||||
if (dateFieldChangeToken)
|
||||
window.clearTimeout(dateFieldChangeToken);
|
||||
dateFieldChangeToken = window.setTimeout(function () {
|
||||
dateFieldChangeToken = window.setTimeout(async function () {
|
||||
$ajaxLoading.show();
|
||||
var data = {};
|
||||
data[UpdatePropertyName] = dateFieldValue;
|
||||
$.getJSON(UpdateUrl, data, function (response, result) {
|
||||
if (result != 'success' || response.Result != 'OK') {
|
||||
alert('Unable to change Date:\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
UserField.text('by ' + response.UserDescription);
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append(UpdatePropertyName, dateFieldValue);
|
||||
|
||||
try {
|
||||
const response = await fetch(UpdateUrl, {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
|
||||
UserField.text('by ' + result.UserDescription);
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to change Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
alert('Unable to change Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
dateFieldChangeToken = null;
|
||||
}, 500);
|
||||
}
|
||||
@@ -157,18 +179,30 @@ if (!document.DiscoFunctions.DateChangeHelper) {
|
||||
dateFieldValue = dateText;
|
||||
if (dateFieldChangeToken)
|
||||
window.clearTimeout(dateFieldChangeToken);
|
||||
dateFieldChangeToken = window.setTimeout(function () {
|
||||
dateFieldChangeToken = window.setTimeout(async function () {
|
||||
$ajaxLoading.show();
|
||||
var data = {};
|
||||
data[UpdatePropertyName] = dateFieldValue;
|
||||
$.getJSON(UpdateUrl, data, function (response, result) {
|
||||
if (result != 'success' || response != 'OK') {
|
||||
alert('Unable to change Date:\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append(UpdatePropertyName, dateFieldValue);
|
||||
|
||||
try {
|
||||
const response = await fetch(UpdateUrl, {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to change Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
alert('Unable to change Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
|
||||
dateFieldChangeToken = null;
|
||||
}, 500);
|
||||
}
|
||||
@@ -209,8 +243,7 @@ if (!document.DiscoFunctions.DateChangeHelper) {
|
||||
|
||||
};
|
||||
}
|
||||
if (!document.DiscoFunctions.DateDialogCreateUpdater)
|
||||
{
|
||||
if (!document.DiscoFunctions.DateDialogCreateUpdater) {
|
||||
var dialog, dialogForm, dialogHeader, dialogDateBox, dialogDatePropertyNameBox;
|
||||
var updateUrl, friendlyName, dateField, userField, updatePropertyName, notSetDisplay, minDate, useAjax;
|
||||
|
||||
@@ -229,7 +262,9 @@ if (!document.DiscoFunctions.DateDialogCreateUpdater)
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Update": dateDialogUpdate,
|
||||
"Update": function () {
|
||||
dateDialogUpdate();
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
@@ -249,7 +284,7 @@ if (!document.DiscoFunctions.DateDialogCreateUpdater)
|
||||
return dialog;
|
||||
}
|
||||
|
||||
function dateDialogUpdate() {
|
||||
async function dateDialogUpdate() {
|
||||
var dateValue = dialogDateBox.val();
|
||||
|
||||
if (useAjax) {
|
||||
@@ -263,20 +298,25 @@ if (!document.DiscoFunctions.DateDialogCreateUpdater)
|
||||
|
||||
var $ajaxLoading = ($userField ? $userField.next('.ajaxLoading') : $dateField.next('.ajaxLoading')).show();
|
||||
|
||||
var data = {
|
||||
key: updatePropertyName,
|
||||
value: dateValue
|
||||
};
|
||||
$.getJSON(updateUrl, data, function (response, result) {
|
||||
if (result != 'success' || response.Result != 'OK') {
|
||||
alert('Unable to change ' + friendlyName + ' Date:\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
if (response.DateTimeFull) {
|
||||
$dateField.attr('data-isodate', response.DateTimeISO8601)
|
||||
.attr('data-livestamp', response.DateTimeUnixEpoc)
|
||||
.attr('title', response.DateTimeFull)
|
||||
.text(response.DateTimeFriendly);
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append('key', updatePropertyName);
|
||||
body.append('value', dateValue);
|
||||
|
||||
try {
|
||||
const response = await fetch(updateUrl, {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
|
||||
if (result.DateTimeFull) {
|
||||
$dateField.attr('data-isodate', result.DateTimeISO8601)
|
||||
.attr('data-livestamp', result.DateTimeUnixEpoc)
|
||||
.attr('title', result.DateTimeFull)
|
||||
.text(result.DateTimeFriendly);
|
||||
} else {
|
||||
$dateField.attr('data-isodate', '')
|
||||
.attr('data-livestamp', '-1')
|
||||
@@ -284,10 +324,16 @@ if (!document.DiscoFunctions.DateDialogCreateUpdater)
|
||||
.text(notSetDisplay);
|
||||
}
|
||||
if ($userField)
|
||||
$userField.text('by ' + response.UserDescription);
|
||||
$userField.text('by ' + result.UserDescription);
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to change ' + friendlyName + ' Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
alert('Unable to change ' + friendlyName + ' Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
} else {
|
||||
// Post Form & Redirect
|
||||
dialog.dialog("disable");
|
||||
|
||||
File diff suppressed because one or more lines are too long
+104
-58
@@ -24,24 +24,34 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
|
||||
fieldValue = changedValue;
|
||||
if (fieldChangeToken)
|
||||
window.clearTimeout(fieldChangeToken);
|
||||
fieldChangeToken = window.setTimeout(function () {
|
||||
fieldChangeToken = window.setTimeout(async function () {
|
||||
$ajaxLoading.show();
|
||||
if (!data) {
|
||||
data = {};
|
||||
}
|
||||
data[updatePropertyName] = fieldValue;
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
|
||||
$.getJSON(updateUrl, data, function (response, result) {
|
||||
if (result != 'success' || response != 'OK') {
|
||||
alert('Unable to change property "' + updatePropertyName + '":\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
if (!data) {
|
||||
for (const prop in data) {
|
||||
body.append(prop, data[prop]);
|
||||
}
|
||||
}).fail(function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to change property "' + updatePropertyName + '":\n' + errorThrown);
|
||||
}
|
||||
body.append(updatePropertyName, fieldValue);
|
||||
|
||||
try {
|
||||
const response = await fetch(updateUrl, {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to change property "' + updatePropertyName + '":\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
} catch (e) {
|
||||
alert('Unable to change property "' + updatePropertyName + '":\n' + e);
|
||||
$ajaxLoading.hide();
|
||||
})
|
||||
}
|
||||
fieldChangeToken = null;
|
||||
}, 500);
|
||||
};
|
||||
@@ -59,11 +69,11 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
|
||||
$(this).blur();
|
||||
}
|
||||
})
|
||||
.blur(function () {
|
||||
$ajaxSave.hide();
|
||||
}).focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
.blur(function () {
|
||||
$ajaxSave.hide();
|
||||
}).focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
if (fieldWatermark) {
|
||||
propertyField.watermark(fieldWatermark);
|
||||
}
|
||||
@@ -91,19 +101,31 @@ if (!document.DiscoFunctions.DateChangeUserHelper) {
|
||||
dateFieldValue = dateText;
|
||||
if (dateFieldChangeToken)
|
||||
window.clearTimeout(dateFieldChangeToken);
|
||||
dateFieldChangeToken = window.setTimeout(function () {
|
||||
dateFieldChangeToken = window.setTimeout(async function () {
|
||||
$ajaxLoading.show();
|
||||
var data = {};
|
||||
data[UpdatePropertyName] = dateFieldValue;
|
||||
$.getJSON(UpdateUrl, data, function (response, result) {
|
||||
if (result != 'success' || response.Result != 'OK') {
|
||||
alert('Unable to change Date:\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
UserField.text('by ' + response.UserDescription);
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append(UpdatePropertyName, dateFieldValue);
|
||||
|
||||
try {
|
||||
const response = await fetch(UpdateUrl, {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
|
||||
UserField.text('by ' + result.UserDescription);
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to change Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
alert('Unable to change Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
dateFieldChangeToken = null;
|
||||
}, 500);
|
||||
}
|
||||
@@ -157,18 +179,30 @@ if (!document.DiscoFunctions.DateChangeHelper) {
|
||||
dateFieldValue = dateText;
|
||||
if (dateFieldChangeToken)
|
||||
window.clearTimeout(dateFieldChangeToken);
|
||||
dateFieldChangeToken = window.setTimeout(function () {
|
||||
dateFieldChangeToken = window.setTimeout(async function () {
|
||||
$ajaxLoading.show();
|
||||
var data = {};
|
||||
data[UpdatePropertyName] = dateFieldValue;
|
||||
$.getJSON(UpdateUrl, data, function (response, result) {
|
||||
if (result != 'success' || response != 'OK') {
|
||||
alert('Unable to change Date:\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append(UpdatePropertyName, dateFieldValue);
|
||||
|
||||
try {
|
||||
const response = await fetch(UpdateUrl, {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to change Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
alert('Unable to change Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
|
||||
dateFieldChangeToken = null;
|
||||
}, 500);
|
||||
}
|
||||
@@ -209,8 +243,7 @@ if (!document.DiscoFunctions.DateChangeHelper) {
|
||||
|
||||
};
|
||||
}
|
||||
if (!document.DiscoFunctions.DateDialogCreateUpdater)
|
||||
{
|
||||
if (!document.DiscoFunctions.DateDialogCreateUpdater) {
|
||||
var dialog, dialogForm, dialogHeader, dialogDateBox, dialogDatePropertyNameBox;
|
||||
var updateUrl, friendlyName, dateField, userField, updatePropertyName, notSetDisplay, minDate, useAjax;
|
||||
|
||||
@@ -229,7 +262,9 @@ if (!document.DiscoFunctions.DateDialogCreateUpdater)
|
||||
modal: true,
|
||||
autoOpen: false,
|
||||
buttons: {
|
||||
"Update": dateDialogUpdate,
|
||||
"Update": function () {
|
||||
dateDialogUpdate();
|
||||
},
|
||||
Cancel: function () {
|
||||
$(this).dialog("close");
|
||||
}
|
||||
@@ -249,7 +284,7 @@ if (!document.DiscoFunctions.DateDialogCreateUpdater)
|
||||
return dialog;
|
||||
}
|
||||
|
||||
function dateDialogUpdate() {
|
||||
async function dateDialogUpdate() {
|
||||
var dateValue = dialogDateBox.val();
|
||||
|
||||
if (useAjax) {
|
||||
@@ -263,20 +298,25 @@ if (!document.DiscoFunctions.DateDialogCreateUpdater)
|
||||
|
||||
var $ajaxLoading = ($userField ? $userField.next('.ajaxLoading') : $dateField.next('.ajaxLoading')).show();
|
||||
|
||||
var data = {
|
||||
key: updatePropertyName,
|
||||
value: dateValue
|
||||
};
|
||||
$.getJSON(updateUrl, data, function (response, result) {
|
||||
if (result != 'success' || response.Result != 'OK') {
|
||||
alert('Unable to change ' + friendlyName + ' Date:\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
if (response.DateTimeFull) {
|
||||
$dateField.attr('data-isodate', response.DateTimeISO8601)
|
||||
.attr('data-livestamp', response.DateTimeUnixEpoc)
|
||||
.attr('title', response.DateTimeFull)
|
||||
.text(response.DateTimeFriendly);
|
||||
const body = new FormData();
|
||||
body.append('__RequestVerificationToken', document.body.dataset.antiforgery);
|
||||
body.append('key', updatePropertyName);
|
||||
body.append('value', dateValue);
|
||||
|
||||
try {
|
||||
const response = await fetch(updateUrl, {
|
||||
method: 'POST',
|
||||
body: body
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
const result = await response.json();
|
||||
|
||||
if (result.DateTimeFull) {
|
||||
$dateField.attr('data-isodate', result.DateTimeISO8601)
|
||||
.attr('data-livestamp', result.DateTimeUnixEpoc)
|
||||
.attr('title', result.DateTimeFull)
|
||||
.text(result.DateTimeFriendly);
|
||||
} else {
|
||||
$dateField.attr('data-isodate', '')
|
||||
.attr('data-livestamp', '-1')
|
||||
@@ -284,10 +324,16 @@ if (!document.DiscoFunctions.DateDialogCreateUpdater)
|
||||
.text(notSetDisplay);
|
||||
}
|
||||
if ($userField)
|
||||
$userField.text('by ' + response.UserDescription);
|
||||
$userField.text('by ' + result.UserDescription);
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
alert('Unable to change ' + friendlyName + ' Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
})
|
||||
} catch (e) {
|
||||
alert('Unable to change ' + friendlyName + ' Date:\n' + response.statusText);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
} else {
|
||||
// Post Form & Redirect
|
||||
dialog.dialog("disable");
|
||||
|
||||
Reference in New Issue
Block a user