Adding works!

pull/21/head
Mark McDowall 12 years ago
parent af2c86e40a
commit d481000001

@ -0,0 +1,20 @@
<ProjectConfiguration>
<CopyReferencedAssembliesToWorkspace>false</CopyReferencedAssembliesToWorkspace>
<ConsiderInconclusiveTestsAsPassing>false</ConsiderInconclusiveTestsAsPassing>
<PreloadReferencedAssemblies>false</PreloadReferencedAssemblies>
<AllowDynamicCodeContractChecking>true</AllowDynamicCodeContractChecking>
<AllowStaticCodeContractChecking>false</AllowStaticCodeContractChecking>
<IgnoreThisComponentCompletely>false</IgnoreThisComponentCompletely>
<RunPreBuildEvents>false</RunPreBuildEvents>
<RunPostBuildEvents>false</RunPostBuildEvents>
<PreviouslyBuiltSuccessfully>true</PreviouslyBuiltSuccessfully>
<InstrumentAssembly>true</InstrumentAssembly>
<PreventSigningOfAssembly>false</PreventSigningOfAssembly>
<AnalyseExecutionTimes>true</AnalyseExecutionTimes>
<IncludeStaticReferencesInWorkspace>true</IncludeStaticReferencesInWorkspace>
<DefaultTestTimeout>60000</DefaultTestTimeout>
<UseBuildConfiguration />
<UseBuildPlatform />
<ProxyProcessPath />
<UseCPUArchitecture>AutoDetect</UseCPUArchitecture>
</ProjectConfiguration>

@ -40,8 +40,8 @@ namespace NzbDrone.Api.QualityProfiles
public override object OnPost(QualityProfileModel request)
{
var profile = Mapper.Map<QualityProfileModel, QualityProfile>(request);
_qualityProvider.Add(profile);
request.Id = _qualityProvider.Add(profile);
return request;
}

@ -16,13 +16,13 @@
#add-profile
{
text-decoration: none;
font-size:16px;
font-size: 14px;
color: black;
font-weight:bold;
font-weight: bold;
vertical-align: middle;
}
#add-profile > i {
#add-profile i:before {
color: green;
font-size: 20px;
}

@ -15,6 +15,7 @@
//Add to cutoff
//Update model
var target = $(e.target);
var el = $(this.el);
var checked = $(target).attr('checked') != undefined;
var id = this.model.get("Id");
@ -25,10 +26,9 @@
if (qualityType.Id == qualityId) {
qualityType.Allowed = checked;
//Todo: Add/Remove from cutoff
//Find cutoff dropdown
var cutoff = ('select#' + id);
var cutoff = $(el).find('.cutoff');
if (checked) {
$('<option>' + qualityType.Name + '</option>').val(qualityId).appendTo(cutoff);
@ -49,7 +49,6 @@
this.model.save();
},
changeCutoff: function(e) {
//Todo: save change
var cutoff = $(e.target).val();
this.model.set({ "Cutoff": cutoff });
@ -58,15 +57,14 @@
changeName: function(e) {
var name = $(e.target).val();
//Todo: update default quality dropdown
$('#DefaultQualityProfileId option[value="' + this.model.get("Id") + '"]').html(name);
this.model.set({ "Name": name });
this.model.save();
},
destroy: function (e) {
if (e === undefined)
return;
//if (e === undefined)
// return;
e.preventDefault();
this.model.destroy();
@ -97,9 +95,22 @@ QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({
'click #add-profile': 'addProfile'
},
addProfile: function (e) {
e.preventDefault();
//Add new profile to collection
//Todo: How will we get the list of qualities (they would all be NOT allowed) - it all comes from the server side...
this.collection.add(new QualityProfile());
e.preventDefault();
var newProfile = new QualityProfile({
Name: '', Cutoff: 0, Qualities: [
{ "Id": 0, "Weight": 0, "Name": "Unknown", "Allowed": false },
{ "Id": 1, "Weight": 1, "Name": "SDTV", "Allowed": false },
{ "Id": 2, "Weight": 2, "Name": "DVD", "Allowed": false },
{ "Id": 4, "Weight": 4, "Name": "HDTV", "Allowed": false },
{ "Id": 5, "Weight": 5, "Name": "WEBDL-720p", "Allowed": false },
{ "Id": 3, "Weight": 7, "Name": "WEBDL-1080p", "Allowed": false },
{ "Id": 6, "Weight": 6, "Name": "Bluray720p", "Allowed": false },
{ "Id": 7, "Weight": 8, "Name": "Bluray1080p", "Allowed": false }
]
});
this.collection.add(newProfile);
}
});

@ -121,7 +121,7 @@
</div>
<div class="quality-profile-setting">
<label>Cutoff</label>
<select id="<%= Id %>" class="cutoff">
<select class="cutoff">
<% _.each(Qualities, function(quality) { %>
<% if (quality.Allowed === true) { %>
<option value="<%= quality.Id %>" <%= quality.Id === Cutoff ? 'selected="selected"' : '' %>><%= quality.Name %></option>
@ -147,12 +147,12 @@
<script id="QualityProfileCollectionTemplate" type="text/template">
<div id="profileHeader">
<button id="add-profile">Add New Profile</button>
@*<button id="add-profile"><i class="icon-plus icon-large"></i> Add New Profile</button>*@
@*<a id="add-profile" href="@Url.Action("AddProfile", "Settings")">
<a id="add-profile" href="@Url.Action("AddProfile", "Settings")">
<i class="icon-plus icon-large"></i>
Add New Profile
</a>*@
</a>
</div>
</script>

Loading…
Cancel
Save