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

DESENG-689: Add image widget #2586

Merged
merged 4 commits into from
Sep 10, 2024
Merged

Conversation

NatSquared
Copy link
Contributor

@NatSquared NatSquared commented Sep 9, 2024

Issue #: 🎟️ DESENG-689

Description of changes:

  • Feature Add image widget
    • Added a new "ImageWidget" widget type in the API
    • Image widgets can have a title, optional description, uploaded image, and optional alt text
    • Added image widget option to the engagement authoring wizard
    • Added image widget display for the engagement view page

User Guide update ticket (if applicable):
https://citz-gdx.atlassian.net/browse/DESENG-705

@codecov-commenter
Copy link

codecov-commenter commented Sep 9, 2024

Codecov Report

Attention: Patch coverage is 60.16949% with 47 lines in your changes missing coverage. Please review.

Project coverage is 75.80%. Comparing base (9e5a4f8) to head (ae7b6b9).

Files with missing lines Patch % Lines
...t-api/src/met_api/services/widget_image_service.py 36.11% 23 Missing ⚠️
met-api/src/met_api/resources/widget_image.py 63.26% 18 Missing ⚠️
met-api/src/met_api/models/widget_image.py 72.72% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2586      +/-   ##
==========================================
+ Coverage   75.74%   75.80%   +0.05%     
==========================================
  Files         603      607       +4     
  Lines       21811    21881      +70     
  Branches     1811     1810       -1     
==========================================
+ Hits        16521    16587      +66     
- Misses       5028     5032       +4     
  Partials      262      262              
Flag Coverage Δ
metapi 87.14% <60.16%> (-0.31%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
met-api/src/met_api/constants/widget.py 100.00% <100.00%> (ø)
met-api/src/met_api/models/__init__.py 100.00% <100.00%> (ø)
met-api/src/met_api/resources/__init__.py 100.00% <100.00%> (ø)
met-api/src/met_api/schemas/widget_image.py 100.00% <100.00%> (ø)
met-web/src/apiManager/endpoints/index.ts 100.00% <ø> (ø)
met-web/src/apiManager/httpRequestHandler/index.ts 47.61% <ø> (-2.39%) ⬇️
met-web/src/components/common/Input/TextInput.tsx 100.00% <ø> (ø)
.../components/engagement/admin/view/AuthoringTab.tsx 25.92% <ø> (-1.35%) ⬇️
...gement/form/EngagementWidgets/WidgetCardSwitch.tsx 100.00% <ø> (+81.63%) ⬆️
...gement/form/EngagementWidgets/WidgetDrawerTabs.tsx 100.00% <ø> (ø)
... and 9 more

@Baelx
Copy link
Collaborator

Baelx commented Sep 9, 2024

Should we create a ticket for documentation in the user guide? Anything holding us back from that?

@NatSquared
Copy link
Contributor Author

Should we create a ticket for documentation in the user guide? Anything holding us back from that?

Created a ticket - https://citz-gdx.atlassian.net/browse/DESENG-705

Copy link
Collaborator

@Baelx Baelx left a comment

Choose a reason for hiding this comment

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

Thanks for this Nat! Also nice of you to keep adding support for the old engagement view. We may want to try to save ourselves some work and ask Steve if we need to keep doing that.

Before proceeding, could you please just let me know:

  • If all form labels are properly associated with controls
  • If the uploaded image gets deleted when a widget is deleted. We'll need to make sure we're doing that

setValue('image_url', '', { shouldValidate: true, shouldDirty: true, shouldTouch: true });
};

const handleUploadImageFile = async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

When a widget is deleted, does the corresponding uploaded image get deleted?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No; there is currently no mechanism for this in MET

<form onSubmit={uploadImageAndSubmit}>
<Grid container direction="row" alignItems={'flex-start'} justifyContent="flex-start" spacing={2}>
<Grid item xs={12}>
<MetLabel>Description</MetLabel>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Form label elements require some mechanism for associating them with inputs. Please review: https://www.w3.org/WAI/tutorials/forms/labels/

I know TextField may have a mechanism for autogenerating its own label, I'm not sure if that's at play here.

name="image_url"
control={control}
render={({ field }) => (
<ImageUpload
Copy link
Collaborator

Choose a reason for hiding this comment

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

Jareth seemed to say that there wasn't an easy way to label the ImageUpload component. If that's the case then don't worry too much about labelling it if it's work. I've created a separate ticket for it

}
const response = await http.PostRequest<GeoJSON>(Endpoints.Maps.SHAPEFILE_PREVIEW, formdata);
const response = await http.PostRequest<GeoJSON>(url, formdata, {}, { 'Content-type': 'multipart/form-data' });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Was the linter throwing errors here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was a small bugfix I implemented to fix an issue with file uploading on the Map widget that turned out not to be related to the Image widget the way I thought it was. I accidentally left it in this PR; should I remove it?

Copy link
Collaborator

@Baelx Baelx Sep 10, 2024

Choose a reason for hiding this comment

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

You don't need to review it but for small, unrelated fixes, the PR description is a great place to mention those!

@NatSquared
Copy link
Contributor Author

Before proceeding, could you please just let me know:

  • If all form labels are properly associated with controls

✅ All form controls now have labels associated where possible.

  • If the uploaded image gets deleted when a widget is deleted. We'll need to make sure we're doing that

☑️ Ticket created to follow up with deleting images from widgets, engagements, etc

…/Form.tsx

Co-authored-by: Baelx <alexander.wintschel@gov.bc.ca>
Copy link

@NatSquared NatSquared merged commit 6ba4401 into main Sep 10, 2024
13 of 15 checks passed
@NatSquared NatSquared deleted the feature/DESENG-689-add-image-widget branch September 10, 2024 16:40
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.

3 participants