Skip to content
Snippets Groups Projects
Commit 5c277be3 authored by OZGCloud's avatar OZGCloud
Browse files

OZG-5981 OZG-6154 Remove isLoading in wrapper Component

isLoading is always available in BinaryFile2Component
parent 230deac2
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
*ngIf="binaryFileStateResource.resource as binaryFile" *ngIf="binaryFileStateResource.resource as binaryFile"
data-test-class="binary-file-container" data-test-class="binary-file-container"
[file]="binaryFile" [file]="binaryFile"
[isLoading]="binaryFileStateResource.loading"
[deletable]="false" [deletable]="false"
></alfa-binary-file2-container> ></alfa-binary-file2-container>
</ods-attachment-wrapper> </ods-attachment-wrapper>
......
...@@ -97,13 +97,6 @@ describe('BinaryFileUriContainerComponent', () => { ...@@ -97,13 +97,6 @@ describe('BinaryFileUriContainerComponent', () => {
expect(binaryFileContainerComponent.file).toEqual(binaryFileStateResource.resource); expect(binaryFileContainerComponent.file).toEqual(binaryFileStateResource.resource);
}); });
it('should be called with isLoading', () => {
const binaryFileContainerComponent: BinaryFile2ContainerComponent =
getMockComponent<BinaryFile2ContainerComponent>(fixture, BinaryFile2ContainerComponent);
expect(binaryFileContainerComponent.isLoading).toBe(binaryFileStateResource.loading);
});
it('should be called with deleteable', () => { it('should be called with deleteable', () => {
const binaryFileContainerComponent: BinaryFile2ContainerComponent = const binaryFileContainerComponent: BinaryFile2ContainerComponent =
getMockComponent<BinaryFile2ContainerComponent>(fixture, BinaryFile2ContainerComponent); getMockComponent<BinaryFile2ContainerComponent>(fixture, BinaryFile2ContainerComponent);
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
[file]="file" [file]="file"
[stateResource]="fileStateResource$ | async" [stateResource]="fileStateResource$ | async"
[deletable]="deletable" [deletable]="deletable"
[isLoading]="isLoading"
[downloadToken]="downloadToken$ | async" [downloadToken]="downloadToken$ | async"
(startDownload)="startDownload($event)" (startDownload)="startDownload($event)"
(startDelete)="startDelete.emit($event)" (startDelete)="startDelete.emit($event)"
......
...@@ -2,7 +2,7 @@ import { ApiDownloadToken, ApiRootService } from '@alfa-client/api-root-shared'; ...@@ -2,7 +2,7 @@ import { ApiDownloadToken, ApiRootService } from '@alfa-client/api-root-shared';
import { BinaryFileResource, BinaryFileService } from '@alfa-client/binary-file-shared'; import { BinaryFileResource, BinaryFileService } from '@alfa-client/binary-file-shared';
import { StateResource } from '@alfa-client/tech-shared'; import { StateResource } from '@alfa-client/tech-shared';
import { Component, EventEmitter, Input, Output } from '@angular/core'; import { Component, EventEmitter, Input, Output } from '@angular/core';
import { Observable, tap } from 'rxjs'; import { Observable } from 'rxjs';
@Component({ @Component({
selector: 'alfa-binary-file2-container', selector: 'alfa-binary-file2-container',
...@@ -12,7 +12,6 @@ export class BinaryFile2ContainerComponent { ...@@ -12,7 +12,6 @@ export class BinaryFile2ContainerComponent {
@Input() file: BinaryFileResource; @Input() file: BinaryFileResource;
@Input() downloadFileNamePrefix: string; @Input() downloadFileNamePrefix: string;
@Input() deletable: boolean = false; @Input() deletable: boolean = false;
@Input() isLoading: boolean = false;
@Output() startDelete: EventEmitter<BinaryFileResource> = new EventEmitter(); @Output() startDelete: EventEmitter<BinaryFileResource> = new EventEmitter();
...@@ -25,9 +24,10 @@ export class BinaryFile2ContainerComponent { ...@@ -25,9 +24,10 @@ export class BinaryFile2ContainerComponent {
) {} ) {}
startDownload(file: BinaryFileResource): void { startDownload(file: BinaryFileResource): void {
this.fileStateResource$ = this.binaryFileService this.fileStateResource$ = this.binaryFileService.downloadFile(
.downloadFile(file, this.downloadFileNamePrefix) file,
.pipe(tap((resource) => (this.isLoading = resource.loading))); this.downloadFileNamePrefix,
);
} }
getDownloadToken(): void { getDownloadToken(): void {
......
...@@ -19,7 +19,6 @@ export class BinaryFile2Component { ...@@ -19,7 +19,6 @@ export class BinaryFile2Component {
@Input() stateResource: StateResource<Resource>; @Input() stateResource: StateResource<Resource>;
@Input() deletable: boolean = false; @Input() deletable: boolean = false;
@Input() downloadToken: ApiDownloadToken = <ApiDownloadToken>{}; @Input() downloadToken: ApiDownloadToken = <ApiDownloadToken>{};
@Input() isLoading: boolean = false;
readonly fileLinkRel = BinaryFileLinkRel; readonly fileLinkRel = BinaryFileLinkRel;
...@@ -33,6 +32,10 @@ export class BinaryFile2Component { ...@@ -33,6 +32,10 @@ export class BinaryFile2Component {
return this.getStateResource().loading; return this.getStateResource().loading;
} }
get isLoading(): boolean {
return this.getStateResource().loading;
}
getStateResource(): StateResource<Resource> { getStateResource(): StateResource<Resource> {
return isNil(this.stateResource) ? createEmptyStateResource<Resource>() : this.stateResource; return isNil(this.stateResource) ? createEmptyStateResource<Resource>() : this.stateResource;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment