mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-28 04:51:45 +02:00
Quality type sizes moved to backbone + SS (API)
This commit is contained in:
38
NzbDrone.Web/Scripts/backbone/models/qualityType.js
Normal file
38
NzbDrone.Web/Scripts/backbone/models/qualityType.js
Normal file
@@ -0,0 +1,38 @@
|
||||
window.QualityType = Backbone.Model.extend({
|
||||
|
||||
urlRoot: '/api/qualitytypes',
|
||||
|
||||
idAttribute: 'Id',
|
||||
|
||||
initialize: function () {
|
||||
this.validators = {};
|
||||
},
|
||||
|
||||
validateItem: function (key) {
|
||||
return (this.validators[key]) ? this.validators[key](this.get(key)) : { isValid: true };
|
||||
},
|
||||
|
||||
// TODO: Implement Backbone's standard validate() method instead.
|
||||
validateAll: function () {
|
||||
|
||||
var messages = {};
|
||||
|
||||
for (var key in this.validators) {
|
||||
if (this.validators.hasOwnProperty(key)) {
|
||||
var check = this.validators[key](this.get(key));
|
||||
if (check.isValid === false) {
|
||||
messages[key] = check.message;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return _.size(messages) > 0 ? { isValid: false, messages: messages } : { isValid: true };
|
||||
},
|
||||
|
||||
defaults: {
|
||||
Id: null,
|
||||
Name: '',
|
||||
MaxSize: 100,
|
||||
MinSize: 0
|
||||
}
|
||||
});
|
@@ -0,0 +1,4 @@
|
||||
window.QualityTypeCollection = Backbone.Collection.extend({
|
||||
model: QualityType,
|
||||
url: '/api/qualitytypes'
|
||||
});
|
Reference in New Issue
Block a user