From 3f6a6d53d5591ca6cb369d30c43a49b1fa2b3ad9 Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Thu, 4 Jul 2013 20:26:07 -0700 Subject: [PATCH] Media Management settings are alive --- NzbDrone.Api/Config/SettingsModule.cs | 4 +- .../MediaFileTests/EpisodeFileMoverFixture.cs | 2 - .../MediaFileTests/MediaFileServiceTest.cs | 19 ---- NzbDrone.Core.Test/NzbDrone.Core.Test.csproj | 1 + .../OrganizerTests/BuildFilePathFixture.cs | 59 +++++++++++++ .../OrganizerTests/GetNewFilenameFixture.cs | 4 +- NzbDrone.Core/Configuration/ConfigService.cs | 2 +- NzbDrone.Core/Configuration/IConfigService.cs | 2 +- .../007_add_renameEpisodes_to_naming.cs | 20 +++++ NzbDrone.Core/MediaFiles/MediaFileService.cs | 20 ----- NzbDrone.Core/NzbDrone.Core.csproj | 1 + NzbDrone.Core/Organizer/FileNameBuilder.cs | 20 ++--- NzbDrone.Core/Organizer/NamingConfig.cs | 8 +- .../RootFolderSelectionPartial.html | 2 +- UI/Content/form.less | 8 -- UI/Content/icons.less | 14 +++ .../MediaManagement/FileManagement/View.js | 13 +++ .../FileManagement/ViewTemplate.html | 23 +++++ UI/Settings/MediaManagement/Layout.js | 31 +++++++ .../MediaManagement/LayoutTemplate.html | 5 ++ .../Naming/Model.js} | 2 +- UI/Settings/MediaManagement/Naming/View.js | 43 +++++++++ .../Naming/ViewTemplate.html} | 72 ++++----------- UI/Settings/MediaManagement/Sorting/View.js | 13 +++ .../MediaManagement/Sorting/ViewTemplate.html | 32 +++++++ UI/Settings/Misc/MiscTemplate.html | 20 ----- UI/Settings/Naming/NamingView.js | 20 ----- UI/Settings/SettingsLayout.js | 88 +++++++++---------- UI/Settings/SettingsLayoutTemplate.html | 16 ++-- 29 files changed, 346 insertions(+), 218 deletions(-) create mode 100644 NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs create mode 100644 NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs create mode 100644 UI/Settings/MediaManagement/FileManagement/View.js create mode 100644 UI/Settings/MediaManagement/FileManagement/ViewTemplate.html create mode 100644 UI/Settings/MediaManagement/Layout.js create mode 100644 UI/Settings/MediaManagement/LayoutTemplate.html rename UI/Settings/{Naming/NamingModel.js => MediaManagement/Naming/Model.js} (81%) create mode 100644 UI/Settings/MediaManagement/Naming/View.js rename UI/Settings/{Naming/NamingTemplate.html => MediaManagement/Naming/ViewTemplate.html} (60%) create mode 100644 UI/Settings/MediaManagement/Sorting/View.js create mode 100644 UI/Settings/MediaManagement/Sorting/ViewTemplate.html delete mode 100644 UI/Settings/Naming/NamingView.js diff --git a/NzbDrone.Api/Config/SettingsModule.cs b/NzbDrone.Api/Config/SettingsModule.cs index 0cb2a288c..8b670c014 100644 --- a/NzbDrone.Api/Config/SettingsModule.cs +++ b/NzbDrone.Api/Config/SettingsModule.cs @@ -23,7 +23,6 @@ namespace NzbDrone.Api.Config SharedValidator.RuleFor(c => c.MultiEpisodeStyle).InclusiveBetween(0, 3); SharedValidator.RuleFor(c => c.NumberStyle).InclusiveBetween(0, 3); - SharedValidator.RuleFor(c => c.SeasonFolderFormat).NotEmpty(); SharedValidator.RuleFor(c => c.Separator).Matches(@"\s|\s\-\s|\."); } @@ -42,10 +41,9 @@ namespace NzbDrone.Api.Config { public Boolean IncludeEpisodeTitle { get; set; } public Boolean ReplaceSpaces { get; set; } - public Boolean UseSceneName { get; set; } + public Boolean RenameEpisodes { get; set; } public Int32 MultiEpisodeStyle { get; set; } public Int32 NumberStyle { get; set; } - public String SeasonFolderFormat { get; set; } public String Separator { get; set; } public Boolean IncludeQuality { get; set; } public Boolean IncludeSeriesTitle { get; set; } diff --git a/NzbDrone.Core.Test/MediaFileTests/EpisodeFileMoverFixture.cs b/NzbDrone.Core.Test/MediaFileTests/EpisodeFileMoverFixture.cs index 1604fabcb..34ca00cb5 100644 --- a/NzbDrone.Core.Test/MediaFileTests/EpisodeFileMoverFixture.cs +++ b/NzbDrone.Core.Test/MediaFileTests/EpisodeFileMoverFixture.cs @@ -55,10 +55,8 @@ namespace NzbDrone.Core.Test.MediaFileTests .Setup(e => e.BuildFilePath(It.IsAny(), fakeEpisode.First().SeasonNumber, filename, ".avi")) .Returns(fi); - var result = Subject.MoveEpisodeFile(file, false); - result.Should().BeNull(); } diff --git a/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs b/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs index f626159e8..9ad774623 100644 --- a/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs +++ b/NzbDrone.Core.Test/MediaFileTests/MediaFileServiceTest.cs @@ -22,24 +22,5 @@ namespace NzbDrone.Core.Test.MediaFileTests { FileNameBuilder.CleanFilename(name).Should().Be(expectedName); } - - [Test] - [TestCase("30 Rock - S01E05 - Episode Title", 1, true, "Season %0s", @"C:\Test\30 Rock\Season 01\30 Rock - S01E05 - Episode Title.mkv")] - [TestCase("30 Rock - S01E05 - Episode Title", 1, true, "Season %s", @"C:\Test\30 Rock\Season 1\30 Rock - S01E05 - Episode Title.mkv")] - [TestCase("30 Rock - S01E05 - Episode Title", 1, false, "Season %0s", @"C:\Test\30 Rock\30 Rock - S01E05 - Episode Title.mkv")] - [TestCase("30 Rock - S01E05 - Episode Title", 1, false, "Season %s", @"C:\Test\30 Rock\30 Rock - S01E05 - Episode Title.mkv")] - [TestCase("30 Rock - S01E05 - Episode Title", 1, true, "ReallyUglySeasonFolder %s", @"C:\Test\30 Rock\ReallyUglySeasonFolder 1\30 Rock - S01E05 - Episode Title.mkv")] - public void CalculateFilePath_SeasonFolder_SingleNumber(string filename, int seasonNumber, bool useSeasonFolder, string seasonFolderFormat, string expectedPath) - { - var fakeSeries = Builder.CreateNew() - .With(s => s.Title = "30 Rock") - .With(s => s.Path = @"C:\Test\30 Rock") - .With(s => s.SeasonFolder = useSeasonFolder) - .Build(); - - Mocker.GetMock().Setup(e => e.SortingSeasonFolderFormat).Returns(seasonFolderFormat); - - Subject.CalculateFilePath(fakeSeries, 1, filename, ".mkv").FullName.Should().Be(expectedPath); - } } } \ No newline at end of file diff --git a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj index a80ac6958..1c6aebb1d 100644 --- a/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj +++ b/NzbDrone.Core.Test/NzbDrone.Core.Test.csproj @@ -161,6 +161,7 @@ + diff --git a/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs b/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs new file mode 100644 index 000000000..9764eaa59 --- /dev/null +++ b/NzbDrone.Core.Test/OrganizerTests/BuildFilePathFixture.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.IO; +using FizzWare.NBuilder; +using FluentAssertions; +using NUnit.Framework; +using NzbDrone.Core.Configuration; +using NzbDrone.Core.MediaFiles; +using NzbDrone.Core.Organizer; +using NzbDrone.Core.Qualities; +using NzbDrone.Core.Tv; +using NzbDrone.Core.Test.Framework; + +namespace NzbDrone.Core.Test.OrganizerTests +{ + [TestFixture] + + public class BuildFilePathFixture : CoreTest + { + private Series _series; + + private NamingConfig namingConfig; + + [SetUp] + public void Setup() + { + _series = Builder + .CreateNew() + .With(s => s.Title = "South Park") + .Build(); + + + namingConfig = new NamingConfig(); + + + Mocker.GetMock() + .Setup(c => c.GetConfig()).Returns(namingConfig); + } + + [Test] + [TestCase("30 Rock - S01E05 - Episode Title", 1, true, "Season %0s", @"C:\Test\30 Rock\Season 01\30 Rock - S01E05 - Episode Title.mkv")] + [TestCase("30 Rock - S01E05 - Episode Title", 1, true, "Season %s", @"C:\Test\30 Rock\Season 1\30 Rock - S01E05 - Episode Title.mkv")] + [TestCase("30 Rock - S01E05 - Episode Title", 1, false, "Season %0s", @"C:\Test\30 Rock\30 Rock - S01E05 - Episode Title.mkv")] + [TestCase("30 Rock - S01E05 - Episode Title", 1, false, "Season %s", @"C:\Test\30 Rock\30 Rock - S01E05 - Episode Title.mkv")] + [TestCase("30 Rock - S01E05 - Episode Title", 1, true, "ReallyUglySeasonFolder %s", @"C:\Test\30 Rock\ReallyUglySeasonFolder 1\30 Rock - S01E05 - Episode Title.mkv")] + public void CalculateFilePath_SeasonFolder_SingleNumber(string filename, int seasonNumber, bool useSeasonFolder, string seasonFolderFormat, string expectedPath) + { + var fakeSeries = Builder.CreateNew() + .With(s => s.Title = "30 Rock") + .With(s => s.Path = @"C:\Test\30 Rock") + .With(s => s.SeasonFolder = useSeasonFolder) + .Build(); + + Mocker.GetMock().Setup(e => e.SeasonFolderFormat).Returns(seasonFolderFormat); + + Subject.BuildFilePath(fakeSeries, 1, filename, ".mkv").Should().Be(expectedPath); + } + } +} \ No newline at end of file diff --git a/NzbDrone.Core.Test/OrganizerTests/GetNewFilenameFixture.cs b/NzbDrone.Core.Test/OrganizerTests/GetNewFilenameFixture.cs index 68889ec70..770d19ac3 100644 --- a/NzbDrone.Core.Test/OrganizerTests/GetNewFilenameFixture.cs +++ b/NzbDrone.Core.Test/OrganizerTests/GetNewFilenameFixture.cs @@ -534,7 +534,7 @@ namespace NzbDrone.Core.Test.OrganizerTests namingConfig.Separator = "."; ; namingConfig.NumberStyle = 0; namingConfig.ReplaceSpaces = false; - namingConfig.UseSceneName = true; + namingConfig.RenameEpisodes = false; var episode = Builder.CreateNew() .With(e => e.Title = "City Sushi") @@ -563,7 +563,7 @@ namespace NzbDrone.Core.Test.OrganizerTests namingConfig.Separator = "."; namingConfig.NumberStyle = 0; namingConfig.ReplaceSpaces = false; - namingConfig.UseSceneName = true; + namingConfig.RenameEpisodes = false; var episode = Builder.CreateNew() .With(e => e.Title = "City Sushi") diff --git a/NzbDrone.Core/Configuration/ConfigService.cs b/NzbDrone.Core/Configuration/ConfigService.cs index 6da46ed50..6677ae46d 100644 --- a/NzbDrone.Core/Configuration/ConfigService.cs +++ b/NzbDrone.Core/Configuration/ConfigService.cs @@ -130,7 +130,7 @@ namespace NzbDrone.Core.Configuration set { SetValue("UseSeasonFolder", value); } } - public string SortingSeasonFolderFormat + public string SeasonFolderFormat { get { return GetValue("Sorting_SeasonFolderFormat", "Season %s"); } set { SetValue("Sorting_SeasonFolderFormat", value); } diff --git a/NzbDrone.Core/Configuration/IConfigService.cs b/NzbDrone.Core/Configuration/IConfigService.cs index 0ee48c889..33bcdf9f9 100644 --- a/NzbDrone.Core/Configuration/IConfigService.cs +++ b/NzbDrone.Core/Configuration/IConfigService.cs @@ -21,7 +21,7 @@ namespace NzbDrone.Core.Configuration SabPriorityType SabRecentTvPriority { get; set; } String DownloadedEpisodesFolder { get; set; } bool UseSeasonFolder { get; set; } - string SortingSeasonFolderFormat { get; set; } + string SeasonFolderFormat { get; set; } bool EnableBacklogSearching { get; set; } bool AutoIgnorePreviouslyDownloadedEpisodes { get; set; } int Retention { get; set; } diff --git a/NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs b/NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs new file mode 100644 index 000000000..5ed4b625a --- /dev/null +++ b/NzbDrone.Core/Datastore/Migration/007_add_renameEpisodes_to_naming.cs @@ -0,0 +1,20 @@ +using FluentMigrator; +using NzbDrone.Core.Datastore.Migration.Framework; + +namespace NzbDrone.Core.Datastore.Migration +{ + [Tags("")] + [Migration(7)] + public class add_renameEpisodes_to_naming : NzbDroneMigrationBase + { + protected override void MainDbUpgrade() + { + Alter.Table("NamingConfig") + .AddColumn("RenameEpisodes") + .AsBoolean() + .Nullable(); + + Execute.Sql("UPDATE NamingConfig SET RenameEpisodes =~ UseSceneName"); + } + } +} diff --git a/NzbDrone.Core/MediaFiles/MediaFileService.cs b/NzbDrone.Core/MediaFiles/MediaFileService.cs index 45709fe8b..a4c0f4d97 100644 --- a/NzbDrone.Core/MediaFiles/MediaFileService.cs +++ b/NzbDrone.Core/MediaFiles/MediaFileService.cs @@ -72,25 +72,5 @@ namespace NzbDrone.Core.MediaFiles var files = GetFilesBySeries(message.Series.Id); _mediaFileRepository.DeleteMany(files); } - - public FileInfo CalculateFilePath(Series series, int seasonNumber, string fileName, string extension) - { - string path = series.Path; - if (series.SeasonFolder) - { - var seasonFolder = _configService.SortingSeasonFolderFormat - .Replace("%sn", series.Title) - .Replace("%s.n", series.Title.Replace(' ', '.')) - .Replace("%s_n", series.Title.Replace(' ', '_')) - .Replace("%0s", seasonNumber.ToString("00")) - .Replace("%s", seasonNumber.ToString()); - - path = Path.Combine(path, seasonFolder); - } - - path = Path.Combine(path, fileName + extension); - - return new FileInfo(path); - } } } \ No newline at end of file diff --git a/NzbDrone.Core/NzbDrone.Core.csproj b/NzbDrone.Core/NzbDrone.Core.csproj index fbaf13913..4abb961f2 100644 --- a/NzbDrone.Core/NzbDrone.Core.csproj +++ b/NzbDrone.Core/NzbDrone.Core.csproj @@ -211,6 +211,7 @@ + diff --git a/NzbDrone.Core/Organizer/FileNameBuilder.cs b/NzbDrone.Core/Organizer/FileNameBuilder.cs index 6a42129e7..76c12b84d 100644 --- a/NzbDrone.Core/Organizer/FileNameBuilder.cs +++ b/NzbDrone.Core/Organizer/FileNameBuilder.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using NLog; +using NzbDrone.Core.Configuration; using NzbDrone.Core.Datastore; using NzbDrone.Core.MediaFiles; using NzbDrone.Core.Tv; @@ -50,25 +51,24 @@ namespace NzbDrone.Core.Organizer } } - public class FileNameBuilder : IBuildFileNames { + private readonly IConfigService _configService; private readonly INamingConfigService _namingConfigService; private readonly Logger _logger; - public FileNameBuilder(INamingConfigService namingConfigService, Logger logger) + public FileNameBuilder(INamingConfigService namingConfigService, IConfigService configService, Logger logger) { _namingConfigService = namingConfigService; + _configService = configService; _logger = logger; } - - public string BuildFilename(IList episodes, Series series, EpisodeFile episodeFile) { var nameSpec = _namingConfigService.GetConfig(); - if (nameSpec.UseSceneName) + if (!nameSpec.RenameEpisodes) { if (String.IsNullOrWhiteSpace(episodeFile.SceneName)) { @@ -162,13 +162,13 @@ namespace NzbDrone.Core.Organizer public string BuildFilePath(Series series, int seasonNumber, string fileName, string extension) { - - var nameSpec = _namingConfigService.GetConfig(); - string path = series.Path; if (series.SeasonFolder) { - var seasonFolder = nameSpec.SeasonFolderFormat + var seasonFolder = _configService.SeasonFolderFormat + .Replace("%sn", series.Title) + .Replace("%s.n", series.Title.Replace(' ', '.')) + .Replace("%s_n", series.Title.Replace(' ', '_')) .Replace("%0s", seasonNumber.ToString("00")) .Replace("%s", seasonNumber.ToString()); @@ -178,7 +178,6 @@ namespace NzbDrone.Core.Organizer return Path.Combine(path, fileName + extension); } - public static string CleanFilename(string name) { string result = name; @@ -191,7 +190,6 @@ namespace NzbDrone.Core.Organizer return result.Trim(); } - private static readonly List NumberStyles = new List { new EpisodeSortingType diff --git a/NzbDrone.Core/Organizer/NamingConfig.cs b/NzbDrone.Core/Organizer/NamingConfig.cs index cfe82aefb..4fba40d41 100644 --- a/NzbDrone.Core/Organizer/NamingConfig.cs +++ b/NzbDrone.Core/Organizer/NamingConfig.cs @@ -10,7 +10,7 @@ namespace NzbDrone.Core.Organizer { return new NamingConfig { - UseSceneName = false, + RenameEpisodes = true, Separator = " - ", NumberStyle = 0, IncludeSeriesTitle = true, @@ -18,12 +18,12 @@ namespace NzbDrone.Core.Organizer IncludeEpisodeTitle = true, IncludeQuality = true, ReplaceSpaces = false, - SeasonFolderFormat = "Season %s" + SeasonFolderFormat = "DO_NOT_USE" }; } } - public bool UseSceneName { get; set; } + public bool RenameEpisodes { get; set; } public string Separator { get; set; } @@ -39,6 +39,8 @@ namespace NzbDrone.Core.Organizer public bool ReplaceSpaces { get; set; } + //Todo: remove - not used public string SeasonFolderFormat { get; set; } + public bool UseSceneName { get; set; } } } \ No newline at end of file diff --git a/UI/AddSeries/RootFolders/RootFolderSelectionPartial.html b/UI/AddSeries/RootFolders/RootFolderSelectionPartial.html index 3655b24bb..97a8b7be1 100644 --- a/UI/AddSeries/RootFolders/RootFolderSelectionPartial.html +++ b/UI/AddSeries/RootFolders/RootFolderSelectionPartial.html @@ -2,5 +2,5 @@ {{#each this}} {{/each}} - + diff --git a/UI/Content/form.less b/UI/Content/form.less index 8ca4c3c03..d01b446c2 100644 --- a/UI/Content/form.less +++ b/UI/Content/form.less @@ -1,11 +1,5 @@ .control-group { .controls { - i.danger { - color : #b94a48; - } - i.warning { - color : #f89406; - } i { font-size : 16px; color : #595959; @@ -19,8 +13,6 @@ margin-bottom : 0px; } - - .help-inline-checkbox { padding-left : 5px; display : inline-block; diff --git a/UI/Content/icons.less b/UI/Content/icons.less index 858fdb150..cadc8de3f 100644 --- a/UI/Content/icons.less +++ b/UI/Content/icons.less @@ -57,3 +57,17 @@ .icon-nd-add:before { .icon(@plus); } + +.icon-form-info:before { + .icon(@question-sign); +} + +.icon-form-warning:before { + .icon(@warning-sign); + color : #f89406; +} + +.icon-form-danger:before { + .icon(@exclamation-sign); + color : #b94a48; +} \ No newline at end of file diff --git a/UI/Settings/MediaManagement/FileManagement/View.js b/UI/Settings/MediaManagement/FileManagement/View.js new file mode 100644 index 000000000..7c4a89638 --- /dev/null +++ b/UI/Settings/MediaManagement/FileManagement/View.js @@ -0,0 +1,13 @@ +'use strict'; +define( + [ + 'marionette', + 'Mixins/AsModelBoundView' + ], function (Marionette, AsModelBoundView) { + + var view = Marionette.ItemView.extend({ + template: 'Settings/MediaManagement/FileManagement/ViewTemplate' + }); + + return AsModelBoundView.call(view); + }); diff --git a/UI/Settings/MediaManagement/FileManagement/ViewTemplate.html b/UI/Settings/MediaManagement/FileManagement/ViewTemplate.html new file mode 100644 index 000000000..089e9a37c --- /dev/null +++ b/UI/Settings/MediaManagement/FileManagement/ViewTemplate.html @@ -0,0 +1,23 @@ +
+ File Management + +
+ + +
+
+
diff --git a/UI/Settings/MediaManagement/Layout.js b/UI/Settings/MediaManagement/Layout.js new file mode 100644 index 000000000..9254a15f7 --- /dev/null +++ b/UI/Settings/MediaManagement/Layout.js @@ -0,0 +1,31 @@ +"use strict"; + +define( + [ + 'marionette', + 'Settings/MediaManagement/Naming/View', + 'Settings/MediaManagement/Sorting/View', + 'Settings/MediaManagement/FileManagement/View' + ], function (Marionette, NamingView, SortingView, FileManagementView) { + return Marionette.Layout.extend({ + template: 'Settings/MediaManagement/LayoutTemplate', + + regions: { + episodeNaming : '#episode-naming', + sorting : '#sorting', + fileManagement : '#file-management' + }, + + initialize: function (options) { + this.settings = options.settings; + this.namingSettings = options.namingSettings; + }, + + onRender: function () { + this.episodeNaming.show(new NamingView({ model: this.namingSettings })); + this.sorting.show(new SortingView({ model: this.settings })); + this.fileManagement.show(new FileManagementView({ model: this.settings })); + } + }); + }); + diff --git a/UI/Settings/MediaManagement/LayoutTemplate.html b/UI/Settings/MediaManagement/LayoutTemplate.html new file mode 100644 index 000000000..4720aa606 --- /dev/null +++ b/UI/Settings/MediaManagement/LayoutTemplate.html @@ -0,0 +1,5 @@ +
+
+
+
+
\ No newline at end of file diff --git a/UI/Settings/Naming/NamingModel.js b/UI/Settings/MediaManagement/Naming/Model.js similarity index 81% rename from UI/Settings/Naming/NamingModel.js rename to UI/Settings/MediaManagement/Naming/Model.js index 23c77e24b..3897989d2 100644 --- a/UI/Settings/Naming/NamingModel.js +++ b/UI/Settings/MediaManagement/Naming/Model.js @@ -5,7 +5,7 @@ define( ], function (ModelBase) { return ModelBase.extend({ url : window.ApiRoot + '/config/naming', - successMessage: 'Naming settings saved', + successMessage: 'MediaManagement settings saved', errorMessage : 'Couldn\'t save naming settings' }); diff --git a/UI/Settings/MediaManagement/Naming/View.js b/UI/Settings/MediaManagement/Naming/View.js new file mode 100644 index 000000000..0a7ee87af --- /dev/null +++ b/UI/Settings/MediaManagement/Naming/View.js @@ -0,0 +1,43 @@ +'use strict'; +define( + [ + 'marionette', + 'Mixins/AsModelBoundView' + ], function (Marionette, AsModelBoundView) { + + var view = Marionette.ItemView.extend({ + template: 'Settings/MediaManagement/Naming/ViewTemplate', + + ui: { + namingOptions : '.x-naming-options', + renameEpisodesCheckbox : '.x-rename-episodes' + }, + + events: { + 'change .x-rename-episodes': '_toggleNamingOptions' + }, + + onShow: function () { + var renameEpisodes = this.model.get('renameEpisodes'); + this._setNamingOptionsVisibility(renameEpisodes); + }, + + _toggleNamingOptions: function() { + var checked = this.ui.renameEpisodesCheckbox.prop('checked'); + this._setNamingOptionsVisibility(checked); + }, + + _setNamingOptionsVisibility: function (showNamingOptions) { + + if (showNamingOptions) { + this.ui.namingOptions.show(); + } + + else { + this.ui.namingOptions.hide(); + } + } + }); + + return AsModelBoundView.call(view); + }); diff --git a/UI/Settings/Naming/NamingTemplate.html b/UI/Settings/MediaManagement/Naming/ViewTemplate.html similarity index 60% rename from UI/Settings/Naming/NamingTemplate.html rename to UI/Settings/MediaManagement/Naming/ViewTemplate.html index f2e819b76..39cdf0b21 100644 --- a/UI/Settings/Naming/NamingTemplate.html +++ b/UI/Settings/MediaManagement/Naming/ViewTemplate.html @@ -1,28 +1,28 @@ -
-
- Episode Naming +
+ Episode Naming -
- +
+ -
-
@@ -100,21 +88,6 @@
- - - - -
-
- -
- - -
- - - -
@@ -127,9 +100,6 @@ - - -
@@ -143,9 +113,6 @@ - - - @@ -159,10 +126,7 @@ - - - - - + + diff --git a/UI/Settings/MediaManagement/Sorting/View.js b/UI/Settings/MediaManagement/Sorting/View.js new file mode 100644 index 000000000..18e7d3d37 --- /dev/null +++ b/UI/Settings/MediaManagement/Sorting/View.js @@ -0,0 +1,13 @@ +'use strict'; +define( + [ + 'marionette', + 'Mixins/AsModelBoundView' + ], function (Marionette, AsModelBoundView) { + + var view = Marionette.ItemView.extend({ + template: 'Settings/MediaManagement/Sorting/ViewTemplate' + }); + + return AsModelBoundView.call(view); + }); diff --git a/UI/Settings/MediaManagement/Sorting/ViewTemplate.html b/UI/Settings/MediaManagement/Sorting/ViewTemplate.html new file mode 100644 index 000000000..c18b0af57 --- /dev/null +++ b/UI/Settings/MediaManagement/Sorting/ViewTemplate.html @@ -0,0 +1,32 @@ +
+ Sorting + + +
+ + +
+
+ +
+ + +
+ + + + +
+
+
diff --git a/UI/Settings/Misc/MiscTemplate.html b/UI/Settings/Misc/MiscTemplate.html index 91bd1cfba..2f41f60e9 100644 --- a/UI/Settings/Misc/MiscTemplate.html +++ b/UI/Settings/Misc/MiscTemplate.html @@ -23,26 +23,6 @@ -
- - -
-
-
diff --git a/UI/Settings/Naming/NamingView.js b/UI/Settings/Naming/NamingView.js deleted file mode 100644 index cf3f4acff..000000000 --- a/UI/Settings/Naming/NamingView.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; -define( - [ - 'marionette', - 'Settings/Naming/NamingModel', - 'Mixins/AsModelBoundView' - ], function (Marionette, NamingModel, AsModelBoundView) { - - var view = Marionette.ItemView.extend({ - template: 'Settings/Naming/NamingTemplate', - - initialize: function () { - this.model = new NamingModel(); - this.model.fetch(); - } - - }); - - return AsModelBoundView.call(view); - }); diff --git a/UI/Settings/SettingsLayout.js b/UI/Settings/SettingsLayout.js index 9126116a4..4dd02c2ff 100644 --- a/UI/Settings/SettingsLayout.js +++ b/UI/Settings/SettingsLayout.js @@ -5,8 +5,8 @@ define( 'marionette', 'Settings/SettingsModel', 'Settings/General/GeneralSettingsModel', - 'Settings/Naming/NamingModel', - 'Settings/Naming/NamingView', + 'Settings/MediaManagement/Naming/Model', + 'Settings/MediaManagement/Layout', 'Settings/Quality/QualityLayout', 'Settings/Indexers/CollectionView', 'Settings/Indexers/Collection', @@ -21,7 +21,7 @@ define( SettingsModel, GeneralSettingsModel, NamingModel, - NamingView, + MediaManagementLayout, QualityLayout, IndexerCollectionView, IndexerCollection, @@ -35,47 +35,47 @@ define( template: 'Settings/SettingsLayoutTemplate', regions: { - naming : '#naming', - quality : '#quality', - indexers : '#indexers', - downloadClient: '#download-client', - notifications : '#notifications', - general : '#general', - misc : '#misc', - loading : '#loading-region' + mediaManagement : '#media-management', + quality : '#quality', + indexers : '#indexers', + downloadClient : '#download-client', + notifications : '#notifications', + general : '#general', + misc : '#misc', + loading : '#loading-region' }, ui: { - namingTab : '.x-naming-tab', - qualityTab : '.x-quality-tab', - indexersTab : '.x-indexers-tab', - downloadClientTab: '.x-download-client-tab', - notificationsTab : '.x-notifications-tab', - generalTab : '.x-general-tab', - miscTab : '.x-misc-tab' + mediaManagementTab : '.x-media-management-tab', + qualityTab : '.x-quality-tab', + indexersTab : '.x-indexers-tab', + downloadClientTab : '.x-download-client-tab', + notificationsTab : '.x-notifications-tab', + generalTab : '.x-general-tab', + miscTab : '.x-misc-tab' }, events: { - 'click .x-naming-tab' : 'showNaming', - 'click .x-quality-tab' : 'showQuality', - 'click .x-indexers-tab' : 'showIndexers', - 'click .x-download-client-tab': 'showDownloadClient', - 'click .x-notifications-tab' : 'showNotifications', - 'click .x-general-tab' : 'showGeneral', - 'click .x-misc-tab' : 'showMisc', - 'click .x-save-settings' : 'save' + 'click .x-media-management-tab' : '_showMediaManagement', + 'click .x-quality-tab' : '_showQuality', + 'click .x-indexers-tab' : '_showIndexers', + 'click .x-download-client-tab' : '_showDownloadClient', + 'click .x-notifications-tab' : '_showNotifications', + 'click .x-general-tab' : '_showGeneral', + 'click .x-misc-tab' : '_showMisc', + 'click .x-save-settings' : '_save' }, - showNaming: function (e) { + _showMediaManagement: function (e) { if (e) { e.preventDefault(); } - this.ui.namingTab.tab('show'); - this._navigate('settings/naming'); + this.ui.mediaManagementTab.tab('show'); + this._navigate('settings/mediamanagement'); }, - showQuality: function (e) { + _showQuality: function (e) { if (e) { e.preventDefault(); } @@ -84,7 +84,7 @@ define( this._navigate('settings/quality'); }, - showIndexers: function (e) { + _showIndexers: function (e) { if (e) { e.preventDefault(); } @@ -93,7 +93,7 @@ define( this._navigate('settings/indexers'); }, - showDownloadClient: function (e) { + _showDownloadClient: function (e) { if (e) { e.preventDefault(); } @@ -102,7 +102,7 @@ define( this._navigate('settings/downloadclient'); }, - showNotifications: function (e) { + _showNotifications: function (e) { if (e) { e.preventDefault(); } @@ -111,7 +111,7 @@ define( this._navigate('settings/notifications'); }, - showGeneral: function (e) { + _showGeneral: function (e) { if (e) { e.preventDefault(); } @@ -120,7 +120,7 @@ define( this._navigate('settings/general'); }, - showMisc: function (e) { + _showMisc: function (e) { if (e) { e.preventDefault(); } @@ -158,7 +158,7 @@ define( this.notificationSettings.fetch() ).done(function () { self.loading.$el.hide(); - self.naming.show(new NamingView()); + self.mediaManagement.show(new MediaManagementLayout({ settings: self.settings, namingSettings: self.namingSettings })); self.quality.show(new QualityLayout({settings: self.settings})); self.indexers.show(new IndexerCollectionView({collection: self.indexerSettings})); self.downloadClient.show(new DownloadClientLayout({model: self.settings})); @@ -171,29 +171,29 @@ define( onShow: function () { switch (this.action) { case 'quality': - this.showQuality(); + this._showQuality(); break; case 'indexers': - this.showIndexers(); + this._showIndexers(); break; case 'downloadclient': - this.showDownloadClient(); + this._showDownloadClient(); break; case 'notifications': - this.showNotifications(); + this._showNotifications(); break; case 'general': - this.showGeneral(); + this._showGeneral(); break; case 'misc': - this.showMisc(); + this._showMisc(); break; default: - this.showNaming(); + this._showMediaManagement(); } }, - save: function () { + _save: function () { App.vent.trigger(App.Commands.SaveSettings); } }); diff --git a/UI/Settings/SettingsLayoutTemplate.html b/UI/Settings/SettingsLayoutTemplate.html index 940681c21..14995d814 100644 --- a/UI/Settings/SettingsLayoutTemplate.html +++ b/UI/Settings/SettingsLayoutTemplate.html @@ -1,5 +1,5 @@ 
-
Naming Settings
-
Quality Settings
-
Indexer Settings
-
Download Client Settings
-
Notification Settings
-
general Settings
-
Misc Settings
+
+
+
+
+
+
+
\ No newline at end of file