Updated underscore - quality profiles in table

pull/4/head
Mark McDowall 12 years ago
parent e635e816f6
commit 1dfd78c0c9

File diff suppressed because it is too large Load Diff

@ -1,47 +1,21 @@
define(['app'], function () { define(['app'], function () {
NzbDrone.Quality.QualityProfileModel = Backbone.Model.extend({ NzbDrone.Quality.QualityProfileModel = Backbone.Model.extend({
initialize: function () {
this.validators = {};
this.validators.name = function (value) { mutators: {
return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must enter a name' }; allowed: function() {
}; return _.where(this.get('qualities'), { allowed: true });
//this.validators.allowed = function (value) {
// return value.length > 0 ? { isValid: true } : { isValid: false, message: 'You must have allowed qualities' };
//};
//Todo: Cutoff should be something that is allowed (double check)
this.validators.cutoff = function (value) {
return value !== null ? { isValid: true } : { isValid: false, message: 'You must have a valid cutoff' };
};
},
validateItem: function (key) {
return (this.validators[key]) ? this.validators[key](this.get(key)) : { isValid: true };
}, },
// TODO: Implement Backbone's standard validate() method instead. cutoffName: function() {
validateAll: function () { return _.findWhere(this.get('qualities'), { id: this.get('cutoff') }).name;
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: { defaults: {
Id: null, id: null,
Name: '', name: '',
//allowed: {}, //allowed: {},
Cutoff: null cutoff: null
} }
}); });
}); });

@ -33,7 +33,7 @@
onRender: function () { onRender: function () {
this.qualityStandard.show(new NzbDrone.Settings.Quality.QualityView({model: this.settings, qualityProfiles: qualityProfileCollection})); this.qualityStandard.show(new NzbDrone.Settings.Quality.QualityView({model: this.settings, qualityProfiles: qualityProfileCollection}));
this.qualityProfile.show(new NzbDrone.Settings.Quality.QualityProfileCollectionView({collection: this.qualityProfileCollection})); this.qualityProfile.show(new NzbDrone.Settings.Quality.QualityProfileCollectionView({collection: qualityProfileCollection}));
this.qualitySize.show(new NzbDrone.Settings.Quality.QualitySizeCollectionView({collection: this.qualitySizeCollection})); this.qualitySize.show(new NzbDrone.Settings.Quality.QualitySizeCollectionView({collection: this.qualitySizeCollection}));
} }
}); });

@ -1,5 +1,14 @@
<fieldset> <fieldset>
<legend>Quality Profiles</legend> <legend>Quality Profiles</legend>
<div id="quality-profiles-container"></div> <table class="table table-hover">
Quality Profiles will be edited here <thead>
<tr>
<th>Name</th>
<th>Allowed</th>
<th>Cutoff</th>
<th>Controls</th>
</tr>
</thead>
<tbody></tbody>
</table>
</fieldset> </fieldset>

@ -3,11 +3,10 @@
define(['app', 'Settings/Quality/QualityProfileView'], function (app) { define(['app', 'Settings/Quality/QualityProfileView'], function (app) {
NzbDrone.Settings.Quality.QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({ NzbDrone.Settings.Quality.QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({
itemView: NzbDrone.Settings.Quality.QualityProfileView, itemView: NzbDrone.Settings.Quality.QualityProfileView,
itemViewContainer: '#quality-profiles-container', itemViewContainer: 'tbody',
template: 'Settings/Quality/QualityProfileCollectionTemplate', template: 'Settings/Quality/QualityProfileCollectionTemplate',
initialize: function (options) { initialize: function (options) {
}, },
ui:{ ui:{

@ -0,0 +1,8 @@
<td name="name"></td>
<td>
{{#each allowed}}
{{name}} |
{{/each}}
</td>
<td name="cutoffName"></td>
<td>Edit | Delete</td>

@ -6,7 +6,7 @@ define([
], function () { ], function () {
NzbDrone.Settings.QualityProfileView = Backbone.Marionette.ItemView.extend({ NzbDrone.Settings.Quality.QualityProfileView = Backbone.Marionette.ItemView.extend({
template: 'Settings/Quality/QualityProfileTemplate', template: 'Settings/Quality/QualityProfileTemplate',
tagName: 'tr', tagName: 'tr',
@ -19,8 +19,8 @@ define([
'click .x-remove': 'removeSeries' 'click .x-remove': 'removeSeries'
}, },
initialize: function (options) { initialize: function () {
this.qualityProfileCollection = options.qualityProfiles; var test = 1;
}, },
onRender: function () { onRender: function () {

Loading…
Cancel
Save