bugs: minor
This commit is contained in:
@@ -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);
|
||||
|
||||
File diff suppressed because one or more lines are too long
+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