From 75decad601ad637f118624541acef503199fbc8c Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Tue, 28 Jan 2014 20:13:00 -0800 Subject: [PATCH] UI looking better for quality profile editing --- .../Converters/EmbeddedDocumentConverter.cs | 4 +- .../Converters/QualityIntConverter.cs | 2 - .../036_update_with_quality_converters.cs | 1 - .../037_add_configurable_qualities.cs | 3 - .../Migration/Framework/SqliteAlter.cs | 7 +- .../Organizer/FileNameBuilder.cs | 1 - src/UI/Config.js | 5 +- .../EditQualityProfileItemViewTemplate.html | 4 +- .../Quality/Profile/EditQualityProfileView.js | 31 +++---- .../EditQualityProfileViewTemplate.html | 15 ++-- .../Profile/QualitySortableCollectionView.js | 2 +- src/UI/Settings/Quality/quality.less | 88 +++++++++++-------- src/UI/Settings/SettingsLayout.js | 4 +- 13 files changed, 81 insertions(+), 86 deletions(-) diff --git a/src/NzbDrone.Core/Datastore/Converters/EmbeddedDocumentConverter.cs b/src/NzbDrone.Core/Datastore/Converters/EmbeddedDocumentConverter.cs index e7591f3ee..806bbf5f4 100644 --- a/src/NzbDrone.Core/Datastore/Converters/EmbeddedDocumentConverter.cs +++ b/src/NzbDrone.Core/Datastore/Converters/EmbeddedDocumentConverter.cs @@ -1,7 +1,6 @@ using System; using Marr.Data.Converters; using Marr.Data.Mapping; -using NzbDrone.Common.Serializer; using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Converters; @@ -25,8 +24,11 @@ namespace NzbDrone.Core.Datastore.Converters SerializerSetting.Converters.Add(new StringEnumConverter { CamelCaseText = true }); SerializerSetting.Converters.Add(new VersionConverter()); + foreach (var converter in converters) + { SerializerSetting.Converters.Add(converter); + } } public virtual object FromDB(ConverterContext context) diff --git a/src/NzbDrone.Core/Datastore/Converters/QualityIntConverter.cs b/src/NzbDrone.Core/Datastore/Converters/QualityIntConverter.cs index ad07994c5..f423758f1 100644 --- a/src/NzbDrone.Core/Datastore/Converters/QualityIntConverter.cs +++ b/src/NzbDrone.Core/Datastore/Converters/QualityIntConverter.cs @@ -48,7 +48,6 @@ namespace NzbDrone.Core.Datastore.Converters } } - #region JsonConverter public override bool CanConvert(Type objectType) { return objectType == typeof(Quality); @@ -64,6 +63,5 @@ namespace NzbDrone.Core.Datastore.Converters { writer.WriteValue(ToDB(value)); } - #endregion } } \ No newline at end of file diff --git a/src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs b/src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs index 35f9dbbb9..090ddd33a 100644 --- a/src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs +++ b/src/NzbDrone.Core/Datastore/Migration/036_update_with_quality_converters.cs @@ -2,7 +2,6 @@ using NzbDrone.Core.Datastore.Migration.Framework; using System.Data; using System.Linq; -using System; using NzbDrone.Common.Serializer; using NzbDrone.Core.Qualities; using System.Collections.Generic; diff --git a/src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs b/src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs index c036ee4ba..fddd8e5a5 100644 --- a/src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs +++ b/src/NzbDrone.Core/Datastore/Migration/037_add_configurable_qualities.cs @@ -2,10 +2,7 @@ using NzbDrone.Core.Datastore.Migration.Framework; using System.Data; using System.Linq; -using System; -using NzbDrone.Common.Serializer; using NzbDrone.Core.Qualities; -using System.Collections.Generic; namespace NzbDrone.Core.Datastore.Migration { diff --git a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteAlter.cs b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteAlter.cs index c8d423a1c..848470de3 100644 --- a/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteAlter.cs +++ b/src/NzbDrone.Core/Datastore/Migration/Framework/SqliteAlter.cs @@ -45,7 +45,6 @@ namespace NzbDrone.Core.Datastore.Migration.Framework var newIndexes = originalIndexes.Union(indexes); - CreateTable(tableName, columns, newIndexes); transaction.Commit(); @@ -57,7 +56,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework using (var transaction = _sqLiteMigrationHelper.BeginTransaction()) { var originalColumns = _sqLiteMigrationHelper.GetColumns(tableName); - var originalIndexes = _sqLiteMigrationHelper.GetIndexes(tableName); + var indexes = _sqLiteMigrationHelper.GetIndexes(tableName); var newColumns = originalColumns.Select(c => { @@ -82,9 +81,7 @@ namespace NzbDrone.Core.Datastore.Migration.Framework return c.Value; }).ToList(); - var newIndexes = originalIndexes; - - CreateTable(tableName, newColumns, newIndexes); + CreateTable(tableName, newColumns, indexes); transaction.Commit(); } diff --git a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs index 9a35534be..2997be7d5 100644 --- a/src/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/src/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -150,7 +150,6 @@ namespace NzbDrone.Core.Organizer tokenValues.Add("{Episode Title}", GetEpisodeTitle(episodeTitles)); tokenValues.Add("{Quality Title}", GetQualityTitle(episodeFile.Quality)); - return CleanFilename(ReplaceTokens(pattern, tokenValues).Trim()); } diff --git a/src/UI/Config.js b/src/UI/Config.js index 797cdadb3..bbc6b54ed 100644 --- a/src/UI/Config.js +++ b/src/UI/Config.js @@ -9,8 +9,9 @@ define( }, Keys : { DefaultQualityProfileId: 'DefaultQualityProfileId', - DefaultRootFolderId: 'DefaultRootFolderId', - UseSeasonFolder: 'UseSeasonFolder' + DefaultRootFolderId : 'DefaultRootFolderId', + UseSeasonFolder : 'UseSeasonFolder', + AdvancedSettings : 'advancedSettings' }, getValueBoolean: function (key, defaultValue) { diff --git a/src/UI/Settings/Quality/Profile/EditQualityProfileItemViewTemplate.html b/src/UI/Settings/Quality/Profile/EditQualityProfileItemViewTemplate.html index f118c528b..33cc7d2f5 100644 --- a/src/UI/Settings/Quality/Profile/EditQualityProfileItemViewTemplate.html +++ b/src/UI/Settings/Quality/Profile/EditQualityProfileItemViewTemplate.html @@ -1,3 +1,3 @@ - + {{quality.name}} - + diff --git a/src/UI/Settings/Quality/Profile/EditQualityProfileView.js b/src/UI/Settings/Quality/Profile/EditQualityProfileView.js index 49e571939..a602e7dbd 100644 --- a/src/UI/Settings/Quality/Profile/EditQualityProfileView.js +++ b/src/UI/Settings/Quality/Profile/EditQualityProfileView.js @@ -1,6 +1,7 @@ 'use strict'; define( [ + 'underscore', 'vent', 'marionette', 'backbone', @@ -8,8 +9,8 @@ define( 'Settings/Quality/Profile/EditQualityProfileItemView', 'Mixins/AsModelBoundView', 'Mixins/AsValidatedView', - 'underscore' - ], function (vent, Marionette, Backbone, BackboneSortableCollectionView, EditQualityProfileItemView, AsModelBoundView, AsValidatedView, _) { + 'Config' + ], function (_, vent, Marionette, Backbone, QualitySortableCollectionView, EditQualityProfileItemView, AsModelBoundView, AsValidatedView, Config) { var view = Marionette.ItemView.extend({ template: 'Settings/Quality/Profile/EditQualityProfileViewTemplate', @@ -26,35 +27,23 @@ define( initialize: function (options) { this.profileCollection = options.profileCollection; - this.allowedCollection = new Backbone.Collection(_.toArray(this.model.get('items')).reverse()); + this.itemsCollection = new Backbone.Collection(_.toArray(this.model.get('items')).reverse()); }, onRender: function() { - var MyCollectionView = BackboneSortableCollectionView.extend({ - events : { - // Backbone.CollectionView used mousedown for the click event, which interferes with the sortable. - "click li, td" : "_listItem_onMousedown", - "dblclick li, td" : "_listItem_onDoubleClick", - "click" : "_listBackground_onClick", - "click ul.collection-list, table.collection-list" : "_listBackground_onClick", - "keydown" : "_onKeydown" - } - }); - var listViewAllowed = new MyCollectionView({ + + var listViewAllowed = new QualitySortableCollectionView({ el : this.ui.allowed, modelView : EditQualityProfileItemView, selectable : true, selectMultiple : true, clickToSelect : true, clickToToggle : true, - sortable : true, - sortableOptions : { - handle: '.x-drag-handle' - }, - collection : this.allowedCollection + sortable : Config.getValueBoolean(Config.Keys.AdvancedSettings, false), + collection : this.itemsCollection }); - listViewAllowed.setSelectedModels(this.allowedCollection.filter(function(item) { return item.get('allowed') === true; })); + listViewAllowed.setSelectedModels(this.itemsCollection.filter(function(item) { return item.get('allowed') === true; })); listViewAllowed.render(); @@ -73,7 +62,7 @@ define( }, _updateModel: function() { - this.model.set('items', this.allowedCollection.toJSON().reverse()); + this.model.set('items', this.itemsCollection.toJSON().reverse()); this.render(); }, diff --git a/src/UI/Settings/Quality/Profile/EditQualityProfileViewTemplate.html b/src/UI/Settings/Quality/Profile/EditQualityProfileViewTemplate.html index 5603f9221..619f6c873 100644 --- a/src/UI/Settings/Quality/Profile/EditQualityProfileViewTemplate.html +++ b/src/UI/Settings/Quality/Profile/EditQualityProfileViewTemplate.html @@ -29,17 +29,14 @@ - -
-
-

- Allowed +
+ +
+
    - + -

    -
      -
    +
    diff --git a/src/UI/Settings/Quality/Profile/QualitySortableCollectionView.js b/src/UI/Settings/Quality/Profile/QualitySortableCollectionView.js index 8af2c7638..0185d82c0 100644 --- a/src/UI/Settings/Quality/Profile/QualitySortableCollectionView.js +++ b/src/UI/Settings/Quality/Profile/QualitySortableCollectionView.js @@ -6,7 +6,7 @@ define( return BackboneSortableCollectionView.extend({ events : { - 'mousedown li, td' : '_listItem_onMousedown', + 'click li, td' : '_listItem_onMousedown', 'dblclick li, td' : '_listItem_onDoubleClick', 'click' : '_listBackground_onClick', 'click ul.collection-list, table.collection-list' : '_listBackground_onClick', diff --git a/src/UI/Settings/Quality/quality.less b/src/UI/Settings/Quality/quality.less index 9a5b65cd9..45edb91a0 100644 --- a/src/UI/Settings/Quality/quality.less +++ b/src/UI/Settings/Quality/quality.less @@ -1,5 +1,6 @@ @import "../../Shared/Styles/card"; @import "../../Content/Bootstrap/mixins"; +@import "../../Content/FontAwesome/font-awesome"; .quality-profiles { li { @@ -36,7 +37,7 @@ } } -ul.allowed-list { +ul.qualities { .user-select(none); min-height: 100px; @@ -44,49 +45,65 @@ ul.allowed-list { padding: 0; list-style-type: none; outline: none; + width: 220px; + display: inline-block; li { margin: 2px; - padding: 2px; + padding: 2px 4px; line-height: 20px; - border: 1px solid #AAA; + border: 1px solid #aaaaaa; border-radius: 4px; /* may need vendor varients */ - background: #FAFAFA; + background: #fafafa; cursor: pointer; - + + &.selected { + .select-handle { + opacity: 1.0; + cursor: pointer; + } + + .quality-label { + color: #444444; + } + + .select-handle:before { + .icon(@check); + } + } + + &:hover { + border-color: #888888; + background: #eeeeee; + + .drag-handle { + opacity: 1.0; + cursor: pointer; + } + } + .quality-label { - color: #CCC; + color: #c6c6c6; } .drag-handle, .select-handle { opacity: 0.2; line-height: 20px; cursor: pointer; } - - .drag-handle:hover { - opacity: 1.0; - cursor: pointer; + + .select-handle:before { + .icon(@check-empty); + display: inline-block; + width: 16px; + margin-top: 1px; } } - - li.selected { - .select-handle { - opacity: 1.0; - cursor: pointer; - } - - .quality-label { - color: #444; - } - } - - li:hover { - border-color: #888; - background: #EEE; - - .select-handle { - opacity: 0.5; - } +} + +.qualities-controls { + .help-inline { + vertical-align: top; + margin-top: 5px; } } @@ -102,22 +119,22 @@ ul.allowed-list { border-top: 1px solid #ddd; vertical-align: middle; padding: 5px; - + input { margin-bottom: 0px; } - + .size-label-wrapper { line-height: 20px; } - + .label { min-width: 70px; text-align: center; margin: 0px 1px; padding: 1px 4px; } - + .ui-slider { position: relative; text-align: left; @@ -125,14 +142,14 @@ ul.allowed-list { border-radius: 3px; border: 1px solid #ccc; height: 8px; - + .ui-slider-range { position: absolute; display: block; background-color: #ddd; height: 100%; } - + .ui-slider-handle { position: absolute; z-index: 2; @@ -147,4 +164,3 @@ ul.allowed-list { } } } - diff --git a/src/UI/Settings/SettingsLayout.js b/src/UI/Settings/SettingsLayout.js index 71948e76e..db90a0a7d 100644 --- a/src/UI/Settings/SettingsLayout.js +++ b/src/UI/Settings/SettingsLayout.js @@ -194,7 +194,7 @@ define( }, _setAdvancedSettingsState: function () { - var checked = Config.getValueBoolean('advancedSettings'); + var checked = Config.getValueBoolean(Config.Keys.AdvancedSettings); this.ui.advancedSettings.prop('checked', checked); if (checked) { @@ -204,7 +204,7 @@ define( _toggleAdvancedSettings: function () { var checked = this.ui.advancedSettings.prop('checked'); - Config.setValue('advancedSettings', checked); + Config.setValue(Config.Keys.AdvancedSettings, checked); if (checked) { $('body').addClass('show-advanced-settings');