This commit is contained in:
Simon Larsen
2023-03-22 11:03:45 +00:00
parent 5cca89a8c4
commit f836d3ca2e
11 changed files with 25 additions and 28 deletions

View File

@@ -46,7 +46,7 @@ export default class FileModel extends BaseModel {
type: TableColumnType.ShortText,
title: 'Name',
description: 'Any friendly name of this object',
canReadOnPopulate: true
canReadOnPopulate: true,
})
@Column({
nullable: false,

View File

@@ -484,7 +484,7 @@ export default class StatusPageAPI extends BaseAPI<
displayName: true,
showStatusHistoryChart: true,
showCurrentStatus: true,
order: true
order: true,
},
populate: {
monitor: {
@@ -493,7 +493,7 @@ export default class StatusPageAPI extends BaseAPI<
},
},
sort: {
order: SortOrder.Ascending
order: SortOrder.Ascending,
},
skip: 0,
limit: LIMIT_PER_PROJECT,

View File

@@ -103,7 +103,6 @@ const BasicForm: ForwardRefExoticComponent<any> = forwardRef(
props: ComponentProps<T>,
ref: Ref<any>
): ReactElement => {
const refCurrentValue = useRef(props.initialValues);
const [currentValue, setCurrentValue] = useState<FormValues<T>>(
@@ -122,17 +121,13 @@ const BasicForm: ForwardRefExoticComponent<any> = forwardRef(
setTouched({ ...touched, [fieldName]: value });
};
useEffect(() => {
console.log("Value changed");
console.log('Value changed');
validate(currentValue);
if (props.onChange) {
props.onChange(currentValue);
}
}, [currentValue]);
useImperativeHandle(
@@ -173,8 +168,6 @@ const BasicForm: ForwardRefExoticComponent<any> = forwardRef(
fieldName: string,
value: JSONValue
): void => {
const updatedValue: FormValues<T> = {
...refCurrentValue.current,
[fieldName]: value as any,
@@ -182,11 +175,10 @@ const BasicForm: ForwardRefExoticComponent<any> = forwardRef(
refCurrentValue.current = updatedValue;
console.log("Set field value");
console.log('Set field value');
console.log(updatedValue);
setCurrentValue(refCurrentValue.current);
};
const submitForm: Function = (): void => {
@@ -571,7 +563,14 @@ const BasicForm: ForwardRefExoticComponent<any> = forwardRef(
setFieldTouched(fieldName, true);
}}
initialValue={
currentValue && (currentValue as any)[fieldName] && ((currentValue as any)[fieldName] === true || (currentValue as any)[fieldName] === false) ? (currentValue as any)[fieldName] : false
currentValue &&
(currentValue as any)[fieldName] &&
((currentValue as any)[fieldName] ===
true ||
(currentValue as any)[fieldName] ===
false)
? (currentValue as any)[fieldName]
: false
}
/>
)}
@@ -932,8 +931,6 @@ const BasicForm: ForwardRefExoticComponent<any> = forwardRef(
};
useEffect(() => {
const values: FormValues<T> = { ...props.initialValues };
for (const field of formFields) {
const fieldName: string = getFieldName(field);
@@ -972,18 +969,20 @@ const BasicForm: ForwardRefExoticComponent<any> = forwardRef(
}
);
}
// if the field is still null but has a default value then... have the default inital value
if(field.defaultValue && (values as any)[fieldName] === undefined){
if (
field.defaultValue &&
(values as any)[fieldName] === undefined
) {
(values as any)[fieldName] = field.defaultValue;
}
}
console.log("Set init value");
console.log('Set init value');
console.log(values);
refCurrentValue.current = values;
setCurrentValue(refCurrentValue.current);
}, [props.initialValues, formFields]);
const primaryButtonStyle: React.CSSProperties = {};

View File

@@ -31,7 +31,6 @@ const Toggle: FunctionComponent<ComponentProps> = (
}
}, [props.initialValue]);
const handleChange: Function = (content: boolean): void => {
setIsChecked(content);
props.onChange(content);

View File

@@ -150,7 +150,7 @@ export default class ApiKey extends BaseModel {
type: TableColumnType.ShortText,
title: 'Name',
description: 'Any friendly name of this object',
canReadOnPopulate: true
canReadOnPopulate: true,
})
@Column({
nullable: false,

View File

@@ -156,7 +156,6 @@ export default class Label extends AccessControlModel {
canReadOnPopulate: true,
title: 'Name',
description: 'Any friendly name of this object',
})
@Column({
nullable: false,

View File

@@ -175,7 +175,7 @@ export default class Monitor extends BaseModel {
type: TableColumnType.ShortText,
title: 'Name',
description: 'Any friendly name of this object',
canReadOnPopulate: true
canReadOnPopulate: true,
})
@Column({
nullable: false,

View File

@@ -165,7 +165,7 @@ export default class OnCallDuty extends BaseModel {
type: TableColumnType.ShortText,
title: 'Name',
description: 'Any friendly name of this object',
canReadOnPopulate: true
canReadOnPopulate: true,
})
@Column({
nullable: false,

View File

@@ -74,7 +74,7 @@ export default class Model extends TenantModel {
type: TableColumnType.ShortText,
title: 'Name',
description: 'Any friendly name of this object',
canReadOnPopulate: true
canReadOnPopulate: true,
})
@Column({
nullable: false,

View File

@@ -175,7 +175,7 @@ export default class StatusPage extends BaseModel {
type: TableColumnType.ShortText,
title: 'Name',
description: 'Any friendly name of this object',
canReadOnPopulate: true
canReadOnPopulate: true,
})
@Column({
nullable: false,

View File

@@ -157,7 +157,7 @@ export default class Team extends BaseModel {
type: TableColumnType.ShortText,
title: 'Name',
description: 'Any friendly name of this object',
canReadOnPopulate: true
canReadOnPopulate: true,
})
@Column({
nullable: false,