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

[feature]: Create resources #51

Open
wants to merge 25 commits into
base: development
Choose a base branch
from
Open

Conversation

deeonwuli
Copy link
Contributor

📌 References

📝 Implementation

  • Create form for users to upload resource templates files and response documents by folder
  • Give user permissions to the resources based on their user group
  • Allow users to download and delete resources
  • Extend select form field to have addNewOption prop

Metadata changes

  • RTSL_ZEBRA_ACCESS_RESOURCES user group created for users with access to download resources only
  • RTSL_ZEBRA_DATA_CAPTURE_RESOURCES user group created for users with access to download, upload and delete resources
  • RTSL_ZEBRA_ADMIN_RESOURCES user group created for users with access to download, upload, and delete resources and create response document folders as well

📹 Screenshots/Screen capture

Screen.Recording.2025-01-13.at.15.09.01.mov

🔥 Notes to the tester

Test link:
https://metadata.eyeseetea.com/rsl-zebra240/api/apps/ZEBRA-test-resources/index.html

#8696yv1th

saveResource(formData: ResourceFormData): FutureData<void> {
const { entity: resource, uploadedResourceFile } = formData;

if (!resource) throw new Error("No resource form data found");
Copy link
Contributor

Choose a reason for hiding this comment

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

Try to use Future.error instead of this directly

if (!uploadedResourceFile) return Future.error(new Error("No file uploaded"));

return this.getAllResources().flatMap(resourcesInDataStore => {
return this.uploadFile(uploadedResourceFile).flatMap(resourceFileId => {
Copy link
Contributor

@anagperal anagperal Jan 15, 2025

Choose a reason for hiding this comment

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

I think that this repository has to be in charge of only Resouce and the ResourceFileD2Repository is the one in charge of download or upload the ResourceFile. So instead of doing here the upload you can manage the upload in the use case, add the id to Resouce and then pass the Resource (because ResourceFormData is something that comes from the presentation, we need the entity) and save it in this repo.

}

deleteResource(fileId: Id): FutureData<void> {
return apiToFuture(this.api.files.delete(fileId)).flatMap(response => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Also move this to ResourceFileD2Repository and in the use case DeleteResourceFileUseCase first delete the ResourceFile and then delete the Resource

public execute(): FutureData<Resource[]> {
return this.resourceRepository
.getAllResources()
.flatMap(resources => Future.success(resources));
Copy link
Contributor

Choose a reason for hiding this comment

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

not need the flatMap

}}
/>

<Button onClick={onAddNewOption}>Add</Button>
Copy link
Contributor

Choose a reason for hiding this comment

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

add translation

Copy link
Contributor

@anagperal anagperal left a comment

Choose a reason for hiding this comment

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

Congrats @deeonwuli for the work done!! 🎉
I have left a few comments about the code and just a suggestion as to how it works: when you are going to delete something by clicking on the trash icon maybe it would be better to show a modal for double confirmation, just in case?

@deeonwuli
Copy link
Contributor Author

Congrats @deeonwuli for the work done!! 🎉 I have left a few comments about the code and just a suggestion as to how it works: when you are going to delete something by clicking on the trash icon maybe it would be better to show a modal for double confirmation, just in case?

good suggestion! thanks Ana, I have added it to the PR now 😁

@deeonwuli deeonwuli requested a review from anagperal January 15, 2025 16:11
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.

2 participants