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

Rename existing files #450

Merged
merged 41 commits into from
Oct 2, 2024
Merged

Conversation

droberts-ctrlo
Copy link
Contributor

Requires merging of #449 before merge

  • Updated datum::File to check file name for marking datum as changed
  • Removed rename within file post request and placed within a put request
  • Updated DocumentComponent as required
  • Removed debug statements
  • Modified edit.tt as required

…ectly

Will now rely on `FormData` methods for catching erroneous objects being passed in - it may be worth working towards a more robust mapper for future use, but for now, it is felt that this version is more than suitable for our needs.
Missed a log statement that is no longer required - this has been removed
This just makes my life easier - these are only useful for TS usage
- Added check for renaming in API endpoint as well as functionality to perform the rename
- Cleaned up some code within `DocumentComponent`, namely:
    - made `el` property `readonly` - this was because I believed it was being overwritten somewhere (see next point)
    - the `updateProgress` function wasn't firing correctly and couldn't find the element it was supposed to be linked to - this has been removed (although it now means the code isn't as DRY)
    - Changed the `showerror` function in an attempt to make result consistent across calls
- Added input and button for document renaming and implemented logic
    - as noted in the code - for some reason I wasn't able to modify the `original-name` data attribute within the component using `event.target` so I had to pass the button in directly - frankly, TypeScript appears to have dropped the ball somewhere on this - I would upgrade the version of TS, Babel, Webpack, etc. but I'm not insane enough to go down that rabbit-hole - this is deemed the lesser of two evils in my opinion.
- Updated `datum::File` to check file name for marking datum as changed
- Removed rename within file post request and placed within a put request
- Updated `DocumentComponent` as required
- Removed debug statements
- Modified `edit.tt` as required
@abeverley
Copy link
Contributor

Thanks - this broadly looks fine, although there is a lot of duplicated code between the new put route and the existing post route. Can we combine some of this in a common function?

@droberts-ctrlo droberts-ctrlo mentioned this pull request Aug 9, 2024
@droberts-ctrlo
Copy link
Contributor Author

Thanks - this broadly looks fine, although there is a lot of duplicated code between the new put route and the existing post route. Can we combine some of this in a common function?

I'm not sure I can entirely see that—the only common code between the two seems to be where the file is created, and that's only (really) one statement. I will add that I may be completely wrong here, so I'll take another look anyway.

I'll add the security checks and the checks for a "new" record for now (although, in theory, the fact it's a new file should be passed as a parameter in the same way the delete option is in the post request).

Also applied perltidy using current config and modified output accordingly
It appears that using `find_with_permission` on the `Fileval` gives a datum object. Due to the only reason you would be able to access the field in this manner for a rename would be if you already have permission, this is seen as an over-complication.
Also updated styling
Following feedback from UX testing, further changes complete and pushed
@droberts-ctrlo
Copy link
Contributor Author

I don't know why the Firefox test is failing. This version contains the latest version of Dev as of 19/09/24 and the fixes from PR #459, which is why it has so many changes. Please merge #459 first, and I shall check the changes before merging to make sure nothing has fallen apart.

- Added old name to rename button event in order to revert the result on error
- Exported `RenameEvent` to keep things DRY
- Modified specifiers on multiple elements within `DocumentComponent` as events were being fired across the board rather than having required specificity
- Removed error as this wasn't displaying correctly
- Moved to async methods as IE11 is no longer in use to add clarity to code
- Refactored out progress function and bound as required (DRY)
- Discovered server is returning errors as strings, not as JSON objects (this will become a new ticket as a bug) so ensured that these are being parsed as required
- Added check for invalid characters on upload
- Allowed specific special characters on upload (underscore and dash)
Any invalid characters will be replaced when the file is saved to the record, but it is felt that the error still remain regardless.
package.json Show resolved Hide resolved
src/frontend/js/lib/component.js Outdated Show resolved Hide resolved
src/frontend/js/lib/component.ts Outdated Show resolved Hide resolved
src/frontend/js/lib/logging.js Show resolved Hide resolved
views/edit.tt Show resolved Hide resolved
@abeverley abeverley merged commit 948394a into ctrlo:dev Oct 2, 2024
1 of 6 checks passed
@droberts-ctrlo droberts-ctrlo deleted the file-rename-existing branch October 2, 2024 15:50
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