Validation is working on Settings -> Indexers again.
This commit is contained in:
parent
11db27f6ac
commit
1a5b20a48b
|
@ -0,0 +1,86 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Web;
|
||||||
|
using System.Web.Mvc;
|
||||||
|
|
||||||
|
namespace NzbDrone.Web.Helpers.Validation
|
||||||
|
{
|
||||||
|
public class RequiredIfAttribute : ValidationAttribute, IClientValidatable
|
||||||
|
{
|
||||||
|
private RequiredAttribute _innerAttribute = new RequiredAttribute();
|
||||||
|
|
||||||
|
public string DependentProperty { get; set; }
|
||||||
|
public object TargetValue { get; set; }
|
||||||
|
|
||||||
|
public RequiredIfAttribute(string dependentProperty, object targetValue)
|
||||||
|
{
|
||||||
|
this.DependentProperty = dependentProperty;
|
||||||
|
this.TargetValue = targetValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override ValidationResult IsValid(object value, ValidationContext validationContext)
|
||||||
|
{
|
||||||
|
// get a reference to the property this validation depends upon
|
||||||
|
var containerType = validationContext.ObjectInstance.GetType();
|
||||||
|
var field = containerType.GetProperty(this.DependentProperty);
|
||||||
|
|
||||||
|
if (field != null)
|
||||||
|
{
|
||||||
|
// get the value of the dependent property
|
||||||
|
var dependentvalue = field.GetValue(validationContext.ObjectInstance, null);
|
||||||
|
|
||||||
|
// compare the value against the target value
|
||||||
|
if ((dependentvalue == null && this.TargetValue == null) ||
|
||||||
|
(dependentvalue != null && dependentvalue.Equals(this.TargetValue)))
|
||||||
|
{
|
||||||
|
// match => means we should try validating this field
|
||||||
|
if (!_innerAttribute.IsValid(value))
|
||||||
|
// validation failed - return an error
|
||||||
|
return new ValidationResult(this.ErrorMessage, new[] { validationContext.MemberName });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ValidationResult.Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext context)
|
||||||
|
{
|
||||||
|
var rule = new ModelClientValidationRule()
|
||||||
|
{
|
||||||
|
ErrorMessage = FormatErrorMessage(metadata.GetDisplayName()),
|
||||||
|
ValidationType = "requiredif",
|
||||||
|
};
|
||||||
|
|
||||||
|
string depProp = BuildDependentPropertyId(metadata, context as ViewContext);
|
||||||
|
|
||||||
|
// find the value on the control we depend on;
|
||||||
|
// if it's a bool, format it javascript style
|
||||||
|
// (the default is True or False!)
|
||||||
|
string targetValue = (this.TargetValue ?? "").ToString();
|
||||||
|
if (this.TargetValue.GetType() == typeof(bool))
|
||||||
|
targetValue = targetValue.ToLower();
|
||||||
|
|
||||||
|
rule.ValidationParameters.Add("dependentproperty", depProp);
|
||||||
|
rule.ValidationParameters.Add("targetvalue", targetValue);
|
||||||
|
|
||||||
|
yield return rule;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string BuildDependentPropertyId(ModelMetadata metadata, ViewContext viewContext)
|
||||||
|
{
|
||||||
|
// build the ID of the property
|
||||||
|
string depProp = viewContext.ViewData.TemplateInfo.GetFullHtmlFieldId(this.DependentProperty);
|
||||||
|
// unfortunately this will have the name of the current field appended to the beginning,
|
||||||
|
// because the TemplateInfo's context has had this fieldname appended to it. Instead, we
|
||||||
|
// want to get the context as though it was one level higher (i.e. outside the current property,
|
||||||
|
// which is the containing object (our Person), and hence the same level as the dependent property.
|
||||||
|
var thisField = metadata.PropertyName + "_";
|
||||||
|
if (depProp.StartsWith(thisField))
|
||||||
|
// strip it off again
|
||||||
|
depProp = depProp.Substring(thisField.Length);
|
||||||
|
return depProp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using NzbDrone.Core.Repository;
|
using NzbDrone.Core.Repository;
|
||||||
|
using NzbDrone.Web.Helpers.Validation;
|
||||||
|
|
||||||
namespace NzbDrone.Web.Models
|
namespace NzbDrone.Web.Models
|
||||||
{
|
{
|
||||||
|
@ -12,48 +13,56 @@ namespace NzbDrone.Web.Models
|
||||||
[DisplayName("Username")]
|
[DisplayName("Username")]
|
||||||
[Description("Username for NZB Matrix")]
|
[Description("Username for NZB Matrix")]
|
||||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||||
|
[RequiredIf("NzbMatrixEnabled", true, ErrorMessage = "USername Required when NZBMatrix is enabled")]
|
||||||
public String NzbMatrixUsername { get; set; }
|
public String NzbMatrixUsername { get; set; }
|
||||||
|
|
||||||
[DataType(DataType.Text)]
|
[DataType(DataType.Text)]
|
||||||
[DisplayName("API Key")]
|
[DisplayName("API Key")]
|
||||||
[Description("API Key for NZB Matrix")]
|
[Description("API Key for NZB Matrix")]
|
||||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||||
|
[RequiredIf("NzbMatrixEnabled", true, ErrorMessage = "API Key Required when NZBMatrix is enabled")]
|
||||||
public String NzbMatrixApiKey { get; set; }
|
public String NzbMatrixApiKey { get; set; }
|
||||||
|
|
||||||
[DataType(DataType.Text)]
|
[DataType(DataType.Text)]
|
||||||
[DisplayName("UID")]
|
[DisplayName("UID")]
|
||||||
[Description("User ID for Nzbs.org")]
|
[Description("User ID for Nzbs.org")]
|
||||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||||
|
[RequiredIf("NzbsOrgEnabled", true, ErrorMessage = "UID Required when Nzbs.org is enabled")]
|
||||||
public String NzbsOrgUId { get; set; }
|
public String NzbsOrgUId { get; set; }
|
||||||
|
|
||||||
[DataType(DataType.Text)]
|
[DataType(DataType.Text)]
|
||||||
[DisplayName("Hash")]
|
[DisplayName("Hash")]
|
||||||
[Description("Hash for Nzbs.org")]
|
[Description("Hash for Nzbs.org")]
|
||||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||||
|
[RequiredIf("NzbsOrgEnabled", true, ErrorMessage = "Hash Required when Nzbs.org is enabled")]
|
||||||
public String NzbsOrgHash { get; set; }
|
public String NzbsOrgHash { get; set; }
|
||||||
|
|
||||||
[DataType(DataType.Text)]
|
[DataType(DataType.Text)]
|
||||||
[DisplayName("UID")]
|
[DisplayName("UID")]
|
||||||
[Description("User ID for NZBsRus")]
|
[Description("User ID for NZBsRus")]
|
||||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||||
|
[RequiredIf("NzbsRUsEnabled", true, ErrorMessage = "UID Required when NzbsRus is enabled")]
|
||||||
public String NzbsrusUId { get; set; }
|
public String NzbsrusUId { get; set; }
|
||||||
|
|
||||||
[DataType(DataType.Text)]
|
[DataType(DataType.Text)]
|
||||||
[DisplayName("Hash")]
|
[DisplayName("Hash")]
|
||||||
[Description("Hash for NZBsRus")]
|
[Description("Hash for NZBsRus")]
|
||||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||||
|
[RequiredIf("NzbsRUsEnabled", true, ErrorMessage = "Hash Required when NzbsRus is enabled")]
|
||||||
public String NzbsrusHash { get; set; }
|
public String NzbsrusHash { get; set; }
|
||||||
|
|
||||||
[DataType(DataType.Text)]
|
[DataType(DataType.Text)]
|
||||||
[DisplayName("Username")]
|
[DisplayName("Username")]
|
||||||
[Description("Username for Newzbin")]
|
[Description("Username for Newzbin")]
|
||||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||||
|
[RequiredIf("NewzbinEnabled", true, ErrorMessage = "Username Required when Newzbin is enabled")]
|
||||||
public String NewzbinUsername { get; set; }
|
public String NewzbinUsername { get; set; }
|
||||||
|
|
||||||
[DataType(DataType.Text)]
|
[DataType(DataType.Text)]
|
||||||
[DisplayName("Password")]
|
[DisplayName("Password")]
|
||||||
[Description("Password for Newzbin")]
|
[Description("Password for Newzbin")]
|
||||||
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
[DisplayFormat(ConvertEmptyStringToNull = false)]
|
||||||
|
[RequiredIf("NewzbinEnabled", true, ErrorMessage = "Password Required when Newzbin is enabled")]
|
||||||
public String NewzbinPassword { get; set; }
|
public String NewzbinPassword { get; set; }
|
||||||
|
|
||||||
[DisplayName("NZBs.org")]
|
[DisplayName("NZBs.org")]
|
||||||
|
|
|
@ -131,6 +131,7 @@
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Helpers\Validation\RequiredIfAttribute.cs" />
|
||||||
<Content Include="Content\DataTables-1.9.0\media\css\jquery.dataTables.css" />
|
<Content Include="Content\DataTables-1.9.0\media\css\jquery.dataTables.css" />
|
||||||
<Content Include="Content\DataTables-1.9.0\media\images\back_disabled.png" />
|
<Content Include="Content\DataTables-1.9.0\media\images\back_disabled.png" />
|
||||||
<Content Include="Content\DataTables-1.9.0\media\images\back_enabled.png" />
|
<Content Include="Content\DataTables-1.9.0\media\images\back_enabled.png" />
|
||||||
|
@ -331,6 +332,7 @@
|
||||||
<Content Include="Content\themes\base\minified\jquery.ui.theme.min.css" />
|
<Content Include="Content\themes\base\minified\jquery.ui.theme.min.css" />
|
||||||
<Content Include="favicon.ico" />
|
<Content Include="favicon.ico" />
|
||||||
<Content Include="Global.asax" />
|
<Content Include="Global.asax" />
|
||||||
|
<Content Include="Scripts\conditional-validation.js" />
|
||||||
<Content Include="Scripts\DataTables-1.9.0\media\js\jquery.dataTables.reloadAjax.js" />
|
<Content Include="Scripts\DataTables-1.9.0\media\js\jquery.dataTables.reloadAjax.js" />
|
||||||
<Content Include="Scripts\DataTables-1.9.0\media\js\jquery.dataTables.editable.js" />
|
<Content Include="Scripts\DataTables-1.9.0\media\js\jquery.dataTables.editable.js" />
|
||||||
<Content Include="Scripts\DataTables-1.9.0\media\js\jquery.dataTables.js" />
|
<Content Include="Scripts\DataTables-1.9.0\media\js\jquery.dataTables.js" />
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
/// <reference path="jquery-1.4.4-vsdoc.js" />
|
||||||
|
/// <reference path="jquery.validate.unobtrusive.js" />
|
||||||
|
|
||||||
|
$.validator.addMethod('requiredif',
|
||||||
|
function (value, element, parameters) {
|
||||||
|
var id = '#' + parameters['dependentproperty'];
|
||||||
|
|
||||||
|
// get the target value (as a string,
|
||||||
|
// as that's what actual value will be)
|
||||||
|
var targetvalue = parameters['targetvalue'];
|
||||||
|
targetvalue =
|
||||||
|
(targetvalue == null ? '' : targetvalue).toString();
|
||||||
|
|
||||||
|
// get the actual value of the target control
|
||||||
|
// note - this probably needs to cater for more
|
||||||
|
// control types, e.g. radios
|
||||||
|
var control = $(id);
|
||||||
|
var controltype = control.attr('type');
|
||||||
|
var actualvalue =
|
||||||
|
controltype === 'checkbox' ?
|
||||||
|
(control.attr('checked') == "checked" ? "true" : "false") :
|
||||||
|
control.val();
|
||||||
|
|
||||||
|
// if the condition is true, reuse the existing
|
||||||
|
// required field validator functionality
|
||||||
|
if (targetvalue === actualvalue)
|
||||||
|
return $.validator.methods.required.call(
|
||||||
|
this, value, element, parameters);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$.validator.unobtrusive.adapters.add(
|
||||||
|
'requiredif',
|
||||||
|
['dependentproperty', 'targetvalue'],
|
||||||
|
function (options) {
|
||||||
|
options.rules['requiredif'] = {
|
||||||
|
dependentproperty: options.params['dependentproperty'],
|
||||||
|
targetvalue: options.params['targetvalue']
|
||||||
|
};
|
||||||
|
options.messages['requiredif'] = options.message;
|
||||||
|
});
|
|
@ -1,19 +1,46 @@
|
||||||
@using NzbDrone.Web.Helpers
|
@using NzbDrone.Web.Helpers
|
||||||
@model NzbDrone.Web.Models.IndexerSettingsModel
|
@model NzbDrone.Web.Models.IndexerSettingsModel
|
||||||
@{ Layout = null; }
|
@{ Layout = null; }
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.indexerStatusContainer {
|
||||||
|
margin-left: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.field-validation-error {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-validation-error {
|
||||||
|
background-color: #FFEEEE;
|
||||||
|
border: 1px solid #FF0000;
|
||||||
|
}
|
||||||
|
|
||||||
|
#IndexersForm .validation-error {
|
||||||
|
background: url("../../Content/jQueryUI/images/ui-bg_flat_30_b40404_40x100.png") repeat-x scroll 50% 50% #B40404;
|
||||||
|
}
|
||||||
|
#validation-error-summary {
|
||||||
|
display: none;
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
<div class="infoBox">
|
<div class="infoBox">
|
||||||
RSS feeds are checked every 25 minutes for new episodes.</div>
|
RSS feeds are checked every 25 minutes for new episodes.</div>
|
||||||
<div class="indexerStatusContainer">
|
<div class="indexerStatusContainer">
|
||||||
<div class="indexerStatus disabled" id="nzbsOrgStatus" title="Enabled/Disabled">
|
@Html.CheckBox("nzbsOrgStatus", @Model.NzbsOrgEnabled, new{ @class = "indexerStatusButton" })
|
||||||
Nzbs.Org</div>
|
<label for="nzbsOrgStatus">Nzbs.Org</label>
|
||||||
<div class="indexerStatus disabled" id="nzbMatrixStatus" title="Enabled/Disabled">
|
|
||||||
NZBMatrix</div>
|
@Html.CheckBox("nzbMatrixStatus", @Model.NzbMatrixEnabled, new { @class = "indexerStatusButton" })
|
||||||
<div class="indexerStatus disabled" id="nzbsRusStatus" title="Enabled/Disabled">
|
<label for="nzbMatrixStatus">NZBMatrix</label>
|
||||||
NZBsRus</div>
|
|
||||||
<div class="indexerStatus disabled" id="newzbinStatus" title="Enabled/Disabled">
|
@Html.CheckBox("nzbsRusStatus", @Model.NzbsRUsEnabled, new { @class = "indexerStatusButton" })
|
||||||
Newzbin</div>
|
<label for="nzbsRusStatus">NZBsRus</label>
|
||||||
<div class="indexerStatus disabled" id="newznabStatus" title="Enabled/Disabled">
|
|
||||||
Newznab</div>
|
@Html.CheckBox("newzbinStatus", @Model.NewzbinEnabled, new { @class = "indexerStatusButton" })
|
||||||
|
<label for="newzbinStatus">Newzbin</label>
|
||||||
|
|
||||||
|
@Html.CheckBox("newznabStatus", @Model.NewznabEnabled, new { @class = "indexerStatusButton" })
|
||||||
|
<label for="newznabStatus">Newznab</label>
|
||||||
</div>
|
</div>
|
||||||
<div id="stylized">
|
<div id="stylized">
|
||||||
@using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "IndexersForm", name = "IndexersForm", @class = "settingsForm" }))
|
@using (Html.BeginForm("SaveIndexers", "Settings", FormMethod.Post, new { id = "IndexersForm", name = "IndexersForm", @class = "settingsForm" }))
|
||||||
|
@ -28,10 +55,12 @@
|
||||||
@Html.CheckBoxFor(m => m.NzbsOrgEnabled, new { @class = "inputClass checkClass enabledCheck" })
|
@Html.CheckBoxFor(m => m.NzbsOrgEnabled, new { @class = "inputClass checkClass enabledCheck" })
|
||||||
<label class="labelClass">@Html.LabelFor(m => m.NzbsOrgUId)
|
<label class="labelClass">@Html.LabelFor(m => m.NzbsOrgUId)
|
||||||
<span class="small">@Html.DescriptionFor(m => m.NzbsOrgUId)</span>
|
<span class="small">@Html.DescriptionFor(m => m.NzbsOrgUId)</span>
|
||||||
|
<span class="small">@Html.ValidationMessageFor(m => m.NzbsOrgUId)</span>
|
||||||
</label>
|
</label>
|
||||||
@Html.TextBoxFor(m => m.NzbsOrgUId, new { @class = "inputClass" })
|
@Html.TextBoxFor(m => m.NzbsOrgUId, new { @class = "inputClass" })
|
||||||
<label class="labelClass">@Html.LabelFor(m => m.NzbsOrgHash)
|
<label class="labelClass">@Html.LabelFor(m => m.NzbsOrgHash)
|
||||||
<span class="small">@Html.DescriptionFor(m => m.NzbsOrgHash)</span>
|
<span class="small">@Html.DescriptionFor(m => m.NzbsOrgHash)</span>
|
||||||
|
<span class="small">@Html.ValidationMessageFor(m => m.NzbsOrgHash)</span>
|
||||||
</label>
|
</label>
|
||||||
@Html.TextBoxFor(m => m.NzbsOrgHash, new { @class = "inputClass" })
|
@Html.TextBoxFor(m => m.NzbsOrgHash, new { @class = "inputClass" })
|
||||||
</div>
|
</div>
|
||||||
|
@ -44,10 +73,12 @@
|
||||||
@Html.CheckBoxFor(m => m.NzbMatrixEnabled, new { @class = "inputClass checkClass enabledCheck" })
|
@Html.CheckBoxFor(m => m.NzbMatrixEnabled, new { @class = "inputClass checkClass enabledCheck" })
|
||||||
<label class="labelClass">@Html.LabelFor(m => m.NzbMatrixUsername)
|
<label class="labelClass">@Html.LabelFor(m => m.NzbMatrixUsername)
|
||||||
<span class="small">@Html.DescriptionFor(m => m.NzbMatrixUsername)</span>
|
<span class="small">@Html.DescriptionFor(m => m.NzbMatrixUsername)</span>
|
||||||
|
<span class="small">@Html.ValidationMessageFor(m => m.NzbMatrixUsername)</span>
|
||||||
</label>
|
</label>
|
||||||
@Html.TextBoxFor(m => m.NzbMatrixUsername, new { @class = "inputClass" })
|
@Html.TextBoxFor(m => m.NzbMatrixUsername, new { @class = "inputClass" })
|
||||||
<label class="labelClass">@Html.LabelFor(m => m.NzbMatrixApiKey)
|
<label class="labelClass">@Html.LabelFor(m => m.NzbMatrixApiKey)
|
||||||
<span class="small">@Html.DescriptionFor(m => m.NzbMatrixApiKey)</span>
|
<span class="small">@Html.DescriptionFor(m => m.NzbMatrixApiKey)</span>
|
||||||
|
<span class="small">@Html.ValidationMessageFor(m => m.NzbMatrixApiKey)</span>
|
||||||
</label>
|
</label>
|
||||||
@Html.TextBoxFor(m => m.NzbMatrixApiKey, new { @class = "inputClass" })
|
@Html.TextBoxFor(m => m.NzbMatrixApiKey, new { @class = "inputClass" })
|
||||||
</div>
|
</div>
|
||||||
|
@ -62,10 +93,12 @@
|
||||||
@Html.CheckBoxFor(m => m.NzbsRUsEnabled, new { @class = "inputClass checkClass enabledCheck" })
|
@Html.CheckBoxFor(m => m.NzbsRUsEnabled, new { @class = "inputClass checkClass enabledCheck" })
|
||||||
<label class="labelClass">@Html.LabelFor(m => m.NzbsrusUId)
|
<label class="labelClass">@Html.LabelFor(m => m.NzbsrusUId)
|
||||||
<span class="small">@Html.DescriptionFor(m => m.NzbsrusUId)</span>
|
<span class="small">@Html.DescriptionFor(m => m.NzbsrusUId)</span>
|
||||||
|
<span class="small">@Html.ValidationMessageFor(m => m.NzbsrusUId)</span>
|
||||||
</label>
|
</label>
|
||||||
@Html.TextBoxFor(m => m.NzbsrusUId, new { @class = "inputClass" })
|
@Html.TextBoxFor(m => m.NzbsrusUId, new { @class = "inputClass" })
|
||||||
<label class="labelClass">@Html.LabelFor(m => m.NzbsrusHash)
|
<label class="labelClass">@Html.LabelFor(m => m.NzbsrusHash)
|
||||||
<span class="small">@Html.DescriptionFor(m => m.NzbsrusHash)</span>
|
<span class="small">@Html.DescriptionFor(m => m.NzbsrusHash)</span>
|
||||||
|
<span class="small">@Html.ValidationMessageFor(m => m.NzbsrusHash)</span>
|
||||||
</label>
|
</label>
|
||||||
@Html.TextBoxFor(m => m.NzbsrusHash, new { @class = "inputClass" })
|
@Html.TextBoxFor(m => m.NzbsrusHash, new { @class = "inputClass" })
|
||||||
</div>
|
</div>
|
||||||
|
@ -78,10 +111,12 @@
|
||||||
@Html.CheckBoxFor(m => m.NewzbinEnabled, new { @class = "inputClass checkClass enabledCheck" })
|
@Html.CheckBoxFor(m => m.NewzbinEnabled, new { @class = "inputClass checkClass enabledCheck" })
|
||||||
<label class="labelClass">@Html.LabelFor(m => m.NewzbinUsername)
|
<label class="labelClass">@Html.LabelFor(m => m.NewzbinUsername)
|
||||||
<span class="small">@Html.DescriptionFor(m => m.NewzbinUsername)</span>
|
<span class="small">@Html.DescriptionFor(m => m.NewzbinUsername)</span>
|
||||||
|
<span class="small">@Html.ValidationMessageFor(m => m.NewzbinUsername)</span>
|
||||||
</label>
|
</label>
|
||||||
@Html.TextBoxFor(m => m.NewzbinUsername, new { @class = "inputClass" })
|
@Html.TextBoxFor(m => m.NewzbinUsername, new { @class = "inputClass" })
|
||||||
<label class="labelClass">@Html.LabelFor(m => m.NewzbinPassword)
|
<label class="labelClass">@Html.LabelFor(m => m.NewzbinPassword)
|
||||||
<span class="small">@Html.DescriptionFor(m => m.NewzbinPassword)</span>
|
<span class="small">@Html.DescriptionFor(m => m.NewzbinPassword)</span>
|
||||||
|
<span class="small">@Html.ValidationMessageFor(m => m.NewzbinPassword)</span>
|
||||||
</label>
|
</label>
|
||||||
@Html.TextBoxFor(m => m.NewzbinPassword, new { @class = "inputClass", type = "password" })
|
@Html.TextBoxFor(m => m.NewzbinPassword, new { @class = "inputClass", type = "password" })
|
||||||
</div>
|
</div>
|
||||||
|
@ -98,7 +133,7 @@
|
||||||
</p>
|
</p>
|
||||||
<a id="addItem" href="@Url.Action("AddNewznabProvider", "Settings")">
|
<a id="addItem" href="@Url.Action("AddNewznabProvider", "Settings")">
|
||||||
<img src="../../Content/Images/Plus.png" alt="Add Newznab Provider" width="20px"
|
<img src="../../Content/Images/Plus.png" alt="Add Newznab Provider" width="20px"
|
||||||
height="20px" />
|
height="20px" />
|
||||||
Add Newznab Provider</a>
|
Add Newznab Provider</a>
|
||||||
<div id="newznabProviders">
|
<div id="newznabProviders">
|
||||||
@foreach (var provider in Model.NewznabDefinitions)
|
@foreach (var provider in Model.NewznabDefinitions)
|
||||||
|
@ -117,47 +152,96 @@
|
||||||
@Html.TextBoxFor(m => m.Retention, new { @class = "inputClass" })
|
@Html.TextBoxFor(m => m.Retention, new { @class = "inputClass" })
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button type="submit" class="save_button" disabled="disabled">
|
<button type="submit" class="save_button" disabled="disabled">Save</button>
|
||||||
Save</button>
|
|
||||||
|
<span id="validation-error-summary">Please check your settings and re-save</span>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
if ($('#NzbsOrgEnabled').attr('checked'))
|
//Allow unobstrusive validation of the AJAX loaded form
|
||||||
$('#nzbsOrgStatus').toggleClass('enabled disabled');
|
$.validator.unobtrusive.parse("#IndexersForm");
|
||||||
|
|
||||||
|
//Make the buttons
|
||||||
|
$('.indexerStatusButton').button();
|
||||||
|
|
||||||
if ($('#NzbMatrixEnabled').attr('checked'))
|
//Validator Settings
|
||||||
$('#nzbMatrixStatus').toggleClass('enabled disabled');
|
var settings = $.data($('#IndexersForm')[0], 'validator').settings;
|
||||||
|
settings.ignore = [];
|
||||||
|
settings.focusInvalid = false;
|
||||||
|
settings.onfocusout = function (element) { $(element).valid(); };
|
||||||
|
|
||||||
if ($('#NzbsRUsEnabled').attr('checked'))
|
var oldHighlight = settings.highlight;
|
||||||
$('#nzbsRusStatus').toggleClass('enabled disabled');
|
var oldUnhighlight = settings.unhighlight;
|
||||||
|
|
||||||
if ($('#NewzbinEnabled').attr('checked'))
|
settings.highlight = function (element, errorClass, validClass) {
|
||||||
$('#newzbinStatus').toggleClass('enabled disabled');
|
oldHighlight(element, errorClass, validClass);
|
||||||
|
$(element).parents('div.indexerPanel').prev('h3.ui-accordion-header').addClass('validation-error');
|
||||||
|
};
|
||||||
|
settings.unhighlight = function (element, errorClass, validClass) {
|
||||||
|
oldUnhighlight(element, errorClass, validClass);
|
||||||
|
|
||||||
if ($('#NewznabEnabled').attr('checked'))
|
var container = $(element).parents('div.indexerPanel');
|
||||||
$('#newznabStatus').toggleClass('enabled disabled');
|
if ($(container).children('.' + errorClass).length == 0)
|
||||||
|
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
|
||||||
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.enabledCheck').on('change', function () {
|
$('.enabledCheck').on('change', function () {
|
||||||
var id = $(this).attr('id');
|
var id = $(this).prop('id');
|
||||||
|
var checked = $(this).prop('checked');
|
||||||
|
|
||||||
if (id == 'NzbsOrgEnabled')
|
if (id == 'NzbsOrgEnabled')
|
||||||
$('#nzbsOrgStatus').toggleClass('enabled disabled');
|
$('#nzbsOrgStatus').prop('checked', checked);
|
||||||
|
|
||||||
if (id == 'NzbMatrixEnabled')
|
if (id == 'NzbMatrixEnabled')
|
||||||
$('#nzbMatrixStatus').toggleClass('enabled disabled');
|
$('#nzbMatrixStatus').prop('checked', checked);
|
||||||
|
|
||||||
if (id == 'NzbsRUsEnabled')
|
if (id == 'NzbsRUsEnabled')
|
||||||
$('#nzbsRusStatus').toggleClass('enabled disabled');
|
$('#nzbsRusStatus').prop('checked', checked);
|
||||||
|
|
||||||
if (id == 'NewzbinEnabled')
|
if (id == 'NewzbinEnabled')
|
||||||
$('#newzbinStatus').toggleClass('enabled disabled');
|
$('#newzbinStatus').prop('checked', checked);
|
||||||
|
|
||||||
if (id == 'NewznabEnabled')
|
if (id == 'NewznabEnabled')
|
||||||
$('#newznabStatus').toggleClass('enabled disabled');
|
$('#newznabStatus').prop('checked', checked);
|
||||||
|
|
||||||
|
$('.indexerStatusButton').button("refresh");
|
||||||
|
reValidate();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('.indexerStatusButton').on('change', function () {
|
||||||
|
var id = $(this).prop('id');
|
||||||
|
var checked = $(this).prop('checked');
|
||||||
|
|
||||||
|
if (id == 'nzbsOrgStatus')
|
||||||
|
$('#NzbsOrgEnabled').prop('checked', checked);
|
||||||
|
|
||||||
|
if (id == 'nzbMatrixStatus')
|
||||||
|
$('#NzbMatrixEnabled').prop('checked', checked);
|
||||||
|
|
||||||
|
if (id == 'nzbsRusStatus')
|
||||||
|
$('#NzbsRUsEnabled').prop('checked', checked);
|
||||||
|
|
||||||
|
if (id == 'newzbinStatus')
|
||||||
|
$('#NewzbinEnabled').prop('checked', checked);
|
||||||
|
|
||||||
|
if (id == 'newznabStatus')
|
||||||
|
$('#NewznabEnabled').prop('checked', checked);
|
||||||
|
|
||||||
|
reValidate();
|
||||||
|
});
|
||||||
|
|
||||||
|
function reValidate() {
|
||||||
|
$("#IndexersForm").validate().form();
|
||||||
|
|
||||||
|
var container = $('div.indexerPanel');
|
||||||
|
if ($(container).children('.input-validation-error').length == 0)
|
||||||
|
$(container).prev('h3.ui-accordion-header').removeClass('validation-error');
|
||||||
|
}
|
||||||
|
|
||||||
|
//Newznab
|
||||||
$("#addItem").live('click', function () {
|
$("#addItem").live('click', function () {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: this.href,
|
url: this.href,
|
||||||
|
@ -180,13 +264,7 @@
|
||||||
alert("Sorry! We could not delete your Provider at this time. " + error);
|
alert("Sorry! We could not delete your Provider at this time. " + error);
|
||||||
},
|
},
|
||||||
success: function (data, textStatus, jqXHR) {
|
success: function (data, textStatus, jqXHR) {
|
||||||
if (data == "ok") {
|
$("#provider_" + id).remove();
|
||||||
$("#provider_" + id).remove();
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
alert(data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -196,10 +274,9 @@
|
||||||
return parentProviderSection.children('.newznabProviderId').val();
|
return parentProviderSection.children('.newznabProviderId').val();
|
||||||
}
|
}
|
||||||
|
|
||||||
$(".providerName_textbox").live('keyup', function () {
|
$(".providerName_textbox").on('keyup', function () {
|
||||||
var value = $(this).val();
|
var value = $(this).val();
|
||||||
var profileId = getProviderId(this);
|
var profileId = getProviderId(this);
|
||||||
$("#title_" + profileId).text(value);
|
$("#title_" + profileId).text(value);
|
||||||
}).keyup();
|
}).keyup();
|
||||||
|
</script>
|
||||||
</script>
|
|
||||||
|
|
|
@ -21,16 +21,18 @@
|
||||||
@Html.IncludeScript("jquery-1.7.1.min.js")
|
@Html.IncludeScript("jquery-1.7.1.min.js")
|
||||||
@Html.IncludeScript("jquery-ui-1.8.17.min.js")
|
@Html.IncludeScript("jquery-ui-1.8.17.min.js")
|
||||||
@Html.IncludeScript("jquery.livequery.js")
|
@Html.IncludeScript("jquery.livequery.js")
|
||||||
@Html.IncludeScript("MicrosoftAjax.js")
|
|
||||||
@Html.IncludeScript("MicrosoftMvcAjax.js")
|
|
||||||
@Html.IncludeScript("jquery.gritter.js")
|
@Html.IncludeScript("jquery.gritter.js")
|
||||||
@Html.IncludeScript("jquery.form.js")
|
@Html.IncludeScript("jquery.form.js")
|
||||||
@Html.IncludeScript("jquery-tgc-countdown-1.0.js")
|
@Html.IncludeScript("jquery-tgc-countdown-1.0.js")
|
||||||
@Html.IncludeScript("jquery.watermark.min.js")
|
@Html.IncludeScript("jquery.watermark.min.js")
|
||||||
@Html.IncludeScript("jquery.hotkeys.js")
|
@Html.IncludeScript("jquery.hotkeys.js")
|
||||||
@Html.IncludeScript("jquery.validate.min.js")
|
@Html.IncludeScript("jquery.signalR.min.js")
|
||||||
|
@Html.IncludeScript("jquery.validate.js")
|
||||||
|
@Html.IncludeScript("jquery.validate.unobtrusive.js")
|
||||||
@Html.IncludeScript("jquery.cookie.js")
|
@Html.IncludeScript("jquery.cookie.js")
|
||||||
@Html.IncludeScript("doTimeout.js")
|
@Html.IncludeScript("doTimeout.js")
|
||||||
|
@Html.IncludeScript("conditional-validation.js")
|
||||||
|
<script src="@Url.Content("~/signalr/hubs")" type="text/javascript"></script>
|
||||||
@Html.IncludeScript("NzbDrone/localSearch.js")
|
@Html.IncludeScript("NzbDrone/localSearch.js")
|
||||||
@Html.IncludeScript("NzbDrone/AutoComplete.js")
|
@Html.IncludeScript("NzbDrone/AutoComplete.js")
|
||||||
@Html.IncludeScript("NzbDrone/Notification.js")
|
@Html.IncludeScript("NzbDrone/Notification.js")
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
<supportedRuntime version="v4.0" />
|
<supportedRuntime version="v4.0" />
|
||||||
</startup>
|
</startup>
|
||||||
<appSettings>
|
<appSettings>
|
||||||
<add key="ClientValidationEnabled" value="false" />
|
<add key="ClientValidationEnabled" value="true" />
|
||||||
<add key="UnobtrusiveJavaScriptEnabled" value="false" />
|
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
|
||||||
</appSettings>
|
</appSettings>
|
||||||
<system.web>
|
<system.web>
|
||||||
<trust level="Full" originUrl=".*" />
|
<trust level="Full" originUrl=".*" />
|
||||||
|
|
Loading…
Reference in New Issue