Skip to content

Commit

Permalink
fix(dh): improve several details from review
Browse files Browse the repository at this point in the history
  • Loading branch information
cmoinier committed Dec 14, 2023
1 parent 72dff1c commit e028e9e
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 59 deletions.
2 changes: 1 addition & 1 deletion apps/datahub-e2e/src/e2e/home.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ describe('home', () => {
})
})

describe.only('my favorites button', () => {
describe('my favorites button', () => {
beforeEach(() => {
cy.login()
cy.clearFavorites()
Expand Down
24 changes: 24 additions & 0 deletions apps/datahub/src/app/record/record-apis/record-apis.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,27 @@
>
</gn-ui-api-card>
</gn-ui-carousel>
<div
class="bg-primary-opacity-10 pt-8 overflow-visible sm:pt-5"
*ngIf="facade.selectedApiLink$ | async"
>
<div class="flex flex-col container-lg px-4 lg:mx-auto gap-6">
<div class="flex flex-wrap justify-between mb-6 sm:mb-2 ng-star-inserted">
<p class="text-[28px] text-title font-title" translate>
record.metadata.api.form.title
</p>
<button type="button" class="text-main" (click)="closeForm()">
<span class="text-sm text-primary" translate
>record.metadata.api.form.closeButton</span
>
<mat-icon
class="material-symbols-outlined ml-1 align-middle leading-none text-primary"
>close</mat-icon
>
</button>
</div>
<gn-ui-record-api-form
[apiLink]="facade.selectedApiLink$ | async"
></gn-ui-record-api-form>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,12 @@ describe('RecordApisComponent', () => {
expect(apiLink).toEqual(serviceDistributionMock)
})
})

describe('#closeForm', () => {
it('should pass undefined to facade.selectedApiLink$', async () => {
component.closeRecordApiForm()
const apiLink = await firstValueFrom(facade.selectedApiLink$)
expect(apiLink).toBeUndefined()
})
})
})
12 changes: 5 additions & 7 deletions apps/datahub/src/app/record/record-apis/record-apis.component.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
Component,
ChangeDetectionStrategy,
Output,
EventEmitter,
Input,
} from '@angular/core'
import { Component, ChangeDetectionStrategy } from '@angular/core'
import { DatasetServiceDistribution } from '@geonetwork-ui/common/domain/model/record'
import { MdViewFacade } from '@geonetwork-ui/feature/record'

Expand All @@ -20,4 +14,8 @@ export class RecordApisComponent {
openRecordApiForm(link: DatasetServiceDistribution) {
this.facade.selectedApiLink$.next(link)
}

closeRecordApiForm() {
this.facade.selectedApiLink$.next(undefined)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -127,30 +127,6 @@
></datahub-record-apis>
</div>
</div>
<div
class="bg-primary-opacity-10 pt-8 overflow-visible sm:pt-5"
*ngIf="facade.selectedApiLink$ | async"
>
<div class="flex flex-col container-lg px-4 lg:mx-auto gap-6">
<div class="flex flex-wrap justify-between mb-6 sm:mb-2 ng-star-inserted">
<p class="text-[28px] text-title font-title" translate>
record.metadata.api.form.title
</p>
<button type="button" class="text-main" (click)="closeForm()">
<span class="text-sm text-primary" translate
>record.metadata.api.form.closeButton</span
>
<mat-icon
class="material-symbols-outlined ml-1 align-middle leading-none text-primary"
>close</mat-icon
>
</button>
</div>
<gn-ui-record-api-form
[apiLink]="facade.selectedApiLink$ | async"
></gn-ui-record-api-form>
</div>
</div>

<div id="related-records" *ngIf="displayRelated$ | async">
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -647,12 +647,4 @@ describe('RecordMetadataComponent', () => {
})
})
})

describe('#closeForm', () => {
it('should pass undefined to facade.selectedApiLink$', async () => {
component.closeForm()
const apiLink = await firstValueFrom(facade.selectedApiLink$)
expect(apiLink).toBeUndefined()
})
})
})
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import {
ChangeDetectionStrategy,
Component,
EventEmitter,
Input,
Output,
} from '@angular/core'
import { ChangeDetectionStrategy, Component, Input } from '@angular/core'
import { SourcesService } from '@geonetwork-ui/feature/catalog'
import { SearchService } from '@geonetwork-ui/feature/search'
import { ErrorType, MetadataQualityDisplay } from '@geonetwork-ui/ui/elements'
import { BehaviorSubject, combineLatest } from 'rxjs'
import { filter, map, mergeMap } from 'rxjs/operators'
import { OrganizationsServiceInterface } from '@geonetwork-ui/common/domain/organizations.service.interface'
import {
Organization,
DatasetServiceDistribution,
} from '@geonetwork-ui/common/domain/model/record'
import { Organization } from '@geonetwork-ui/common/domain/model/record'
import { MdViewFacade } from '@geonetwork-ui/feature/record'

@Component({
Expand All @@ -25,7 +16,6 @@ import { MdViewFacade } from '@geonetwork-ui/feature/record'
})
export class RecordMetadataComponent {
@Input() metadataQualityDisplay: MetadataQualityDisplay
@Output() apiLink = new EventEmitter<DatasetServiceDistribution>()

displayMap$ = combineLatest([
this.facade.mapApiLinks$,
Expand Down Expand Up @@ -94,10 +84,6 @@ export class RecordMetadataComponent {
: this.facade.selectedApiLink$.next(val)
}

closeForm() {
this.facade.selectedApiLink$.next(undefined)
}

get hasMetadataQualityWidget() {
return this.metadataQualityDisplay?.widget === true
}
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/elements/src/lib/api-card/api-card.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<button
*ngIf="displayApiFormButton"
type="button"
(click)="openPanel()"
(click)="openRecordApiFormPanel()"
[ngClass]="{
'py-2 px-4 rounded-r-md bg-gray-400 hover:bg-gray-600 focus:bg-gray-800 text-white':
displayText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('ApiCardComponent', () => {
})

it('should toggle currentlyActive and emit openRecordApiForm event', () => {
component.openPanel()
component.openRecordApiFormPanel()

expect(component.currentlyActive).toBe(true)
expect(openRecordApiFormEmit.emit).toHaveBeenCalled()
Expand Down
2 changes: 1 addition & 1 deletion libs/ui/elements/src/lib/api-card/api-card.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export class ApiCardComponent implements OnInit, OnChanges {
changes.currentLink.currentValue === this.link ? true : false
}

openPanel() {
openRecordApiFormPanel() {
this.currentlyActive = !this.currentlyActive
this.openRecordApiForm.emit(this.currentlyActive ? this.link : undefined)
}
Expand Down

0 comments on commit e028e9e

Please sign in to comment.