diff --git a/client/components/modals/AccountModal.vue b/client/components/modals/AccountModal.vue index b1cdabf0..070baab4 100644 --- a/client/components/modals/AccountModal.vue +++ b/client/components/modals/AccountModal.vue @@ -6,7 +6,7 @@
-
+
@@ -96,7 +96,14 @@
- +
+ +
+

{{ $strings.LabelInvert }}

+ +
+
+
@@ -185,6 +192,9 @@ export default { value: t } }) + }, + tagsSelectionText() { + return this.newUser.permissions.selectedTagsNotAccessible ? this.$strings.LabelTagsNotAccessibleToUser : this.$strings.LabelTagsAccessibleToUser } }, methods: { @@ -193,8 +203,11 @@ export default { if (this.$refs.modal) this.$refs.modal.setHide() }, accessAllTagsToggled(val) { - if (val && this.newUser.itemTagsAccessible.length) { - this.newUser.itemTagsAccessible = [] + if (val) { + if (this.newUser.itemTagsSelected?.length) { + this.newUser.itemTagsSelected = [] + } + this.newUser.permissions.selectedTagsNotAccessible = false } }, fetchAllTags() { @@ -226,7 +239,7 @@ export default { this.$toast.error('Must select at least one library') return } - if (!this.newUser.permissions.accessAllTags && !this.newUser.itemTagsAccessible.length) { + if (!this.newUser.permissions.accessAllTags && !this.newUser.itemTagsSelected.length) { this.$toast.error('Must select at least one tag') return } @@ -307,12 +320,12 @@ export default { delete: type === 'admin', upload: type === 'admin', accessAllLibraries: true, - accessAllTags: true + accessAllTags: true, + selectedTagsNotAccessible: false } }, init() { this.fetchAllTags() - this.isNew = !this.account if (this.account) { this.newUser = { @@ -322,9 +335,10 @@ export default { isActive: this.account.isActive, permissions: { ...this.account.permissions }, librariesAccessible: [...(this.account.librariesAccessible || [])], - itemTagsAccessible: [...(this.account.itemTagsAccessible || [])] + itemTagsSelected: [...(this.account.itemTagsSelected || [])] } } else { + this.fetchAllTags() this.newUser = { username: null, password: null, @@ -336,7 +350,8 @@ export default { delete: false, upload: false, accessAllLibraries: true, - accessAllTags: true + accessAllTags: true, + selectedTagsNotAccessible: false }, librariesAccessible: [] } diff --git a/client/strings/de.json b/client/strings/de.json index fcd09dfd..fb5b570a 100644 --- a/client/strings/de.json +++ b/client/strings/de.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "Jeden Tag", "LabelIntervalEveryHour": "Jede Stunde", "LabelInvalidParts": "Ungültige Teile", + "LabelInvert": "Invert", "LabelItem": "Medium", "LabelLanguage": "Sprache", "LabelLanguageDefaultServer": "Standard-Server-Sprache", @@ -412,6 +413,7 @@ "LabelTag": "Schlagwort", "LabelTags": "Schlagwörter", "LabelTagsAccessibleToUser": "Für Benutzer zugängliche Schlagwörter", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "Laufende Aufgaben", "LabelTimeBase": "Basiszeit", "LabelTimeListened": "Gehörte Zeit", diff --git a/client/strings/en-us.json b/client/strings/en-us.json index 07d8bbe9..31b7145b 100644 --- a/client/strings/en-us.json +++ b/client/strings/en-us.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "Every day", "LabelIntervalEveryHour": "Every hour", "LabelInvalidParts": "Invalid Parts", + "LabelInvert": "Invert", "LabelItem": "Item", "LabelLanguage": "Language", "LabelLanguageDefaultServer": "Default Server Language", @@ -412,6 +413,7 @@ "LabelTag": "Tag", "LabelTags": "Tags", "LabelTagsAccessibleToUser": "Tags Accessible to User", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "Tasks Running", "LabelTimeBase": "Time Base", "LabelTimeListened": "Time Listened", diff --git a/client/strings/es.json b/client/strings/es.json index 242a25e4..05fcc220 100644 --- a/client/strings/es.json +++ b/client/strings/es.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "Cada Dia", "LabelIntervalEveryHour": "Cada Hora", "LabelInvalidParts": "Partes Invalidas", + "LabelInvert": "Invert", "LabelItem": "Elemento", "LabelLanguage": "Lenguaje", "LabelLanguageDefaultServer": "Lenguaje Predeterminado del Servidor", @@ -412,6 +413,7 @@ "LabelTag": "Etiqueta", "LabelTags": "Etiquetas", "LabelTagsAccessibleToUser": "Etiquetas Accessible para el Usuario", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "Tareas Corriendo", "LabelTimeBase": "Time Base", "LabelTimeListened": "Tiempo Escuchando", diff --git a/client/strings/fr.json b/client/strings/fr.json index 3affb7e0..3e6512a6 100644 --- a/client/strings/fr.json +++ b/client/strings/fr.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "Tous les jours", "LabelIntervalEveryHour": "Toutes les heures", "LabelInvalidParts": "Parties invalides", + "LabelInvert": "Invert", "LabelItem": "Article", "LabelLanguage": "Langue", "LabelLanguageDefaultServer": "Langue par défaut", @@ -412,6 +413,7 @@ "LabelTag": "Étiquette", "LabelTags": "Étiquettes", "LabelTagsAccessibleToUser": "Étiquettes accessibles à l’utilisateur", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "Tâches en cours", "LabelTimeBase": "Base de temps", "LabelTimeListened": "Temps d’écoute", diff --git a/client/strings/gu.json b/client/strings/gu.json index c1d80158..7825882e 100644 --- a/client/strings/gu.json +++ b/client/strings/gu.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "Every day", "LabelIntervalEveryHour": "Every hour", "LabelInvalidParts": "Invalid Parts", + "LabelInvert": "Invert", "LabelItem": "Item", "LabelLanguage": "Language", "LabelLanguageDefaultServer": "Default Server Language", @@ -412,6 +413,7 @@ "LabelTag": "Tag", "LabelTags": "Tags", "LabelTagsAccessibleToUser": "Tags Accessible to User", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "Tasks Running", "LabelTimeBase": "Time Base", "LabelTimeListened": "Time Listened", diff --git a/client/strings/hi.json b/client/strings/hi.json index 928d9cf2..fa4de440 100644 --- a/client/strings/hi.json +++ b/client/strings/hi.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "Every day", "LabelIntervalEveryHour": "Every hour", "LabelInvalidParts": "Invalid Parts", + "LabelInvert": "Invert", "LabelItem": "Item", "LabelLanguage": "Language", "LabelLanguageDefaultServer": "Default Server Language", @@ -412,6 +413,7 @@ "LabelTag": "Tag", "LabelTags": "Tags", "LabelTagsAccessibleToUser": "Tags Accessible to User", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "Tasks Running", "LabelTimeBase": "Time Base", "LabelTimeListened": "Time Listened", diff --git a/client/strings/hr.json b/client/strings/hr.json index 45fffdf4..777aef15 100644 --- a/client/strings/hr.json +++ b/client/strings/hr.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "Every day", "LabelIntervalEveryHour": "Every hour", "LabelInvalidParts": "Nevaljajuči dijelovi", + "LabelInvert": "Invert", "LabelItem": "Stavka", "LabelLanguage": "Jezik", "LabelLanguageDefaultServer": "Default jezik servera", @@ -412,6 +413,7 @@ "LabelTag": "Tag", "LabelTags": "Tags", "LabelTagsAccessibleToUser": "Tags dostupni korisniku", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "Tasks Running", "LabelTimeBase": "Time Base", "LabelTimeListened": "Vremena odslušano", diff --git a/client/strings/it.json b/client/strings/it.json index 6ca8ae99..9606aaf4 100644 --- a/client/strings/it.json +++ b/client/strings/it.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "Ogni Giorno", "LabelIntervalEveryHour": "Ogni ora", "LabelInvalidParts": "Parti Invalide", + "LabelInvert": "Invert", "LabelItem": "Oggetti", "LabelLanguage": "Lingua", "LabelLanguageDefaultServer": "Lingua di Default", @@ -412,6 +413,7 @@ "LabelTag": "Tag", "LabelTags": "Tags", "LabelTagsAccessibleToUser": "Tags permessi agli Utenti", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "Processi in esecuzione", "LabelTimeBase": "Time Base", "LabelTimeListened": "Tempo di Ascolto", diff --git a/client/strings/pl.json b/client/strings/pl.json index 5b52c210..7babe3f4 100644 --- a/client/strings/pl.json +++ b/client/strings/pl.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "Każdego dnia", "LabelIntervalEveryHour": "Każdej godziny", "LabelInvalidParts": "Nieprawidłowe części", + "LabelInvert": "Invert", "LabelItem": "Pozycja", "LabelLanguage": "Język", "LabelLanguageDefaultServer": "Domyślny język serwera", @@ -412,6 +413,7 @@ "LabelTag": "Tag", "LabelTags": "Tagi", "LabelTagsAccessibleToUser": "Tagi dostępne dla użytkownika", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "Tasks Running", "LabelTimeBase": "Time Base", "LabelTimeListened": "Czas odtwarzania", diff --git a/client/strings/ru.json b/client/strings/ru.json index 1a04e611..8ac05e05 100644 --- a/client/strings/ru.json +++ b/client/strings/ru.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "Каждый день", "LabelIntervalEveryHour": "Каждый час", "LabelInvalidParts": "Неверные части", + "LabelInvert": "Invert", "LabelItem": "Элемент", "LabelLanguage": "Язык", "LabelLanguageDefaultServer": "Язык сервера по умолчанию", @@ -412,6 +413,7 @@ "LabelTag": "Тег", "LabelTags": "Теги", "LabelTagsAccessibleToUser": "Теги доступные для пользователя", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "Запущенные задачи", "LabelTimeBase": "Time Base", "LabelTimeListened": "Время прослушивания", diff --git a/client/strings/zh-cn.json b/client/strings/zh-cn.json index 87293a35..1ad22d69 100644 --- a/client/strings/zh-cn.json +++ b/client/strings/zh-cn.json @@ -254,6 +254,7 @@ "LabelIntervalEveryDay": "每天", "LabelIntervalEveryHour": "每小时", "LabelInvalidParts": "无效部件", + "LabelInvert": "Invert", "LabelItem": "项目", "LabelLanguage": "语言", "LabelLanguageDefaultServer": "默认服务器语言", @@ -412,6 +413,7 @@ "LabelTag": "标签", "LabelTags": "标签", "LabelTagsAccessibleToUser": "用户可访问的标签", + "LabelTagsNotAccessibleToUser": "Tags not Accessible to User", "LabelTasks": "正在运行的任务", "LabelTimeBase": "Time Base", "LabelTimeListened": "收听时间", diff --git a/server/objects/user/User.js b/server/objects/user/User.js index ed59aca1..c46bd9a7 100644 --- a/server/objects/user/User.js +++ b/server/objects/user/User.js @@ -20,7 +20,7 @@ class User { this.permissions = {} this.librariesAccessible = [] // Library IDs (Empty if ALL libraries) - this.itemTagsAccessible = [] // Empty if ALL item tags accessible + this.itemTagsSelected = [] // Empty if ALL item tags accessible if (user) { this.construct(user) @@ -86,7 +86,7 @@ class User { createdAt: this.createdAt, permissions: this.permissions, librariesAccessible: [...this.librariesAccessible], - itemTagsAccessible: [...this.itemTagsAccessible] + itemTagsSelected: [...this.itemTagsSelected] } } @@ -105,7 +105,7 @@ class User { createdAt: this.createdAt, permissions: this.permissions, librariesAccessible: [...this.librariesAccessible], - itemTagsAccessible: [...this.itemTagsAccessible] + itemTagsSelected: [...this.itemTagsSelected] } if (minimal) { delete json.mediaProgress @@ -169,9 +169,15 @@ class User { if (this.permissions.accessAllTags === undefined) this.permissions.accessAllTags = true // Explicit content restriction permission added v2.0.18 if (this.permissions.accessExplicitContent === undefined) this.permissions.accessExplicitContent = true + // itemTagsAccessible was renamed to itemTagsSelected in version v2.x + if (this.itemTagsAccessible) { + this.permissions.selectedTagsNotAccessible = false + this.itemTagsSelected = this.itemTagsAccessible + this.itemTagsAccessible = undefined + } this.librariesAccessible = [...(user.librariesAccessible || [])] - this.itemTagsAccessible = [...(user.itemTagsAccessible || [])] + this.itemTagsSelected = [...(user.itemTagsSelected || [])] } update(payload) { @@ -228,19 +234,21 @@ class User { // Update accessible tags if (this.permissions.accessAllTags) { // Access all tags - if (this.itemTagsAccessible.length) { - this.itemTagsAccessible = [] + if (this.itemTagsSelected.length) { + this.itemTagsSelected = [] + this.permissions.selectedTagsNotAccessible = false hasUpdates = true } - } else if (payload.itemTagsAccessible !== undefined) { - if (payload.itemTagsAccessible.length) { - if (payload.itemTagsAccessible.join(',') !== this.itemTagsAccessible.join(',')) { + } else if (payload.itemTagsSelected !== undefined) { + if (payload.itemTagsSelected.length) { + if (payload.itemTagsSelected.join(',') !== this.itemTagsSelected.join(',')) { hasUpdates = true - this.itemTagsAccessible = [...payload.itemTagsAccessible] + this.itemTagsSelected = [...payload.itemTagsSelected] } - } else if (this.itemTagsAccessible.length > 0) { + } else if (this.itemTagsSelected.length > 0) { hasUpdates = true - this.itemTagsAccessible = [] + this.itemTagsSelected = [] + this.permissions.selectedTagsNotAccessible = false } } return hasUpdates @@ -343,8 +351,12 @@ class User { checkCanAccessLibraryItemWithTags(tags) { if (this.permissions.accessAllTags) return true + if (this.permissions.selectedTagsNotAccessible) { + if (!tags || !tags.length) return true + return tags.every(tag => !this.itemTagsSelected.includes(tag)) + } if (!tags || !tags.length) return false - return this.itemTagsAccessible.some(tag => tags.includes(tag)) + return this.itemTagsSelected.some(tag => tags.includes(tag)) } checkCanAccessLibraryItem(libraryItem) {