Skip to content

Commit

Permalink
fix: prevent saving invalid related files PLAT-25056
Browse files Browse the repository at this point in the history
  • Loading branch information
amirch1 committed Dec 22, 2024
1 parent 0fc44cd commit aea4150
Showing 1 changed file with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
KeyValueDiffers,
OnDestroy
} from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import {BehaviorSubject, Observable} from 'rxjs';
import { throwError } from 'rxjs';
import { KalturaClient } from 'kaltura-ngx-client';
import { KalturaMultiRequest } from 'kaltura-ngx-client';
Expand Down Expand Up @@ -295,7 +295,6 @@ export class EntryRelatedWidget extends EntryWidget implements OnDestroy
public _removeFile(file: RelatedFile): void {
// update the list by filtering the assets array.
this._relatedFiles.next({ items: this._relatedFiles.getValue().items.filter((item: RelatedFile) => item !== file) });

// stop tracking changes on this asset
// if file id is empty it was added by the user so no need to track its changes.
if (file.id && this.relatedFileDiffer[file.id]) {
Expand Down Expand Up @@ -398,6 +397,16 @@ export class EntryRelatedWidget extends EntryWidget implements OnDestroy
super.updateState({isDirty: true});
}

protected onValidate(wasActivated: boolean) : Observable<{ isValid : boolean}>
{
const isValid = this._relatedFiles.getValue().items.filter((item: RelatedFile) => item.uploadFailure === true).length === 0;
return Observable.create(observer =>
{
observer.next({ isValid });
observer.complete()
});
}

ngOnDestroy()
{

Expand Down

0 comments on commit aea4150

Please sign in to comment.