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

Add Read-Only Project View, Add Username to Projects Table #144

Merged
merged 5 commits into from
Feb 15, 2024

Conversation

mgdaily
Copy link
Contributor

@mgdaily mgdaily commented Feb 15, 2024

This PR adds an "inspect" button to the projects table, which opens up a read-only view of the CreateProjectForm, pre-populated with the data that needs to be displayed.

RightAscensionInput/DeclinationInput/ProjectSitesSelector:

  • Add "disabled" prop so the underlying input fields may be disabled

CreateProjectForm

  • Go through and conditionally disable each input/field/checkbox if the form is read-only
  • Adjust the props to have defaults so we can set read-only to false by default

UserProjectsTable

  • Add "inspect" button to table row, which fetches the project, saves whatever is currently entered into the form into the store to be reloaded after the inspector is closed, and emits an inspect-project signal along with the project data for the so the parent SiteProjects component can pop up and render the modal.
  • Add username as column, make sortable

SiteProjects

  • Add modal that is hidden by default, but will be shown and render a read-only CreateProjectsForm, with all data from the project that has been selected for inspection.

project_params store module

  • Add a draft_project_params store variable to hold the draft of the project that's been entered into the project form prior to the user clicking "inspect," so that they may be re-loaded when the user closes the inspection tab. Unfortunately the CreateProjectForm is tightly coupled to the vuex store and whenever we render a new instance of that component, it overwrites the data in the project_params module of the store - so we need to keep a history of anything that was entered into the form, if the user had done that.
  • Add actions to both save and re-load a project draft from the store.

Video!

Screen.Recording.2024-02-15.at.11.24.33.AM.mov

Still need to clean up footer in component and conditionally render based on read_only state.
When re-rendering the project form, any project data passed to the component is written to the project_params in the store. This effectively nukes any input that has already been made in the creation of a new project, so make sure we save the draft off before showing the project view. Also add user ID to projects table and make it sortable.
@mgdaily mgdaily requested review from LTDakin and capetillo February 15, 2024 19:27
rewrite_state (state, val) {
// loop through and rewrite the state
for (const stateItem in val) {
Vue.set(state, stateItem, val[stateItem])
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to restore the state from the draft_project_params, we need to loop through every attribute in the draft params and set the corresponding state variable.

const project_loader = {
project: response.data
}
this.$store.dispatch('project_params/saveProjectDraft')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the new CreateProjectForm is rendered with project data, it re-writes the current project data in the store, so we need to first save off anything that has been entered before we destroy it, so we can load it back later!

data () {
return {
localDec: null,
localDec: this.value,
Copy link
Contributor Author

@mgdaily mgdaily Feb 15, 2024

Choose a reason for hiding this comment

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

Here we default the localDec value to the prop that was passed in - I was having an issue when I was re-rendering the component, the dec wasn't displaying even though the value was being passed. So set the default to the value passed in. (I had to do the same with the RightAscensionInput)

@mgdaily mgdaily requested a review from jnation3406 February 15, 2024 20:00
Copy link
Contributor

@LTDakin LTDakin left a comment

Choose a reason for hiding this comment

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

Like the reuse of the form component, and how closing the inspection reloads from drafts. Lgtm

Copy link
Contributor

@capetillo capetillo left a comment

Choose a reason for hiding this comment

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

beautiful! also thank you for the video, that's very helpful : )

@mgdaily mgdaily merged commit 43e4b82 into dev Feb 15, 2024
1 check passed
@mgdaily mgdaily deleted the feature/inspect-project branch February 15, 2024 22:16
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