bulk generation refactoring
This commit is contained in:
@@ -1,8 +1,22 @@
|
|||||||
namespace Disco.Models.UI.Config.DocumentTemplate
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Disco.Models.UI.Config.DocumentTemplate
|
||||||
{
|
{
|
||||||
public interface ConfigDocumentTemplateBulkGenerate : BaseUIModel
|
public interface ConfigDocumentTemplateBulkGenerate : BaseUIModel
|
||||||
{
|
{
|
||||||
Repository.DocumentTemplate DocumentTemplate { get; set; }
|
Repository.DocumentTemplate DocumentTemplate { get; set; }
|
||||||
int TemplatePageCount { get; set; }
|
int TemplatePageCount { get; set; }
|
||||||
|
|
||||||
|
List<ItemWithCount<Repository.UserFlag>> UserFlags { get; set; }
|
||||||
|
List<ItemWithCount<Repository.DeviceProfile>> DeviceProfiles { get; set; }
|
||||||
|
List<ItemWithCount<Repository.DeviceBatch>> DeviceBatches { get; set; }
|
||||||
|
List<ItemWithCount<Repository.DocumentTemplate>> DocumentTemplates { get; set; }
|
||||||
|
List<ItemWithCount<string>> UserDetails { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ItemWithCount<T>
|
||||||
|
{
|
||||||
|
public T Item { get; set; }
|
||||||
|
public int Count { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -733,6 +733,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
results.Add(new BulkGenerateUserModel()
|
results.Add(new BulkGenerateUserModel()
|
||||||
{
|
{
|
||||||
Id = user.UserId,
|
Id = user.UserId,
|
||||||
|
UserEmailAddress = user.EmailAddress,
|
||||||
DisplayName = user.DisplayName,
|
DisplayName = user.DisplayName,
|
||||||
Scope = $"Matched '{dataId}'",
|
Scope = $"Matched '{dataId}'",
|
||||||
IsError = false,
|
IsError = false,
|
||||||
@@ -763,6 +764,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
Id = adUser.Id,
|
Id = adUser.Id,
|
||||||
DisplayName = adUser.DisplayName,
|
DisplayName = adUser.DisplayName,
|
||||||
|
UserEmailAddress = adUser.Email,
|
||||||
Scope = $"Group Member '{group.Name}'",
|
Scope = $"Group Member '{group.Name}'",
|
||||||
IsError = false,
|
IsError = false,
|
||||||
});
|
});
|
||||||
@@ -816,6 +818,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
Id = adUser.Id,
|
Id = adUser.Id,
|
||||||
DisplayName = adUser.DisplayName,
|
DisplayName = adUser.DisplayName,
|
||||||
|
UserEmailAddress = adUser.Email,
|
||||||
Scope = $"Group Member '{group.Name}'",
|
Scope = $"Group Member '{group.Name}'",
|
||||||
IsError = false,
|
IsError = false,
|
||||||
});
|
});
|
||||||
@@ -827,6 +830,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
Id = user.Id,
|
Id = user.Id,
|
||||||
DisplayName = user.DisplayName,
|
DisplayName = user.DisplayName,
|
||||||
|
UserEmailAddress = user.Email,
|
||||||
Scope = $"Matched '{groupId}'",
|
Scope = $"Matched '{groupId}'",
|
||||||
IsError = false,
|
IsError = false,
|
||||||
});
|
});
|
||||||
@@ -887,6 +891,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
results.Add(new BulkGenerateUserModel()
|
results.Add(new BulkGenerateUserModel()
|
||||||
{
|
{
|
||||||
Id = assignment.UserId,
|
Id = assignment.UserId,
|
||||||
|
UserEmailAddress = assignment.User.EmailAddress,
|
||||||
DisplayName = assignment.User.DisplayName,
|
DisplayName = assignment.User.DisplayName,
|
||||||
Scope = $"Assigned User Flag '{flag.Name}'",
|
Scope = $"Assigned User Flag '{flag.Name}'",
|
||||||
IsError = false,
|
IsError = false,
|
||||||
@@ -941,6 +946,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
Id = assignment.AssignedUserId,
|
Id = assignment.AssignedUserId,
|
||||||
DisplayName = assignment.AssignedUser.DisplayName,
|
DisplayName = assignment.AssignedUser.DisplayName,
|
||||||
|
UserEmailAddress = assignment.AssignedUser.EmailAddress,
|
||||||
Scope = $"Device Profile '{profile.Name}' Matches Assigned Device '{assignment.SerialNumber}'",
|
Scope = $"Device Profile '{profile.Name}' Matches Assigned Device '{assignment.SerialNumber}'",
|
||||||
IsError = false,
|
IsError = false,
|
||||||
});
|
});
|
||||||
@@ -994,6 +1000,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
Id = assignment.AssignedUserId,
|
Id = assignment.AssignedUserId,
|
||||||
DisplayName = assignment.AssignedUser.DisplayName,
|
DisplayName = assignment.AssignedUser.DisplayName,
|
||||||
|
UserEmailAddress = assignment.AssignedUser.EmailAddress,
|
||||||
Scope = $"Device Batch '{batch.Name}' Matches Assigned Device '{assignment.SerialNumber}'",
|
Scope = $"Device Batch '{batch.Name}' Matches Assigned Device '{assignment.SerialNumber}'",
|
||||||
IsError = false,
|
IsError = false,
|
||||||
});
|
});
|
||||||
@@ -1040,6 +1047,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
Id = assignment.Device.AssignedUserId,
|
Id = assignment.Device.AssignedUserId,
|
||||||
DisplayName = assignment.Device.AssignedUser.DisplayName,
|
DisplayName = assignment.Device.AssignedUser.DisplayName,
|
||||||
|
UserEmailAddress = assignment.Device.AssignedUser.EmailAddress,
|
||||||
Scope = $"Document Template '{template.Id}' Attachment Matches Assigned Device '{assignment.Device.SerialNumber}'",
|
Scope = $"Document Template '{template.Id}' Attachment Matches Assigned Device '{assignment.Device.SerialNumber}'",
|
||||||
IsError = false,
|
IsError = false,
|
||||||
});
|
});
|
||||||
@@ -1056,6 +1064,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
Id = assignment.Job.UserId,
|
Id = assignment.Job.UserId,
|
||||||
DisplayName = assignment.Job.User.DisplayName,
|
DisplayName = assignment.Job.User.DisplayName,
|
||||||
|
UserEmailAddress = assignment.Job.User.EmailAddress,
|
||||||
Scope = $"Document Template '{template.Id}' Attachment Matches Job '{assignment.Job.Id}'",
|
Scope = $"Document Template '{template.Id}' Attachment Matches Job '{assignment.Job.Id}'",
|
||||||
IsError = false,
|
IsError = false,
|
||||||
});
|
});
|
||||||
@@ -1072,6 +1081,7 @@ namespace Disco.Web.Areas.API.Controllers
|
|||||||
{
|
{
|
||||||
Id = assignment.UserId,
|
Id = assignment.UserId,
|
||||||
DisplayName = assignment.User.DisplayName,
|
DisplayName = assignment.User.DisplayName,
|
||||||
|
UserEmailAddress = assignment.User.EmailAddress,
|
||||||
Scope = $"Document Template '{template.Id}' Attachment Matches User",
|
Scope = $"Document Template '{template.Id}' Attachment Matches User",
|
||||||
IsError = false,
|
IsError = false,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
public class BulkGenerateUserModel
|
public class BulkGenerateUserModel
|
||||||
{
|
{
|
||||||
public string Id { get; set; }
|
public string Id { get; set; }
|
||||||
|
public string UserEmailAddress { get; set; }
|
||||||
public string DisplayName { get; set; }
|
public string DisplayName { get; set; }
|
||||||
public string Scope { get; set; }
|
public string Scope { get; set; }
|
||||||
public bool IsError { get; set; }
|
public bool IsError { get; set; }
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Disco.BI.Extensions;
|
using Disco.BI.Extensions;
|
||||||
|
using Disco.Data.Repository;
|
||||||
using Disco.Models.Repository;
|
using Disco.Models.Repository;
|
||||||
using Disco.Models.UI.Config.DocumentTemplate;
|
using Disco.Models.UI.Config.DocumentTemplate;
|
||||||
using Disco.Services;
|
using Disco.Services;
|
||||||
@@ -9,10 +10,8 @@ using Disco.Services.Expressions;
|
|||||||
using Disco.Services.Plugins.Features.UIExtension;
|
using Disco.Services.Plugins.Features.UIExtension;
|
||||||
using Disco.Services.Web;
|
using Disco.Services.Web;
|
||||||
using Disco.Web.Areas.Config.Models.DocumentTemplate;
|
using Disco.Web.Areas.Config.Models.DocumentTemplate;
|
||||||
using Disco.Web.Areas.Config.Views.DocumentTemplate;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.Eventing.Reader;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
|
||||||
@@ -213,59 +212,53 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
return View(model);
|
return View(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments)]
|
public static ConfigDocumentTemplateBulkGenerate BuildBulkGenerateModel(DocumentTemplate documentTemplate, DiscoDataContext database, AuthorizationToken authorization)
|
||||||
public virtual ActionResult BulkGenerate(string id)
|
|
||||||
{
|
{
|
||||||
var m = new BulkGenerateModel()
|
var model = new BulkGenerateModel()
|
||||||
{
|
{
|
||||||
DocumentTemplate = Database.DocumentTemplates.FirstOrDefault(at => at.Id == id),
|
DocumentTemplate = documentTemplate,
|
||||||
};
|
};
|
||||||
if (m.DocumentTemplate == null)
|
|
||||||
throw new ArgumentException("Invalid Document Template Id", nameof(id));
|
|
||||||
|
|
||||||
if (m.DocumentTemplate.Scope != DocumentTemplate.DocumentTemplateScopes.User)
|
model.TemplatePageCount = model.DocumentTemplate.PdfPageHasAttachmentId(database).Count;
|
||||||
throw new NotSupportedException("Only user-scoped document templates can be bulk generated using this method");
|
model.UserFlags = database.UserFlags.Select(f => new ItemWithCount<UserFlag>()
|
||||||
|
|
||||||
m.TemplatePageCount = m.DocumentTemplate.PdfPageHasAttachmentId(Database).Count;
|
|
||||||
m.UserFlags = Database.UserFlags.Select(f => new BulkGenerateModel.ItemWithCount<UserFlag>()
|
|
||||||
{
|
{
|
||||||
Item = f,
|
Item = f,
|
||||||
Count = f.UserFlagAssignments.Where(a => a.RemovedDate == null).Count(),
|
Count = f.UserFlagAssignments.Where(a => a.RemovedDate == null).Count(),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
m.DeviceProfiles = Database.DeviceProfiles.Select(p => new BulkGenerateModel.ItemWithCount<DeviceProfile>()
|
model.DeviceProfiles = database.DeviceProfiles.Select(p => new ItemWithCount<DeviceProfile>()
|
||||||
{
|
{
|
||||||
Item = p,
|
Item = p,
|
||||||
Count = p.Devices.Where(d => d.AssignedUserId != null).Count(),
|
Count = p.Devices.Where(d => d.AssignedUserId != null).Count(),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
m.DeviceBatches = Database.DeviceBatches.Select(p => new BulkGenerateModel.ItemWithCount<DeviceBatch>()
|
model.DeviceBatches = database.DeviceBatches.Select(p => new ItemWithCount<DeviceBatch>()
|
||||||
{
|
{
|
||||||
Item = p,
|
Item = p,
|
||||||
Count = p.Devices.Where(d => d.AssignedUserId != null).Count(),
|
Count = p.Devices.Where(d => d.AssignedUserId != null).Count(),
|
||||||
}).ToList();
|
}).ToList();
|
||||||
m.DocumentTemplates = Database.DocumentTemplates.Select(dt => new BulkGenerateModel.ItemWithCount<DocumentTemplate>()
|
model.DocumentTemplates = database.DocumentTemplates.Select(dt => new ItemWithCount<DocumentTemplate>()
|
||||||
{
|
{
|
||||||
Item = dt,
|
Item = dt,
|
||||||
}).ToList();
|
}).ToList();
|
||||||
foreach (var record in m.DocumentTemplates)
|
foreach (var record in model.DocumentTemplates)
|
||||||
{
|
{
|
||||||
switch (record.Item.AttachmentType)
|
switch (record.Item.AttachmentType)
|
||||||
{
|
{
|
||||||
case AttachmentTypes.Device:
|
case AttachmentTypes.Device:
|
||||||
record.Count = Database.DeviceAttachments.Where(a => a.DocumentTemplateId == record.Item.Id).Select(a => a.Device.AssignedUser).Distinct().Count();
|
record.Count = database.DeviceAttachments.Where(a => a.DocumentTemplateId == record.Item.Id).Select(a => a.Device.AssignedUser).Distinct().Count();
|
||||||
break;
|
break;
|
||||||
case AttachmentTypes.Job:
|
case AttachmentTypes.Job:
|
||||||
record.Count = Database.JobAttachments.Where(a => a.DocumentTemplateId == record.Item.Id).Select(a => a.Job.User).Distinct().Count();
|
record.Count = database.JobAttachments.Where(a => a.DocumentTemplateId == record.Item.Id).Select(a => a.Job.User).Distinct().Count();
|
||||||
break;
|
break;
|
||||||
case AttachmentTypes.User:
|
case AttachmentTypes.User:
|
||||||
record.Count = Database.UserAttachments.Where(a => a.DocumentTemplateId == record.Item.Id).Select(a => a.User).Distinct().Count();
|
record.Count = database.UserAttachments.Where(a => a.DocumentTemplateId == record.Item.Id).Select(a => a.User).Distinct().Count();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Authorization.Has(Claims.User.ShowDetails))
|
if (authorization.Has(Claims.User.ShowDetails))
|
||||||
{
|
{
|
||||||
m.UserDetails = Database.UserDetails.Where(d => d.Scope == "Details").GroupBy(d => d.Key).Select(g => new BulkGenerateModel.ItemWithCount<string>()
|
model.UserDetails = database.UserDetails.Where(d => d.Scope == "Details").GroupBy(d => d.Key).Select(g => new ItemWithCount<string>()
|
||||||
{
|
{
|
||||||
Item = g.Key,
|
Item = g.Key,
|
||||||
Count = g.Count(),
|
Count = g.Count(),
|
||||||
@@ -273,13 +266,30 @@ namespace Disco.Web.Areas.Config.Controllers
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m.UserDetails = new List<BulkGenerateModel.ItemWithCount<string>>();
|
model.UserDetails = new List<ItemWithCount<string>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
// UI Extensions
|
return model;
|
||||||
UIExtensions.ExecuteExtensions<ConfigDocumentTemplateBulkGenerate>(ControllerContext, m);
|
}
|
||||||
|
|
||||||
return View(MVC.Config.DocumentTemplate.Views.BulkGenerate, m);
|
[DiscoAuthorizeAll(Claims.Config.DocumentTemplate.BulkGenerate, Claims.User.Actions.GenerateDocuments)]
|
||||||
|
public virtual ActionResult BulkGenerate(string id)
|
||||||
|
{
|
||||||
|
var documentTemplate = Database.DocumentTemplates.FirstOrDefault(at => at.Id == id);
|
||||||
|
|
||||||
|
if (documentTemplate == null)
|
||||||
|
throw new ArgumentException("Invalid Document Template Id", nameof(id));
|
||||||
|
|
||||||
|
if (documentTemplate.Scope != DocumentTemplate.DocumentTemplateScopes.User)
|
||||||
|
throw new NotSupportedException("Only user-scoped document templates can be bulk generated using this method");
|
||||||
|
|
||||||
|
|
||||||
|
var model = BuildBulkGenerateModel(documentTemplate, Database, Authorization);
|
||||||
|
|
||||||
|
// UI Extensions
|
||||||
|
UIExtensions.ExecuteExtensions(ControllerContext, model);
|
||||||
|
|
||||||
|
return View(MVC.Config.DocumentTemplate.Views.BulkGenerate, model);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DiscoAuthorize(Claims.Config.Show)]
|
[DiscoAuthorize(Claims.Config.Show)]
|
||||||
|
|||||||
@@ -12,11 +12,5 @@ namespace Disco.Web.Areas.Config.Models.DocumentTemplate
|
|||||||
public List<ItemWithCount<Disco.Models.Repository.DeviceBatch>> DeviceBatches { get; set; }
|
public List<ItemWithCount<Disco.Models.Repository.DeviceBatch>> DeviceBatches { get; set; }
|
||||||
public List<ItemWithCount<Disco.Models.Repository.DocumentTemplate>> DocumentTemplates { get; set; }
|
public List<ItemWithCount<Disco.Models.Repository.DocumentTemplate>> DocumentTemplates { get; set; }
|
||||||
public List<ItemWithCount<string>> UserDetails { get; set; }
|
public List<ItemWithCount<string>> UserDetails { get; set; }
|
||||||
|
|
||||||
public class ItemWithCount<T>
|
|
||||||
{
|
|
||||||
public T Item { get; set; }
|
|
||||||
public int Count { get; set; }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,6 +75,20 @@ $(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function excludeOtherUsers(r) {
|
||||||
|
let changeCount = 0;
|
||||||
|
for (var i = 0; i < users.length; i++) {
|
||||||
|
const user = users[i];
|
||||||
|
if (!r.find(u => u.Id === user.Id)) {
|
||||||
|
user.checkbox.checked = false;
|
||||||
|
changeCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changeCount) {
|
||||||
|
redrawTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$table.on('change', 'input[type="checkbox"]', e => {
|
$table.on('change', 'input[type="checkbox"]', e => {
|
||||||
redrawTable();
|
redrawTable();
|
||||||
});
|
});
|
||||||
@@ -97,59 +111,49 @@ $(() => {
|
|||||||
$('#AddUsers').click(e => {
|
$('#AddUsers').click(e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!dialogAddUsers) {
|
let dialog = dialogAddUsers;
|
||||||
dialogAddUsers = $('#DocumentTemplate_BulkGenerate_Dialog_AddUsers').dialog({
|
if (!dialog) {
|
||||||
|
const action = function (applier) {
|
||||||
|
const form = dialog.find('form')[0];
|
||||||
|
if (form.reportValidity()) {
|
||||||
|
const body = new FormData(form);
|
||||||
|
fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: body
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(r => {
|
||||||
|
applier(r);
|
||||||
|
dialog.find('textarea').html('').val('');
|
||||||
|
dialog.dialog("close");
|
||||||
|
dialog.dialog("enable");
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
alert('Failed to validate users: ' + reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dialog.dialog("disable");
|
||||||
|
}
|
||||||
|
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUsers').dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Other Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Users": function () {
|
"Exclude Users": function () {
|
||||||
const form = dialogAddUsers.find('form')[0];
|
action(excludeUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
excludeUsers(r);
|
|
||||||
dialogAddUsers.find('textarea').html('').val('');
|
|
||||||
dialogAddUsers.dialog("close");
|
|
||||||
dialogAddUsers.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate users: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialogAddUsers.dialog("disable");
|
|
||||||
},
|
},
|
||||||
"Add Users": function () {
|
"Add Users": function () {
|
||||||
const form = dialogAddUsers.find('form')[0];
|
action(addUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
addUsers(r);
|
|
||||||
dialogAddUsers.find('textarea').html('').val('');
|
|
||||||
dialogAddUsers.dialog("close");
|
|
||||||
dialogAddUsers.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate users: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialogAddUsers.dialog("disable");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
dialogAddUsers = dialog;
|
||||||
}
|
}
|
||||||
dialogAddUsers.dialog('open');
|
dialog.dialog('open');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -157,73 +161,63 @@ $(() => {
|
|||||||
$('#AddGroupMembers').click(e => {
|
$('#AddGroupMembers').click(e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!dialogAddGroupMembers) {
|
let dialog = dialogAddGroupMembers;
|
||||||
dialogAddGroupMembers = $('#DocumentTemplate_BulkGenerate_Dialog_AddGroupMembers').dialog({
|
if (!dialog) {
|
||||||
|
const action = function (applier) {
|
||||||
|
const form = dialog.find('form')[0];
|
||||||
|
if (form.reportValidity()) {
|
||||||
|
const body = new FormData(form);
|
||||||
|
fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: body
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(r => {
|
||||||
|
applier(r);
|
||||||
|
dialog.find('input[type="text"]').val('');
|
||||||
|
dialog.dialog("close");
|
||||||
|
dialog.dialog("enable");
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
alert('Failed to validate group: ' + reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dialog.dialog("disable");
|
||||||
|
}
|
||||||
|
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddGroupMembers').dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Non-Group Members": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Group Members": function () {
|
"Exclude Group Members": function () {
|
||||||
const form = dialogAddGroupMembers.find('form')[0];
|
action(excludeUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
excludeUsers(r);
|
|
||||||
dialogAddGroupMembers.find('input[type="text"]').val('');
|
|
||||||
dialogAddGroupMembers.dialog("close");
|
|
||||||
dialogAddGroupMembers.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate group: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialogAddGroupMembers.dialog("disable");
|
|
||||||
},
|
},
|
||||||
"Add Group Members": function () {
|
"Add Group Members": function () {
|
||||||
const form = dialogAddGroupMembers.find('form')[0];
|
action(addUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
addUsers(r);
|
|
||||||
dialogAddGroupMembers.find('input[type="text"]').val('');
|
|
||||||
dialogAddGroupMembers.dialog("close");
|
|
||||||
dialogAddGroupMembers.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate group: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialogAddGroupMembers.dialog("disable");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $input = dialog.find('input[type="text"]');
|
||||||
|
$input.autocomplete({
|
||||||
|
source: $input.attr('data-autocomplete-src'),
|
||||||
|
minLength: 2,
|
||||||
|
select: function (e, ui) {
|
||||||
|
$input.val(ui.item.Id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).data('ui-autocomplete')._renderItem = function (ul, item) {
|
||||||
|
return $("<li>")
|
||||||
|
.data("item.autocomplete", item)
|
||||||
|
.append("<a><strong>" + item.Name + "</strong><br>" + item.Id + " (" + item.Type + ")</a>")
|
||||||
|
.appendTo(ul);
|
||||||
|
};
|
||||||
|
dialogAddGroupMembers = dialog;
|
||||||
}
|
}
|
||||||
const $input = dialogAddGroupMembers.find('input[type="text"]');
|
dialog.dialog('open');
|
||||||
$input.autocomplete({
|
|
||||||
source: $input.attr('data-autocomplete-src'),
|
|
||||||
minLength: 2,
|
|
||||||
select: function (e, ui) {
|
|
||||||
$input.val(ui.item.Id);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).data('ui-autocomplete')._renderItem = function (ul, item) {
|
|
||||||
return $("<li>")
|
|
||||||
.data("item.autocomplete", item)
|
|
||||||
.append("<a><strong>" + item.Name + "</strong><br>" + item.Id + " (" + item.Type + ")</a>")
|
|
||||||
.appendTo(ul);
|
|
||||||
};
|
|
||||||
dialogAddGroupMembers.dialog('open');
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -231,71 +225,59 @@ $(() => {
|
|||||||
$('#AddUserFlag').click(e => {
|
$('#AddUserFlag').click(e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!dialogAddUserFlag) {
|
let dialog = dialogAddUserFlag;
|
||||||
const dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserFlag').dialog({
|
if (!dialog) {
|
||||||
|
const action = function (applier) {
|
||||||
|
const form = dialog.find('form')[0];
|
||||||
|
if (form.reportValidity()) {
|
||||||
|
const body = new FormData(form);
|
||||||
|
fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: body
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(r => {
|
||||||
|
applier(r);
|
||||||
|
dialog.find('input[name="flagId"]').val('');
|
||||||
|
dialog.find('div.item').removeClass('selected');
|
||||||
|
dialog.dialog("close");
|
||||||
|
dialog.dialog("enable");
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
alert('Failed to validate user flag: ' + reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dialog.dialog("disable");
|
||||||
|
}
|
||||||
|
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserFlag').dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Unassigned Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Assigned Users": function () {
|
"Exclude Assigned Users": function () {
|
||||||
const form = dialog.find('form')[0];
|
action(excludeUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
excludeUsers(r);
|
|
||||||
dialog.find('input[name="flagId"]').val('');
|
|
||||||
dialog.find('div.item').removeClass('selected');
|
|
||||||
dialog.dialog("close");
|
|
||||||
dialog.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate user flag: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialog.dialog("disable");
|
|
||||||
},
|
},
|
||||||
"Add Assigned Users": function () {
|
"Add Assigned Users": function () {
|
||||||
const form = dialog.find('form')[0];
|
action(addUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
addUsers(r);
|
|
||||||
dialog.find('input[name="flagId"]').val('');
|
|
||||||
dialog.find('div.item').removeClass('selected');
|
|
||||||
dialog.dialog("close");
|
|
||||||
dialog.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate user flag: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialog.dialog("disable");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $input = dialog.find('input[name="flagId"]');
|
||||||
|
dialog.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
$input.val($target.attr('data-userflagid'));
|
||||||
|
dialog.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
dialogAddUserFlag = dialog;
|
dialogAddUserFlag = dialog;
|
||||||
}
|
}
|
||||||
const $input = dialogAddUserFlag.find('input[name="flagId"]');
|
dialog.dialog('open');
|
||||||
dialogAddUserFlag.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
$input.val($target.attr('data-userflagid'));
|
|
||||||
dialogAddUserFlag.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
dialogAddUserFlag.dialog('open');
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -304,7 +286,7 @@ $(() => {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let dialog = dialogAddDeviceProfile;
|
let dialog = dialogAddDeviceProfile;
|
||||||
if (!dialog) {
|
if (!dialog) {
|
||||||
const action = delegate => {
|
const action = function (applier) {
|
||||||
const form = dialog.find('form')[0];
|
const form = dialog.find('form')[0];
|
||||||
const input = dialog.find('input[name="deviceProfileId"]');
|
const input = dialog.find('input[name="deviceProfileId"]');
|
||||||
if (input.val()) {
|
if (input.val()) {
|
||||||
@@ -316,7 +298,7 @@ $(() => {
|
|||||||
})
|
})
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(r => {
|
.then(r => {
|
||||||
delegate(r);
|
applier(r);
|
||||||
input.val('');
|
input.val('');
|
||||||
dialog.find('div.item').removeClass('selected');
|
dialog.find('div.item').removeClass('selected');
|
||||||
dialog.dialog("close");
|
dialog.dialog("close");
|
||||||
@@ -335,6 +317,9 @@ $(() => {
|
|||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Unassigned Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Assigned Users": function () {
|
"Exclude Assigned Users": function () {
|
||||||
action(excludeUsers);
|
action(excludeUsers);
|
||||||
},
|
},
|
||||||
@@ -343,17 +328,17 @@ $(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $input = dialog.find('input[name="deviceProfileId"]');
|
||||||
|
dialog.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
$input.val($target.attr('data-id'));
|
||||||
|
dialog.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
dialogAddDeviceProfile = dialog;
|
dialogAddDeviceProfile = dialog;
|
||||||
}
|
}
|
||||||
const $input = dialog.find('input[name="deviceProfileId"]');
|
|
||||||
dialog.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
$input.val($target.attr('data-id'));
|
|
||||||
dialog.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
dialog.dialog('open');
|
dialog.dialog('open');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -363,7 +348,7 @@ $(() => {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let dialog = dialogAddDeviceBatch;
|
let dialog = dialogAddDeviceBatch;
|
||||||
if (!dialog) {
|
if (!dialog) {
|
||||||
const action = delegate => {
|
const action = function (applier) {
|
||||||
const form = dialog.find('form')[0];
|
const form = dialog.find('form')[0];
|
||||||
const input = dialog.find('input[name="deviceBatchId"]');
|
const input = dialog.find('input[name="deviceBatchId"]');
|
||||||
if (input.val()) {
|
if (input.val()) {
|
||||||
@@ -375,7 +360,7 @@ $(() => {
|
|||||||
})
|
})
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(r => {
|
.then(r => {
|
||||||
delegate(r);
|
applier(r);
|
||||||
input.val('');
|
input.val('');
|
||||||
dialog.find('div.item').removeClass('selected');
|
dialog.find('div.item').removeClass('selected');
|
||||||
dialog.dialog("close");
|
dialog.dialog("close");
|
||||||
@@ -394,6 +379,9 @@ $(() => {
|
|||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Unassigned Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Assigned Users": function () {
|
"Exclude Assigned Users": function () {
|
||||||
action(excludeUsers);
|
action(excludeUsers);
|
||||||
},
|
},
|
||||||
@@ -402,17 +390,17 @@ $(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $input = dialog.find('input[name="deviceBatchId"]');
|
||||||
|
dialog.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
$input.val($target.attr('data-id'));
|
||||||
|
dialog.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
dialogAddDeviceBatch = dialog;
|
dialogAddDeviceBatch = dialog;
|
||||||
}
|
}
|
||||||
const $input = dialog.find('input[name="deviceBatchId"]');
|
|
||||||
dialog.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
$input.val($target.attr('data-id'));
|
|
||||||
dialog.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
dialog.dialog('open');
|
dialog.dialog('open');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -422,7 +410,7 @@ $(() => {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let dialog = dialogAddDocumentAttachment;
|
let dialog = dialogAddDocumentAttachment;
|
||||||
if (!dialog) {
|
if (!dialog) {
|
||||||
const action = delegate => {
|
const action = function (applier) {
|
||||||
const form = dialog.find('form')[0];
|
const form = dialog.find('form')[0];
|
||||||
const input = dialog.find('input[name="documentTemplateId"]');
|
const input = dialog.find('input[name="documentTemplateId"]');
|
||||||
if (input.val()) {
|
if (input.val()) {
|
||||||
@@ -434,7 +422,7 @@ $(() => {
|
|||||||
})
|
})
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(r => {
|
.then(r => {
|
||||||
delegate(r);
|
applier(r);
|
||||||
input.val('');
|
input.val('');
|
||||||
dialog.find('div.item').removeClass('selected');
|
dialog.find('div.item').removeClass('selected');
|
||||||
dialog.dialog("close");
|
dialog.dialog("close");
|
||||||
@@ -453,6 +441,9 @@ $(() => {
|
|||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Unassigned Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Assigned Users": function () {
|
"Exclude Assigned Users": function () {
|
||||||
action(excludeUsers);
|
action(excludeUsers);
|
||||||
},
|
},
|
||||||
@@ -461,17 +452,17 @@ $(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $input = dialog.find('input[name="documentTemplateId"]');
|
||||||
|
dialog.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
$input.val($target.attr('data-id'));
|
||||||
|
dialog.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
dialogAddDocumentAttachment = dialog;
|
dialogAddDocumentAttachment = dialog;
|
||||||
}
|
}
|
||||||
const $input = dialog.find('input[name="documentTemplateId"]');
|
|
||||||
dialog.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
$input.val($target.attr('data-id'));
|
|
||||||
dialog.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
dialog.dialog('open');
|
dialog.dialog('open');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -481,7 +472,7 @@ $(() => {
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let dialog = dialogAddUserDetail;
|
let dialog = dialogAddUserDetail;
|
||||||
if (!dialog) {
|
if (!dialog) {
|
||||||
const action = delegate => {
|
const action = function (applier) {
|
||||||
const form = dialog.find('form')[0];
|
const form = dialog.find('form')[0];
|
||||||
const key = $(form).find('input[name="key"]');
|
const key = $(form).find('input[name="key"]');
|
||||||
if (key.val()) {
|
if (key.val()) {
|
||||||
@@ -493,7 +484,7 @@ $(() => {
|
|||||||
})
|
})
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(r => {
|
.then(r => {
|
||||||
delegate(r);
|
applier(r);
|
||||||
key.val('');
|
key.val('');
|
||||||
$(form).find('input[name="value"]').val('');
|
$(form).find('input[name="value"]').val('');
|
||||||
$('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value').empty();
|
$('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value').empty();
|
||||||
@@ -514,6 +505,9 @@ $(() => {
|
|||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 690,
|
width: 690,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Unmatched Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Matched Users": function () {
|
"Exclude Matched Users": function () {
|
||||||
action(excludeUsers);
|
action(excludeUsers);
|
||||||
},
|
},
|
||||||
@@ -522,59 +516,59 @@ $(() => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $key = dialog.find('input[name="key"]');
|
||||||
|
const $value = dialog.find('input[name="value"]');
|
||||||
|
const $keys = dialog.find('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Key');
|
||||||
|
const $values = dialog.find('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value');
|
||||||
|
$keys.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
const keyValue = $target.attr('data-id');
|
||||||
|
$key.val(keyValue);
|
||||||
|
$keys.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
|
||||||
|
$values.empty();
|
||||||
|
$values.append($('<i class="ajaxLoading" title="Loading"></i>'));
|
||||||
|
|
||||||
|
const form = dialog.find('form')[1];
|
||||||
|
const body = new FormData(form);
|
||||||
|
fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: body
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(r => {
|
||||||
|
$values.empty();
|
||||||
|
|
||||||
|
const allValues = $('<div class="item selected" data-id=""><i class="fa fa-info fa-fw fa-lg"></i><em>All Matched Users</em></div>');
|
||||||
|
allValues.appendTo($values);
|
||||||
|
$value.val('');
|
||||||
|
|
||||||
|
r.map(v => {
|
||||||
|
const container = $('<div class="item"><i class="fa fa-info fa-fw fa-lg"></i ></div>');
|
||||||
|
container.attr('data-id', v);
|
||||||
|
const span = $('<span>').text(v);
|
||||||
|
span.appendTo(container);
|
||||||
|
container.appendTo($values);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
alert('Failed to validate user detail: ' + reason);
|
||||||
|
});
|
||||||
|
dialog.dialog("disable");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$values.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
$value.val($target.attr('data-id'));
|
||||||
|
$values.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
});
|
||||||
dialogAddUserDetail = dialog;
|
dialogAddUserDetail = dialog;
|
||||||
}
|
}
|
||||||
const $key = dialog.find('input[name="key"]');
|
|
||||||
const $value = dialog.find('input[name="value"]');
|
|
||||||
const $keys = dialog.find('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Key');
|
|
||||||
const $values = dialog.find('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value');
|
|
||||||
$keys.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
const keyValue = $target.attr('data-id');
|
|
||||||
$key.val(keyValue);
|
|
||||||
$keys.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
|
|
||||||
$values.empty();
|
|
||||||
$values.append($('<i class="ajaxLoading" title="Loading"></i>'));
|
|
||||||
|
|
||||||
const form = dialog.find('form')[1];
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
$values.empty();
|
|
||||||
|
|
||||||
const allValues = $('<div class="item selected" data-id=""><i class="fa fa-info fa-fw fa-lg"></i><em>All Matched Users</em></div>');
|
|
||||||
allValues.appendTo($values);
|
|
||||||
$value.val('');
|
|
||||||
|
|
||||||
r.map(v => {
|
|
||||||
const container = $('<div class="item"><i class="fa fa-info fa-fw fa-lg"></i ></div>');
|
|
||||||
container.attr('data-id', v);
|
|
||||||
const span = $('<span>').text(v);
|
|
||||||
span.appendTo(container);
|
|
||||||
container.appendTo($values);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate user detail: ' + reason);
|
|
||||||
});
|
|
||||||
dialog.dialog("disable");
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$values.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
$value.val($target.attr('data-id'));
|
|
||||||
$values.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
});
|
|
||||||
dialog.dialog('open');
|
dialog.dialog('open');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+228
-234
@@ -75,6 +75,20 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function excludeOtherUsers(r) {
|
||||||
|
let changeCount = 0;
|
||||||
|
for (var i = 0; i < users.length; i++) {
|
||||||
|
const user = users[i];
|
||||||
|
if (!r.find(u => u.Id === user.Id)) {
|
||||||
|
user.checkbox.checked = false;
|
||||||
|
changeCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (changeCount) {
|
||||||
|
redrawTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$table.on('change', 'input[type="checkbox"]', e => {
|
$table.on('change', 'input[type="checkbox"]', e => {
|
||||||
redrawTable();
|
redrawTable();
|
||||||
});
|
});
|
||||||
@@ -97,59 +111,49 @@
|
|||||||
$('#AddUsers').click(e => {
|
$('#AddUsers').click(e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!dialogAddUsers) {
|
let dialog = dialogAddUsers;
|
||||||
dialogAddUsers = $('#DocumentTemplate_BulkGenerate_Dialog_AddUsers').dialog({
|
if (!dialog) {
|
||||||
|
const action = function (applier) {
|
||||||
|
const form = dialog.find('form')[0];
|
||||||
|
if (form.reportValidity()) {
|
||||||
|
const body = new FormData(form);
|
||||||
|
fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: body
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(r => {
|
||||||
|
applier(r);
|
||||||
|
dialog.find('textarea').html('').val('');
|
||||||
|
dialog.dialog("close");
|
||||||
|
dialog.dialog("enable");
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
alert('Failed to validate users: ' + reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dialog.dialog("disable");
|
||||||
|
}
|
||||||
|
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUsers').dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Other Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Users": function () {
|
"Exclude Users": function () {
|
||||||
const form = dialogAddUsers.find('form')[0];
|
action(excludeUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
excludeUsers(r);
|
|
||||||
dialogAddUsers.find('textarea').html('').val('');
|
|
||||||
dialogAddUsers.dialog("close");
|
|
||||||
dialogAddUsers.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate users: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialogAddUsers.dialog("disable");
|
|
||||||
},
|
},
|
||||||
"Add Users": function () {
|
"Add Users": function () {
|
||||||
const form = dialogAddUsers.find('form')[0];
|
action(addUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
addUsers(r);
|
|
||||||
dialogAddUsers.find('textarea').html('').val('');
|
|
||||||
dialogAddUsers.dialog("close");
|
|
||||||
dialogAddUsers.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate users: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialogAddUsers.dialog("disable");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
dialogAddUsers = dialog;
|
||||||
}
|
}
|
||||||
dialogAddUsers.dialog('open');
|
dialog.dialog('open');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -157,73 +161,63 @@
|
|||||||
$('#AddGroupMembers').click(e => {
|
$('#AddGroupMembers').click(e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!dialogAddGroupMembers) {
|
let dialog = dialogAddGroupMembers;
|
||||||
dialogAddGroupMembers = $('#DocumentTemplate_BulkGenerate_Dialog_AddGroupMembers').dialog({
|
if (!dialog) {
|
||||||
|
const action = function (applier) {
|
||||||
|
const form = dialog.find('form')[0];
|
||||||
|
if (form.reportValidity()) {
|
||||||
|
const body = new FormData(form);
|
||||||
|
fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: body
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(r => {
|
||||||
|
applier(r);
|
||||||
|
dialog.find('input[type="text"]').val('');
|
||||||
|
dialog.dialog("close");
|
||||||
|
dialog.dialog("enable");
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
alert('Failed to validate group: ' + reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dialog.dialog("disable");
|
||||||
|
}
|
||||||
|
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddGroupMembers').dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Non-Group Members": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Group Members": function () {
|
"Exclude Group Members": function () {
|
||||||
const form = dialogAddGroupMembers.find('form')[0];
|
action(excludeUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
excludeUsers(r);
|
|
||||||
dialogAddGroupMembers.find('input[type="text"]').val('');
|
|
||||||
dialogAddGroupMembers.dialog("close");
|
|
||||||
dialogAddGroupMembers.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate group: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialogAddGroupMembers.dialog("disable");
|
|
||||||
},
|
},
|
||||||
"Add Group Members": function () {
|
"Add Group Members": function () {
|
||||||
const form = dialogAddGroupMembers.find('form')[0];
|
action(addUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
addUsers(r);
|
|
||||||
dialogAddGroupMembers.find('input[type="text"]').val('');
|
|
||||||
dialogAddGroupMembers.dialog("close");
|
|
||||||
dialogAddGroupMembers.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate group: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialogAddGroupMembers.dialog("disable");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $input = dialog.find('input[type="text"]');
|
||||||
|
$input.autocomplete({
|
||||||
|
source: $input.attr('data-autocomplete-src'),
|
||||||
|
minLength: 2,
|
||||||
|
select: function (e, ui) {
|
||||||
|
$input.val(ui.item.Id);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}).data('ui-autocomplete')._renderItem = function (ul, item) {
|
||||||
|
return $("<li>")
|
||||||
|
.data("item.autocomplete", item)
|
||||||
|
.append("<a><strong>" + item.Name + "</strong><br>" + item.Id + " (" + item.Type + ")</a>")
|
||||||
|
.appendTo(ul);
|
||||||
|
};
|
||||||
|
dialogAddGroupMembers = dialog;
|
||||||
}
|
}
|
||||||
const $input = dialogAddGroupMembers.find('input[type="text"]');
|
dialog.dialog('open');
|
||||||
$input.autocomplete({
|
|
||||||
source: $input.attr('data-autocomplete-src'),
|
|
||||||
minLength: 2,
|
|
||||||
select: function (e, ui) {
|
|
||||||
$input.val(ui.item.Id);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}).data('ui-autocomplete')._renderItem = function (ul, item) {
|
|
||||||
return $("<li>")
|
|
||||||
.data("item.autocomplete", item)
|
|
||||||
.append("<a><strong>" + item.Name + "</strong><br>" + item.Id + " (" + item.Type + ")</a>")
|
|
||||||
.appendTo(ul);
|
|
||||||
};
|
|
||||||
dialogAddGroupMembers.dialog('open');
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -231,71 +225,59 @@
|
|||||||
$('#AddUserFlag').click(e => {
|
$('#AddUserFlag').click(e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
if (!dialogAddUserFlag) {
|
let dialog = dialogAddUserFlag;
|
||||||
const dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserFlag').dialog({
|
if (!dialog) {
|
||||||
|
const action = function (applier) {
|
||||||
|
const form = dialog.find('form')[0];
|
||||||
|
if (form.reportValidity()) {
|
||||||
|
const body = new FormData(form);
|
||||||
|
fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: body
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(r => {
|
||||||
|
applier(r);
|
||||||
|
dialog.find('input[name="flagId"]').val('');
|
||||||
|
dialog.find('div.item').removeClass('selected');
|
||||||
|
dialog.dialog("close");
|
||||||
|
dialog.dialog("enable");
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
alert('Failed to validate user flag: ' + reason);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dialog.dialog("disable");
|
||||||
|
}
|
||||||
|
dialog = $('#DocumentTemplate_BulkGenerate_Dialog_AddUserFlag').dialog({
|
||||||
resizable: false,
|
resizable: false,
|
||||||
modal: true,
|
modal: true,
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Unassigned Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Assigned Users": function () {
|
"Exclude Assigned Users": function () {
|
||||||
const form = dialog.find('form')[0];
|
action(excludeUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
excludeUsers(r);
|
|
||||||
dialog.find('input[name="flagId"]').val('');
|
|
||||||
dialog.find('div.item').removeClass('selected');
|
|
||||||
dialog.dialog("close");
|
|
||||||
dialog.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate user flag: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialog.dialog("disable");
|
|
||||||
},
|
},
|
||||||
"Add Assigned Users": function () {
|
"Add Assigned Users": function () {
|
||||||
const form = dialog.find('form')[0];
|
action(addUsers);
|
||||||
if (form.reportValidity()) {
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
addUsers(r);
|
|
||||||
dialog.find('input[name="flagId"]').val('');
|
|
||||||
dialog.find('div.item').removeClass('selected');
|
|
||||||
dialog.dialog("close");
|
|
||||||
dialog.dialog("enable");
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate user flag: ' + reason);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
dialog.dialog("disable");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $input = dialog.find('input[name="flagId"]');
|
||||||
|
dialog.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
$input.val($target.attr('data-userflagid'));
|
||||||
|
dialog.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
dialogAddUserFlag = dialog;
|
dialogAddUserFlag = dialog;
|
||||||
}
|
}
|
||||||
const $input = dialogAddUserFlag.find('input[name="flagId"]');
|
dialog.dialog('open');
|
||||||
dialogAddUserFlag.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
$input.val($target.attr('data-userflagid'));
|
|
||||||
dialogAddUserFlag.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
dialogAddUserFlag.dialog('open');
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -304,7 +286,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let dialog = dialogAddDeviceProfile;
|
let dialog = dialogAddDeviceProfile;
|
||||||
if (!dialog) {
|
if (!dialog) {
|
||||||
const action = delegate => {
|
const action = function (applier) {
|
||||||
const form = dialog.find('form')[0];
|
const form = dialog.find('form')[0];
|
||||||
const input = dialog.find('input[name="deviceProfileId"]');
|
const input = dialog.find('input[name="deviceProfileId"]');
|
||||||
if (input.val()) {
|
if (input.val()) {
|
||||||
@@ -316,7 +298,7 @@
|
|||||||
})
|
})
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(r => {
|
.then(r => {
|
||||||
delegate(r);
|
applier(r);
|
||||||
input.val('');
|
input.val('');
|
||||||
dialog.find('div.item').removeClass('selected');
|
dialog.find('div.item').removeClass('selected');
|
||||||
dialog.dialog("close");
|
dialog.dialog("close");
|
||||||
@@ -335,6 +317,9 @@
|
|||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Unassigned Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Assigned Users": function () {
|
"Exclude Assigned Users": function () {
|
||||||
action(excludeUsers);
|
action(excludeUsers);
|
||||||
},
|
},
|
||||||
@@ -343,17 +328,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $input = dialog.find('input[name="deviceProfileId"]');
|
||||||
|
dialog.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
$input.val($target.attr('data-id'));
|
||||||
|
dialog.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
dialogAddDeviceProfile = dialog;
|
dialogAddDeviceProfile = dialog;
|
||||||
}
|
}
|
||||||
const $input = dialog.find('input[name="deviceProfileId"]');
|
|
||||||
dialog.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
$input.val($target.attr('data-id'));
|
|
||||||
dialog.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
dialog.dialog('open');
|
dialog.dialog('open');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -363,7 +348,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let dialog = dialogAddDeviceBatch;
|
let dialog = dialogAddDeviceBatch;
|
||||||
if (!dialog) {
|
if (!dialog) {
|
||||||
const action = delegate => {
|
const action = function (applier) {
|
||||||
const form = dialog.find('form')[0];
|
const form = dialog.find('form')[0];
|
||||||
const input = dialog.find('input[name="deviceBatchId"]');
|
const input = dialog.find('input[name="deviceBatchId"]');
|
||||||
if (input.val()) {
|
if (input.val()) {
|
||||||
@@ -375,7 +360,7 @@
|
|||||||
})
|
})
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(r => {
|
.then(r => {
|
||||||
delegate(r);
|
applier(r);
|
||||||
input.val('');
|
input.val('');
|
||||||
dialog.find('div.item').removeClass('selected');
|
dialog.find('div.item').removeClass('selected');
|
||||||
dialog.dialog("close");
|
dialog.dialog("close");
|
||||||
@@ -394,6 +379,9 @@
|
|||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Unassigned Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Assigned Users": function () {
|
"Exclude Assigned Users": function () {
|
||||||
action(excludeUsers);
|
action(excludeUsers);
|
||||||
},
|
},
|
||||||
@@ -402,17 +390,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $input = dialog.find('input[name="deviceBatchId"]');
|
||||||
|
dialog.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
$input.val($target.attr('data-id'));
|
||||||
|
dialog.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
dialogAddDeviceBatch = dialog;
|
dialogAddDeviceBatch = dialog;
|
||||||
}
|
}
|
||||||
const $input = dialog.find('input[name="deviceBatchId"]');
|
|
||||||
dialog.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
$input.val($target.attr('data-id'));
|
|
||||||
dialog.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
dialog.dialog('open');
|
dialog.dialog('open');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -422,7 +410,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let dialog = dialogAddDocumentAttachment;
|
let dialog = dialogAddDocumentAttachment;
|
||||||
if (!dialog) {
|
if (!dialog) {
|
||||||
const action = delegate => {
|
const action = function (applier) {
|
||||||
const form = dialog.find('form')[0];
|
const form = dialog.find('form')[0];
|
||||||
const input = dialog.find('input[name="documentTemplateId"]');
|
const input = dialog.find('input[name="documentTemplateId"]');
|
||||||
if (input.val()) {
|
if (input.val()) {
|
||||||
@@ -434,7 +422,7 @@
|
|||||||
})
|
})
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(r => {
|
.then(r => {
|
||||||
delegate(r);
|
applier(r);
|
||||||
input.val('');
|
input.val('');
|
||||||
dialog.find('div.item').removeClass('selected');
|
dialog.find('div.item').removeClass('selected');
|
||||||
dialog.dialog("close");
|
dialog.dialog("close");
|
||||||
@@ -453,6 +441,9 @@
|
|||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 460,
|
width: 460,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Unassigned Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Assigned Users": function () {
|
"Exclude Assigned Users": function () {
|
||||||
action(excludeUsers);
|
action(excludeUsers);
|
||||||
},
|
},
|
||||||
@@ -461,17 +452,17 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $input = dialog.find('input[name="documentTemplateId"]');
|
||||||
|
dialog.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
$input.val($target.attr('data-id'));
|
||||||
|
dialog.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
dialogAddDocumentAttachment = dialog;
|
dialogAddDocumentAttachment = dialog;
|
||||||
}
|
}
|
||||||
const $input = dialog.find('input[name="documentTemplateId"]');
|
|
||||||
dialog.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
$input.val($target.attr('data-id'));
|
|
||||||
dialog.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
dialog.dialog('open');
|
dialog.dialog('open');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@@ -481,7 +472,7 @@
|
|||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
let dialog = dialogAddUserDetail;
|
let dialog = dialogAddUserDetail;
|
||||||
if (!dialog) {
|
if (!dialog) {
|
||||||
const action = delegate => {
|
const action = function (applier) {
|
||||||
const form = dialog.find('form')[0];
|
const form = dialog.find('form')[0];
|
||||||
const key = $(form).find('input[name="key"]');
|
const key = $(form).find('input[name="key"]');
|
||||||
if (key.val()) {
|
if (key.val()) {
|
||||||
@@ -493,7 +484,7 @@
|
|||||||
})
|
})
|
||||||
.then(r => r.json())
|
.then(r => r.json())
|
||||||
.then(r => {
|
.then(r => {
|
||||||
delegate(r);
|
applier(r);
|
||||||
key.val('');
|
key.val('');
|
||||||
$(form).find('input[name="value"]').val('');
|
$(form).find('input[name="value"]').val('');
|
||||||
$('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value').empty();
|
$('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value').empty();
|
||||||
@@ -514,6 +505,9 @@
|
|||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 690,
|
width: 690,
|
||||||
buttons: {
|
buttons: {
|
||||||
|
"Exclude Unmatched Users": function () {
|
||||||
|
action(excludeOtherUsers);
|
||||||
|
},
|
||||||
"Exclude Matched Users": function () {
|
"Exclude Matched Users": function () {
|
||||||
action(excludeUsers);
|
action(excludeUsers);
|
||||||
},
|
},
|
||||||
@@ -522,59 +516,59 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
const $key = dialog.find('input[name="key"]');
|
||||||
|
const $value = dialog.find('input[name="value"]');
|
||||||
|
const $keys = dialog.find('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Key');
|
||||||
|
const $values = dialog.find('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value');
|
||||||
|
$keys.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
const keyValue = $target.attr('data-id');
|
||||||
|
$key.val(keyValue);
|
||||||
|
$keys.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
|
||||||
|
$values.empty();
|
||||||
|
$values.append($('<i class="ajaxLoading" title="Loading"></i>'));
|
||||||
|
|
||||||
|
const form = dialog.find('form')[1];
|
||||||
|
const body = new FormData(form);
|
||||||
|
fetch(form.action, {
|
||||||
|
method: 'POST',
|
||||||
|
body: body
|
||||||
|
})
|
||||||
|
.then(r => r.json())
|
||||||
|
.then(r => {
|
||||||
|
$values.empty();
|
||||||
|
|
||||||
|
const allValues = $('<div class="item selected" data-id=""><i class="fa fa-info fa-fw fa-lg"></i><em>All Matched Users</em></div>');
|
||||||
|
allValues.appendTo($values);
|
||||||
|
$value.val('');
|
||||||
|
|
||||||
|
r.map(v => {
|
||||||
|
const container = $('<div class="item"><i class="fa fa-info fa-fw fa-lg"></i ></div>');
|
||||||
|
container.attr('data-id', v);
|
||||||
|
const span = $('<span>').text(v);
|
||||||
|
span.appendTo(container);
|
||||||
|
container.appendTo($values);
|
||||||
|
})
|
||||||
|
})
|
||||||
|
.catch(reason => {
|
||||||
|
alert('Failed to validate user detail: ' + reason);
|
||||||
|
});
|
||||||
|
dialog.dialog("disable");
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
$values.on('click', 'div.item:not(.disabled)', e => {
|
||||||
|
e.preventDefault();
|
||||||
|
const $target = $(e.currentTarget);
|
||||||
|
$value.val($target.attr('data-id'));
|
||||||
|
$values.find('div.item').removeClass('selected');
|
||||||
|
$target.addClass('selected');
|
||||||
|
});
|
||||||
dialogAddUserDetail = dialog;
|
dialogAddUserDetail = dialog;
|
||||||
}
|
}
|
||||||
const $key = dialog.find('input[name="key"]');
|
|
||||||
const $value = dialog.find('input[name="value"]');
|
|
||||||
const $keys = dialog.find('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Key');
|
|
||||||
const $values = dialog.find('#DocumentTemplate_BulkGenerate_Dialog_AddUserDetail_Value');
|
|
||||||
$keys.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
const keyValue = $target.attr('data-id');
|
|
||||||
$key.val(keyValue);
|
|
||||||
$keys.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
|
|
||||||
$values.empty();
|
|
||||||
$values.append($('<i class="ajaxLoading" title="Loading"></i>'));
|
|
||||||
|
|
||||||
const form = dialog.find('form')[1];
|
|
||||||
const body = new FormData(form);
|
|
||||||
fetch(form.action, {
|
|
||||||
method: 'POST',
|
|
||||||
body: body
|
|
||||||
})
|
|
||||||
.then(r => r.json())
|
|
||||||
.then(r => {
|
|
||||||
$values.empty();
|
|
||||||
|
|
||||||
const allValues = $('<div class="item selected" data-id=""><i class="fa fa-info fa-fw fa-lg"></i><em>All Matched Users</em></div>');
|
|
||||||
allValues.appendTo($values);
|
|
||||||
$value.val('');
|
|
||||||
|
|
||||||
r.map(v => {
|
|
||||||
const container = $('<div class="item"><i class="fa fa-info fa-fw fa-lg"></i ></div>');
|
|
||||||
container.attr('data-id', v);
|
|
||||||
const span = $('<span>').text(v);
|
|
||||||
span.appendTo(container);
|
|
||||||
container.appendTo($values);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
.catch(reason => {
|
|
||||||
alert('Failed to validate user detail: ' + reason);
|
|
||||||
});
|
|
||||||
dialog.dialog("disable");
|
|
||||||
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
$values.on('click', 'div.item:not(.disabled)', e => {
|
|
||||||
e.preventDefault();
|
|
||||||
const $target = $(e.currentTarget);
|
|
||||||
$value.val($target.attr('data-id'));
|
|
||||||
$values.find('div.item').removeClass('selected');
|
|
||||||
$target.addClass('selected');
|
|
||||||
});
|
|
||||||
dialog.dialog('open');
|
dialog.dialog('open');
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user