Skip to content

Commit

Permalink
Updated based on feedback before merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcottner committed Nov 14, 2023
1 parent 6c145af commit 055d04f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 3 additions & 4 deletions src/components/record/JSONRecordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import BaseForm from "../BaseForm";
import JSONEditor from "../JSONEditor";
import { RJSFSchema, UiSchema } from "@rjsf/utils";
import { omit } from "../../utils";

const schema: RJSFSchema = {
type: "string",
Expand Down Expand Up @@ -51,11 +52,9 @@ type Props = {
};

function splitAttachment(record: string) {
const jsRecord = JSON.parse(record);
let jsRecord = JSON.parse(record);
const attachment = jsRecord.attachment || {};
if (jsRecord.attachment) {
delete jsRecord.attachment;
}
jsRecord = omit(jsRecord, ["attachment"]);
return {
attachment: attachment,
jsonContent: JSON.stringify(jsRecord),
Expand Down
2 changes: 1 addition & 1 deletion src/components/record/RecordForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ export default function RecordForm(props: Props) {
record={JSON.stringify(recordData, null, 2)}
onSubmit={handleOnSubmit}
attachmentEnabled={attachment?.enabled}
// require an attachment on initial insert if attachments are required
// require an attachment on insert if attachments are required, don't need to re-upload on every edit
attachmentRequired={attachment?.required && !record}
>
{buttons}
Expand Down

0 comments on commit 055d04f

Please sign in to comment.