From 26d32cbf284d6d2c21c53c41abddcac14a00d59c Mon Sep 17 00:00:00 2001 From: Joe Milazzo Date: Wed, 19 Oct 2022 17:48:52 -0700 Subject: [PATCH] Release Shakeout Day 2 (#1594) * Fixed a bad color on the PWA titlebar * Added more unit tests, cleaned up some dead code, and made it so when age restriction is Not Applicable, the Unknowns field disables * Don't show an empty menu when user has no permissions * Fixed deleting a library with relation causing library deleting to fail * Consolidated some includes code into one method for Series Repo * Small fixes --- API.Tests/Services/SeriesServiceTests.cs | 182 +++++++++++++++++- API/Controllers/LibraryController.cs | 7 +- .../Migrations/DataContextModelSnapshot.cs | 58 +++--- API/Data/Repositories/LibraryRepository.cs | 6 +- API/Data/Repositories/SeriesRepository.cs | 74 +++---- API/Entities/Library.cs | 12 -- .../card-actionables.component.ts | 6 + .../restriction-selector.component.ts | 5 + UI/Web/src/index.html | 2 +- 9 files changed, 252 insertions(+), 100 deletions(-) diff --git a/API.Tests/Services/SeriesServiceTests.cs b/API.Tests/Services/SeriesServiceTests.cs index 762a0ed9a..8307136b7 100644 --- a/API.Tests/Services/SeriesServiceTests.cs +++ b/API.Tests/Services/SeriesServiceTests.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Data.Common; using System.IO.Abstractions.TestingHelpers; using System.Linq; @@ -125,7 +126,7 @@ public class SeriesServiceTests return fileSystem; } - private static UpdateRelatedSeriesDto InstantiateRelationsDto(Series series) + private static UpdateRelatedSeriesDto CreateRelationsDto(Series series) { return new UpdateRelatedSeriesDto() { @@ -1178,7 +1179,7 @@ public class SeriesServiceTests var series1 = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Related); // Add relations - var addRelationDto = InstantiateRelationsDto(series1); + var addRelationDto = CreateRelationsDto(series1); addRelationDto.Adaptations.Add(2); addRelationDto.Sequels.Add(3); await _seriesService.UpdateRelatedSeries(addRelationDto); @@ -1225,7 +1226,7 @@ public class SeriesServiceTests var series1 = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Related); // Add relations - var addRelationDto = InstantiateRelationsDto(series1); + var addRelationDto = CreateRelationsDto(series1); addRelationDto.Adaptations.Add(2); addRelationDto.Sequels.Add(3); await _seriesService.UpdateRelatedSeries(addRelationDto); @@ -1233,7 +1234,7 @@ public class SeriesServiceTests Assert.Equal(3, series1.Relations.Single(s => s.TargetSeriesId == 3).TargetSeriesId); // Remove relations - var removeRelationDto = InstantiateRelationsDto(series1); + var removeRelationDto = CreateRelationsDto(series1); await _seriesService.UpdateRelatedSeries(removeRelationDto); Assert.Empty(series1.Relations.Where(s => s.TargetSeriesId == 1)); Assert.Empty(series1.Relations.Where(s => s.TargetSeriesId == 2)); @@ -1284,7 +1285,7 @@ public class SeriesServiceTests series1.Relations.Add(relation); // Create a new dto with the previous relation as well - var relationDto = InstantiateRelationsDto(series1); + var relationDto = CreateRelationsDto(series1); relationDto.Adaptations.Add(2); await _seriesService.UpdateRelatedSeries(relationDto); @@ -1339,7 +1340,7 @@ public class SeriesServiceTests await _context.SaveChangesAsync(); var series1 = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Related); // Add relations - var addRelationDto = InstantiateRelationsDto(series1); + var addRelationDto = CreateRelationsDto(series1); addRelationDto.Editions.Add(2); addRelationDto.Prequels.Add(3); addRelationDto.Sequels.Add(4); @@ -1353,5 +1354,172 @@ public class SeriesServiceTests Assert.NotEmpty(_seriesService.GetRelatedSeries(1, 5).Result.Parent); } + [Fact] + public async Task SeriesRelation_ShouldAllowDeleteOnLibrary() + { + await ResetDb(); + _context.Library.Add(new Library() + { + AppUsers = new List() + { + new AppUser() + { + UserName = "majora2007" + } + }, + Name = "Test LIb", + Type = LibraryType.Book, + Series = new List() + { + new Series() + { + Name = "Test Series", + Volumes = new List(){} + }, + new Series() + { + Name = "Test Series Prequels", + Volumes = new List(){} + }, + new Series() + { + Name = "Test Series Sequels", + Volumes = new List(){} + } + } + }); + + await _context.SaveChangesAsync(); + + var series1 = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Related); + // Add relations + var addRelationDto = CreateRelationsDto(series1); + addRelationDto.Adaptations.Add(2); + addRelationDto.Sequels.Add(3); + await _seriesService.UpdateRelatedSeries(addRelationDto); + + var library = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(1); + _unitOfWork.LibraryRepository.Delete(library); + + try + { + await _unitOfWork.CommitAsync(); + } + catch (Exception) + { + Assert.False(true); + } + + Assert.Null(await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(1)); + } + + [Fact] + public async Task SeriesRelation_ShouldAllowDeleteOnLibrary_WhenSeriesCrossLibraries() + { + await ResetDb(); + _context.Library.Add(new Library() + { + AppUsers = new List() + { + new AppUser() + { + UserName = "majora2007" + } + }, + Name = "Test LIb", + Type = LibraryType.Book, + Series = new List() + { + new Series() + { + Name = "Test Series", + Volumes = new List() + { + new Volume() + { + Chapters = new List() + { + new Chapter() + { + Files = new List() + { + new MangaFile() + { + Pages = 1, + FilePath = "fake file" + } + } + } + } + } + } + }, + new Series() + { + Name = "Test Series Prequels", + Volumes = new List(){} + }, + new Series() + { + Name = "Test Series Sequels", + Volumes = new List(){} + } + } + }); + + _context.Library.Add(new Library() + { + AppUsers = new List() + { + new AppUser() + { + UserName = "majora2007" + } + }, + Name = "Test LIb 2", + Type = LibraryType.Book, + Series = new List() + { + new Series() + { + Name = "Test Series 2", + Volumes = new List(){} + }, + new Series() + { + Name = "Test Series Prequels 2", + Volumes = new List(){} + }, + new Series() + { + Name = "Test Series Sequels 2", + Volumes = new List(){} + } + } + }); + + await _context.SaveChangesAsync(); + + var series1 = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(1, SeriesIncludes.Related); + // Add relations + var addRelationDto = CreateRelationsDto(series1); + addRelationDto.Adaptations.Add(4); // cross library link + await _seriesService.UpdateRelatedSeries(addRelationDto); + + var library = await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(1, LibraryIncludes.Series); + _unitOfWork.LibraryRepository.Delete(library); + + try + { + await _unitOfWork.CommitAsync(); + } + catch (Exception) + { + Assert.False(true); + } + + Assert.Null(await _unitOfWork.LibraryRepository.GetLibraryForIdAsync(1)); + } + #endregion } diff --git a/API/Controllers/LibraryController.cs b/API/Controllers/LibraryController.cs index 618c345da..202d6b2cb 100644 --- a/API/Controllers/LibraryController.cs +++ b/API/Controllers/LibraryController.cs @@ -248,19 +248,24 @@ public class LibraryController : BaseApiController if (TaskScheduler.HasScanTaskRunningForLibrary(libraryId)) { // TODO: Figure out how to cancel a job + _logger.LogInformation("User is attempting to delete a library while a scan is in progress"); return BadRequest( "You cannot delete a library while a scan is in progress. Please wait for scan to continue then try to delete"); } // Due to a bad schema that I can't figure out how to fix, we need to erase all RelatedSeries before we delete the library - foreach (var s in await _unitOfWork.SeriesRepository.GetSeriesForLibraryIdAsync(library.Id)) + // Aka SeriesRelation has an invalid foreign key + foreach (var s in await _unitOfWork.SeriesRepository.GetSeriesForLibraryIdAsync(library.Id, + SeriesIncludes.Related)) { s.Relations = new List(); _unitOfWork.SeriesRepository.Update(s); } + await _unitOfWork.CommitAsync(); _unitOfWork.LibraryRepository.Delete(library); + await _unitOfWork.CommitAsync(); if (chapterIds.Any()) diff --git a/API/Data/Migrations/DataContextModelSnapshot.cs b/API/Data/Migrations/DataContextModelSnapshot.cs index 5ff8b98d0..ca7164702 100644 --- a/API/Data/Migrations/DataContextModelSnapshot.cs +++ b/API/Data/Migrations/DataContextModelSnapshot.cs @@ -165,7 +165,7 @@ namespace API.Data.Migrations b.HasIndex("AppUserId"); - b.ToTable("AppUserBookmark"); + b.ToTable("AppUserBookmark", (string)null); }); modelBuilder.Entity("API.Entities.AppUserPreferences", b => @@ -256,7 +256,7 @@ namespace API.Data.Migrations b.HasIndex("ThemeId"); - b.ToTable("AppUserPreferences"); + b.ToTable("AppUserPreferences", (string)null); }); modelBuilder.Entity("API.Entities.AppUserProgress", b => @@ -295,7 +295,7 @@ namespace API.Data.Migrations b.HasIndex("SeriesId"); - b.ToTable("AppUserProgresses"); + b.ToTable("AppUserProgresses", (string)null); }); modelBuilder.Entity("API.Entities.AppUserRating", b => @@ -322,7 +322,7 @@ namespace API.Data.Migrations b.HasIndex("SeriesId"); - b.ToTable("AppUserRating"); + b.ToTable("AppUserRating", (string)null); }); modelBuilder.Entity("API.Entities.AppUserRole", b => @@ -413,7 +413,7 @@ namespace API.Data.Migrations b.HasIndex("VolumeId"); - b.ToTable("Chapter"); + b.ToTable("Chapter", (string)null); }); modelBuilder.Entity("API.Entities.CollectionTag", b => @@ -448,7 +448,7 @@ namespace API.Data.Migrations b.HasIndex("Id", "Promoted") .IsUnique(); - b.ToTable("CollectionTag"); + b.ToTable("CollectionTag", (string)null); }); modelBuilder.Entity("API.Entities.Device", b => @@ -485,7 +485,7 @@ namespace API.Data.Migrations b.HasIndex("AppUserId"); - b.ToTable("Device"); + b.ToTable("Device", (string)null); }); modelBuilder.Entity("API.Entities.FolderPath", b => @@ -507,7 +507,7 @@ namespace API.Data.Migrations b.HasIndex("LibraryId"); - b.ToTable("FolderPath"); + b.ToTable("FolderPath", (string)null); }); modelBuilder.Entity("API.Entities.Genre", b => @@ -530,7 +530,7 @@ namespace API.Data.Migrations b.HasIndex("NormalizedTitle", "ExternalTag") .IsUnique(); - b.ToTable("Genre"); + b.ToTable("Genre", (string)null); }); modelBuilder.Entity("API.Entities.Library", b => @@ -559,7 +559,7 @@ namespace API.Data.Migrations b.HasKey("Id"); - b.ToTable("Library"); + b.ToTable("Library", (string)null); }); modelBuilder.Entity("API.Entities.MangaFile", b => @@ -593,7 +593,7 @@ namespace API.Data.Migrations b.HasIndex("ChapterId"); - b.ToTable("MangaFile"); + b.ToTable("MangaFile", (string)null); }); modelBuilder.Entity("API.Entities.Metadata.SeriesMetadata", b => @@ -689,7 +689,7 @@ namespace API.Data.Migrations b.HasIndex("Id", "SeriesId") .IsUnique(); - b.ToTable("SeriesMetadata"); + b.ToTable("SeriesMetadata", (string)null); }); modelBuilder.Entity("API.Entities.Metadata.SeriesRelation", b => @@ -713,7 +713,7 @@ namespace API.Data.Migrations b.HasIndex("TargetSeriesId"); - b.ToTable("SeriesRelation"); + b.ToTable("SeriesRelation", (string)null); }); modelBuilder.Entity("API.Entities.Person", b => @@ -733,7 +733,7 @@ namespace API.Data.Migrations b.HasKey("Id"); - b.ToTable("Person"); + b.ToTable("Person", (string)null); }); modelBuilder.Entity("API.Entities.ReadingList", b => @@ -776,7 +776,7 @@ namespace API.Data.Migrations b.HasIndex("AppUserId"); - b.ToTable("ReadingList"); + b.ToTable("ReadingList", (string)null); }); modelBuilder.Entity("API.Entities.ReadingListItem", b => @@ -810,7 +810,7 @@ namespace API.Data.Migrations b.HasIndex("VolumeId"); - b.ToTable("ReadingListItem"); + b.ToTable("ReadingListItem", (string)null); }); modelBuilder.Entity("API.Entities.Series", b => @@ -897,7 +897,7 @@ namespace API.Data.Migrations b.HasIndex("LibraryId"); - b.ToTable("Series"); + b.ToTable("Series", (string)null); }); modelBuilder.Entity("API.Entities.ServerSetting", b => @@ -914,7 +914,7 @@ namespace API.Data.Migrations b.HasKey("Key"); - b.ToTable("ServerSetting"); + b.ToTable("ServerSetting", (string)null); }); modelBuilder.Entity("API.Entities.SiteTheme", b => @@ -946,7 +946,7 @@ namespace API.Data.Migrations b.HasKey("Id"); - b.ToTable("SiteTheme"); + b.ToTable("SiteTheme", (string)null); }); modelBuilder.Entity("API.Entities.Tag", b => @@ -969,7 +969,7 @@ namespace API.Data.Migrations b.HasIndex("NormalizedTitle", "ExternalTag") .IsUnique(); - b.ToTable("Tag"); + b.ToTable("Tag", (string)null); }); modelBuilder.Entity("API.Entities.Volume", b => @@ -1015,7 +1015,7 @@ namespace API.Data.Migrations b.HasIndex("SeriesId"); - b.ToTable("Volume"); + b.ToTable("Volume", (string)null); }); modelBuilder.Entity("AppUserLibrary", b => @@ -1030,7 +1030,7 @@ namespace API.Data.Migrations b.HasIndex("LibrariesId"); - b.ToTable("AppUserLibrary"); + b.ToTable("AppUserLibrary", (string)null); }); modelBuilder.Entity("ChapterGenre", b => @@ -1045,7 +1045,7 @@ namespace API.Data.Migrations b.HasIndex("GenresId"); - b.ToTable("ChapterGenre"); + b.ToTable("ChapterGenre", (string)null); }); modelBuilder.Entity("ChapterPerson", b => @@ -1060,7 +1060,7 @@ namespace API.Data.Migrations b.HasIndex("PeopleId"); - b.ToTable("ChapterPerson"); + b.ToTable("ChapterPerson", (string)null); }); modelBuilder.Entity("ChapterTag", b => @@ -1075,7 +1075,7 @@ namespace API.Data.Migrations b.HasIndex("TagsId"); - b.ToTable("ChapterTag"); + b.ToTable("ChapterTag", (string)null); }); modelBuilder.Entity("CollectionTagSeriesMetadata", b => @@ -1090,7 +1090,7 @@ namespace API.Data.Migrations b.HasIndex("SeriesMetadatasId"); - b.ToTable("CollectionTagSeriesMetadata"); + b.ToTable("CollectionTagSeriesMetadata", (string)null); }); modelBuilder.Entity("GenreSeriesMetadata", b => @@ -1105,7 +1105,7 @@ namespace API.Data.Migrations b.HasIndex("SeriesMetadatasId"); - b.ToTable("GenreSeriesMetadata"); + b.ToTable("GenreSeriesMetadata", (string)null); }); modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => @@ -1204,7 +1204,7 @@ namespace API.Data.Migrations b.HasIndex("SeriesMetadatasId"); - b.ToTable("PersonSeriesMetadata"); + b.ToTable("PersonSeriesMetadata", (string)null); }); modelBuilder.Entity("SeriesMetadataTag", b => @@ -1219,7 +1219,7 @@ namespace API.Data.Migrations b.HasIndex("TagsId"); - b.ToTable("SeriesMetadataTag"); + b.ToTable("SeriesMetadataTag", (string)null); }); modelBuilder.Entity("API.Entities.AppUserBookmark", b => diff --git a/API/Data/Repositories/LibraryRepository.cs b/API/Data/Repositories/LibraryRepository.cs index 58c0faa11..7a50f365e 100644 --- a/API/Data/Repositories/LibraryRepository.cs +++ b/API/Data/Repositories/LibraryRepository.cs @@ -33,7 +33,7 @@ public interface ILibraryRepository void Delete(Library library); Task> GetLibraryDtosAsync(); Task LibraryExists(string libraryName); - Task GetLibraryForIdAsync(int libraryId, LibraryIncludes includes); + Task GetLibraryForIdAsync(int libraryId, LibraryIncludes includes = LibraryIncludes.None); Task> GetLibraryDtosForUsernameAsync(string userName); Task> GetLibrariesAsync(LibraryIncludes includes = LibraryIncludes.None); Task DeleteLibrary(int libraryId); @@ -203,14 +203,14 @@ public class LibraryRepository : ILibraryRepository .ToListAsync(); } - public async Task GetLibraryForIdAsync(int libraryId, LibraryIncludes includes) + public async Task GetLibraryForIdAsync(int libraryId, LibraryIncludes includes = LibraryIncludes.None) { var query = _context.Library .Where(x => x.Id == libraryId); query = AddIncludesToQuery(query, includes); - return await query.SingleAsync(); + return await query.SingleOrDefaultAsync(); } private static IQueryable AddIncludesToQuery(IQueryable query, LibraryIncludes includeFlags) diff --git a/API/Data/Repositories/SeriesRepository.cs b/API/Data/Repositories/SeriesRepository.cs index e04a18b6c..4423db98d 100644 --- a/API/Data/Repositories/SeriesRepository.cs +++ b/API/Data/Repositories/SeriesRepository.cs @@ -63,9 +63,8 @@ public interface ISeriesRepository /// /// Task SearchSeries(int userId, bool isAdmin, int[] libraryIds, string searchQuery); - Task> GetSeriesForLibraryIdAsync(int libraryId); + Task> GetSeriesForLibraryIdAsync(int libraryId, SeriesIncludes includes = SeriesIncludes.None); Task GetSeriesDtoByIdAsync(int seriesId, int userId); - Task DeleteSeriesAsync(int seriesId); Task GetSeriesByIdAsync(int seriesId, SeriesIncludes includes = SeriesIncludes.Volumes | SeriesIncludes.Metadata); Task> GetSeriesByIdsAsync(IList seriesIds); Task GetChapterIdsForSeriesAsync(IList seriesIds); @@ -160,12 +159,14 @@ public class SeriesRepository : ISeriesRepository } - public async Task> GetSeriesForLibraryIdAsync(int libraryId) + public async Task> GetSeriesForLibraryIdAsync(int libraryId, SeriesIncludes includes = SeriesIncludes.None) { - return await _context.Series - .Where(s => s.LibraryId == libraryId) - .OrderBy(s => s.SortName) - .ToListAsync(); + var query = _context.Series + .Where(s => s.LibraryId == libraryId); + + query = AddIncludesToQuery(query, includes); + + return await query.OrderBy(s => s.SortName).ToListAsync(); } /// @@ -418,15 +419,6 @@ public class SeriesRepository : ISeriesRepository return seriesList[0]; } - public async Task DeleteSeriesAsync(int seriesId) - { - var series = await _context.Series.Where(s => s.Id == seriesId).SingleOrDefaultAsync(); - if (series != null) _context.Series.Remove(series); - - return await _context.SaveChangesAsync() > 0; - } - - /// /// Returns Volumes, Metadata (Incl Genres and People), and Collection Tags /// @@ -439,29 +431,7 @@ public class SeriesRepository : ISeriesRepository .Where(s => s.Id == seriesId) .AsSplitQuery(); - if (includes.HasFlag(SeriesIncludes.Volumes)) - { - query = query.Include(s => s.Volumes); - } - - if (includes.HasFlag(SeriesIncludes.Related)) - { - query = query.Include(s => s.Relations) - .ThenInclude(r => r.TargetSeries) - .Include(s => s.RelationOf); - } - - if (includes.HasFlag(SeriesIncludes.Metadata)) - { - query = query.Include(s => s.Metadata) - .ThenInclude(m => m.CollectionTags) - .Include(s => s.Metadata) - .ThenInclude(m => m.Genres) - .Include(s => s.Metadata) - .ThenInclude(m => m.People) - .Include(s => s.Metadata) - .ThenInclude(m => m.Tags); - } + query = AddIncludesToQuery(query, includes); return await query.SingleOrDefaultAsync(); } @@ -1561,27 +1531,37 @@ public class SeriesRepository : ISeriesRepository private static IQueryable AddIncludesToQuery(IQueryable query, SeriesIncludes includeFlags) { + // TODO: Move this to an Extension Method if (includeFlags.HasFlag(SeriesIncludes.Library)) { query = query.Include(u => u.Library); } + if (includeFlags.HasFlag(SeriesIncludes.Volumes)) + { + query = query.Include(s => s.Volumes); + } + if (includeFlags.HasFlag(SeriesIncludes.Related)) { - query = query.Include(u => u.Relations); + query = query.Include(s => s.Relations) + .ThenInclude(r => r.TargetSeries) + .Include(s => s.RelationOf); } if (includeFlags.HasFlag(SeriesIncludes.Metadata)) { - query = query.Include(u => u.Metadata); - } - - if (includeFlags.HasFlag(SeriesIncludes.Volumes)) - { - query = query.Include(u => u.Volumes); + query = query.Include(s => s.Metadata) + .ThenInclude(m => m.CollectionTags) + .Include(s => s.Metadata) + .ThenInclude(m => m.Genres) + .Include(s => s.Metadata) + .ThenInclude(m => m.People) + .Include(s => s.Metadata) + .ThenInclude(m => m.Tags); } - return query; + return query.AsSplitQuery(); } } diff --git a/API/Entities/Library.cs b/API/Entities/Library.cs index 1208151f0..b6fac76f3 100644 --- a/API/Entities/Library.cs +++ b/API/Entities/Library.cs @@ -27,16 +27,4 @@ public class Library : IEntityDate public ICollection Folders { get; set; } public ICollection AppUsers { get; set; } public ICollection Series { get; set; } - - // Methods - /// - /// Has there been any modifications to the FolderPath's directory since the date - /// - /// - public bool AnyModificationsSinceLastScan() - { - // NOTE: I don't think we can do this due to NTFS - return Folders.All(folder => File.GetLastWriteTimeUtc(folder.Path) > folder.LastScanned); - } - } diff --git a/UI/Web/src/app/cards/card-item/card-actionables/card-actionables.component.ts b/UI/Web/src/app/cards/card-item/card-actionables/card-actionables.component.ts index 846399bd6..53984b200 100644 --- a/UI/Web/src/app/cards/card-item/card-actionables/card-actionables.component.ts +++ b/UI/Web/src/app/cards/card-item/card-actionables/card-actionables.component.ts @@ -31,6 +31,12 @@ export class CardActionablesComponent implements OnInit { if (!user) return; this.isAdmin = this.accountService.hasAdminRole(user); this.canDownload = this.accountService.hasDownloadRole(user); + + // We want to avoid an empty menu when user doesn't have access to anything + const validActions = this.actions.filter(a => a.children.length > 0 || a.dynamicList); + if (!this.isAdmin && validActions.filter(a => !a.requiresAdmin).length === 0) { + this.actions = []; + } this.cdRef.markForCheck(); }); } diff --git a/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.ts b/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.ts index 0a49a0211..609af437f 100644 --- a/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.ts +++ b/UI/Web/src/app/user-settings/restriction-selector/restriction-selector.component.ts @@ -56,6 +56,11 @@ export class RestrictionSelectorComponent implements OnInit, OnChanges { ageRating: parseInt(e, 10), includeUnknowns: this.restrictionForm?.get('ageRestrictionIncludeUnknowns')?.value }); + if (parseInt(e, 10) === AgeRating.NotApplicable) { + this.restrictionForm!.get('ageRestrictionIncludeUnknowns')?.disable(); + } else { + this.restrictionForm!.get('ageRestrictionIncludeUnknowns')?.enable(); + } }); this.restrictionForm.get('ageRestrictionIncludeUnknowns')?.valueChanges.subscribe(e => { diff --git a/UI/Web/src/index.html b/UI/Web/src/index.html index 992957479..befd1b415 100644 --- a/UI/Web/src/index.html +++ b/UI/Web/src/index.html @@ -12,7 +12,7 @@ - +