Skip to content

Commit

Permalink
[TLC-277] Clean dupe section if workspace item / section data not yet…
Browse files Browse the repository at this point in the history
… defined
  • Loading branch information
kshepherd committed Aug 11, 2022
1 parent 0a193b8 commit 9bbbbfa
Showing 1 changed file with 20 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { select, Store } from '@ngrx/store';
import { distinctUntilChanged, map, startWith } from 'rxjs/operators';

import { SubmissionState } from '../../submission.reducers';
import { SetDuplicateDecisionAction } from '../../objects/submission-objects.actions';
import {CleanDetectDuplicateAction, SetDuplicateDecisionAction} from '../../objects/submission-objects.actions';
import { submissionSectionDataFromIdSelector } from '../../selectors';
import { WorkspaceitemSectionDetectDuplicateObject } from '../../../core/submission/models/workspaceitem-section-deduplication.model';
import { isEmpty, isNotEmpty } from '../../../shared/empty.util';
import {isEmpty, isNotEmpty, isNotUndefined} from '../../../shared/empty.util';
import { Observable } from 'rxjs';

/**
Expand Down Expand Up @@ -62,19 +62,24 @@ export class DetectDuplicateService {
map((item: WorkspaceitemSectionDetectDuplicateObject) => {
const outputObject: WorkspaceitemSectionDetectDuplicateObject = {} as WorkspaceitemSectionDetectDuplicateObject;
outputObject.matches = {};
Object.keys(item.matches)
.filter((key) => {
let output = false;
if (isWorkFlow) {
output = isEmpty(item.matches[key].workflowDecision);
} else {
output = isEmpty(item.matches[key].submitterDecision);
}
return output;
})
.forEach((key) => {
outputObject.matches[key] = item.matches[key];
});
if (isNotUndefined(item)) {
Object.keys(item.matches)
.filter((key) => {
let output = false;
if (isWorkFlow) {
output = isEmpty(item.matches[key].workflowDecision);
} else {
output = isEmpty(item.matches[key].submitterDecision);
}
return output;
})
.forEach((key) => {
outputObject.matches[key] = item.matches[key];
});
} else {
// Item is undefined, we should clear / clean the whole section
this.store.dispatch(new CleanDetectDuplicateAction(submissionId))
}
return outputObject;
})
);
Expand Down

0 comments on commit 9bbbbfa

Please sign in to comment.