Comment tagging#2312
Conversation
|
Looks good! |
…refilled) (#2347) * hide feature selection in web forms * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…ads (#2349) * cache form xml and ODK Web Forms js library * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
…f URLs pt1 (#2348) * feat: WIP add osm-fieldwork api for form attachment download + API endpoint * refactor: hardcode values until PR continued
for more information, see https://pre-commit.ci
| import { useAppDispatch, useAppSelector } from '@/types/reduxTypes'; | ||
| import { task_event } from '@/types/enums'; | ||
| import { featureType } from '@/store/types/ISubmissions'; | ||
| import '@/styles/rc-mentions.css'; |
There was a problem hiding this comment.
Theres no convention for this, but I always place CSS imports at the top of files to groups them / make it obvious
| "pako": "^2.1.0", | ||
| "pmtiles": "^3.0.6", | ||
| "qrcode-generator": "^1.4.4", | ||
| "rc-mentions": "^2.19.1", |
There was a problem hiding this comment.
The more react specific components we add, the more we will need to refactor in future.
I dont see the future of the management frontend being in React (in the long run).
As much as possible, could we try to use web components instead?
For example, what about this text expander web component from Github?
https://github.com/github/text-expander-element
It also picks up a specific tag (e.g. @ or #) from a text input, with a hook to do something.
I would suggest we only query the backend after 3 characters or more are typed. Hopefully this narrows it down a fair bit before searching the db
There was a problem hiding this comment.
Sure! I'll have a look at text-expander-element.
Also completely agree with you on querying after 3 characters
| SetUserListForSelectLoading: (state, action: PayloadAction<boolean>) => { | ||
| state.userListLoading = action.payload; | ||
| }, | ||
| SetUserNames: (state, action: PayloadAction<UserStateTypes['userNames']>) => { |
There was a problem hiding this comment.
This will set all available usernames from the backend into the browser right?
If we have 10,000 users at some point, do you think this would cause an issue?
No need to over-optimise at the start (we dont have 10,000 users...), but its always good to keep scalability in mind when designing solutions 👍
There was a problem hiding this comment.
So currently instead of showing all user list, I am querying if there's 1 character, but will change to 3 min character as you mentioned!
|
As a tradeoff for performance and scalability, we could consider the following:
|
|
The web component I linked provides a demo implementation: <text-expander keys="@">
<textarea autofocus rows="10" cols="40"></textarea>
</text-expander>
expander.addEventListener('text-expander-change', event => {
const {key, provide, text} = event.detail
if (key === '@') {
const menu = document.createElement('ul')
menu.classList.add('menu')
menu.role = 'listbox'
// TODO instead of hardcoding values, we would query the API if 3 characters present
for (const issue of [
'#1 Implement a text-expander element',
'#2 Implement multi word option',
'#3 Fix tpoy',
'#4 Implement #12',
'#5 Implement #123 and #456',
]) {
if (issue.toLowerCase().includes(text.toLowerCase())) {
const item = document.createElement('li')
item.setAttribute('role', 'option')
item.textContent = issue
item.setAttribute('data-value', issue.split(' ')[0])
item.id = `option-${issue}`
menu.append(item)
}
}
provide(Promise.resolve({matched: true, fragment: menu}))
} |
|
@spwoodcock tried implementing
|
|
No worries @NSUWAL123 - it was maybe a bit ambitious to use that web component, as I haven't tested it myself! It's not a huge deal, as the React frontend doesn't really use any web-components anyway - updating most things to use them would be a big undertaking. The key thing is to ensure we are using web components everywhere possible in the mapper frontend. Thanks for trying though!! 🙏 |
What type of PR is this? (check all applicable)
Related Issue
Describe this PR
Update Review State modal, & display comment via popup if the user is mentioned on the comment in mapper frontendScreenshots
Uploading Screen Recording 2025-04-09 120527.mp4…