Feature #4: Pre-defined/Restricted Locations

Configurable list and location suggestions. Ability to restrict
locations. Shows 'occupied' locations.
This commit is contained in:
Gary Sharp
2014-02-17 21:44:34 +11:00
parent ed7caf8b4a
commit 5be747afbc
35 changed files with 2136 additions and 729 deletions
@@ -11,65 +11,6 @@
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
Html.BundleDeferred("~/ClientScripts/Modules/Disco-AjaxHelperIcons");
}
}
<div class="form" style="width: 530px;">
<h2>General Preferences</h2>
<table>
<tr>
<th style="width: 200px">Long Running Threshold:
</th>
<td>@if (canConfig)
{
@Html.DropDownListFor(model => model.LongRunningJobDaysThreshold, Model.LongRunningJobDaysThresholdOptions().Select(o => new SelectListItem() { Value = o.Key.ToString(), Text = o.Value }))
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
document.DiscoFunctions.PropertyChangeHelper(
$('#LongRunningJobDaysThreshold'),
null,
'@(Url.Action(MVC.API.JobPreferences.UpdateLongRunningJobDaysThreshold()))',
'LongRunningJobDaysThreshold');
});
</script>
}
else
{
@Model.LongRunningJobDaysThresholdOptions().First(o => o.Key == Model.LongRunningJobDaysThreshold).Value
}
<div class="smallMessage">
Jobs which have been open for longer than the threshold are considered 'long-running' and will appear in the <code>Long Running Jobs</code> list.
</div>
@if (Authorization.Has(Claims.Job.Lists.LongRunningJobs)) { @Html.ActionLinkSmallButton("Show Long Running Jobs", MVC.Job.LongRunning()) }
</td>
</tr>
<tr>
<th style="width: 200px">Stale Threshold:
</th>
<td>@if (canConfig)
{
@Html.DropDownListFor(model => model.StaleJobMinutesThreshold, Model.StaleJobMinutesThresholdOptions().Select(o => new SelectListItem() { Value = o.Key.ToString(), Text = o.Value }))
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
document.DiscoFunctions.PropertyChangeHelper(
$('#StaleJobMinutesThreshold'),
null,
'@(Url.Action(MVC.API.JobPreferences.UpdateStaleJobMinutesThreshold()))',
'StaleJobMinutesThreshold');
});
</script>
}
else
{
@Model.StaleJobMinutesThresholdOptions().First(o => o.Key == Model.StaleJobMinutesThreshold).Value
}
<div class="smallMessage">
Jobs which have no recoded action for longer than the threshold are considered 'stale' and will appear in the <code>Stale Jobs</code> list.
</div>
@if (Authorization.Has(Claims.Job.Lists.LongRunningJobs)) { @Html.ActionLinkSmallButton("Show Stale Jobs", MVC.Job.Stale()) }
</td>
</tr>
</table>
</div>
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.General);
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Locations);
}
@@ -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.
@@ -58,282 +58,12 @@ namespace Disco.Web.Areas.Config.Views.JobPreferences
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
Html.BundleDeferred("~/ClientScripts/Modules/Disco-AjaxHelperIcons");
}
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.General);
Html.RenderPartial(MVC.Config.JobPreferences.Views.Parts.Locations);
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 530px;\"");
WriteLiteral(">\r\n <h2>General Preferences</h2>\r\n <table>\r\n <tr>\r\n <th");
WriteLiteral(" style=\"width: 200px\"");
WriteLiteral(">Long Running Threshold:\r\n </th>\r\n <td>");
#line 21 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
if (canConfig)
{
#line default
#line hidden
#line 23 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(Html.DropDownListFor(model => model.LongRunningJobDaysThreshold, Model.LongRunningJobDaysThresholdOptions().Select(o => new SelectListItem() { Value = o.Key.ToString(), Text = o.Value })));
#line default
#line hidden
#line 23 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
#line default
#line hidden
#line 24 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(AjaxHelpers.AjaxSave());
#line default
#line hidden
#line 24 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
#line default
#line hidden
#line 25 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(AjaxHelpers.AjaxLoader());
#line default
#line hidden
#line 25 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
#line default
#line hidden
WriteLiteral(" <script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n document.DiscoFun" +
"ctions.PropertyChangeHelper(\r\n $(\'#LongRunningJobDays" +
"Threshold\'),\r\n null,\r\n \'");
#line 31 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(Url.Action(MVC.API.JobPreferences.UpdateLongRunningJobDaysThreshold()));
#line default
#line hidden
WriteLiteral("\',\r\n \'LongRunningJobDaysThreshold\');\r\n " +
" });\r\n </script>\r\n");
#line 35 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
}
else
{
#line default
#line hidden
#line 38 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(Model.LongRunningJobDaysThresholdOptions().First(o => o.Key == Model.LongRunningJobDaysThreshold).Value);
#line default
#line hidden
#line 38 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"smallMessage\"");
WriteLiteral(">\r\n Jobs which have been open for longer than the threshold ar" +
"e considered \'long-running\' and will appear in the <code>Long Running Jobs</code" +
"> list.\r\n </div>\r\n");
#line 43 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
#line default
#line hidden
#line 43 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
if (Authorization.Has(Claims.Job.Lists.LongRunningJobs)) {
#line default
#line hidden
#line 43 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(Html.ActionLinkSmallButton("Show Long Running Jobs", MVC.Job.LongRunning()));
#line default
#line hidden
#line 43 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n </tr>\r\n <tr>\r\n <th");
WriteLiteral(" style=\"width: 200px\"");
WriteLiteral(">Stale Threshold:\r\n </th>\r\n <td>");
#line 49 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
if (canConfig)
{
#line default
#line hidden
#line 51 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(Html.DropDownListFor(model => model.StaleJobMinutesThreshold, Model.StaleJobMinutesThresholdOptions().Select(o => new SelectListItem() { Value = o.Key.ToString(), Text = o.Value })));
#line default
#line hidden
#line 51 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
#line default
#line hidden
#line 52 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(AjaxHelpers.AjaxSave());
#line default
#line hidden
#line 52 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
#line default
#line hidden
#line 53 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(AjaxHelpers.AjaxLoader());
#line default
#line hidden
#line 53 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
#line default
#line hidden
WriteLiteral(" <script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n document.DiscoFun" +
"ctions.PropertyChangeHelper(\r\n $(\'#StaleJobMinutesThr" +
"eshold\'),\r\n null,\r\n \'");
#line 59 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(Url.Action(MVC.API.JobPreferences.UpdateStaleJobMinutesThreshold()));
#line default
#line hidden
WriteLiteral("\',\r\n \'StaleJobMinutesThreshold\');\r\n " +
" });\r\n </script>\r\n");
#line 63 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
}
else
{
#line default
#line hidden
#line 66 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(Model.StaleJobMinutesThresholdOptions().First(o => o.Key == Model.StaleJobMinutesThreshold).Value);
#line default
#line hidden
#line 66 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"smallMessage\"");
WriteLiteral(">\r\n Jobs which have no recoded action for longer than the thre" +
"shold are considered \'stale\' and will appear in the <code>Stale Jobs</code> list" +
".\r\n </div>\r\n");
#line 71 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
#line default
#line hidden
#line 71 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
if (Authorization.Has(Claims.Job.Lists.LongRunningJobs)) {
#line default
#line hidden
#line 71 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
Write(Html.ActionLinkSmallButton("Show Stale Jobs", MVC.Job.Stale()));
#line default
#line hidden
#line 71 "..\..\Areas\Config\Views\JobPreferences\Index.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n </tr>\r\n </table>\r\n</div>\r\n");
}
}
}
@@ -0,0 +1,67 @@
@model Disco.Web.Areas.Config.Models.JobPreferences.IndexModel
@{
Authorization.Require(Claims.Config.JobPreferences.Show);
var canConfig = Authorization.Has(Claims.Config.JobPreferences.Configure);
}
<div class="form" style="width: 530px;">
<h2>General Preferences</h2>
<table>
<tr>
<th style="width: 200px">Long Running Threshold:
</th>
<td>@if (canConfig)
{
@Html.DropDownListFor(model => model.LongRunningJobDaysThreshold, Model.LongRunningJobDaysThresholdOptions().Select(o => new SelectListItem() { Value = o.Key.ToString(), Text = o.Value }))
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
document.DiscoFunctions.PropertyChangeHelper(
$('#LongRunningJobDaysThreshold'),
null,
'@(Url.Action(MVC.API.JobPreferences.UpdateLongRunningJobDaysThreshold()))',
'LongRunningJobDaysThreshold');
});
</script>
}
else
{
@Model.LongRunningJobDaysThresholdOptions().First(o => o.Key == Model.LongRunningJobDaysThreshold).Value
}
<div class="smallMessage">
Jobs which have been open for longer than the threshold are considered 'long-running' and will appear in the <code>Long Running Jobs</code> list.
</div>
@if (Authorization.Has(Claims.Job.Lists.LongRunningJobs)) { @Html.ActionLinkSmallButton("Show Long Running Jobs", MVC.Job.LongRunning()) }
</td>
</tr>
<tr>
<th style="width: 200px">Stale Threshold:
</th>
<td>@if (canConfig)
{
@Html.DropDownListFor(model => model.StaleJobMinutesThreshold, Model.StaleJobMinutesThresholdOptions().Select(o => new SelectListItem() { Value = o.Key.ToString(), Text = o.Value }))
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<script type="text/javascript">
$(function () {
document.DiscoFunctions.PropertyChangeHelper(
$('#StaleJobMinutesThreshold'),
null,
'@(Url.Action(MVC.API.JobPreferences.UpdateStaleJobMinutesThreshold()))',
'StaleJobMinutesThreshold');
});
</script>
}
else
{
@Model.StaleJobMinutesThresholdOptions().First(o => o.Key == Model.StaleJobMinutesThreshold).Value
}
<div class="smallMessage">
Jobs which have no recoded action for longer than the threshold are considered 'stale' and will appear in the <code>Stale Jobs</code> list.
</div>
@if (Authorization.Has(Claims.Job.Lists.LongRunningJobs)) { @Html.ActionLinkSmallButton("Show Stale Jobs", MVC.Job.Stale()) }
</td>
</tr>
</table>
</div>
@@ -0,0 +1,332 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Areas.Config.Views.JobPreferences.Parts
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.BI.Extensions;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
using Disco.Web.Extensions;
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/JobPreferences/Parts/General.cshtml")]
public partial class General : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.JobPreferences.IndexModel>
{
public General()
{
}
public override void Execute()
{
#line 2 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Authorization.Require(Claims.Config.JobPreferences.Show);
var canConfig = Authorization.Has(Claims.Config.JobPreferences.Configure);
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 530px;\"");
WriteLiteral(">\r\n <h2>General Preferences</h2>\r\n <table>\r\n <tr>\r\n <th");
WriteLiteral(" style=\"width: 200px\"");
WriteLiteral(">Long Running Threshold:\r\n </th>\r\n <td>");
#line 13 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
if (canConfig)
{
#line default
#line hidden
#line 15 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(Html.DropDownListFor(model => model.LongRunningJobDaysThreshold, Model.LongRunningJobDaysThresholdOptions().Select(o => new SelectListItem() { Value = o.Key.ToString(), Text = o.Value })));
#line default
#line hidden
#line 15 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
#line default
#line hidden
#line 16 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(AjaxHelpers.AjaxSave());
#line default
#line hidden
#line 16 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
#line default
#line hidden
#line 17 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(AjaxHelpers.AjaxLoader());
#line default
#line hidden
#line 17 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
#line default
#line hidden
WriteLiteral(" <script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n document.DiscoFun" +
"ctions.PropertyChangeHelper(\r\n $(\'#LongRunningJobDays" +
"Threshold\'),\r\n null,\r\n \'");
#line 23 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(Url.Action(MVC.API.JobPreferences.UpdateLongRunningJobDaysThreshold()));
#line default
#line hidden
WriteLiteral("\',\r\n \'LongRunningJobDaysThreshold\');\r\n " +
" });\r\n </script>\r\n");
#line 27 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
}
else
{
#line default
#line hidden
#line 30 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(Model.LongRunningJobDaysThresholdOptions().First(o => o.Key == Model.LongRunningJobDaysThreshold).Value);
#line default
#line hidden
#line 30 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
}
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"smallMessage\"");
WriteLiteral(">\r\n Jobs which have been open for longer than the threshold ar" +
"e considered \'long-running\' and will appear in the <code>Long Running Jobs</code" +
"> list.\r\n </div>\r\n");
#line 35 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
#line default
#line hidden
#line 35 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
if (Authorization.Has(Claims.Job.Lists.LongRunningJobs)) {
#line default
#line hidden
#line 35 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(Html.ActionLinkSmallButton("Show Long Running Jobs", MVC.Job.LongRunning()));
#line default
#line hidden
#line 35 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n </tr>\r\n <tr>\r\n <th");
WriteLiteral(" style=\"width: 200px\"");
WriteLiteral(">Stale Threshold:\r\n </th>\r\n <td>");
#line 41 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
if (canConfig)
{
#line default
#line hidden
#line 43 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(Html.DropDownListFor(model => model.StaleJobMinutesThreshold, Model.StaleJobMinutesThresholdOptions().Select(o => new SelectListItem() { Value = o.Key.ToString(), Text = o.Value })));
#line default
#line hidden
#line 43 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
#line default
#line hidden
#line 44 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(AjaxHelpers.AjaxSave());
#line default
#line hidden
#line 44 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
#line default
#line hidden
#line 45 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(AjaxHelpers.AjaxLoader());
#line default
#line hidden
#line 45 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
#line default
#line hidden
WriteLiteral(" <script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n document.DiscoFun" +
"ctions.PropertyChangeHelper(\r\n $(\'#StaleJobMinutesThr" +
"eshold\'),\r\n null,\r\n \'");
#line 51 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(Url.Action(MVC.API.JobPreferences.UpdateStaleJobMinutesThreshold()));
#line default
#line hidden
WriteLiteral("\',\r\n \'StaleJobMinutesThreshold\');\r\n " +
" });\r\n </script>\r\n");
#line 55 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
}
else
{
#line default
#line hidden
#line 58 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(Model.StaleJobMinutesThresholdOptions().First(o => o.Key == Model.StaleJobMinutesThreshold).Value);
#line default
#line hidden
#line 58 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
}
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" class=\"smallMessage\"");
WriteLiteral(">\r\n Jobs which have no recoded action for longer than the thre" +
"shold are considered \'stale\' and will appear in the <code>Stale Jobs</code> list" +
".\r\n </div>\r\n");
#line 63 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
#line default
#line hidden
#line 63 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
if (Authorization.Has(Claims.Job.Lists.LongRunningJobs)) {
#line default
#line hidden
#line 63 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
Write(Html.ActionLinkSmallButton("Show Stale Jobs", MVC.Job.Stale()));
#line default
#line hidden
#line 63 "..\..\Areas\Config\Views\JobPreferences\Parts\General.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n </tr>\r\n </table>\r\n</div>");
}
}
}
#pragma warning restore 1591
@@ -0,0 +1,233 @@
@model Disco.Web.Areas.Config.Models.JobPreferences.IndexModel
@{
Authorization.Require(Claims.Config.JobPreferences.Show);
var canConfig = Authorization.Has(Claims.Config.JobPreferences.Configure);
}
<div id="Config_Location" class="form" style="width: 530px;">
<h2>Job Locations</h2>
<table>
<tr>
<th style="width: 200px">Mode:
</th>
<td>@if (canConfig)
{
@Html.DropDownListFor(model => model.LocationMode, Model.LocationModeOptions().Select(o => new SelectListItem() { Value = o.Key.ToString(), Text = o.Value }))
@AjaxHelpers.AjaxSave()
@AjaxHelpers.AjaxLoader()
<div id="Config_Location_Unrestricted">
<div style="padding: 0.7em 0.7em;" class="ui-state-highlight ui-corner-all">
<i class="fa fa-info-circle information"></i>&nbsp;Technicians will be able to specify <em>any</em> value when entering a location. A selection of locations used historically will be offered.
</div>
</div>
<div id="Config_Location_List">
<a id="Config_Location_List_Button" href="#" class="button small">Update List</a>
<div id="Config_Location_List_Dialog" class="dialog" title="Locations">
<div id="Config_Location_List_Dialog_ListContainer">
<span id="Config_Location_List_Dialog_None" class="smallMessage">The List is Empty</span>
<ul id="Config_Location_List_Dialog_List" class="none">
@foreach (var loc in Model.LocationList)
{
<li data-location="@loc">@loc<i class="fa fa-times-circle remove"></i></li>
}
</ul>
</div>
<div id="Config_Location_List_Dialog_AddContainer">
<input type="text" id="Config_Location_List_Dialog_TextAdd" />
<a id="Config_Location_List_Dialog_Add" href="#" class="button small">Add</a>
</div>
<form id="Config_Location_List_Dialog_Form" action="@(Url.Action(MVC.API.JobPreferences.UpdateLocationList(null, redirect: true)))" method="post"></form>
</div>
</div>
<div id="Config_Location_Optional">
<div style="padding: 0.7em 0.7em;" class="ui-state-highlight ui-corner-all">
<i class="fa fa-info-circle information"></i>&nbsp;Technicians will be able to specify <em>any</em> value when entering a location. A defined list of location options is suggested.
</div>
</div>
<div id="Config_Location_Restricted">
<div style="padding: 0.7em 0.7em;" class="ui-state-highlight ui-corner-all">
<i class="fa fa-info-circle information"></i>&nbsp;Technicians are restricted to select a location from the defined list.
</div>
</div>
<script type="text/javascript">
$(function () {
document.DiscoFunctions.PropertyChangeHelper(
$('#LocationMode'),
null,
'@(Url.Action(MVC.API.JobPreferences.UpdateLocationMode()))',
'LocationMode');
var $locationMode = $('#LocationMode');
function update() {
var $Config_Location_List = $('#Config_Location_List');
var $Config_Location_Unrestricted = $('#Config_Location_Unrestricted');
var $Config_Location_Optional = $('#Config_Location_Optional');
var $Config_Location_Restricted = $('#Config_Location_Restricted');
switch ($locationMode.val()) {
case 'Unrestricted':
$Config_Location_List.hide();
$Config_Location_Optional.hide();
$Config_Location_Restricted.hide();
$Config_Location_Unrestricted.show();
break;
case 'OptionalList':
$Config_Location_Unrestricted.hide();
$Config_Location_Restricted.hide();
$Config_Location_List.show();
$Config_Location_Optional.show();
break;
case 'RestrictedList':
$Config_Location_Unrestricted.hide();
$Config_Location_Optional.hide();
$Config_Location_List.show();
$Config_Location_Restricted.show();
break;
}
}
update();
$locationMode.change(update);
var dialog, textAdd, list, noList, form;
$('#Config_Location_List_Button').click(showDialog);
function showDialog() {
if (!dialog) {
dialog = $('#Config_Location_List_Dialog').dialog({
resizable: false,
modal: true,
autoOpen: false,
width: 350,
height: 420,
buttons: {
"Save Changes": saveChanges,
Cancel: cancel
}
});
dialog.on('click', '.remove', remove);
list = $('#Config_Location_List_Dialog_List');
noList = $('#Config_Location_List_Dialog_None');
textAdd = $('#Config_Location_List_Dialog_TextAdd');
textAdd.watermark('Location');
textAdd.keydown(function (e) {
if (e.keyCode == 13)
add();
});
$('#Config_Location_List_Dialog_Add').click(add);
}
dialog.dialog('open');
updateNoList();
return false;
}
function cancel() {
$(this).dialog("close");
list.find('li').each(function () {
$this = $(this);
if ($this.is('[data-status="new"]')) {
$this.remove();
} else {
if ($this.is('[data-status="removed"]')) {
$this.show();
$this.attr('data-status', '')
}
}
});
}
function remove() {
$this = $(this).closest('li');
if ($this.is('[data-status="new"]')) {
$this.remove();
} else {
$this.attr('data-status', 'removed').hide();
}
updateNoList();
}
function add() {
var value = textAdd.val();
// Trim
value = jQuery.trim(value);
if (!value) {
alert('Enter a location to be added');
return;
}
// Already Exists
var existingValues = list.find('li[data-location]').filter('[data-status!="removed"]').map(function () { return $(this).attr('data-location') }).get();
if (jQuery.inArray(value, existingValues) >= 0) {
alert('That item already exists in the list');
return;
}
// Add Item
var li = $('<li>')
.append($('<span>').text(value))
.append($('<i>').addClass('fa fa-times-circle remove'))
.attr('data-location', value)
.attr('data-status', 'new');
list.append(li);
textAdd.focus();
updateNoList();
}
function updateNoList() {
if (list.find('li:visible').length > 0)
noList.hide();
else
noList.show();
}
function saveChanges() {
var form = $('#Config_Location_List_Dialog_Form').empty();
list.find('li[data-status!="removed"]').each(function () {
var location = $(this).attr('data-location');
form.append($('<input>').attr({
'name': 'LocationList',
'type': 'hidden'
}).val(location));
}).get();
form.submit();
dialog.dialog("disable");
dialog.dialog("option", "buttons", null);
}
});
</script>
}
else
{
@Model.LocationModeOptions().First(o => o.Key == Model.LocationMode.ToString()).Value
}
</td>
</tr>
</table>
</div>
@@ -0,0 +1,435 @@
#pragma warning disable 1591
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.34011
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Disco.Web.Areas.Config.Views.JobPreferences.Parts
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Web.Helpers;
using System.Web.Mvc;
using System.Web.Mvc.Ajax;
using System.Web.Mvc.Html;
using System.Web.Routing;
using System.Web.Security;
using System.Web.UI;
using System.Web.WebPages;
using Disco;
using Disco.BI.Extensions;
using Disco.Models.Repository;
using Disco.Services;
using Disco.Services.Authorization;
using Disco.Services.Web;
using Disco.Web;
using Disco.Web.Extensions;
[System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")]
[System.Web.WebPages.PageVirtualPathAttribute("~/Areas/Config/Views/JobPreferences/Parts/Locations.cshtml")]
public partial class Locations : Disco.Services.Web.WebViewPage<Disco.Web.Areas.Config.Models.JobPreferences.IndexModel>
{
public Locations()
{
}
public override void Execute()
{
#line 2 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
Authorization.Require(Claims.Config.JobPreferences.Show);
var canConfig = Authorization.Has(Claims.Config.JobPreferences.Configure);
#line default
#line hidden
WriteLiteral("\r\n<div");
WriteLiteral(" id=\"Config_Location\"");
WriteLiteral(" class=\"form\"");
WriteLiteral(" style=\"width: 530px;\"");
WriteLiteral(">\r\n <h2>Job Locations</h2>\r\n <table>\r\n <tr>\r\n <th");
WriteLiteral(" style=\"width: 200px\"");
WriteLiteral(">Mode:\r\n </th>\r\n <td>");
#line 13 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
if (canConfig)
{
#line default
#line hidden
#line 15 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
Write(Html.DropDownListFor(model => model.LocationMode, Model.LocationModeOptions().Select(o => new SelectListItem() { Value = o.Key.ToString(), Text = o.Value })));
#line default
#line hidden
#line 15 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
#line default
#line hidden
#line 16 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
Write(AjaxHelpers.AjaxSave());
#line default
#line hidden
#line 16 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
#line default
#line hidden
#line 17 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
Write(AjaxHelpers.AjaxLoader());
#line default
#line hidden
#line 17 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
#line default
#line hidden
WriteLiteral(" <div");
WriteLiteral(" id=\"Config_Location_Unrestricted\"");
WriteLiteral(">\r\n <div");
WriteLiteral(" style=\"padding: 0.7em 0.7em;\"");
WriteLiteral(" class=\"ui-state-highlight ui-corner-all\"");
WriteLiteral(">\r\n <i");
WriteLiteral(" class=\"fa fa-info-circle information\"");
WriteLiteral("></i>&nbsp;Technicians will be able to specify <em>any</em> value when entering a" +
" location. A selection of locations used historically will be offered.\r\n " +
" </div>\r\n </div>\r\n");
WriteLiteral(" <div");
WriteLiteral(" id=\"Config_Location_List\"");
WriteLiteral(">\r\n <a");
WriteLiteral(" id=\"Config_Location_List_Button\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Update List</a>\r\n <div");
WriteLiteral(" id=\"Config_Location_List_Dialog\"");
WriteLiteral(" class=\"dialog\"");
WriteLiteral(" title=\"Locations\"");
WriteLiteral(">\r\n <div");
WriteLiteral(" id=\"Config_Location_List_Dialog_ListContainer\"");
WriteLiteral(">\r\n <span");
WriteLiteral(" id=\"Config_Location_List_Dialog_None\"");
WriteLiteral(" class=\"smallMessage\"");
WriteLiteral(">The List is Empty</span>\r\n <ul");
WriteLiteral(" id=\"Config_Location_List_Dialog_List\"");
WriteLiteral(" class=\"none\"");
WriteLiteral(">\r\n");
#line 29 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
#line default
#line hidden
#line 29 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
foreach (var loc in Model.LocationList)
{
#line default
#line hidden
WriteLiteral(" <li");
WriteLiteral(" data-location=\"");
#line 31 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
Write(loc);
#line default
#line hidden
WriteLiteral("\"");
WriteLiteral(">");
#line 31 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
Write(loc);
#line default
#line hidden
WriteLiteral("<i");
WriteLiteral(" class=\"fa fa-times-circle remove\"");
WriteLiteral("></i></li>\r\n");
#line 32 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
}
#line default
#line hidden
WriteLiteral(" </ul>\r\n </div>\r\n " +
" <div");
WriteLiteral(" id=\"Config_Location_List_Dialog_AddContainer\"");
WriteLiteral(">\r\n <input");
WriteLiteral(" type=\"text\"");
WriteLiteral(" id=\"Config_Location_List_Dialog_TextAdd\"");
WriteLiteral(" />\r\n <a");
WriteLiteral(" id=\"Config_Location_List_Dialog_Add\"");
WriteLiteral(" href=\"#\"");
WriteLiteral(" class=\"button small\"");
WriteLiteral(">Add</a>\r\n </div>\r\n <form");
WriteLiteral(" id=\"Config_Location_List_Dialog_Form\"");
WriteAttribute("action", Tuple.Create(" action=\"", 2359), Tuple.Create("\"", 2446)
#line 39 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
, Tuple.Create(Tuple.Create("", 2368), Tuple.Create<System.Object, System.Int32>(Url.Action(MVC.API.JobPreferences.UpdateLocationList(null, redirect: true))
#line default
#line hidden
, 2368), false)
);
WriteLiteral(" method=\"post\"");
WriteLiteral("></form>\r\n </div>\r\n </div>\r\n");
WriteLiteral(" <div");
WriteLiteral(" id=\"Config_Location_Optional\"");
WriteLiteral(">\r\n <div");
WriteLiteral(" style=\"padding: 0.7em 0.7em;\"");
WriteLiteral(" class=\"ui-state-highlight ui-corner-all\"");
WriteLiteral(">\r\n <i");
WriteLiteral(" class=\"fa fa-info-circle information\"");
WriteLiteral("></i>&nbsp;Technicians will be able to specify <em>any</em> value when entering a" +
" location. A defined list of location options is suggested.\r\n " +
" </div>\r\n </div>\r\n");
WriteLiteral(" <div");
WriteLiteral(" id=\"Config_Location_Restricted\"");
WriteLiteral(">\r\n <div");
WriteLiteral(" style=\"padding: 0.7em 0.7em;\"");
WriteLiteral(" class=\"ui-state-highlight ui-corner-all\"");
WriteLiteral(">\r\n <i");
WriteLiteral(" class=\"fa fa-info-circle information\"");
WriteLiteral("></i>&nbsp;Technicians are restricted to select a location from the defined list." +
"\r\n </div>\r\n </div>\r\n");
WriteLiteral(" <script");
WriteLiteral(" type=\"text/javascript\"");
WriteLiteral(">\r\n $(function () {\r\n document.DiscoFun" +
"ctions.PropertyChangeHelper(\r\n $(\'#LocationMode\'),\r\n " +
" null,\r\n \'");
#line 57 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
Write(Url.Action(MVC.API.JobPreferences.UpdateLocationMode()));
#line default
#line hidden
WriteLiteral("\',\r\n \'LocationMode\');\r\n\r\n var $" +
"locationMode = $(\'#LocationMode\');\r\n\r\n function update() " +
"{\r\n var $Config_Location_List = $(\'#Config_Location_L" +
"ist\');\r\n\r\n var $Config_Location_Unrestricted = $(\'#Co" +
"nfig_Location_Unrestricted\');\r\n var $Config_Location_" +
"Optional = $(\'#Config_Location_Optional\');\r\n var $Con" +
"fig_Location_Restricted = $(\'#Config_Location_Restricted\');\r\n\r\n\r\n " +
" switch ($locationMode.val()) {\r\n cas" +
"e \'Unrestricted\':\r\n $Config_Location_List.hid" +
"e();\r\n $Config_Location_Optional.hide();\r\n " +
" $Config_Location_Restricted.hide();\r\n\r\n " +
" $Config_Location_Unrestricted.show();\r\n " +
" break;\r\n case \'OptionalLis" +
"t\':\r\n $Config_Location_Unrestricted.hide();\r\n" +
" $Config_Location_Restricted.hide();\r\n\r\n " +
" $Config_Location_List.show();\r\n " +
" $Config_Location_Optional.show();\r\n " +
" break;\r\n case \'RestrictedList\':\r\n " +
" $Config_Location_Unrestricted.hide();\r\n " +
" $Config_Location_Optional.hide();\r\n\r\n " +
" $Config_Location_List.show();\r\n " +
" $Config_Location_Restricted.show();\r\n bre" +
"ak;\r\n }\r\n }\r\n " +
" update();\r\n $locationMode.change(update);\r\n\r\n " +
" var dialog, textAdd, list, noList, form;\r\n\r\n " +
" $(\'#Config_Location_List_Button\').click(showDialog);\r\n\r\n " +
" function showDialog() {\r\n if (!dialog) {\r\n " +
" dialog = $(\'#Config_Location_List_Dialog\').dialog({\r" +
"\n resizable: false,\r\n " +
" modal: true,\r\n autoOpen: false,\r\n" +
" width: 350,\r\n " +
" height: 420,\r\n buttons: {\r\n " +
" \"Save Changes\": saveChanges,\r\n " +
" Cancel: cancel\r\n }\r\n " +
" });\r\n\r\n dialog.on(\'click\'" +
", \'.remove\', remove);\r\n\r\n list = $(\'#Config_Locat" +
"ion_List_Dialog_List\');\r\n noList = $(\'#Config_Loc" +
"ation_List_Dialog_None\');\r\n\r\n textAdd = $(\'#Confi" +
"g_Location_List_Dialog_TextAdd\');\r\n\r\n textAdd.wat" +
"ermark(\'Location\');\r\n textAdd.keydown(function (e" +
") {\r\n if (e.keyCode == 13)\r\n " +
" add();\r\n });\r\n\r\n " +
" $(\'#Config_Location_List_Dialog_Add\').click(add);\r\n " +
" }\r\n\r\n dialog.dialog(\'open\');\r\n\r\n" +
" updateNoList();\r\n return " +
"false;\r\n }\r\n\r\n function cancel() {" +
"\r\n $(this).dialog(\"close\");\r\n\r\n " +
" list.find(\'li\').each(function () {\r\n $this " +
"= $(this);\r\n if ($this.is(\'[data-status=\"new\"]\'))" +
" {\r\n $this.remove();\r\n " +
" } else {\r\n if ($this.is(\'[data-statu" +
"s=\"removed\"]\')) {\r\n $this.show();\r\n " +
" $this.attr(\'data-status\', \'\')\r\n " +
" }\r\n }\r\n " +
" });\r\n }\r\n\r\n function remove" +
"() {\r\n $this = $(this).closest(\'li\');\r\n\r\n " +
" if ($this.is(\'[data-status=\"new\"]\')) {\r\n " +
" $this.remove();\r\n } else {\r\n " +
" $this.attr(\'data-status\', \'removed\').hide();\r\n " +
" }\r\n\r\n updateNoList();\r\n " +
" }\r\n\r\n function add() {\r\n\r\n " +
"var value = textAdd.val();\r\n\r\n // Trim\r\n " +
" value = jQuery.trim(value);\r\n\r\n if (!v" +
"alue) {\r\n alert(\'Enter a location to be added\');\r" +
"\n return;\r\n }\r\n\r\n " +
" // Already Exists\r\n var existi" +
"ngValues = list.find(\'li[data-location]\').filter(\'[data-status!=\"removed\"]\').map" +
"(function () { return $(this).attr(\'data-location\') }).get();\r\n " +
" if (jQuery.inArray(value, existingValues) >= 0) {\r\n " +
" alert(\'That item already exists in the list\');\r\n " +
" return;\r\n }\r\n\r\n " +
" // Add Item\r\n var li = $(\'<li>\')\r\n " +
" .append($(\'<span>\').text(value))\r\n " +
" .append($(\'<i>\').addClass(\'fa fa-times-circle remove\'))\r\n " +
" .attr(\'data-location\', value)\r\n .attr" +
"(\'data-status\', \'new\');\r\n\r\n list.append(li);\r\n\r\n " +
" textAdd.focus();\r\n\r\n updateNoL" +
"ist();\r\n }\r\n\r\n function updateNoLi" +
"st() {\r\n if (list.find(\'li:visible\').length > 0)\r\n " +
" noList.hide();\r\n else\r\n " +
" noList.show();\r\n }\r\n\r\n " +
" function saveChanges() {\r\n var fo" +
"rm = $(\'#Config_Location_List_Dialog_Form\').empty();\r\n\r\n " +
" list.find(\'li[data-status!=\"removed\"]\').each(function () {\r\n " +
" var location = $(this).attr(\'data-location\');\r\n\r\n " +
" form.append($(\'<input>\').attr({\r\n " +
" \'name\': \'LocationList\',\r\n \'type\': \'hidd" +
"en\'\r\n }).val(location));\r\n\r\n " +
" }).get();\r\n\r\n form.submit();\r\n\r\n " +
" dialog.dialog(\"disable\");\r\n dialog.dial" +
"og(\"option\", \"buttons\", null);\r\n }\r\n }" +
");\r\n </script>\r\n");
#line 225 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
}
else
{
#line default
#line hidden
#line 228 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
Write(Model.LocationModeOptions().First(o => o.Key == Model.LocationMode.ToString()).Value);
#line default
#line hidden
#line 228 "..\..\Areas\Config\Views\JobPreferences\Parts\Locations.cshtml"
}
#line default
#line hidden
WriteLiteral(" </td>\r\n </tr>\r\n </table>\r\n</div>\r\n");
}
}
}
#pragma warning restore 1591