From a6a5277de843c023f8b8731a03cc477954ce6596 Mon Sep 17 00:00:00 2001
From: Mark McDowall <markus.mcd5@gmail.com>
Date: Wed, 5 Dec 2012 08:34:43 -0800
Subject: [PATCH] Stylized the new profiles

---
 .gitignore                                    |   1 +
 .../QualityProfiles/QualityProfileService.cs  |  22 +++----
 NzbDrone.Web/Content/QualitySettings.css      |  60 ++++++------------
 .../FakesAssemblies/Ninject.Web.Mvc.Fakes.dll | Bin 91136 -> 91136 bytes
 .../Scripts/backbone/views/qualityProfiles.js |  18 +++++-
 NzbDrone.Web/Views/Settings/Quality.cshtml    |  21 +++---
 6 files changed, 59 insertions(+), 63 deletions(-)

diff --git a/.gitignore b/.gitignore
index 26929ed7a..d938c5a70 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,6 +32,7 @@ _ReSharper*/
 [Ll]ogs/
 [Aa]pp_Data/
 /[Pp]ackage/
+/FakesAssemblies/
 #NZBDrone specific
 *.db
 *Web.Publish.xml
diff --git a/NzbDrone.Api/QualityProfiles/QualityProfileService.cs b/NzbDrone.Api/QualityProfiles/QualityProfileService.cs
index c21f40ad2..abaeffc7d 100644
--- a/NzbDrone.Api/QualityProfiles/QualityProfileService.cs
+++ b/NzbDrone.Api/QualityProfiles/QualityProfileService.cs
@@ -36,29 +36,29 @@ namespace NzbDrone.Api.QualityProfiles
             return Mapper.Map<QualityProfile, QualityProfileModel>(profile);
         }
 
-        public override object OnPost(QualityProfileModel data)
+        //Create
+        public override object OnPost(QualityProfileModel request)
         {
-            //Create
-            var profile = Mapper.Map<QualityProfileModel, QualityProfile>(data);
+            var profile = Mapper.Map<QualityProfileModel, QualityProfile>(request);
             _qualityProvider.Add(profile);
 
-            return data;
+            return request;
         }
 
-        public override object OnPut(QualityProfileModel data)
+        //Update
+        public override object OnPut(QualityProfileModel request)
         {
-            //Update
-            var profile = Mapper.Map<QualityProfileModel, QualityProfile>(data);
+            var profile = Mapper.Map<QualityProfileModel, QualityProfile>(request);
             _qualityProvider.Update(profile);
 
-            return data;
+            return request;
         }
 
-        public override object OnDelete(QualityProfileModel data)
+        public override object OnDelete(QualityProfileModel request)
         {
-            _qualityProvider.Delete(data.Id);
+            _qualityProvider.Delete(request.Id);
 
-            return "ok";
+            return request.Id.ToString();
         }
     }
 }
\ No newline at end of file
diff --git a/NzbDrone.Web/Content/QualitySettings.css b/NzbDrone.Web/Content/QualitySettings.css
index 740fb0081..1fe456a0a 100644
--- a/NzbDrone.Web/Content/QualitySettings.css
+++ b/NzbDrone.Web/Content/QualitySettings.css
@@ -38,8 +38,7 @@
 }
 
 /* QualityProfileItem */
-.quality-selectee
-{
+.quality-selectee {
     border-color: #065EFE;
     border-style: solid;
     border-width: 1px;
@@ -51,73 +50,50 @@
     float: left;
     cursor: default;
 }
-.quality-selecting
-{
+.quality-selecting {
     background: #85AEF9;
 }
-.quality-selected
-{
+
+.quality-selected {
     background: #065EFE;
     color: white;
 }
     
-.profileSection
-{
+.quality-profile {
     float: left;
-    width: 265px;
+    width: 260px;
     margin: 2px;
     border:solid 1px #CCCCCD;
     display: inline-block;
     overflow: hidden;
     padding: 5px 5px 5px 5px;
+    position: relative;
 }
-    
-.profileOptions label
-{
-    margin-top: 10px;
-    margin-left: 7px;
-    margin-right: 20px;
-    font-weight: bold;
+
+.quality-profile-setting label {
+    width: 45px;
     display: inline-block;
-    width: 40px;
-}
-    
-.profileOptions input, .profileOptions select
-{
-    font-size:12px;
-    padding:4px 2px;
-    border:solid 1px #aacfe4;
-    width:170px;
-    margin-right: 2px;
 }
 
-.profileOptions input
-{
+.quality-profile-setting input {
     margin-left: 10px;
-    margin-bottom: 2px;
+    width: 160px;
 }
 
-.profileOptions select
-{
-    width: 176px;
-    margin-bottom: 7px;
+.quality-profile-setting select {
+    width: 166px;
 }
     
-.qualitySelector
-{
-    padding-left: 5px;
-}
-    
-.delete-profile {
+.remove-profile {
     position: absolute;
     top: 0px;
-    right: 0px;
-    font-size: 16px;
+    right: 4px;
+    font-size: 20px;
     color: #000000;
     text-decoration: none;
 }
 
-.delete-profile > i[class*="icon-"]:hover {
+.remove-profile > i[class*="icon-"]:hover {
     cursor: pointer !important;
 }
     
diff --git a/NzbDrone.Web/FakesAssemblies/Ninject.Web.Mvc.Fakes.dll b/NzbDrone.Web/FakesAssemblies/Ninject.Web.Mvc.Fakes.dll
index 8c7ba3d3afb3ee25dbff6fc6e1e4dac993f93de9..51fc2b09cb1cec97fb102b5aade5d2a0ae1af84c 100644
GIT binary patch
delta 199
zcmV;&0671E$OVAN1(1jXhpN7ji%kNh9kJSX0e_+Gc>$3Ufd2rkIyPIJunxBu8U!^y
z-OqKbmO^Aw_NMbYth{ek_J(r9<BQ_aDdn(WMQo^EwMYIX<}#(}QlLwA&=?^&7k{8p
zV@GDB7elEh_EO%#K)o#vx!^_?!82_n{NhdjSMV_o+|R4lS{;!t(Q48;wyM>0l=}F_
zs)Nu1x6lFsP#F+ft#NPVaL`S)f#A2omSn59FdPBoJ_CoUzLytU0Vx3jw?SJ0zX-_B
BU!nj2

delta 199
zcmV;&0671E$OVAN1(1jXSY5r5i%kO34zb#I0e@5oxaomVp12*#^K-4bfqMl!8p)jA
zQ4<C~JiA1vn)LG00xizL+hUqz_r6~skRlsY@d{2%V7eMSuWis5cZrF}=c<Vi_G)RR
z{G98rpM@iTjC&AvFa0cHcy~1;HBPQu>WCNa47Z?mn+@{jzb$^Ob@0Bz3gsLZvb_~9
zPJ_?_x6lFsP#F;F2;EF!pz%(u<C9HFm9NFOFdPBoJ_A@?y_XkT0Vx3iw?SJ0zX%lN
BTjBr!

diff --git a/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js b/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js
index a95fa5794..d13a3fe4b 100644
--- a/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js
+++ b/NzbDrone.Web/Scripts/backbone/views/qualityProfiles.js
@@ -2,10 +2,14 @@
     tagName: "div",
     className: "quality-profile",
     template: "#QualityProfileTemplate",
+    initialize: function() {
+        this.model.on('destroy', this.remove, this)
+    },
     events: {
         'click .quality-selectee': 'toggleAllowed',
         'change .cutoff': 'changeCutoff',
-        'change .name': 'changeName'
+        'change .name': 'changeName',
+        'click .remove-profile': 'destroy'
     },
     toggleAllowed: function (e) {
         //Add to cutoff
@@ -54,6 +58,17 @@
 
         this.model.set({ "Name": name });
         this.model.save();
+    },
+    destroy: function (e) {
+        if (e === undefined)
+            return;
+
+        e.preventDefault();
+        this.model.destroy();
+        e.stopPropagation();
+    },
+    remove: function (e) {
+        $(this.el).remove();
     }
 });
 
@@ -78,6 +93,7 @@ QualityProfileCollectionView = Backbone.Marionette.CompositeView.extend({
     },
     addProfile: function (e) {
         //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();
     }
diff --git a/NzbDrone.Web/Views/Settings/Quality.cshtml b/NzbDrone.Web/Views/Settings/Quality.cshtml
index 0bb6df07f..2c72b2d8c 100644
--- a/NzbDrone.Web/Views/Settings/Quality.cshtml
+++ b/NzbDrone.Web/Views/Settings/Quality.cshtml
@@ -114,12 +114,13 @@
     @*@Html.IncludeScript("backbone/bootstrapper.js")*@
 
     <script id="QualityProfileTemplate" type="text/template">
-        <div>
-            <strong>Name</strong>
+        <a href="#" class="remove-profile"><i class="icon-remove"></i></a>
+        <div class="quality-profile-setting">
+            <label>Name</label>
             <input type="text" value="<%= Name %>" class="name" />
         </div>
-        <div>
-            <strong>Cutoff</strong>
+        <div class="quality-profile-setting">
+            <label>Cutoff</label>
             <select id="<%= Id %>" class="cutoff">
             <% _.each(Qualities, function(quality) { %>
                 <% if (quality.Allowed === true) { %>
@@ -132,14 +133,16 @@
 
         <% _.each(Qualities, function(quality) { %>
             <input id="<%= Id %>_<%= quality.Id %>"
-                   class="quality-selectee"
-                   type="checkbox"
-                   value="<%= quality.Allowed %>"
-                   data-quality-id="<%= quality.Id %>"
-                   <%= quality.Allowed ? 'checked="checked"' : '' %>
+                    class="quality-selectee"
+                    type="checkbox"
+                    value="<%= quality.Allowed %>"
+                    data-quality-id="<%= quality.Id %>"
+                    <%= quality.Allowed ? 'checked="checked"' : '' %>
             />
             <label for="<%= Id %>_<%= quality.Id %>"><%= quality.Name %></label>
         <% }); %>
+    
+    
     </script>
     
     <script id="QualityProfileCollectionTemplate" type="text/template">