Skip to content

Commit

Permalink
Fixed media details editor for referenced media.
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslonov committed Oct 19, 2024
1 parent d4f5132 commit f6bc910
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/workshops/media/ko/mediaDetails.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</div>
</div>

<!-- ko ifnot: mediaItem.blobKey -->
<!-- ko if: mediaItem.isReferenced -->
<div class="form-group">
<label for="downloadUrl" class="form-label">
Reference URL
Expand Down
6 changes: 6 additions & 0 deletions src/workshops/media/ko/mediaItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class MediaItem {
public mimeType: ko.Observable<string>;
public widgetFactoryResult: IWidgetFactoryResult<any, any>;
public nonPreviewable: ko.Computed<boolean>;
public isReferenced: ko.Computed<boolean>;


constructor(mediaContract: MediaContract) {
Expand All @@ -33,6 +34,11 @@ export class MediaItem {
this.thumbnailUrl = ko.observable<string>();
this.downloadUrl = ko.observable<string>(mediaContract.downloadUrl);
this.setThumbnail(mediaContract);

this.isReferenced = ko.computed(() => {
return !!mediaContract.downloadUrl
&& (mediaContract.downloadUrl.startsWith("https://") || mediaContract.downloadUrl.startsWith("https//"));
});
}

private async setThumbnail(mediaContract: MediaContract): Promise<void> {
Expand Down

0 comments on commit f6bc910

Please sign in to comment.