Skip to content

Commit

Permalink
refactor(metadata-editor): changed resourceFileName to imageAltText.
Browse files Browse the repository at this point in the history
  • Loading branch information
Romuald Caplier committed Jul 29, 2024
1 parent 7856573 commit 1f5faaf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<gn-ui-image-input
[maxSizeMB]="5"
[previewUrl]="resourceUrl"
[altText]="resourceFileName"
[altText]="imageAltText"
(fileChange)="handleFileChange($event)"
(urlChange)="handleUrlChange($event)"
(delete)="handleDelete()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe('OverviewUploadComponent', () => {

it('should get all resources corresponding to the metadata UUID on init', () => {
expect(recordsApiService.getAllResources).toHaveBeenCalledWith(metadataUuid)
expect(component.resourceFileName).toEqual('filenameGet')
expect(component.imageAltText).toEqual('filenameGet')
expect(component.resourceUrl).toEqual('urlGet')
})

Expand All @@ -63,7 +63,7 @@ describe('OverviewUploadComponent', () => {
someFile,
'public'
)
expect(component.resourceFileName).toEqual('filenamePut')
expect(component.imageAltText).toEqual('filenamePut')
expect(component.resourceUrl).toEqual('urlPut')
})

Expand All @@ -74,18 +74,18 @@ describe('OverviewUploadComponent', () => {
'someUrl',
'public'
)
expect(component.resourceFileName).toEqual('filenamePutUrl')
expect(component.imageAltText).toEqual('filenamePutUrl')
expect(component.resourceUrl).toEqual('urlPutUrl')
})

it('should delete the resource corresponding to the metadata UUID on delete', () => {
component.resourceFileName = 'filenameDelete'
component.imageAltText = 'filenameDelete'
component.handleDelete()
expect(recordsApiService.delResource).toHaveBeenCalledWith(
metadataUuid,
'filenameDelete'
)
expect(component.resourceFileName).toBeNull()
expect(component.imageAltText).toBeNull()
expect(component.resourceUrl).toBeNull()
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { UiInputsModule } from '@geonetwork-ui/ui/inputs'
export class OverviewUploadComponent implements OnInit {
@Input() metadataUuid: string

resourceFileName: string
imageAltText: string
resourceUrl: string

constructor(
Expand All @@ -32,7 +32,7 @@ export class OverviewUploadComponent implements OnInit {
this.recordsApiService
.getAllResources(this.metadataUuid)
.subscribe((resources) => {
this.resourceFileName = resources[0]?.filename
this.imageAltText = resources[0]?.filename
this.resourceUrl = resources[0]?.url
this.cd.markForCheck()
})
Expand All @@ -42,7 +42,7 @@ export class OverviewUploadComponent implements OnInit {
this.recordsApiService
.putResource(this.metadataUuid, file, 'public')
.subscribe((resource) => {
this.resourceFileName = resource.filename
this.imageAltText = resource.filename
this.resourceUrl = resource.url
this.cd.markForCheck()
})
Expand All @@ -52,17 +52,17 @@ export class OverviewUploadComponent implements OnInit {
this.recordsApiService
.putResourceFromURL(this.metadataUuid, url, 'public')
.subscribe((resource) => {
this.resourceFileName = resource.filename
this.imageAltText = resource.filename
this.resourceUrl = resource.url
this.cd.markForCheck()
})
}

handleDelete() {
this.recordsApiService
.delResource(this.metadataUuid, this.resourceFileName)
.delResource(this.metadataUuid, this.imageAltText)
.subscribe(() => {
this.resourceFileName = null
this.imageAltText = null
this.resourceUrl = null
this.cd.markForCheck()
})
Expand Down

0 comments on commit 1f5faaf

Please sign in to comment.