-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: development
Are you sure you want to change the base?
Conversation
…response document hierarchy
…eSeeTea/zebra-dev into feat/resources-screen
add ResourceFile entity and repository for file handling
saveResource(formData: ResourceFormData): FutureData<void> { | ||
const { entity: resource, uploadedResourceFile } = formData; | ||
|
||
if (!resource) throw new Error("No resource form data found"); |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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 => { |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add translation
There was a problem hiding this 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?
good suggestion! thanks Ana, I have added it to the PR now 😁 |
📌 References
📝 Implementation
select
form field to haveaddNewOption
propMetadata changes
RTSL_ZEBRA_ACCESS_RESOURCES
user group created for users with access to download resources onlyRTSL_ZEBRA_DATA_CAPTURE_RESOURCES
user group created for users with access to download, upload and delete resourcesRTSL_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