From fe41aada06a2b29b1d73ef9df6cf49faf2150b6f Mon Sep 17 00:00:00 2001
From: Ricardo Christmann <80476005+ricci2511@users.noreply.github.com>
Date: Tue, 4 Jul 2023 18:18:44 +0200
Subject: [PATCH] New: Add tags field to MovieCollection (#8736)
* New: Add tags field to MovieCollection
* Added Tag input prepopulation for new collection movies
* Handle editting of collection tags
* Revert changes to CollectionController.cs
---
.../AddNewCollectionMovieModalContentConnector.js | 2 +-
.../Collection/Edit/EditCollectionModalContent.js | 12 ++++++++++++
.../Edit/EditCollectionModalContentConnector.js | 1 +
.../Migration/225_add_tags_to_collections.cs | 14 ++++++++++++++
.../Movies/Collections/MovieCollection.cs | 2 ++
.../Movies/RefreshCollectionService.cs | 3 ++-
src/NzbDrone.Core/Movies/RefreshMovieService.cs | 3 ++-
.../Collections/CollectionResource.cs | 7 +++++--
8 files changed, 39 insertions(+), 5 deletions(-)
create mode 100644 src/NzbDrone.Core/Datastore/Migration/225_add_tags_to_collections.cs
diff --git a/frontend/src/Collection/AddNewCollectionMovieModalContentConnector.js b/frontend/src/Collection/AddNewCollectionMovieModalContentConnector.js
index 740e04322..46351b303 100644
--- a/frontend/src/Collection/AddNewCollectionMovieModalContentConnector.js
+++ b/frontend/src/Collection/AddNewCollectionMovieModalContentConnector.js
@@ -28,7 +28,7 @@ function createMapStateToProps() {
qualityProfileId: collection.qualityProfileId,
minimumAvailability: collection.minimumAvailability,
searchForMovie: collection.searchOnAdd,
- tags: []
+ tags: collection.tags || []
};
const {
diff --git a/frontend/src/Collection/Edit/EditCollectionModalContent.js b/frontend/src/Collection/Edit/EditCollectionModalContent.js
index 7a924fbfb..5063fb28d 100644
--- a/frontend/src/Collection/Edit/EditCollectionModalContent.js
+++ b/frontend/src/Collection/Edit/EditCollectionModalContent.js
@@ -50,6 +50,7 @@ class EditCollectionModalContent extends Component {
minimumAvailability,
// Id,
rootFolderPath,
+ tags,
searchOnAdd
} = item;
@@ -126,6 +127,17 @@ class EditCollectionModalContent extends Component {
/>
+
+ {translate('Tags')}
+
+
+
+
{translate('SearchOnAdd')}
diff --git a/frontend/src/Collection/Edit/EditCollectionModalContentConnector.js b/frontend/src/Collection/Edit/EditCollectionModalContentConnector.js
index 9600647b2..32f639ca9 100644
--- a/frontend/src/Collection/Edit/EditCollectionModalContentConnector.js
+++ b/frontend/src/Collection/Edit/EditCollectionModalContentConnector.js
@@ -42,6 +42,7 @@ function createMapStateToProps() {
qualityProfileId: collection.qualityProfileId,
minimumAvailability: collection.minimumAvailability,
rootFolderPath: collection.rootFolderPath,
+ tags: collection.tags,
searchOnAdd: collection.searchOnAdd
};
diff --git a/src/NzbDrone.Core/Datastore/Migration/225_add_tags_to_collections.cs b/src/NzbDrone.Core/Datastore/Migration/225_add_tags_to_collections.cs
new file mode 100644
index 000000000..79483e141
--- /dev/null
+++ b/src/NzbDrone.Core/Datastore/Migration/225_add_tags_to_collections.cs
@@ -0,0 +1,14 @@
+using FluentMigrator;
+using NzbDrone.Core.Datastore.Migration.Framework;
+
+namespace NzbDrone.Core.Datastore.Migration
+{
+ [Migration(225)]
+ public class add_tags_to_collections : NzbDroneMigrationBase
+ {
+ protected override void MainDbUpgrade()
+ {
+ Alter.Table("Collections").AddColumn("Tags").AsString().Nullable();
+ }
+ }
+}
diff --git a/src/NzbDrone.Core/Movies/Collections/MovieCollection.cs b/src/NzbDrone.Core/Movies/Collections/MovieCollection.cs
index 18a33b28f..9e8cd1d0d 100644
--- a/src/NzbDrone.Core/Movies/Collections/MovieCollection.cs
+++ b/src/NzbDrone.Core/Movies/Collections/MovieCollection.cs
@@ -25,6 +25,7 @@ namespace NzbDrone.Core.Movies.Collections
public List Images { get; set; }
public DateTime Added { get; set; }
public List Movies { get; set; }
+ public HashSet Tags { get; set; }
public void ApplyChanges(MovieCollection otherCollection)
{
@@ -35,6 +36,7 @@ namespace NzbDrone.Core.Movies.Collections
QualityProfileId = otherCollection.QualityProfileId;
MinimumAvailability = otherCollection.MinimumAvailability;
RootFolderPath = otherCollection.RootFolderPath;
+ Tags = otherCollection.Tags;
}
}
}
diff --git a/src/NzbDrone.Core/Movies/RefreshCollectionService.cs b/src/NzbDrone.Core/Movies/RefreshCollectionService.cs
index e69dd6535..e864052e3 100644
--- a/src/NzbDrone.Core/Movies/RefreshCollectionService.cs
+++ b/src/NzbDrone.Core/Movies/RefreshCollectionService.cs
@@ -139,7 +139,8 @@ namespace NzbDrone.Core.Movies
SearchForMovie = collection.SearchOnAdd,
AddMethod = AddMovieMethod.Collection
},
- Monitored = true
+ Monitored = true,
+ Tags = collection.Tags
}).ToList(), true);
}
}
diff --git a/src/NzbDrone.Core/Movies/RefreshMovieService.cs b/src/NzbDrone.Core/Movies/RefreshMovieService.cs
index b779b3cd2..c4e1fd48f 100644
--- a/src/NzbDrone.Core/Movies/RefreshMovieService.cs
+++ b/src/NzbDrone.Core/Movies/RefreshMovieService.cs
@@ -141,7 +141,8 @@ namespace NzbDrone.Core.Movies
SearchOnAdd = movie.AddOptions?.SearchForMovie ?? false,
QualityProfileId = movie.ProfileId,
MinimumAvailability = movie.MinimumAvailability,
- RootFolderPath = _folderService.GetBestRootFolderPath(movie.Path).TrimEnd('/', '\\', ' ')
+ RootFolderPath = _folderService.GetBestRootFolderPath(movie.Path).TrimEnd('/', '\\', ' '),
+ Tags = movie.Tags
});
if (newCollection != null)
diff --git a/src/Radarr.Api.V3/Collections/CollectionResource.cs b/src/Radarr.Api.V3/Collections/CollectionResource.cs
index 6b54e5e08..fe5b3798b 100644
--- a/src/Radarr.Api.V3/Collections/CollectionResource.cs
+++ b/src/Radarr.Api.V3/Collections/CollectionResource.cs
@@ -26,6 +26,7 @@ namespace Radarr.Api.V3.Collections
public MovieStatusType MinimumAvailability { get; set; }
public List Movies { get; set; }
public int MissingMovies { get; set; }
+ public HashSet Tags { get; set; }
}
public static class CollectionResourceMapper
@@ -49,7 +50,8 @@ namespace Radarr.Api.V3.Collections
QualityProfileId = model.QualityProfileId,
RootFolderPath = model.RootFolderPath,
MinimumAvailability = model.MinimumAvailability,
- SearchOnAdd = model.SearchOnAdd
+ SearchOnAdd = model.SearchOnAdd,
+ Tags = model.Tags
};
}
@@ -76,7 +78,8 @@ namespace Radarr.Api.V3.Collections
QualityProfileId = resource.QualityProfileId,
RootFolderPath = resource.RootFolderPath,
SearchOnAdd = resource.SearchOnAdd,
- MinimumAvailability = resource.MinimumAvailability
+ MinimumAvailability = resource.MinimumAvailability,
+ Tags = resource.Tags
};
}