Feature #2: Implement Repair Provider
Logging Repair for Non-Warranty jobs has been brought into line with Logging Warranty. RepairProviderFeature implemented which allows plugins to be used in submitting jobs to third-parties for repair.
This commit is contained in:
@@ -3,6 +3,12 @@
|
||||
Authorization.Require(Claims.Config.DeviceModel.Show);
|
||||
|
||||
var canConfig = Authorization.Has(Claims.Config.DeviceModel.Configure);
|
||||
var canViewPlugins = Authorization.Has(Claims.Config.Plugin.Install);
|
||||
|
||||
if (canConfig)
|
||||
{
|
||||
Html.BundleDeferred("~/ClientScripts/Modules/Disco-PropertyChangeHelpers");
|
||||
}
|
||||
|
||||
ViewBag.Title = Html.ToBreadcrumb("Configuration", MVC.Config.Config.Index(), "Device Models", MVC.Config.DeviceModel.Index(null), Model.DeviceModel.ToString());
|
||||
}
|
||||
@@ -23,6 +29,16 @@
|
||||
@Html.EditorFor(model => model.DeviceModel.Description)
|
||||
@AjaxHelpers.AjaxSave()
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceModel_Description'),
|
||||
'Model Description',
|
||||
'@Url.Action(MVC.API.DeviceModel.UpdateDescription(Model.DeviceModel.Id))',
|
||||
'Description'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -61,6 +77,19 @@
|
||||
{
|
||||
@Html.EditorFor(model => model.DeviceModel.DefaultPurchaseDate)
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
var dateField = $('#DeviceModel_DefaultPurchaseDate');
|
||||
document.DiscoFunctions.DateChangeHelper(
|
||||
dateField,
|
||||
'None',
|
||||
'@(Url.Action(MVC.API.DeviceModel.UpdateDefaultPurchaseDate(Model.DeviceModel.Id)))',
|
||||
'DefaultPurchaseDate',
|
||||
null,
|
||||
true
|
||||
);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -73,8 +102,33 @@
|
||||
</th>
|
||||
<td>@if (canConfig)
|
||||
{
|
||||
if (Model.WarrantyProviders.Count > 0)
|
||||
{
|
||||
@Html.DropDownListFor(model => model.DeviceModel.DefaultWarrantyProvider, Model.WarrantyProviders.ToSelectListItems(Model.DeviceModel.DefaultWarrantyProvider, true, "None"))
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceModel_DefaultWarrantyProvider'),
|
||||
null,
|
||||
'@Url.Action(MVC.API.DeviceModel.UpdateDefaultWarrantyProvider(Model.DeviceModel.Id))',
|
||||
'DefaultWarrantyProvider'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="smallMessage">No warranty provider plugins installed</span>
|
||||
}
|
||||
if (canViewPlugins)
|
||||
{
|
||||
<div class="info-box">
|
||||
<p class="fa-p">
|
||||
<i class="fa fa-info-circle"></i>View the <a href="@(Url.Action(MVC.Config.Plugins.Install()))">Plugin Catalogue</a> to discover and install warranty provider plugins.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -97,6 +151,60 @@
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Default Repair Provider:
|
||||
</th>
|
||||
<td>@if (canConfig)
|
||||
{
|
||||
if (Model.RepairProviders.Count > 0)
|
||||
{
|
||||
@Html.DropDownListFor(model => model.DeviceModel.DefaultRepairProvider, Model.RepairProviders.ToSelectListItems(Model.DeviceModel.DefaultRepairProvider, true, "None"))
|
||||
@AjaxHelpers.AjaxLoader()
|
||||
<script>
|
||||
$(function () {
|
||||
document.DiscoFunctions.PropertyChangeHelper(
|
||||
$('#DeviceModel_DefaultRepairProvider'),
|
||||
null,
|
||||
'@Url.Action(MVC.API.DeviceModel.UpdateDefaultRepairProvider(Model.DeviceModel.Id))',
|
||||
'DefaultRepairProvider'
|
||||
);
|
||||
});
|
||||
</script>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div>No repair provider plugins installed</div>
|
||||
}
|
||||
if (canViewPlugins)
|
||||
{
|
||||
<div class="info-box">
|
||||
<p class="fa-p">
|
||||
<i class="fa fa-info-circle"></i>View the <a href="@(Url.Action(MVC.Config.Plugins.Install()))">Plugin Catalogue</a> to discover and install repair provider plugins.
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Model.DeviceModel.DefaultRepairProvider == null)
|
||||
{
|
||||
<span class="smallMessage"><None Specified></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
var provider = Model.RepairProviders.FirstOrDefault(wp => wp.Id == Model.DeviceModel.DefaultRepairProvider);
|
||||
if (provider == null)
|
||||
{
|
||||
<span class="smallMessage"><None Specified></span>
|
||||
}
|
||||
else
|
||||
{
|
||||
@provider.Name
|
||||
}
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Type:
|
||||
</th>
|
||||
@@ -109,135 +217,18 @@
|
||||
</th>
|
||||
<td>
|
||||
<img alt="Model Image" src="@Url.Action(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, Model.DeviceModel.ImageHash()))" />
|
||||
@if (canConfig)
|
||||
{
|
||||
<hr />
|
||||
using (Html.BeginForm(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, true, null), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
<input type="file" name="Image" id="Image" style="width: 220px;" />
|
||||
<input class="button small" type="submit" value="Upload Image" />
|
||||
}
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
@if (canConfig)
|
||||
{
|
||||
<tr>
|
||||
<th>
|
||||
<label for="DeviceModel_Image">
|
||||
Update Image:
|
||||
</label>
|
||||
</th>
|
||||
<td>
|
||||
@using (Html.BeginForm(MVC.API.DeviceModel.Image(Model.DeviceModel.Id, true, null), FormMethod.Post, new { enctype = "multipart/form-data" }))
|
||||
{
|
||||
<input type="file" name="Image" id="Image" style="width: 250px;" />
|
||||
<input class="button" type="submit" value="Update" />
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</table>
|
||||
@if (canConfig)
|
||||
{
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var $Description = $('#DeviceModel_Description');
|
||||
var $DescriptionAjaxSave = $Description.next('.ajaxSave');
|
||||
$Description
|
||||
.watermark('Model Description')
|
||||
.focus(function () { $Description.select() })
|
||||
.keydown(function (e) {
|
||||
$DescriptionAjaxSave.show();
|
||||
if (e.which == 13) {
|
||||
$(this).blur();
|
||||
}
|
||||
}).blur(function () {
|
||||
$DescriptionAjaxSave.hide();
|
||||
})
|
||||
.change(function () {
|
||||
$DescriptionAjaxSave.hide();
|
||||
var $ajaxLoading = $DescriptionAjaxSave.next('.ajaxLoading').show();
|
||||
var data = { Description: $Description.val() };
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.DeviceModel.UpdateDescription(Model.DeviceModel.Id))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
$ajaxLoading.hide();
|
||||
alert('Unable to update description: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to update description: ' + textStatus);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var $dataField = $('#DeviceModel_DefaultPurchaseDate');
|
||||
var $ajaxLoading = $dataField.next('.ajaxLoading');
|
||||
var dateFieldValue = $dataField.val();
|
||||
var dateFieldChangeToken = null;
|
||||
$dataField
|
||||
.watermark('None')
|
||||
.datepicker({
|
||||
changeYear: true,
|
||||
changeMonth: true,
|
||||
dateFormat: 'yy/mm/dd'
|
||||
})
|
||||
.change(function () {
|
||||
var dateText = $dataField.val();
|
||||
if (dateFieldValue.toLowerCase() != dateText.toLowerCase()) {
|
||||
dateFieldValue = dateText;
|
||||
if (dateFieldChangeToken)
|
||||
window.clearTimeout(dateFieldChangeToken);
|
||||
dateFieldChangeToken = window.setTimeout(function () {
|
||||
$ajaxLoading.show();
|
||||
var data = {};
|
||||
data['DefaultPurchaseDate'] = dateFieldValue;
|
||||
$.getJSON('@(Url.Action(MVC.API.DeviceModel.UpdateDefaultPurchaseDate(Model.DeviceModel.Id)))', data, function (response, result) {
|
||||
if (result != 'success' || response != 'OK') {
|
||||
alert('Unable to change Date:\n' + response);
|
||||
$ajaxLoading.hide();
|
||||
} else {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
}
|
||||
})
|
||||
dateFieldChangeToken = null;
|
||||
}, 500);
|
||||
}
|
||||
}).focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
var $DefaultWarrantyProvider = $('#DeviceModel_DefaultWarrantyProvider');
|
||||
var $ajaxLoading = $DefaultWarrantyProvider.next('.ajaxLoading');
|
||||
$DefaultWarrantyProvider
|
||||
.change(function () {
|
||||
$ajaxLoading.show();
|
||||
var data = { DefaultWarrantyProvider: $DefaultWarrantyProvider.val() };
|
||||
$.ajax({
|
||||
url: '@Url.Action(MVC.API.DeviceModel.UpdateDefaultWarrantyProvider(Model.DeviceModel.Id))',
|
||||
dataType: 'json',
|
||||
data: data,
|
||||
success: function (d) {
|
||||
if (d == 'OK') {
|
||||
$ajaxLoading.hide().next('.ajaxOk').show().delay('fast').fadeOut('slow');
|
||||
} else {
|
||||
$ajaxLoading.hide();
|
||||
alert('Unable to default warranty provider: ' + d);
|
||||
}
|
||||
},
|
||||
error: function (jqXHR, textStatus, errorThrown) {
|
||||
alert('Unable to default warranty provider: ' + textStatus);
|
||||
$ajaxLoading.hide();
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
</div>
|
||||
<h2>Components</h2>
|
||||
@Html.Partial(MVC.Config.DeviceModel.Views._DeviceComponentsTable, Model.DeviceComponentsModel)
|
||||
|
||||
Reference in New Issue
Block a user