Skip to content

Conversation

@jochenklar
Copy link
Member

This PR updates rdmo/projects/assets/js/project/utils/location.js to be more flexible. parseLocation and updateLocation now use both the same object as input/output:

{ page, pageId, action, actionId }

This should parse the following urls:

/projects/1/
/projects/1/interview/
/projects/1/documents/
/projects/1/documents/views/1
/projects/1/snapshots/1/
/projects/1/snapshots/1/answers
/projects/1/snapshots/1/views/1

I suggest we use the documents page for current answers/views and snapshots and snapshots for the snapshots. The highlighting of the sidebar can then just check page.

@jochenklar jochenklar requested a review from CalamityC November 28, 2025 14:32
@jochenklar jochenklar self-assigned this Nov 28, 2025
@jochenklar jochenklar added this to the RDMO 3.0.0 milestone Nov 28, 2025
@jochenklar jochenklar changed the base branch from main to 3.0.0 November 28, 2025 14:32
@CalamityC
Copy link
Collaborator

This should parse the following urls:

/projects/1/
/projects/1/interview/
/projects/1/documents/
/projects/1/documents/views/1
/projects/1/snapshots/1/
/projects/1/snapshots/1/answers
/projects/1/snapshots/1/views/1

Will it also work for
/projects/1/snapshots
projects/1/documents/answers
?

And as the Documents page contains the snapshots switch the
/projects/1/snapshots/1/views/1 somehow "belongs" there
The Snapshots page does not offer a link to the specific view of a snapshot, does it?

@CalamityC
Copy link
Collaborator

I don't quite understand how to use it

@jochenklar
Copy link
Member Author

Like this (preferably in the redux actions):

updateLocation() -> /projects/1/
updateLocation({ page: 'interview' }) -> /projects/1/interview/
updateLocation({ page: 'documents' }) -> /projects/1/documents/
updateLocation({ page: 'interview', action: 'views', actionId: 1 }) -> /projects/1/documents/views/1
updateLocation({ page: 'snapshots', pageId: 1 }) -> /projects/1/snapshots/1/
updateLocation({ page: 'snapshots', pageId: 1, action: 'answers' }) -> /projects/1/snapshots/1/answers
updateLocation({ page: 'snapshots', pageId: 1, action: 'views', actionId: 1 }) -> /projects/1/snapshots/1/views/1

When the page loads, this information is then collected from the URL and put into the config reducer: https://github.com/rdmorganiser/rdmo/blob/3.0.0-refactor-project-location/rdmo/projects/assets/js/project/store/configureStore.js#L58

const patterns = [
/\/projects\/\d+\/(?<page>[a-z-]+)\/(?<pageId>\d+)\/(?<action>[a-z-]+)\/(?<actionId>\d+)[/]*$/,
/\/projects\/\d+\/(?<page>[a-z-]+)\/(?<pageId>\d+)\/(?<action>[a-z-]+)[/]*$/,
/\/projects\/\d+\/(?<page>[a-z-]+)\/(?<action>[a-z-]+)\/(?<actionId>\d+)[/]*$/,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need this pattern also:
/\/projects\/\d+\/(?<page>[a-z-]+)\/(?<pageId>\d+)[/]*$/,

to reflect eg. /projects/1/snapshots/1/ for the documents page with a snapshot selected

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