1
0
Fork 0

Plugins can register html/select settings

This commit is contained in:
Chocobozzz 2021-04-09 11:19:14 +02:00
parent 55b84d5346
commit 32d13b203b
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 20 additions and 6 deletions

View File

@ -1,10 +1,16 @@
<div [formGroup]="form">
<label *ngIf="setting.type !== 'input-checkbox'" [attr.for]="setting.name" [innerHTML]="setting.label"></label>
<label *ngIf="setting.label" [attr.for]="setting.name" [innerHTML]="setting.label"></label>
<div *ngIf="setting.descriptionHTML" class="label-small-info" [innerHTML]="setting.descriptionHTML"></div>
<input *ngIf="setting.type === 'input'" type="text" [id]="setting.name" [formControlName]="setting.name" />
<div *ngIf="setting.type === 'select'" class="peertube-select-container">
<select [id]="setting.name" [formControlName]="setting.name" class="form-control">
<option *ngFor="let option of setting.options" [value]="option.value">{{ option.label }}</option>
</select>
</div>
<my-input-toggle-hidden *ngIf="setting.type === 'input-password'" [formControlName]="setting.name" [inputId]="setting.name"></my-input-toggle-hidden>
<textarea *ngIf="setting.type === 'input-textarea'" type="text" [id]="setting.name" [formControlName]="setting.name"></textarea>
@ -32,6 +38,8 @@
[labelInnerHTML]="setting.label"
></my-peertube-checkbox>
<div *ngIf="setting.type === 'html'" [innerHTML]="setting.html"></div>
<div *ngIf="formErrors[setting.name]" class="form-error">
{{ formErrors[setting.name] }}
</div>

View File

@ -1,7 +1,13 @@
export interface RegisterClientFormFieldOptions {
name: string
label: string
type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced'
export type RegisterClientFormFieldOptions = {
name?: string
label?: string
type: 'input' | 'input-checkbox' | 'input-password' | 'input-textarea' | 'markdown-text' | 'markdown-enhanced' | 'select' | 'html'
// For select type
options?: { value: string, label: string }[]
// For html type
html?: string
descriptionHTML?: string

View File

@ -1,6 +1,6 @@
import { RegisterClientFormFieldOptions } from './register-client-form-field.model'
export interface RegisterServerSettingOptions extends RegisterClientFormFieldOptions {
export type RegisterServerSettingOptions = RegisterClientFormFieldOptions & {
// If the setting is not private, anyone can view its value (client code included)
// If the setting is private, only server-side hooks can access it
// Mainly used by the PeerTube client to get admin config