Skip to content

Commit

Permalink
Merge pull request #280 from gisce/hotfix/bug_webclient#436
Browse files Browse the repository at this point in the history
Adjust always save document before entering report,action,related or attachments
  • Loading branch information
mguellsegarra authored Apr 11, 2023
2 parents fc43dc8 + 61737cd commit 7b0f6aa
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 22 deletions.
4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@gisce/react-ooui",
"version": "1.1.34",
"version": "1.1.35",
"files": [
"dist",
"src",
Expand Down
26 changes: 7 additions & 19 deletions src/actionbar/FormActionBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,8 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
return;
}

const result = await saveNewDocumentIfNeeded({
const result = await saveDocument({
onFormSave,
currentId,
});

if (!result.succeed) {
Expand All @@ -365,9 +364,8 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
if (!report) {
return;
}
const result = await saveNewDocumentIfNeeded({
const result = await saveDocument({
onFormSave,
currentId,
});

if (!result.succeed) {
Expand All @@ -393,9 +391,8 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
return;
}

const result = await saveNewDocumentIfNeeded({
const result = await saveDocument({
onFormSave,
currentId,
});

if (!result.succeed) {
Expand All @@ -415,9 +412,8 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
disabled={mustDisableButtons}
attachments={attachments}
onAddNewAttachment={async () => {
const result = await saveNewDocumentIfNeeded({
const result = await saveDocument({
onFormSave,
currentId,
});

if (!result.succeed) {
Expand All @@ -439,9 +435,8 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
});
}}
onListAllAttachments={async () => {
const result = await saveNewDocumentIfNeeded({
const result = await saveDocument({
onFormSave,
currentId,
});

if (!result.succeed) {
Expand All @@ -460,9 +455,8 @@ function FormActionBar({ toolbar }: { toolbar: any }) {
});
}}
onViewAttachmentDetails={async (attachment: Attachment) => {
const result = await saveNewDocumentIfNeeded({
const result = await saveDocument({
onFormSave,
currentId,
});

if (!result.succeed) {
Expand All @@ -484,18 +478,12 @@ function separator() {
return <div className="inline-block w-2" />;
}

async function saveNewDocumentIfNeeded({
async function saveDocument({
onFormSave,
currentId,
}: {
onFormSave?: () => Promise<{ succeed: boolean; id: number }>;
currentId: number | undefined;
}): Promise<{ succeed: boolean; currentId?: number }> {
if (currentId !== undefined) {
return { succeed: true, currentId: currentId };
}
const result = await onFormSave?.();

if (result?.succeed) {
return { succeed: true, currentId: result.id };
} else {
Expand Down

0 comments on commit 7b0f6aa

Please sign in to comment.