Update: Quick Log & Queue Support
This commit is contained in:
@@ -10,7 +10,7 @@ namespace Disco.BI.JobBI
|
||||
{
|
||||
public static class Utilities
|
||||
{
|
||||
public static Job Create(DiscoDataContext Database, Device device, User user, JobType type, List<JobSubType> subTypes, User initialTech)
|
||||
public static Job Create(DiscoDataContext Database, Device device, User user, JobType type, List<JobSubType> subTypes, User initialTech, bool addAutoQueues = true)
|
||||
{
|
||||
Job j = new Job()
|
||||
{
|
||||
@@ -41,31 +41,34 @@ namespace Disco.BI.JobBI
|
||||
Database.Jobs.Add(j);
|
||||
|
||||
// Job Queues
|
||||
var queues = from st in subTypes
|
||||
from jq in st.JobQueues
|
||||
group st by jq into g
|
||||
select new { queue = g.Key, subTypes = g };
|
||||
foreach (var queue in queues)
|
||||
if (addAutoQueues)
|
||||
{
|
||||
var commentBuilder = new StringBuilder("Automatically added by:");
|
||||
foreach (var subType in queue.subTypes)
|
||||
var queues = from st in subTypes
|
||||
from jq in st.JobQueues
|
||||
group st by jq into g
|
||||
select new { queue = g.Key, subTypes = g };
|
||||
foreach (var queue in queues)
|
||||
{
|
||||
commentBuilder.AppendLine();
|
||||
commentBuilder.Append(subType.Description);
|
||||
var commentBuilder = new StringBuilder("Automatically added by:");
|
||||
foreach (var subType in queue.subTypes)
|
||||
{
|
||||
commentBuilder.AppendLine();
|
||||
commentBuilder.Append(subType.Description);
|
||||
}
|
||||
|
||||
var jqj = new JobQueueJob()
|
||||
{
|
||||
JobQueueId = queue.queue.Id,
|
||||
Job = j,
|
||||
AddedDate = DateTime.Now,
|
||||
AddedUserId = initialTech.Id,
|
||||
AddedComment = commentBuilder.ToString(),
|
||||
SLAExpiresDate = queue.queue.DefaultSLAExpiry.HasValue ? (DateTime?)DateTime.Now.AddMinutes(queue.queue.DefaultSLAExpiry.Value) : null,
|
||||
Priority = JobQueuePriority.Normal
|
||||
};
|
||||
|
||||
Database.JobQueueJobs.Add(jqj);
|
||||
}
|
||||
|
||||
var jqj = new JobQueueJob()
|
||||
{
|
||||
JobQueueId = queue.queue.Id,
|
||||
Job = j,
|
||||
AddedDate = DateTime.Now,
|
||||
AddedUserId = initialTech.Id,
|
||||
AddedComment = commentBuilder.ToString(),
|
||||
SLAExpiresDate = queue.queue.DefaultSLAExpiry.HasValue ? (DateTime?)DateTime.Now.AddMinutes(queue.queue.DefaultSLAExpiry.Value) : null,
|
||||
Priority = JobQueuePriority.Normal
|
||||
};
|
||||
|
||||
Database.JobQueueJobs.Add(jqj);
|
||||
}
|
||||
|
||||
switch (type.Id)
|
||||
|
||||
@@ -724,6 +724,9 @@
|
||||
#createJob_Container #createJob_SubTypes li.highlight i {
|
||||
display: inline-block;
|
||||
}
|
||||
#createJob_Container #createJob_SubTypes.isQuickLog li i {
|
||||
display: none;
|
||||
}
|
||||
#createJob_Container #createJob_CommentsContainer #Comments {
|
||||
width: 100%;
|
||||
min-width: 500px;
|
||||
|
||||
@@ -756,6 +756,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
#createJob_SubTypes.isQuickLog li i {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
#createJob_CommentsContainer {
|
||||
#Comments {
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -396,7 +396,13 @@ namespace Disco.Web.Controllers
|
||||
{
|
||||
// Create New Job
|
||||
var currentUser = Database.Users.Find(UserService.CurrentUserId);
|
||||
var j = BI.JobBI.Utilities.Create(Database, m.Device, m.User, m.GetJobType, m.GetJobSubTypes, currentUser);
|
||||
|
||||
// Try QuickLog?
|
||||
bool addAutoQueues = !(Authorization.Has(Claims.Job.Actions.Close)
|
||||
&& m.QuickLog.HasValue && m.QuickLog.Value
|
||||
&& m.QuickLogTaskTimeMinutes.HasValue && m.QuickLogTaskTimeMinutes.Value > 0);
|
||||
|
||||
var j = BI.JobBI.Utilities.Create(Database, m.Device, m.User, m.GetJobType, m.GetJobSubTypes, currentUser, addAutoQueues);
|
||||
|
||||
if (m.DeviceHeld.Value)
|
||||
{
|
||||
|
||||
@@ -258,7 +258,6 @@
|
||||
|
||||
$deviceHeld.change(validateQuickLog);
|
||||
$jobTypes.change(validateQuickLog);
|
||||
$('#createJob_SubTypes').on('change', 'input', validateQuickLog);
|
||||
validateQuickLog();
|
||||
|
||||
function validateQuickLog() {
|
||||
@@ -275,11 +274,7 @@
|
||||
case 'SImg':
|
||||
case 'SOS':
|
||||
case 'UMgmt':
|
||||
// If Job-Queues are configured for a Sub-Type, don't allow quick-log.
|
||||
if ($('#createJob_SubType_' + $jobTypes.filter(':checked').val()).find('input:checked').closest('li').has('i.queue').length == 0)
|
||||
quickLogAllowed = true;
|
||||
else
|
||||
quickLogAllowed = false;
|
||||
quickLogAllowed = true;
|
||||
break;
|
||||
default:
|
||||
quickLogAllowed = false;
|
||||
@@ -301,8 +296,10 @@
|
||||
$quickLog.change(function () {
|
||||
if ($(this).is(':checked')) {
|
||||
$quickLogTaskTimeContainer.slideDown();
|
||||
$('#createJob_SubTypes').addClass('isQuickLog');
|
||||
} else {
|
||||
$quickLogTaskTimeContainer.slideUp();
|
||||
$('#createJob_SubTypes').removeClass('isQuickLog');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.34003
|
||||
// Runtime Version:4.0.30319.34011
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
@@ -701,43 +701,40 @@ WriteLiteral("\r\n //#region QuickLog\r\n var $quickLog =
|
||||
"teJob_TaskTimeOtherMinutes\');\r\n var $quickLogTaskTimeValidationMessag" +
|
||||
"e = $quickLogTaskTimeContainer.find(\'[data-valmsg-for=\"QuickLogTaskTimeMinutes\"]" +
|
||||
"\');\r\n\r\n $deviceHeld.change(validateQuickLog);\r\n $jobTypes." +
|
||||
"change(validateQuickLog);\r\n $(\'#createJob_SubTypes\').on(\'change\', \'in" +
|
||||
"put\', validateQuickLog);\r\n validateQuickLog();\r\n\r\n functio" +
|
||||
"n validateQuickLog() {\r\n var quickLogAllowed = false;\r\n\r\n " +
|
||||
" if ($deviceHeld.val() === \'True\') {\r\n quickLogAllowed" +
|
||||
" = false;\r\n } else {\r\n // Allow Quick-Log only" +
|
||||
" for certain Job Types\r\n var selectedType = $jobTypes.filter(" +
|
||||
"\':checked\').val();\r\n switch (selectedType) {\r\n " +
|
||||
" case \'HMisc\':\r\n case \'SApp\':\r\n " +
|
||||
" case \'SImg\':\r\n case \'SOS\':\r\n " +
|
||||
" case \'UMgmt\':\r\n // If Job-Queues are configured for " +
|
||||
"a Sub-Type, don\'t allow quick-log.\r\n if ($(\'#createJo" +
|
||||
"b_SubType_\' + $jobTypes.filter(\':checked\').val()).find(\'input:checked\').closest(" +
|
||||
"\'li\').has(\'i.queue\').length == 0)\r\n quickLogAllow" +
|
||||
"ed = true;\r\n else\r\n qu" +
|
||||
"ickLogAllowed = false;\r\n break;\r\n " +
|
||||
" default:\r\n quickLogAllowed = false;\r\n " +
|
||||
" break;\r\n }\r\n }\r\n\r\n " +
|
||||
" if (quickLogAllowed) {\r\n $quickLogContainer.slideDown();\r" +
|
||||
"\n } else {\r\n if (init)\r\n " +
|
||||
" $quickLogContainer.hide();\r\n else\r\n " +
|
||||
"$quickLogContainer.slideUp();\r\n $quickLog.prop(\'checked\', fal" +
|
||||
"se).change();\r\n }\r\n }\r\n\r\n $quickLog.change(" +
|
||||
"function () {\r\n if ($(this).is(\':checked\')) {\r\n " +
|
||||
" $quickLogTaskTimeContainer.slideDown();\r\n } else {\r\n " +
|
||||
" $quickLogTaskTimeContainer.slideUp();\r\n }\r\n }" +
|
||||
");\r\n\r\n $quickLogTaskTimes.change(function () {\r\n if ($" +
|
||||
"quickLogTaskTimes.filter(\':checked\').val() === \"\") {\r\n $(\'#cr" +
|
||||
"eateJob_TaskTimeOtherMinutesContainer\').show();\r\n $quickLogTa" +
|
||||
"skTimeOtherMinutes.attr(\'disabled\', null).focus().select();\r\n } e" +
|
||||
"lse {\r\n $(\'#createJob_TaskTimeOtherMinutesContainer\').hide();" +
|
||||
"\r\n $quickLogTaskTimeOtherMinutes.attr(\'disabled\', \'disabled\')" +
|
||||
";\r\n }\r\n });\r\n //#endregion\r\n ");
|
||||
"change(validateQuickLog);\r\n validateQuickLog();\r\n\r\n functi" +
|
||||
"on validateQuickLog() {\r\n var quickLogAllowed = false;\r\n\r\n " +
|
||||
" if ($deviceHeld.val() === \'True\') {\r\n quickLogAllowe" +
|
||||
"d = false;\r\n } else {\r\n // Allow Quick-Log onl" +
|
||||
"y for certain Job Types\r\n var selectedType = $jobTypes.filter" +
|
||||
"(\':checked\').val();\r\n switch (selectedType) {\r\n " +
|
||||
" case \'HMisc\':\r\n case \'SApp\':\r\n " +
|
||||
" case \'SImg\':\r\n case \'SOS\':\r\n " +
|
||||
" case \'UMgmt\':\r\n quickLogAllowed = true;\r\n " +
|
||||
" break;\r\n default:\r\n " +
|
||||
" quickLogAllowed = false;\r\n break;\r\n " +
|
||||
" }\r\n }\r\n\r\n if (quickLogAllowed) {\r\n " +
|
||||
" $quickLogContainer.slideDown();\r\n } else {\r\n " +
|
||||
" if (init)\r\n $quickLogContainer.hide();\r\n " +
|
||||
" else\r\n $quickLogContainer.slideUp();\r\n " +
|
||||
" $quickLog.prop(\'checked\', false).change();\r\n }\r\n" +
|
||||
" }\r\n\r\n $quickLog.change(function () {\r\n if " +
|
||||
"($(this).is(\':checked\')) {\r\n $quickLogTaskTimeContainer.slide" +
|
||||
"Down();\r\n $(\'#createJob_SubTypes\').addClass(\'isQuickLog\');\r\n " +
|
||||
" } else {\r\n $quickLogTaskTimeContainer.slideUp(" +
|
||||
");\r\n $(\'#createJob_SubTypes\').removeClass(\'isQuickLog\');\r\n " +
|
||||
" }\r\n });\r\n\r\n $quickLogTaskTimes.change(functio" +
|
||||
"n () {\r\n if ($quickLogTaskTimes.filter(\':checked\').val() === \"\") " +
|
||||
"{\r\n $(\'#createJob_TaskTimeOtherMinutesContainer\').show();\r\n " +
|
||||
" $quickLogTaskTimeOtherMinutes.attr(\'disabled\', null).focus().s" +
|
||||
"elect();\r\n } else {\r\n $(\'#createJob_TaskTimeOt" +
|
||||
"herMinutesContainer\').hide();\r\n $quickLogTaskTimeOtherMinutes" +
|
||||
".attr(\'disabled\', \'disabled\');\r\n }\r\n });\r\n " +
|
||||
"//#endregion\r\n ");
|
||||
|
||||
WriteLiteral("\r\n");
|
||||
|
||||
|
||||
#line 320 "..\..\Views\Job\Create.cshtml"
|
||||
#line 317 "..\..\Views\Job\Create.cshtml"
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user