bugs: minor
This commit is contained in:
1 parent
708ca16de8
commit
47e11c0fd6
5 files changed
+15
-6
No files matched your search
@@ -99,19 +99,19 @@ namespace Disco.Services
|
||||
switch (scope)
|
||||
{
|
||||
case AttachmentTypes.Device:
|
||||
var device = database.Devices.Find(targetId);
|
||||
var device = database.Devices.Include(d => d.AssignedUser).First(d => d.SerialNumber == targetId);
|
||||
targetUser = device?.AssignedUser;
|
||||
return device;
|
||||
case AttachmentTypes.Job:
|
||||
if (!int.TryParse(targetId, out var targetIdInt))
|
||||
throw new ArgumentOutOfRangeException(nameof(targetId));
|
||||
var job = database.Jobs.Find(targetIdInt);
|
||||
var job = database.Jobs.Include(j => j.User).First(j => j.Id == targetIdInt);
|
||||
targetUser = job?.User;
|
||||
return job;
|
||||
case AttachmentTypes.User:
|
||||
// special usecase in resolving users (they may not exist in the database yet)
|
||||
targetId = ActiveDirectory.ParseDomainAccountId(targetId);
|
||||
var user = database.Users.Find(targetId);
|
||||
var user = database.Users.First(u => u.UserId == targetId);
|
||||
if (user == null)
|
||||
{
|
||||
// try importing user
|
||||
|
||||
@@ -156,6 +156,7 @@ namespace Disco.Services.Plugins
|
||||
"Microsoft.Owin.Security",
|
||||
"Microsoft.Web.Infrastructure",
|
||||
"Newtonsoft.Json",
|
||||
"Newtonsoft.Json.Bson",
|
||||
"Owin",
|
||||
"PdfiumViewer",
|
||||
"PdfSharp",
|
||||
|
||||
@@ -8,7 +8,7 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
|
||||
}
|
||||
return propertyField.val();
|
||||
};
|
||||
document.DiscoFunctions.PropertyChangeHelper = function (propertyField, fieldWatermark, updateUrl, updatePropertyName, data) {
|
||||
document.DiscoFunctions.PropertyChangeHelper = function (propertyField, fieldWatermark, updateUrl, updatePropertyName, data, validator) {
|
||||
var fieldValue = document.DiscoFunctions.PropertyValue(propertyField);
|
||||
var fieldChangeToken = null;
|
||||
var $ajaxSave = propertyField.nextAll('.ajaxSave').first();
|
||||
@@ -17,6 +17,10 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
|
||||
$ajaxSave.hide();
|
||||
var changedValue = document.DiscoFunctions.PropertyValue(propertyField);
|
||||
if (fieldValue != changedValue) {
|
||||
if (validator && !validator(changedValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fieldValue = changedValue;
|
||||
if (fieldChangeToken)
|
||||
window.clearTimeout(fieldChangeToken);
|
||||
|
||||
@@ -1 +1 @@
|
||||
if(document.DiscoFunctions||(document.DiscoFunctions={}),document.DiscoFunctions.PropertyChangeHelper||(document.DiscoFunctions.PropertyValue=function(n){return n[0].nodeName.toLowerCase()=="input"&&n.attr("type")=="checkbox"?n.is(":checked"):n.val()},document.DiscoFunctions.PropertyChangeHelper=function(n,t,i,r,u){var s=document.DiscoFunctions.PropertyValue(n),e=null,f=n.nextAll(".ajaxSave").first(),o=n.nextAll(".ajaxLoading").first(),h=function(){f.hide();var t=document.DiscoFunctions.PropertyValue(n);s!=t&&(s=t,e&&window.clearTimeout(e),e=window.setTimeout(function(){o.show();u||(u={});u[r]=s;$.getJSON(i,u,function(n,t){t!="success"||n!="OK"?(alert('Unable to change property "'+r+'":\n'+n),o.hide()):o.hide().next(".ajaxOk").show().delay("fast").fadeOut("slow")}).fail(function(n,t,i){alert('Unable to change property "'+r+'":\n'+i);o.hide()});e=null},500))};n[0].nodeName.toLowerCase()=="input"&&n.attr("type")=="checkbox"?n.click(h):n.change(h);n[0].nodeName.toLowerCase()=="input"&&n.attr("type")=="text"&&(n.keydown(function(n){f.show();n.which==13&&$(this).blur()}).blur(function(){f.hide()}).focus(function(){$(this).select()}),t&&n.watermark(t));n[0].nodeName.toLowerCase()=="textarea"&&n.keydown(function(){f.show()}).blur(function(){f.hide()})}),document.DiscoFunctions.DateChangeUserHelper||(document.DiscoFunctions.DateChangeUserHelper=function(n,t,i,r,u,f,e){var s=n.val(),o=null,h=t.next(".ajaxLoading");n.watermark(i).change(function(){var i=n.val();s.toLowerCase()!=i.toLowerCase()&&(s=i,o&&window.clearTimeout(o),o=window.setTimeout(function(){h.show();var n={};n[u]=s;$.getJSON(r,n,function(n,i){i!="success"||n.Result!="OK"?(alert("Unable to change Date:\n"+n),h.hide()):(t.text("by "+n.UserDescription),h.hide().next(".ajaxOk").show().delay("fast").fadeOut("slow"))});o=null},500))}).focus(function(){$(this).select()});e?n.datepicker({defaultDate:new Date,minDate:moment(f).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datepicker("setDate",new Date)}}):n.datetimepicker({defaultDate:new Date,ampm:!0,minDate:moment(f).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datetimepicker("setDate",new Date)}})}),document.DiscoFunctions.DateChangeHelper||(document.DiscoFunctions.DateChangeHelper=function(n,t,i,r,u,f){var o=n.val(),e=null,s=n.next(".ajaxLoading");n.watermark(t).change(function(){var t=n.val();o.toLowerCase()!=t.toLowerCase()&&(o=t,e&&window.clearTimeout(e),e=window.setTimeout(function(){s.show();var n={};n[r]=o;$.getJSON(i,n,function(n,t){t!="success"||n!="OK"?(alert("Unable to change Date:\n"+n),s.hide()):s.hide().next(".ajaxOk").show().delay("fast").fadeOut("slow")});e=null},500))}).focus(function(){$(this).select()});f?n.datepicker({defaultDate:new Date,minDate:moment(u).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datepicker("setDate",new Date)}}):n.datetimepicker({defaultDate:new Date,ampm:!0,minDate:moment(u).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datetimepicker("setDate",new Date)}})}),!document.DiscoFunctions.DateDialogCreateUpdater){var dialog,dialogForm,dialogHeader,dialogDateBox,dialogDatePropertyNameBox,updateUrl,friendlyName,dateField,userField,updatePropertyName,notSetDisplay,minDate,useAjax;function dateDialogGet(){if(!dialog){dialog=$("<div>").attr({"class":"dialog"});dialogForm=$("<form>").attr({action:"/",method:"post"}).appendTo(dialog);var n=$("<p>").appendTo(dialogForm);dialogHeader=$("<h3>").attr("autofocus","autofocus").appendTo(n);dialogDatePropertyNameBox=$("<input>").attr({type:"hidden",name:"key"}).appendTo(n);dialogDateBox=$("<input>").attr({type:"datetime",name:"value"}).css({display:"block","margin-top":15,"margin-left":"auto","margin-right":"auto"}).appendTo(n);$("<input>").attr({type:"hidden",name:"redirect"}).val("true").appendTo(n);dialog.dialog({resizable:!1,modal:!0,autoOpen:!1,buttons:{Update:dateDialogUpdate,Cancel:function(){$(this).dialog("close")}},open:function(){dialog.dialog("widget").find(".ui-dialog-buttonpane :tabbable:first").focus()}});dialogDateBox.datetimepicker({defaultDate:new Date,ampm:!0,changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd"})}return dialog}function dateDialogUpdate(){var u=dialogDateBox.val(),t,n,i,r;useAjax?(t=$("#"+dateField),userField&&(n=$("#"+userField)),dialog.dialog("close"),i=(n?n.next(".ajaxLoading"):t.next(".ajaxLoading")).show(),r={key:updatePropertyName,value:u},$.getJSON(updateUrl,r,function(r,u){u!="success"||r.Result!="OK"?(alert("Unable to change "+friendlyName+" Date:\n"+r),i.hide()):(r.DateTimeFull?t.attr("data-isodate",r.DateTimeISO8601).attr("data-livestamp",r.DateTimeUnixEpoc).attr("title",r.DateTimeFull).text(r.DateTimeFriendly):t.attr("data-isodate","").attr("data-livestamp","-1").attr("title",notSetDisplay).text(notSetDisplay),n&&Line truncated
|
||||
if(document.DiscoFunctions||(document.DiscoFunctions={}),document.DiscoFunctions.PropertyChangeHelper||(document.DiscoFunctions.PropertyValue=function(n){return n[0].nodeName.toLowerCase()=="input"&&n.attr("type")=="checkbox"?n.is(":checked"):n.val()},document.DiscoFunctions.PropertyChangeHelper=function(n,t,i,r,u,f){var h=document.DiscoFunctions.PropertyValue(n),o=null,e=n.nextAll(".ajaxSave").first(),s=n.nextAll(".ajaxLoading").first(),c=function(){e.hide();var t=document.DiscoFunctions.PropertyValue(n);if(h!=t){if(f&&!f(t))return;h=t;o&&window.clearTimeout(o);o=window.setTimeout(function(){s.show();u||(u={});u[r]=h;$.getJSON(i,u,function(n,t){t!="success"||n!="OK"?(alert('Unable to change property "'+r+'":\n'+n),s.hide()):s.hide().next(".ajaxOk").show().delay("fast").fadeOut("slow")}).fail(function(n,t,i){alert('Unable to change property "'+r+'":\n'+i);s.hide()});o=null},500)}};n[0].nodeName.toLowerCase()=="input"&&n.attr("type")=="checkbox"?n.click(c):n.change(c);n[0].nodeName.toLowerCase()=="input"&&n.attr("type")=="text"&&(n.keydown(function(n){e.show();n.which==13&&$(this).blur()}).blur(function(){e.hide()}).focus(function(){$(this).select()}),t&&n.watermark(t));n[0].nodeName.toLowerCase()=="textarea"&&n.keydown(function(){e.show()}).blur(function(){e.hide()})}),document.DiscoFunctions.DateChangeUserHelper||(document.DiscoFunctions.DateChangeUserHelper=function(n,t,i,r,u,f,e){var s=n.val(),o=null,h=t.next(".ajaxLoading");n.watermark(i).change(function(){var i=n.val();s.toLowerCase()!=i.toLowerCase()&&(s=i,o&&window.clearTimeout(o),o=window.setTimeout(function(){h.show();var n={};n[u]=s;$.getJSON(r,n,function(n,i){i!="success"||n.Result!="OK"?(alert("Unable to change Date:\n"+n),h.hide()):(t.text("by "+n.UserDescription),h.hide().next(".ajaxOk").show().delay("fast").fadeOut("slow"))});o=null},500))}).focus(function(){$(this).select()});e?n.datepicker({defaultDate:new Date,minDate:moment(f).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datepicker("setDate",new Date)}}):n.datetimepicker({defaultDate:new Date,ampm:!0,minDate:moment(f).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datetimepicker("setDate",new Date)}})}),document.DiscoFunctions.DateChangeHelper||(document.DiscoFunctions.DateChangeHelper=function(n,t,i,r,u,f){var o=n.val(),e=null,s=n.next(".ajaxLoading");n.watermark(t).change(function(){var t=n.val();o.toLowerCase()!=t.toLowerCase()&&(o=t,e&&window.clearTimeout(e),e=window.setTimeout(function(){s.show();var n={};n[r]=o;$.getJSON(i,n,function(n,t){t!="success"||n!="OK"?(alert("Unable to change Date:\n"+n),s.hide()):s.hide().next(".ajaxOk").show().delay("fast").fadeOut("slow")});e=null},500))}).focus(function(){$(this).select()});f?n.datepicker({defaultDate:new Date,minDate:moment(u).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datepicker("setDate",new Date)}}):n.datetimepicker({defaultDate:new Date,ampm:!0,minDate:moment(u).toDate(),changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd",beforeShow:function(n){$input=$(n);$input.val()||$input.datetimepicker("setDate",new Date)}})}),!document.DiscoFunctions.DateDialogCreateUpdater){var dialog,dialogForm,dialogHeader,dialogDateBox,dialogDatePropertyNameBox,updateUrl,friendlyName,dateField,userField,updatePropertyName,notSetDisplay,minDate,useAjax;function dateDialogGet(){if(!dialog){dialog=$("<div>").attr({"class":"dialog"});dialogForm=$("<form>").attr({action:"/",method:"post"}).appendTo(dialog);var n=$("<p>").appendTo(dialogForm);dialogHeader=$("<h3>").attr("autofocus","autofocus").appendTo(n);dialogDatePropertyNameBox=$("<input>").attr({type:"hidden",name:"key"}).appendTo(n);dialogDateBox=$("<input>").attr({type:"datetime",name:"value"}).css({display:"block","margin-top":15,"margin-left":"auto","margin-right":"auto"}).appendTo(n);$("<input>").attr({type:"hidden",name:"redirect"}).val("true").appendTo(n);dialog.dialog({resizable:!1,modal:!0,autoOpen:!1,buttons:{Update:dateDialogUpdate,Cancel:function(){$(this).dialog("close")}},open:function(){dialog.dialog("widget").find(".ui-dialog-buttonpane :tabbable:first").focus()}});dialogDateBox.datetimepicker({defaultDate:new Date,ampm:!0,changeYear:!0,changeMonth:!0,dateFormat:"yy/mm/dd"})}return dialog}function dateDialogUpdate(){var u=dialogDateBox.val(),t,n,i,r;useAjax?(t=$("#"+dateField),userField&&(n=$("#"+userField)),dialog.dialog("close"),i=(n?n.next(".ajaxLoading"):t.next(".ajaxLoading")).show(),r={key:updatePropertyName,value:u},$.getJSON(updateUrl,r,function(r,u){u!="success"||r.Result!="OK"?(alert("Unable to change "+friendlyName+" Date:\n"+r),i.hide()):(r.DateTimeFull?t.attr("data-isodate",r.DateTimeISO8601).attr("data-livestamp",r.DateTimeUnixEpoc).attr("title",r.DateTimeFull).text(r.DateTimeFriendly):t.attr("data-isodate","").attr("data-livestamp","-1").attr("title",notSetDisplay).Line truncated
|
||||
+5
-1
@@ -8,7 +8,7 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
|
||||
}
|
||||
return propertyField.val();
|
||||
};
|
||||
document.DiscoFunctions.PropertyChangeHelper = function (propertyField, fieldWatermark, updateUrl, updatePropertyName, data) {
|
||||
document.DiscoFunctions.PropertyChangeHelper = function (propertyField, fieldWatermark, updateUrl, updatePropertyName, data, validator) {
|
||||
var fieldValue = document.DiscoFunctions.PropertyValue(propertyField);
|
||||
var fieldChangeToken = null;
|
||||
var $ajaxSave = propertyField.nextAll('.ajaxSave').first();
|
||||
@@ -17,6 +17,10 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
|
||||
$ajaxSave.hide();
|
||||
var changedValue = document.DiscoFunctions.PropertyValue(propertyField);
|
||||
if (fieldValue != changedValue) {
|
||||
if (validator && !validator(changedValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
fieldValue = changedValue;
|
||||
if (fieldChangeToken)
|
||||
window.clearTimeout(fieldChangeToken);
|
||||
|
||||
Reference in new issue
Block a user