Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ME] spatial extents field #941

Merged
merged 14 commits into from
Aug 27, 2024
Merged

[ME] spatial extents field #941

merged 14 commits into from
Aug 27, 2024

Conversation

Angi-Kinas
Copy link
Collaborator

@Angi-Kinas Angi-Kinas commented Jul 15, 2024

Description

This PR introduces the form field for the spatial extents.

The tests have no been written yet and the PR depends on #944.

For some reason the translation keys are not being applied.

Architectural changes

There are some changes in the record-form.component in the way we render this field. This is the first field that needs input from two sources of the field config (place keywords and spatial extents). That's why we made it specific here. If there will be more fields like this, we can think about making this more generic.

Screenshots

image

Quality Assurance Checklist

  • Commit history is devoid of any merge commits and readable to facilitate reviews
  • If new logic ⚙️ is introduced: unit tests were added
  • If new user stories 🤏 are introduced: E2E tests were added
  • If new UI components 🕹️ are introduced: corresponding stories in Storybook were created
  • If breaking changes 🪚 are introduced: add the breaking change label
  • If bugs 🐞 are fixed: add the backport <release branch> label
  • The documentation website 📚 has received the love it deserves

This work is sponsored by Organization ABC.

Copy link
Contributor

github-actions bot commented Jul 15, 2024

Affected libs: api-metadata-converter, api-repository, feature-catalog, feature-record, feature-router, feature-search, feature-map, feature-dataviz, feature-editor, feature-auth, ui-search, common-domain, common-fixtures, ui-elements, feature-notifications, ui-catalog, util-shared, ui-widgets, ui-inputs, ui-layout, ui-map, ui-dataviz,
Affected apps: metadata-editor, metadata-converter, datahub, demo, webcomponents, map-viewer, search, datafeeder, data-platform,

  • 🚀 Build and deploy storybook and demo on GitHub Pages
  • 📦 Build and push affected docker images

Copy link
Contributor

github-actions bot commented Jul 15, 2024

📷 Screenshots are here!

@Angi-Kinas Angi-Kinas force-pushed the ME-geographical-extent branch 2 times, most recently from 0226510 to 6c9291c Compare July 31, 2024 07:26
Copy link
Collaborator Author

@Angi-Kinas Angi-Kinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @LHBruneton-C2C for your help on this!

Please feel free to review and leave comments.
I already left some comments to not forget what still needs to be done.
Another ting that I was unsure about, is where to place the components that have been created. Namely "GenericFormFieldKeywordsComponent" and "FormFieldMapContainerComponent" and about their naming.

Thanks in advance!

libs/common/domain/src/lib/model/record/metadata.model.ts Outdated Show resolved Hide resolved

import { FormFieldMapContainerComponent } from './form-field-map-container.component';

describe('FormFieldMapContainerComponent', () => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To do: write tests for this component

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this could be moved to feature/editor/src/lib too, to split things a bit more.

libs/feature/map/src/lib/utils/map-utils.service.ts Outdated Show resolved Hide resolved
@Angi-Kinas Angi-Kinas changed the title Draft: [ME] geographical extent Draft: [ME] spatial extents Jul 31, 2024
@Angi-Kinas Angi-Kinas changed the title Draft: [ME] spatial extents Draft: [ME] spatial extents field Jul 31, 2024
Comment on lines 40 to 43
@Input() keywordsWithSpatialExtents: {
[key: string]: {
placeKeyword?: Keyword
spatialExtents?: DatasetSpatialExtent
}
}[]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not critical, but this component doesn't need to know anything about keywords, so it would be better if you only gave it an array of spatial extents as input. This could be done by reducing/flattening your keywordsWithSpatialExtents from the parent component before sending it to the child component.

bboxCoordsToGeometry(bbox: [number, number, number, number]): Geometry {
const geometry = new Polygon([
[
[bbox[2], bbox[3]],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is original, why not start with 0 - 1?

Copy link
Collaborator

@LHBruneton-C2C LHBruneton-C2C left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work already! Not tested yet, will try tomorrow.

@Angi-Kinas Angi-Kinas force-pushed the ME-geographical-extent branch from cf67074 to 0978a24 Compare August 7, 2024 06:38
@Angi-Kinas Angi-Kinas marked this pull request as ready for review August 7, 2024 12:43
@coveralls
Copy link

coveralls commented Aug 7, 2024

Coverage Status

coverage: 83.147% (+1.3%) from 81.886%
when pulling 2e2cd38 on ME-geographical-extent
into dd042ce on main.

@Angi-Kinas Angi-Kinas changed the title Draft: [ME] spatial extents field [ME] spatial extents field Aug 8, 2024
@jahow jahow force-pushed the ME-geographical-extent branch 4 times, most recently from dde0774 to 54a114b Compare August 22, 2024 21:33
@jahow
Copy link
Collaborator

jahow commented Aug 22, 2024

@LHBruneton-C2C @Angi-Kinas I finally managed to rework this, I have rewritten the commit history to make it more readable and hopefully easier to review.

Things I added to the original work:

  • make it so that the form-field-spatial-extent component directly reads from and writes to the editor facade; this makes it not necessary to have an elaborate logic in the record-form component because this field works with two properties (keywords and extents) instead of one
  • fixed the missing translation bug (was due to an erroneous import of TranslateModule.forRoot() in ui-map which caused another translate store to be instanced)
  • reworked the form-field-spatial-extent to make it more straightforward: the link between extents and keywords is now done directly on the keyword (by storing it in a _linkedExtent property); this works because the user only interacts with keywords so then when one is added/removed we can add and remove extents accordingly
  • wrote missing tests
  • added a searchKeywordsByThesaurus in platform service; this is useful because keywords coming from the XML record do not have a bbox or key attached; this information has to be read from the thesaurus API
  • added a missing ol.css file

This is ready for review, I hope I didn't miss anything.

edit: Coveralls is down which explains the failure in the CI, but the rest works

@jahow jahow force-pushed the ME-geographical-extent branch 2 times, most recently from 3b92553 to 2e2cd38 Compare August 23, 2024 08:53
@jahow jahow force-pushed the ME-geographical-extent branch from 2e2cd38 to 321ae56 Compare August 26, 2024 14:02
jahow added 4 commits August 26, 2024 16:12
This required adding TranslateModule to some tests in return
This fixes an issue where we can't match a deleted keywords with the
array of shown keywords because the array would be recreated on each
subscription

The generic-keywords component is also not mutating its input array (this
was causing a bug as well)
@jahow jahow force-pushed the ME-geographical-extent branch from 321ae56 to ebe9333 Compare August 26, 2024 14:12
Copy link
Collaborator

@LHBruneton-C2C LHBruneton-C2C left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking great! Thanks @Angi-Kinas and @jahow for this huge feature.
Tested draft and publishing, working as it should.

},
])
})
it('returns an empty array of the thesaurus is unknown', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('returns an empty array of the thesaurus is unknown', async () => {
it('returns an empty array if the thesaurus is unknown', async () => {

Comment on lines 138 to 142
.overrideComponent(FormFieldSpatialExtentComponent, {
set: {
changeDetection: ChangeDetectionStrategy.Default,
},
})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary anymore with the MockBuilder.

TranslateModule.forRoot(),
HttpClientTestingModule,
],
schemas: [NO_ERRORS_SCHEMA],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't wait to see more of those disappear!

@@ -17,6 +17,7 @@ export interface FormFieldConfig {
}

export interface EditorField {
id?: string
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not needed anymore, since you used the facade to retrieve multiple fields.


ngMocks.globalKeep(CommonModule, true)
ngMocks.globalKeep(BrowserModule, true)
ngMocks.globalKeep(RouterModule, true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure the Router should be kept in libs.

Copy link
Collaborator Author

@Angi-Kinas Angi-Kinas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much @jahow for making this work! It was a really big and complicated feature.

I tested the feature a bit and I think we still need to filter out the place keywords from the "other" keywords that we display on the 3rd page of the editor.
Otherwise we get issues like this:
image
And when we delete the keyword "Africa" and go back to the first page, we see:
image
WDYT?

@jahow
Copy link
Collaborator

jahow commented Aug 27, 2024

@Angi-Kinas yes you're right... could this be done in another PR? because I honestly don't feel like adding anything else to this one 😱

@Angi-Kinas
Copy link
Collaborator Author

@jahow yes you are right, I totally understand! Let's do it in another PR.

@Angi-Kinas Angi-Kinas merged commit a6f221e into main Aug 27, 2024
12 checks passed
@Angi-Kinas Angi-Kinas deleted the ME-geographical-extent branch August 27, 2024 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants