bugs: minor

This commit is contained in:
Gary Sharp
2023-01-29 10:10:37 +11:00
parent 708ca16de8
commit 47e11c0fd6
5 changed files with 15 additions and 6 deletions
@@ -99,19 +99,19 @@ namespace Disco.Services
switch (scope) switch (scope)
{ {
case AttachmentTypes.Device: 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; targetUser = device?.AssignedUser;
return device; return device;
case AttachmentTypes.Job: case AttachmentTypes.Job:
if (!int.TryParse(targetId, out var targetIdInt)) if (!int.TryParse(targetId, out var targetIdInt))
throw new ArgumentOutOfRangeException(nameof(targetId)); 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; targetUser = job?.User;
return job; return job;
case AttachmentTypes.User: case AttachmentTypes.User:
// special usecase in resolving users (they may not exist in the database yet) // special usecase in resolving users (they may not exist in the database yet)
targetId = ActiveDirectory.ParseDomainAccountId(targetId); targetId = ActiveDirectory.ParseDomainAccountId(targetId);
var user = database.Users.Find(targetId); var user = database.Users.First(u => u.UserId == targetId);
if (user == null) if (user == null)
{ {
// try importing user // try importing user
+1
View File
@@ -156,6 +156,7 @@ namespace Disco.Services.Plugins
"Microsoft.Owin.Security", "Microsoft.Owin.Security",
"Microsoft.Web.Infrastructure", "Microsoft.Web.Infrastructure",
"Newtonsoft.Json", "Newtonsoft.Json",
"Newtonsoft.Json.Bson",
"Owin", "Owin",
"PdfiumViewer", "PdfiumViewer",
"PdfSharp", "PdfSharp",
@@ -8,7 +8,7 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
} }
return propertyField.val(); 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 fieldValue = document.DiscoFunctions.PropertyValue(propertyField);
var fieldChangeToken = null; var fieldChangeToken = null;
var $ajaxSave = propertyField.nextAll('.ajaxSave').first(); var $ajaxSave = propertyField.nextAll('.ajaxSave').first();
@@ -17,6 +17,10 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
$ajaxSave.hide(); $ajaxSave.hide();
var changedValue = document.DiscoFunctions.PropertyValue(propertyField); var changedValue = document.DiscoFunctions.PropertyValue(propertyField);
if (fieldValue != changedValue) { if (fieldValue != changedValue) {
if (validator && !validator(changedValue)) {
return;
}
fieldValue = changedValue; fieldValue = changedValue;
if (fieldChangeToken) if (fieldChangeToken)
window.clearTimeout(fieldChangeToken); window.clearTimeout(fieldChangeToken);
File diff suppressed because one or more lines are too long
@@ -8,7 +8,7 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
} }
return propertyField.val(); 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 fieldValue = document.DiscoFunctions.PropertyValue(propertyField);
var fieldChangeToken = null; var fieldChangeToken = null;
var $ajaxSave = propertyField.nextAll('.ajaxSave').first(); var $ajaxSave = propertyField.nextAll('.ajaxSave').first();
@@ -17,6 +17,10 @@ if (!document.DiscoFunctions.PropertyChangeHelper) {
$ajaxSave.hide(); $ajaxSave.hide();
var changedValue = document.DiscoFunctions.PropertyValue(propertyField); var changedValue = document.DiscoFunctions.PropertyValue(propertyField);
if (fieldValue != changedValue) { if (fieldValue != changedValue) {
if (validator && !validator(changedValue)) {
return;
}
fieldValue = changedValue; fieldValue = changedValue;
if (fieldChangeToken) if (fieldChangeToken)
window.clearTimeout(fieldChangeToken); window.clearTimeout(fieldChangeToken);