mirror of
https://github.com/Radarr/Radarr.git
synced 2024-09-17 15:02:34 +02:00
new quality profile edit view.
This commit is contained in:
parent
ef58acb4b5
commit
dca32e9e0f
@ -8,7 +8,7 @@ public class QualityProfileResource : RestResource
|
|||||||
{
|
{
|
||||||
public String Name { get; set; }
|
public String Name { get; set; }
|
||||||
public QualityResource Cutoff { get; set; }
|
public QualityResource Cutoff { get; set; }
|
||||||
public List<QualityResource> Qualities { get; set; }
|
public List<QualityResource> Available { get; set; }
|
||||||
public List<QualityResource> Allowed { get; set; }
|
public List<QualityResource> Allowed { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,10 @@ private static QualityProfileResource QualityToResource(QualityProfile profile)
|
|||||||
return new QualityProfileResource
|
return new QualityProfileResource
|
||||||
{
|
{
|
||||||
Cutoff = profile.Cutoff.InjectTo<QualityResource>(),
|
Cutoff = profile.Cutoff.InjectTo<QualityResource>(),
|
||||||
Qualities = Quality.All().InjectTo<List<QualityResource>>(),
|
Available = Quality.All()
|
||||||
|
.Where(c => !profile.Allowed.Any(q => c.Id == q.Id))
|
||||||
|
.InjectTo<List<QualityResource>>(),
|
||||||
|
|
||||||
Allowed = profile.Allowed.InjectTo<List<QualityResource>>(),
|
Allowed = profile.Allowed.InjectTo<List<QualityResource>>(),
|
||||||
Name = profile.Name,
|
Name = profile.Name,
|
||||||
Id = profile.Id
|
Id = profile.Id
|
||||||
|
@ -5,7 +5,6 @@ define(['app'], function () {
|
|||||||
defaults: {
|
defaults: {
|
||||||
id : null,
|
id : null,
|
||||||
name : '',
|
name : '',
|
||||||
//'qualities.allowed': false,
|
|
||||||
cutoff: null
|
cutoff: null
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||||
<h3>Edit</h3>
|
<h3>Edit: Quality Profile</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<div class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">Name</label>
|
<label class="control-label">Name</label>
|
||||||
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<input type="text" name="name">
|
<input type="text" name="name">
|
||||||
<span class="help-inline">
|
<span class="help-inline">
|
||||||
@ -15,15 +13,12 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label">Cutoff</label>
|
<label class="control-label">Cutoff</label>
|
||||||
|
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
|
||||||
<select class="x-cutoff" name="cutoff">
|
<select class="x-cutoff" name="cutoff">
|
||||||
{{#each allowed}}
|
{{#each allowed}}
|
||||||
<option value="{{id}}">{{name}}</option>
|
<option value="{{id}}">{{name}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</select>
|
</select>
|
||||||
<span class="help-inline">
|
<span class="help-inline">
|
||||||
@ -31,33 +26,28 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
<!--Todo: Why is a null allowed being treated as a true?-->
|
<div class="offset1 span3">
|
||||||
{{debug}}
|
<h3>Available</h3>
|
||||||
{{#each qualities}}
|
<select multiple="multiple" class="x-available-list">
|
||||||
<div class="control-group">
|
{{#each available}}
|
||||||
<label class="control-label">{{name}}</label>
|
<option value="{{id}}">{{name}}</option>
|
||||||
|
{{/each}}
|
||||||
<div class="controls">
|
</select>
|
||||||
<label class="checkbox toggle well">
|
</div>
|
||||||
<input type="checkbox" name="qualities.{{@index}}.allowed"/>
|
<div class="span3">
|
||||||
<p>
|
<h3>Allowed</h3>
|
||||||
<span>Yes</span>
|
<select multiple="multiple" class="x-allowed-list">
|
||||||
<span>No</span>
|
{{#each allowed}}
|
||||||
</p>
|
<option value="{{id}}">{{name}}</option>
|
||||||
|
{{/each}}
|
||||||
<div class="btn btn-primary slide-button"></div>
|
</select>
|
||||||
</label>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{/each}}
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button class="btn btn-danger pull-left x-remove">delete</button>
|
<button class="btn btn-danger pull-left x-remove">delete</button>
|
||||||
<button class="btn" data-dismiss="modal">cancel</button>
|
<button class="btn" data-dismiss="modal">cancel</button>
|
||||||
<button class="btn btn-primary x-save">save</button>
|
<button class="btn btn-primary x-save">save</button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,10 +2,48 @@
|
|||||||
define(['app', 'Quality/QualityProfileModel'], function () {
|
define(['app', 'Quality/QualityProfileModel'], function () {
|
||||||
|
|
||||||
NzbDrone.Settings.Quality.Profile.EditQualityProfileView = Backbone.Marionette.ItemView.extend({
|
NzbDrone.Settings.Quality.Profile.EditQualityProfileView = Backbone.Marionette.ItemView.extend({
|
||||||
template : 'Settings/Quality/Profile/EditQualityProfileTemplate',
|
template: 'Settings/Quality/Profile/EditQualityProfileTemplate',
|
||||||
|
|
||||||
events: {
|
events: {
|
||||||
'click .x-save': 'saveQualityProfile'
|
'click .x-save' : 'saveQualityProfile',
|
||||||
|
'dblclick .x-available-list': '_moveQuality',
|
||||||
|
'dblclick .x-allowed-list' : '_moveQuality'
|
||||||
|
},
|
||||||
|
|
||||||
|
_moveQuality: function (event) {
|
||||||
|
|
||||||
|
var quality;
|
||||||
|
var qualityId = event.target.value;
|
||||||
|
var availableCollection = new Backbone.Collection(this.model.get('available'));
|
||||||
|
availableCollection.comparator = function (model) {
|
||||||
|
return model.get('weight');
|
||||||
|
};
|
||||||
|
|
||||||
|
var allowedCollection = new Backbone.Collection(this.model.get('allowed'));
|
||||||
|
allowedCollection.comparator = function (model) {
|
||||||
|
return model.get('weight');
|
||||||
|
};
|
||||||
|
|
||||||
|
if (availableCollection.get(qualityId)) {
|
||||||
|
quality = availableCollection.get(qualityId);
|
||||||
|
availableCollection.remove(quality);
|
||||||
|
allowedCollection.add(quality);
|
||||||
|
}
|
||||||
|
else if (allowedCollection.get(qualityId)) {
|
||||||
|
quality = allowedCollection.get(qualityId);
|
||||||
|
|
||||||
|
allowedCollection.remove(quality);
|
||||||
|
availableCollection.add(quality);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw 'couldnt find quality id ' + qualityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.model.set('available', availableCollection.toJSON());
|
||||||
|
this.model.set('allowed', allowedCollection.toJSON());
|
||||||
|
|
||||||
|
this.render();
|
||||||
},
|
},
|
||||||
|
|
||||||
saveQualityProfile: function () {
|
saveQualityProfile: function () {
|
||||||
|
Loading…
Reference in New Issue
Block a user