Fix ng-select labels

This commit is contained in:
Chocobozzz 2024-09-27 10:10:33 +02:00
parent ff7ac05d11
commit 7c9089ecc2
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
9 changed files with 14 additions and 6 deletions

View File

@ -76,7 +76,7 @@
<div> <div>
<my-select-checkbox <my-select-checkbox
id="instanceCategories" labelForId="instanceCategories"
formControlName="categories" [availableItems]="categoryItems" formControlName="categories" [availableItems]="categoryItems"
[selectableGroup]="false" [selectableGroup]="false"
i18n-placeholder placeholder="Add a new category" i18n-placeholder placeholder="Add a new category"
@ -90,7 +90,7 @@
<div> <div>
<my-select-checkbox <my-select-checkbox
id="instanceLanguages" labelForId="instanceLanguages"
formControlName="languages" [availableItems]="languageItems" formControlName="languages" [availableItems]="languageItems"
[selectableGroup]="false" [selectableGroup]="false"
i18n-placeholder placeholder="Add a new language" i18n-placeholder placeholder="Add a new language"

View File

@ -1,4 +1,5 @@
<my-select-checkbox-all <my-select-checkbox-all
[labelForId]="labelForId"
[(ngModel)]="selectedCategories" [(ngModel)]="selectedCategories"
(ngModelChange)="onModelChange()" (ngModelChange)="onModelChange()"
[availableItems]="availableCategories" [availableItems]="availableCategories"

View File

@ -1,4 +1,4 @@
import { Component, forwardRef, OnInit } from '@angular/core' import { Component, forwardRef, Input, OnInit } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms' import { ControlValueAccessor, NG_VALUE_ACCESSOR, FormsModule } from '@angular/forms'
import { ServerService } from '@app/core' import { ServerService } from '@app/core'
import { SelectOptionsItem } from '../../../../types/select-options-item.model' import { SelectOptionsItem } from '../../../../types/select-options-item.model'
@ -20,6 +20,8 @@ import { SelectCheckboxAllComponent } from './select-checkbox-all.component'
imports: [ SelectCheckboxAllComponent, FormsModule ] imports: [ SelectCheckboxAllComponent, FormsModule ]
}) })
export class SelectCategoriesComponent implements ControlValueAccessor, OnInit { export class SelectCategoriesComponent implements ControlValueAccessor, OnInit {
@Input({ required: true }) labelForId: string
selectedCategories: ItemSelectCheckboxValue[] = [] selectedCategories: ItemSelectCheckboxValue[] = []
availableCategories: SelectOptionsItem[] = [] availableCategories: SelectOptionsItem[] = []

View File

@ -15,6 +15,7 @@ import { ItemSelectCheckboxValue, SelectCheckboxComponent } from './select-check
[availableItems]="availableItems" [availableItems]="availableItems"
[selectableGroup]="true" [selectableGroupAsModel]="true" [selectableGroup]="true" [selectableGroupAsModel]="true"
[placeholder]="placeholder" [placeholder]="placeholder"
[labelForId]="labelForId"
(focusout)="onBlur()" (focusout)="onBlur()"
> >
</my-select-checkbox>`, </my-select-checkbox>`,
@ -29,6 +30,7 @@ import { ItemSelectCheckboxValue, SelectCheckboxComponent } from './select-check
imports: [ SelectCheckboxComponent, FormsModule ] imports: [ SelectCheckboxComponent, FormsModule ]
}) })
export class SelectCheckboxAllComponent implements ControlValueAccessor { export class SelectCheckboxAllComponent implements ControlValueAccessor {
@Input({ required: true }) labelForId: string
@Input() availableItems: SelectOptionsItem[] = [] @Input() availableItems: SelectOptionsItem[] = []
@Input() allGroupLabel: string @Input() allGroupLabel: string

View File

@ -20,6 +20,7 @@ export type ItemSelectCheckboxValue = { id?: string, group?: string } | string
imports: [ NgSelectModule, FormsModule ] imports: [ NgSelectModule, FormsModule ]
}) })
export class SelectCheckboxComponent implements OnInit, ControlValueAccessor { export class SelectCheckboxComponent implements OnInit, ControlValueAccessor {
@Input({ required: true }) labelForId: string
@Input() availableItems: SelectOptionsItem[] = [] @Input() availableItems: SelectOptionsItem[] = []
@Input() selectedItems: ItemSelectCheckboxValue[] = [] @Input() selectedItems: ItemSelectCheckboxValue[] = []
@Input() selectableGroup: boolean @Input() selectableGroup: boolean

View File

@ -5,5 +5,6 @@
[maxItems]="maxLanguages" [maxItems]="maxLanguages"
i18n-placeholder placeholder="Add a new language" i18n-placeholder placeholder="Add a new language"
[allGroupLabel]="allLanguagesGroup" [allGroupLabel]="allLanguagesGroup"
[labelForId]="labelForId"
> >
</my-select-checkbox-all> </my-select-checkbox-all>

View File

@ -20,6 +20,7 @@ import { SelectCheckboxAllComponent } from './select-checkbox-all.component'
imports: [ SelectCheckboxAllComponent, FormsModule ] imports: [ SelectCheckboxAllComponent, FormsModule ]
}) })
export class SelectLanguagesComponent implements ControlValueAccessor, OnInit { export class SelectLanguagesComponent implements ControlValueAccessor, OnInit {
@Input({ required: true }) labelForId: string
@Input() maxLanguages: number @Input() maxLanguages: number
selectedLanguages: ItemSelectCheckboxValue[] selectedLanguages: ItemSelectCheckboxValue[]

View File

@ -30,7 +30,7 @@
</my-help> </my-help>
<div> <div>
<my-select-languages [maxLanguages]="20" formControlName="videoLanguages"></my-select-languages> <my-select-languages labelForId="videoLanguages" [maxLanguages]="20" formControlName="videoLanguages"></my-select-languages>
</div> </div>
</div> </div>

View File

@ -80,7 +80,7 @@
<label class="with-description" for="languageOneOf" i18n>Languages:</label> <label class="with-description" for="languageOneOf" i18n>Languages:</label>
<ng-template *ngTemplateOutlet="updateSettings; context: { $implicit: 'video-languages-subtitles' }"></ng-template> <ng-template *ngTemplateOutlet="updateSettings; context: { $implicit: 'video-languages-subtitles' }"></ng-template>
<my-select-languages [maxLanguages]="20" formControlName="languageOneOf"></my-select-languages> <my-select-languages labelForId="languageOneOf" [maxLanguages]="20" formControlName="languageOneOf"></my-select-languages>
</div> </div>
<div class="form-group" role="radiogroup"> <div class="form-group" role="radiogroup">
@ -134,7 +134,7 @@
<div class="form-group"> <div class="form-group">
<label for="categoryOneOf" i18n>Categories:</label> <label for="categoryOneOf" i18n>Categories:</label>
<my-select-categories formControlName="categoryOneOf"></my-select-categories> <my-select-categories labelForId="categoryOneOf" formControlName="categoryOneOf"></my-select-categories>
</div> </div>
<div class="form-group" *ngIf="canSeeAllVideos()"> <div class="form-group" *ngIf="canSeeAllVideos()">