Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Fix select languages component label

Chocobozzzf61581280d2f
diff --git a/client/src/app/shared/shared-forms/select/select-checkbox-default-all.component.ts b/client/src/app/shared/shared-forms/select/select-checkbox-default-all.component.ts
index 8b5a002a64..5c626c9e9c 100644
--- a/client/src/app/shared/shared-forms/select/select-checkbox-default-all.component.ts
+++ b/client/src/app/shared/shared-forms/select/select-checkbox-default-all.component.ts
@@ -1,4 +1,4 @@
-import { booleanAttribute, Component, forwardRef, inject, input } from '@angular/core'
+import { booleanAttribute, Component, forwardRef, inject, input, OnChanges } from '@angular/core'
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'
import { Notifier } from '@app/core'
import { formatICU } from '@app/helpers'
@@ -34,7 +34,7 @@ import { SelectCheckboxComponent } from './select-checkbox.component'
],
imports: [ SelectCheckboxComponent, FormsModule ]
})
-export class SelectCheckboxDefaultAllComponent implements ControlValueAccessor {
+export class SelectCheckboxDefaultAllComponent implements ControlValueAccessor, OnChanges {
private notifier = inject(Notifier)
readonly inputId = input.required<string>()
@@ -56,8 +56,13 @@ export class SelectCheckboxDefaultAllComponent implements ControlValueAccessor {
}
writeValue (items: string[]) {
- if (items) this.selectedItems = items
- else this.selectAll()
+ if (items) {
+ this.selectedItems = items
+ this.updateLabel()
+ return
+ }
+
+ this.selectAll()
}
registerOnChange (fn: (_: any) => void) {
@@ -68,6 +73,10 @@ export class SelectCheckboxDefaultAllComponent implements ControlValueAccessor {
// Unused
}
+ ngOnChanges () {
+ this.updateLabel()
+ }
+
onModelChange () {
this.updateLabel()
@@ -82,7 +91,7 @@ export class SelectCheckboxDefaultAllComponent implements ControlValueAccessor {
this.selectAll()
}
- this.checkMaxItems()
+ this.checkMaxItemsOrSelectAll()
}
private isMaxItemsValid () {
@@ -97,7 +106,7 @@ export class SelectCheckboxDefaultAllComponent implements ControlValueAccessor {
return true
}
- private checkMaxItems () {
+ private checkMaxItemsOrSelectAll () {
if (!this.isMaxItemsValid()) {
this.notifier.error(
formatICU(
@@ -118,6 +127,7 @@ export class SelectCheckboxDefaultAllComponent implements ControlValueAccessor {
private updateLabel () {
const availableItems = this.availableItems()
+
if (this.selectedItems && availableItems && this.selectedItems.length === availableItems.length) {
this.selectedItemsLabel = this.allSelectedLabel()
} else {
diff --git a/client/src/app/shared/shared-forms/select/select-languages.component.ts b/client/src/app/shared/shared-forms/select/select-languages.component.ts
index 462d58a247..136f2d0127 100644
--- a/client/src/app/shared/shared-forms/select/select-languages.component.ts
+++ b/client/src/app/shared/shared-forms/select/select-languages.component.ts
@@ -1,5 +1,5 @@
-import { NgIf } from '@angular/common'
-import { Component, forwardRef, OnInit, inject, input } from '@angular/core'
+import { CommonModule } from '@angular/common'
+import { Component, forwardRef, inject, input, OnInit } from '@angular/core'
import { ControlValueAccessor, FormsModule, NG_VALUE_ACCESSOR } from '@angular/forms'
import { ServerService } from '@app/core'
import { SelectOptionsItem } from '../../../../types/select-options-item.model'
@@ -35,7 +35,7 @@ import { SelectCheckboxDefaultAllComponent } from './select-checkbox-default-all
multi: true
}
],
- imports: [ SelectCheckboxDefaultAllComponent, FormsModule, NgIf ]
+ imports: [ SelectCheckboxDefaultAllComponent, FormsModule, CommonModule ]
})
export class SelectLanguagesComponent implements ControlValueAccessor, OnInit {
private server = inject(ServerService)