mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
clean up and extra fields
This commit is contained in:
parent
f385233109
commit
f19dba31da
@ -1,21 +1,4 @@
|
|||||||
/*
|
|
||||||
- auto saves ,ajax call (submit when blur or onEnter)
|
|
||||||
- set default text
|
|
||||||
- show error state/confirm states
|
|
||||||
- show info
|
|
||||||
- label
|
|
||||||
- min/max length
|
|
||||||
|
|
||||||
- populate with curren val (from local sstate)
|
|
||||||
|
|
||||||
load page,
|
|
||||||
get all config vals,
|
|
||||||
save to local state/context.
|
|
||||||
read vals from there.
|
|
||||||
update vals to state, andthru api.
|
|
||||||
|
|
||||||
|
|
||||||
*/
|
|
||||||
import React, { useState, useContext } from 'react';
|
import React, { useState, useContext } from 'react';
|
||||||
import { Button, Form, Input, InputNumber } from 'antd';
|
import { Button, Form, Input, InputNumber } from 'antd';
|
||||||
import { FormItemProps } from 'antd/es/form';
|
import { FormItemProps } from 'antd/es/form';
|
||||||
@ -51,6 +34,8 @@ export default function TextField(props: TextFieldProps) {
|
|||||||
handleResetValue,
|
handleResetValue,
|
||||||
initialValues = {},
|
initialValues = {},
|
||||||
onSubmit,
|
onSubmit,
|
||||||
|
onBlur,
|
||||||
|
onChange,
|
||||||
type,
|
type,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
@ -92,6 +77,10 @@ export default function TextField(props: TextFieldProps) {
|
|||||||
setHasChanged(true);
|
setHasChanged(true);
|
||||||
setFieldValueForSubmit(val);
|
setFieldValueForSubmit(val);
|
||||||
}
|
}
|
||||||
|
// if an extra onChange handler was sent in as a prop, let's run that too.
|
||||||
|
if (onChange) {
|
||||||
|
onChange();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// if you blur a required field with an empty value, restore its original value
|
// if you blur a required field with an empty value, restore its original value
|
||||||
@ -100,12 +89,16 @@ export default function TextField(props: TextFieldProps) {
|
|||||||
if (required && val === '') {
|
if (required && val === '') {
|
||||||
handleResetValue(fieldName);
|
handleResetValue(fieldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if an extra onBlur handler was sent in as a prop, let's run that too.
|
||||||
|
if (onBlur) {
|
||||||
|
onBlur();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// how to get current value of input
|
// how to get current value of input
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if ((required && fieldValueForSubmit !== '') || fieldValueForSubmit !== initialValue) {
|
if ((required && fieldValueForSubmit !== '') || fieldValueForSubmit !== initialValue) {
|
||||||
// postUpdateToAPI(fieldValueForSubmit);
|
|
||||||
setSubmitStatus('validating');
|
setSubmitStatus('validating');
|
||||||
|
|
||||||
await postConfigUpdateToAPI({
|
await postConfigUpdateToAPI({
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
import React, { useContext, useEffect } from 'react';
|
import React, { useContext, useEffect } from 'react';
|
||||||
import { Typography, Form } from 'antd';
|
import { Typography, Form } from 'antd';
|
||||||
|
|
||||||
import TextField, { TEXTFIELD_TYPE_NUMBER, TEXTFIELD_TYPE_PASSWORD, TEXTFIELD_TYPE_TEXTAREA } from './components/config/form-textfield';
|
import TextField, { TEXTFIELD_TYPE_NUMBER, TEXTFIELD_TYPE_PASSWORD } from './components/config/form-textfield';
|
||||||
|
|
||||||
import { ServerStatusContext } from '../utils/server-status-context';
|
import { ServerStatusContext } from '../utils/server-status-context';
|
||||||
import { TEXTFIELD_DEFAULTS } from './components/config/constants';
|
import { TEXTFIELD_DEFAULTS } from './components/config/constants';
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
// TS types for elements on the Config pages
|
// TS types for elements on the Config pages
|
||||||
|
|
||||||
export interface TextFieldProps {
|
export interface TextFieldProps {
|
||||||
handleResetValue?: (fieldName) => void;
|
handleResetValue?: (fieldName: string) => void;
|
||||||
fieldName: string;
|
fieldName: string;
|
||||||
initialValues?: any;
|
initialValues?: any;
|
||||||
type?: string;
|
type?: string;
|
||||||
@ -27,8 +27,8 @@ export interface UpdateArgs {
|
|||||||
export interface ApiPostArgs {
|
export interface ApiPostArgs {
|
||||||
apiPath: string,
|
apiPath: string,
|
||||||
data: object,
|
data: object,
|
||||||
onSuccess?: (arg: any) => {},
|
onSuccess?: (arg: any) => void,
|
||||||
onError?: (arg: any) => {},
|
onError?: (arg: any) => void,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ConfigDirectoryFields {
|
export interface ConfigDirectoryFields {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user