Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat Column & Review Improvements and Bug fixes #701

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ export class BaseReview {
break;
case ColumnTypesEnum.NUMBER:
property = {
allOf: [{ type: 'integer' }, ...(!column.isRequired ? [{ type: ['integer', 'null'] }] : [])],
allOf: [{ type: ['integer', 'null'] }],
...(!column.isRequired && { default: null }),
};
break;
case ColumnTypesEnum.DOUBLE:
property = {
allOf: [{ type: 'number' }, ...(!column.isRequired ? [{ type: ['number', 'null'] }] : [])],
allOf: [{ type: ['number', 'null'] }],
...(!column.isRequired && { default: null }),
};
break;
Expand Down Expand Up @@ -281,7 +281,7 @@ export class BaseReview {
if (heading === '_') return acc;
let val = record[index];

if (numberColumnHeadings.has(heading) && val !== '' && !isNaN(val)) val = Number(val);
if (numberColumnHeadings.has(heading)) val = val !== '' && !isNaN(val) ? Number(val) : null;
if (typeof val === 'string') val = val.trim();
if (multiSelectColumnHeadings[heading]) {
if (val)
Expand Down
26 changes: 17 additions & 9 deletions apps/web/components/imports/forms/CreateImportForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useForm } from 'react-hook-form';
import { useFocusTrap } from '@mantine/hooks';
import { Stack, TextInput as Input } from '@mantine/core';
import { Stack, TextInput as Input, FocusTrap } from '@mantine/core';

import { Button } from '@ui/button';

Expand All @@ -17,13 +17,21 @@ export function CreateImportForm({ onSubmit }: CreateImportFormProps) {
} = useForm<ICreateTemplateData>();

return (
<form onSubmit={handleSubmit(onSubmit)} ref={focusTrapRef}>
<Stack spacing="sm">
<Input placeholder="Import title" autoFocus required {...register('name')} error={errors.name?.message} />
<Button type="submit" fullWidth>
Create & Continue
</Button>
</Stack>
</form>
<FocusTrap active>
<form onSubmit={handleSubmit(onSubmit)} ref={focusTrapRef}>
<Stack spacing="sm">
<Input
placeholder="Import title"
data-autofocus
required
{...register('name')}
error={errors.name?.message}
/>
<Button type="submit" fullWidth>
Create & Continue
</Button>
</Stack>
</form>
</FocusTrap>
);
}
5 changes: 2 additions & 3 deletions apps/web/components/imports/schema/ColumnsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,8 @@ export function ColumnsTable({ templateId }: ColumnsTableProps) {
});

const onValidationsButtonClick = () => {
const name = getValues('name');
const type = getValues('type');
onValidationsClick({ name, key: name, type });
const values = getValues();
onValidationsClick({ ...values, key: values.key || values.name });
};

return (
Expand Down
5 changes: 3 additions & 2 deletions apps/widget/src/components/Common/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ Handsontable.renderers.registerRenderer(
TD.classList.add('custom-cell');
TD.ariaLabel = '';
const soureData = instance.getSourceDataAtRow(row) as IRecord;
let fieldValue = typeof soureData.record[name] === 'undefined' ? '' : soureData.record[name];
let fieldValue =
typeof soureData.record[name] === 'undefined' || soureData.record[name] === null ? null : soureData.record[name];
if (typeof fieldValue === 'string' && fieldValue.length > name.length + 20)
fieldValue = value.substring(0, name.length + 20) + '...';

Expand All @@ -91,7 +92,7 @@ Handsontable.renderers.registerRenderer(
if (soureData.updated?.[name] || soureData.errors?.[name]) {
valueSpan.classList.add('cell-value');
}
valueSpan.appendChild(document.createTextNode(fieldValue));
if (fieldValue !== null) valueSpan.appendChild(document.createTextNode(fieldValue));
TD.appendChild(valueSpan);
if (soureData.updated && soureData.updated[name]) {
errorSvg.setAttribute('style', 'vertical-align: middle;float: right;cursor: pointer;color:#795e00;');
Expand Down
4 changes: 2 additions & 2 deletions apps/widget/src/components/widget/Phases/Phase3/Phase3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,12 @@ export function Phase3(props: IPhase3Props) {
currentData &&
oldVal != newVal &&
!(oldVal === '' && newVal === undefined) &&
!(newVal === '' && oldVal === undefined)
!(newVal === '' && (oldVal === undefined || oldVal === null))
) {
if (!currentData[row].updated) {
currentData[row].updated = {};
}
currentData[row].record[name] = newVal;
currentData[row].record[name] = newVal === '' ? null : newVal;
currentData[row].updated[name] = true;
setReviewData(currentData);
updateRecord({
Expand Down
Loading