Skip to content

Commit 965c1a6

Browse files
committed
fix: ensure proper handling of attachment updates and error management in AttachmentComponent
1 parent 3920b4d commit 965c1a6

File tree

2 files changed

+19
-6
lines changed

2 files changed

+19
-6
lines changed

packages/angular-sdk-components/src/lib/_components/infra/assignment/assignment.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -435,12 +435,13 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
435435
const finishPromise = this.finishAssignment(this.itemKey$); // JA - was itemID but Nebula/Constellation uses itemKey
436436
finishPromise
437437
.then(() => {
438-
this.psService.sendMessage(false);
439438
this.updateChanges();
440439
})
441440
.catch(() => {
442-
this.psService.sendMessage(false);
443441
this.snackBarRef = this.snackBar.open(`${this.localizedVal('Submit failed!', this.localeCategory)}`, 'Ok');
442+
})
443+
.finally(() => {
444+
this.psService.sendMessage(false);
444445
});
445446
break;
446447

@@ -450,8 +451,10 @@ export class AssignmentComponent implements OnInit, OnDestroy, OnChanges {
450451
approvePromise
451452
.then(() => {})
452453
.catch(() => {
453-
this.psService.sendMessage(false);
454454
this.snackBarRef = this.snackBar.open(`${this.localizedVal('Approve failed!', this.localeCategory)}`, 'Ok');
455+
})
456+
.finally(() => {
457+
this.psService.sendMessage(false);
455458
});
456459

457460
break;

packages/angular-sdk-components/src/lib/_components/widget/attachment/attachment.component.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,16 @@ export class AttachmentComponent implements OnInit, OnDestroy {
156156
this.displayMode = displayMode;
157157
this.isMultiAttachmentInInlineEditTable = isTableFormatter && allowMultiple && editMode === 'tableRows';
158158

159+
const rawValue = this.pConn$.getComponentConfig().value;
160+
const isAttachmentAnnotationPresent = typeof rawValue === 'object' ? false : rawValue?.includes('@ATTACHMENT');
161+
const { attachments, isOldAttachment } = isAttachmentAnnotationPresent ? value : PCore.getAttachmentUtils().prepareAttachmentData(value);
162+
this.isOldAttachment = isOldAttachment;
163+
this.attachments = attachments;
164+
159165
// update the attachments shown in the UI
160-
this.updateAttachments();
166+
if (this.attachments.length) {
167+
this.updateAttachments();
168+
}
161169
}
162170

163171
updateAttachments() {
@@ -330,6 +338,7 @@ export class AttachmentComponent implements OnInit, OnDestroy {
330338
}
331339

332340
populateErrorAndUpdateRedux(file) {
341+
console.log('populateErrorAndUpdateRedux');
333342
const fieldName = (this.pConn$.getStateProps() as any).value;
334343
// set errors to property to block submit even on errors in file upload
335344
PCore.getMessageManager().addMessages({
@@ -439,12 +448,13 @@ export class AttachmentComponent implements OnInit, OnDestroy {
439448
if (this.filesWithError?.length === 0) {
440449
clearFieldErrorMessages(this.pConn$);
441450
}
442-
443-
this.actionSequencer.deRegisterBlockingAction(this.contextName).catch(() => {});
444451
}
452+
453+
this.actionSequencer.deRegisterBlockingAction(this.contextName).catch(() => {});
445454
})
446455
.catch(error => {
447456
console.log(error);
457+
this.actionSequencer.cancelDeferredActionsOnError(this.contextName);
448458
});
449459
}
450460

0 commit comments

Comments
 (0)