resolves #151: BYOD sub type added to User - Management jobs
This commit is contained in:
@@ -208,6 +208,15 @@ namespace Disco.Data.Repository
|
||||
#endregion
|
||||
// End
|
||||
|
||||
// 2025-07-11
|
||||
#region "User Management - BYOD" Added
|
||||
if (Database.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.UMgmt && jst.Id == JobSubType.UserManagementJobSubTypes.BYOD) == 0)
|
||||
{
|
||||
Database.JobSubTypes.Add(new JobSubType { Id = JobSubType.UserManagementJobSubTypes.BYOD, JobTypeId = JobType.JobTypeIds.UMgmt, Description = JobSubType.UserManagementJobSubTypes.BYOD });
|
||||
}
|
||||
#endregion
|
||||
// End
|
||||
|
||||
// 2012-05-29 - Audits
|
||||
#region "Audit" Added
|
||||
if (Database.JobSubTypes.Count(jst => jst.JobTypeId == JobType.JobTypeIds.HMisc && jst.Id == "Audit") == 0)
|
||||
|
||||
@@ -60,10 +60,6 @@ namespace Disco.Models.Repository
|
||||
[ForeignKey("DeviceReturnedTechUserId")]
|
||||
public virtual User DeviceReturnedTechUser { get; set; }
|
||||
|
||||
//// Added 2012-10-23 G# - DBv5 Migration
|
||||
//public virtual IList<JobAssignment> JobAssignments { get; set; }
|
||||
//// End Added 2012-10-23 G# - DBv5 Migration
|
||||
|
||||
public virtual IList<JobAttachment> JobAttachments { get; set; }
|
||||
public virtual IList<JobComponent> JobComponents { get; set; }
|
||||
public virtual IList<JobLog> JobLogs { get; set; }
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Disco.Models.Repository
|
||||
{
|
||||
public const string Infringement = "Infringement";
|
||||
public const string Contact = "Contact";
|
||||
public const string BYOD = "BYOD";
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
||||
@@ -8,11 +8,11 @@ namespace Disco.Services
|
||||
{
|
||||
public static class JobFlagExtensions
|
||||
{
|
||||
private static Dictionary<string, Dictionary<long, string>> cache;
|
||||
|
||||
private static Dictionary<string, Dictionary<long, string>> allFlags;
|
||||
private static void CacheAllFlags()
|
||||
private static Dictionary<string, Dictionary<long, string>> GetAllFlags()
|
||||
{
|
||||
if (allFlags == null)
|
||||
if (cache == null)
|
||||
{
|
||||
var fType = typeof(Job.UserManagementFlags);
|
||||
var fMembers = fType.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static);
|
||||
@@ -20,57 +20,52 @@ namespace Disco.Services
|
||||
var flags = new Dictionary<string, Dictionary<long, string>>();
|
||||
foreach (var f in fMembers)
|
||||
{
|
||||
DisplayAttribute display = (DisplayAttribute)(f.GetCustomAttributes(typeof(DisplayAttribute), false)[0]);
|
||||
string gn = display.GroupName;
|
||||
Dictionary<long, string> g;
|
||||
if (!flags.TryGetValue(gn, out g))
|
||||
var display = (DisplayAttribute)f.GetCustomAttributes(typeof(DisplayAttribute), false)[0];
|
||||
|
||||
if (!flags.TryGetValue(display.GroupName, out var group))
|
||||
{
|
||||
g = new Dictionary<long, string>();
|
||||
flags.Add(gn, g);
|
||||
group = new Dictionary<long, string>();
|
||||
flags.Add(display.GroupName, group);
|
||||
}
|
||||
g[(long)f.GetRawConstantValue()] = display.Name;
|
||||
group[(long)f.GetRawConstantValue()] = display.Name;
|
||||
}
|
||||
allFlags = flags;
|
||||
cache = flags;
|
||||
}
|
||||
return cache;
|
||||
}
|
||||
|
||||
public static Dictionary<string, List<Tuple<long, string, bool>>> ValidFlagsGrouped(this Job j)
|
||||
public static Dictionary<string, List<Tuple<long, string, bool>>> ValidFlagsGrouped(this Job job)
|
||||
{
|
||||
Dictionary<string, List<Tuple<long, string, bool>>> validFlags = new Dictionary<string, List<Tuple<long, string, bool>>>();
|
||||
var validFlags = new Dictionary<string, List<Tuple<long, string, bool>>>();
|
||||
|
||||
CacheAllFlags();
|
||||
var allFlags = GetAllFlags();
|
||||
|
||||
var currentFlags = (long)(j.Flags ?? 0);
|
||||
var currentFlags = (long)(job.Flags ?? 0);
|
||||
|
||||
foreach (var jt in j.JobSubTypes)
|
||||
foreach (var jobSubType in job.JobSubTypes)
|
||||
{
|
||||
Dictionary<long, string> g;
|
||||
if (allFlags.TryGetValue(jt.Id, out g))
|
||||
if (allFlags.TryGetValue(jobSubType.Id, out var group))
|
||||
{
|
||||
validFlags[jt.Id] = g.Select(f => new Tuple<long, string, bool>(f.Key, f.Value, ((currentFlags & f.Key) == f.Key))).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
validFlags[jt.Id] = null;
|
||||
validFlags[jobSubType.Id] = group.Select(o => Tuple.Create(o.Key, o.Value, (currentFlags & o.Key) == o.Key)).ToList();
|
||||
}
|
||||
}
|
||||
return validFlags;
|
||||
}
|
||||
public static Dictionary<long, Tuple<string, bool>> ValidFlags(this Job j)
|
||||
|
||||
public static Dictionary<long, Tuple<string, bool>> ValidFlags(this Job job)
|
||||
{
|
||||
Dictionary<long, Tuple<string, bool>> validFlags = new Dictionary<long, Tuple<string, bool>>();
|
||||
var validFlags = new Dictionary<long, Tuple<string, bool>>();
|
||||
|
||||
CacheAllFlags();
|
||||
var allFlags = GetAllFlags();
|
||||
|
||||
var currentFlags = (long)(j.Flags ?? 0);
|
||||
var currentFlags = (long)(job.Flags ?? 0);
|
||||
|
||||
foreach (var jt in j.JobSubTypes)
|
||||
foreach (var jobSubType in job.JobSubTypes)
|
||||
{
|
||||
Dictionary<long, string> g;
|
||||
if (allFlags.TryGetValue(jt.Id, out g))
|
||||
if (allFlags.TryGetValue(jobSubType.Id, out var group))
|
||||
{
|
||||
foreach (var f in g)
|
||||
validFlags[f.Key] = new Tuple<string, bool>(string.Format("{0}: {1}", jt.Description, f.Value), ((currentFlags & f.Key) == f.Key));
|
||||
foreach (var option in group)
|
||||
validFlags[option.Key] = Tuple.Create($"{jobSubType.Description}: {option.Value}", (currentFlags & option.Key) == option.Key);
|
||||
}
|
||||
}
|
||||
return validFlags;
|
||||
|
||||
@@ -3,6 +3,12 @@
|
||||
Authorization.Require(Claims.Job.ShowFlags);
|
||||
|
||||
var validFlags = Model.Job.ValidFlagsGrouped();
|
||||
|
||||
if (validFlags.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var canEdit = Authorization.Has(Claims.Job.Properties.Flags);
|
||||
}
|
||||
<div id="jobDetailTab-Flags" class="jobPart">
|
||||
@@ -92,7 +98,8 @@
|
||||
$flagCheckboxes.click(updateFlags);
|
||||
});
|
||||
</script>
|
||||
}else
|
||||
}
|
||||
else
|
||||
{
|
||||
<script>
|
||||
$('#jobDetailTabItems').append('<li><a href="#jobDetailTab-Flags">Flags [@(validFlags.SelectMany(g => g.Value).Count(f => f.Item3))]</a></li>');
|
||||
|
||||
@@ -49,6 +49,12 @@ namespace Disco.Web.Views.Job.JobParts
|
||||
Authorization.Require(Claims.Job.ShowFlags);
|
||||
|
||||
var validFlags = Model.Job.ValidFlagsGrouped();
|
||||
|
||||
if (validFlags.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var canEdit = Authorization.Has(Claims.Job.Properties.Flags);
|
||||
|
||||
|
||||
@@ -67,13 +73,13 @@ WriteLiteral(" id=\"jobFlags\"");
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
|
||||
#line 10 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 16 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 10 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 16 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
foreach (var flagGroup in validFlags)
|
||||
{
|
||||
|
||||
@@ -87,7 +93,7 @@ WriteLiteral(" class=\"flagGroupName\"");
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 14 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 20 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
Write(flagGroup.Key);
|
||||
|
||||
|
||||
@@ -98,7 +104,7 @@ WriteLiteral("</span><br />\r\n");
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 15 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 21 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
Write(AjaxHelpers.AjaxLoader());
|
||||
|
||||
|
||||
@@ -107,13 +113,13 @@ WriteLiteral(" ");
|
||||
WriteLiteral("\r\n </th>\r\n <td>\r\n");
|
||||
|
||||
|
||||
#line 18 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 24 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 18 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 24 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
foreach (var flagItem in flagGroup.Value)
|
||||
{
|
||||
|
||||
@@ -124,31 +130,31 @@ WriteLiteral(" <div>\r\n <inpu
|
||||
|
||||
WriteLiteral(" type=\"checkbox\"");
|
||||
|
||||
WriteAttribute("value", Tuple.Create(" value=\"", 728), Tuple.Create("\"", 751)
|
||||
WriteAttribute("value", Tuple.Create(" value=\"", 795), Tuple.Create("\"", 818)
|
||||
|
||||
#line 21 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 736), Tuple.Create<System.Object, System.Int32>(flagItem.Item1
|
||||
#line 27 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 803), Tuple.Create<System.Object, System.Int32>(flagItem.Item1
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 736), false)
|
||||
, 803), false)
|
||||
);
|
||||
|
||||
WriteAttribute("id", Tuple.Create(" id=\"", 752), Tuple.Create("\"", 782)
|
||||
, Tuple.Create(Tuple.Create("", 757), Tuple.Create("jobFlag_", 757), true)
|
||||
WriteAttribute("id", Tuple.Create(" id=\"", 819), Tuple.Create("\"", 849)
|
||||
, Tuple.Create(Tuple.Create("", 824), Tuple.Create("jobFlag_", 824), true)
|
||||
|
||||
#line 21 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 765), Tuple.Create<System.Object, System.Int32>(flagItem.Item1
|
||||
#line 27 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 832), Tuple.Create<System.Object, System.Int32>(flagItem.Item1
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 765), false)
|
||||
, 832), false)
|
||||
);
|
||||
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 21 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 27 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
Write(flagItem.Item3 ? new HtmlString("checked=\"checked\"") : new HtmlString(string.Empty));
|
||||
|
||||
|
||||
@@ -157,7 +163,7 @@ WriteLiteral(" ");
|
||||
WriteLiteral(" ");
|
||||
|
||||
|
||||
#line 21 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 27 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
Write(canEdit ? new HtmlString(string.Empty) : new HtmlString("disabled=\"disabled\""));
|
||||
|
||||
|
||||
@@ -165,32 +171,32 @@ WriteLiteral(" ");
|
||||
#line hidden
|
||||
WriteLiteral(" /><label");
|
||||
|
||||
WriteAttribute("id", Tuple.Create(" id=\"", 965), Tuple.Create("\"", 1000)
|
||||
, Tuple.Create(Tuple.Create("", 970), Tuple.Create("jobFlagLabel_", 970), true)
|
||||
WriteAttribute("id", Tuple.Create(" id=\"", 1032), Tuple.Create("\"", 1067)
|
||||
, Tuple.Create(Tuple.Create("", 1037), Tuple.Create("jobFlagLabel_", 1037), true)
|
||||
|
||||
#line 21 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 983), Tuple.Create<System.Object, System.Int32>(flagItem.Item1
|
||||
#line 27 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1050), Tuple.Create<System.Object, System.Int32>(flagItem.Item1
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 983), false)
|
||||
, 1050), false)
|
||||
);
|
||||
|
||||
WriteAttribute("for", Tuple.Create(" for=\"", 1001), Tuple.Create("\"", 1032)
|
||||
, Tuple.Create(Tuple.Create("", 1007), Tuple.Create("jobFlag_", 1007), true)
|
||||
WriteAttribute("for", Tuple.Create(" for=\"", 1068), Tuple.Create("\"", 1099)
|
||||
, Tuple.Create(Tuple.Create("", 1074), Tuple.Create("jobFlag_", 1074), true)
|
||||
|
||||
#line 21 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1015), Tuple.Create<System.Object, System.Int32>(flagItem.Item1
|
||||
#line 27 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
, Tuple.Create(Tuple.Create("", 1082), Tuple.Create<System.Object, System.Int32>(flagItem.Item1
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
, 1015), false)
|
||||
, 1082), false)
|
||||
);
|
||||
|
||||
WriteLiteral(">");
|
||||
|
||||
|
||||
#line 21 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 27 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
Write(flagItem.Item2);
|
||||
|
||||
|
||||
@@ -199,7 +205,7 @@ WriteLiteral(">");
|
||||
WriteLiteral("</label>\r\n </div>\r\n");
|
||||
|
||||
|
||||
#line 23 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 29 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
}
|
||||
|
||||
|
||||
@@ -208,7 +214,7 @@ WriteLiteral("</label>\r\n </div>\r\n");
|
||||
WriteLiteral(" </td>\r\n </tr>\r\n");
|
||||
|
||||
|
||||
#line 26 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 32 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
}
|
||||
|
||||
|
||||
@@ -217,13 +223,13 @@ WriteLiteral(" </td>\r\n </tr>\r\n");
|
||||
WriteLiteral(" </table>\r\n");
|
||||
|
||||
|
||||
#line 28 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 34 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 28 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 34 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
if (canEdit)
|
||||
{
|
||||
|
||||
@@ -239,13 +245,13 @@ WriteLiteral(" title=\"Add Flag\"");
|
||||
WriteLiteral(">\r\n");
|
||||
|
||||
|
||||
#line 31 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 37 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
|
||||
|
||||
#line default
|
||||
#line hidden
|
||||
|
||||
#line 31 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 37 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
using (Html.BeginForm(MVC.API.Job.UpdateFlag(Model.Job.Id, null, null, true)))
|
||||
{
|
||||
|
||||
@@ -275,7 +281,7 @@ WriteLiteral(" class=\"block\"");
|
||||
WriteLiteral("></textarea>\r\n </p>\r\n");
|
||||
|
||||
|
||||
#line 38 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 44 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
}
|
||||
|
||||
|
||||
@@ -291,7 +297,7 @@ WriteLiteral(">\r\n $(\'#jobDetailTabItems\').append(\'<li><a href=\"
|
||||
"Flags [");
|
||||
|
||||
|
||||
#line 41 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 47 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
Write(validFlags.SelectMany(g => g.Value).Count(f => f.Item3));
|
||||
|
||||
|
||||
@@ -320,7 +326,7 @@ WriteLiteral(@"]</a></li>');
|
||||
$.getJSON('");
|
||||
|
||||
|
||||
#line 61 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 67 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
Write(Url.Action(MVC.API.Job.UpdateFlag(Model.Job.Id, null, null, false)));
|
||||
|
||||
|
||||
@@ -363,8 +369,9 @@ WriteLiteral(@"', { Flag: '-' + flagValue }, function (response, result) {
|
||||
");
|
||||
|
||||
|
||||
#line 95 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
}else
|
||||
#line 101 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
@@ -374,7 +381,7 @@ WriteLiteral(" <script>\r\n $(\'#jobDetailTabItems\').append(\
|
||||
"tailTab-Flags\">Flags [");
|
||||
|
||||
|
||||
#line 98 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 105 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
Write(validFlags.SelectMany(g => g.Value).Count(f => f.Item3));
|
||||
|
||||
|
||||
@@ -383,7 +390,7 @@ WriteLiteral(" <script>\r\n $(\'#jobDetailTabItems\').append(\
|
||||
WriteLiteral("]</a></li>\');\r\n </script>\r\n");
|
||||
|
||||
|
||||
#line 100 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
#line 107 "..\..\Views\Job\JobParts\Flags.cshtml"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user