As a user, I should be able to edit a Planetary System.
AC
GIVEN the user is logged in and visits the Planetary System page
THEN they should see an "Edit" button on the bottom left corner of each planetary system card
AND when they click the "Edit" button
THEN a pre-populated modal will appear where they can enter the new planetary system details
AND the key value pairs for your food item will be printed to the modal as labels for an input form where the user will enter the new food details
THEN when the user clicks the "submit" button, the details for the selected item (via the values of the input form) will be updated in the Firebase data and on the module itself
AND your planetary systems will be reprinted
Dev Notes
in planetSystemData.js, write a function to get the planet systems by id so we can use it in our function that will prepopulate the modal upon clicking the "Edit" button in each card, with all the key value pairs of the selected sector:
Then write an update function that will take a planetary system Id and the value of an updated planetary system, and pass both through an axios.put function to recognize the selected planet system's id, and pass in the new values entered into the modal that will pop up on clicking the "Edit" button for each card, and update those new values in Firebase:
const editSystem = (id, updatedSystem) => axios.put(${baseUrl}/planetSystems/${id}.json, updatedSystem);
Create a function in planetSystem.js to pass through the value of the new edited sector, based on the value of the text in the input form of the modal referenced in ticket #77. Code should look something along the lines of:
Then, create a function that will take the id of the selected Sector, retrieve it's data from firebase based on id, and populate the modal inputs with prepopulated values pulled from firebase. Then the function will create an event listener for the "Submit" button on the modal and call the editedSector function created above:
Finally create an event listener at the end of displayAllSectors that will pull all the functions above together by calling updateSectorValues on click of the "Edit" button:
$(document.body).on('click', '.edit-sector', updateSystemValues);
User Story
As a user, I should be able to edit a Planetary System.
AC
GIVEN the user is logged in and visits the Planetary System page THEN they should see an "Edit" button on the bottom left corner of each planetary system card AND when they click the "Edit" button THEN a pre-populated modal will appear where they can enter the new planetary system details AND the key value pairs for your food item will be printed to the modal as labels for an input form where the user will enter the new food details THEN when the user clicks the "submit" button, the details for the selected item (via the values of the input form) will be updated in the Firebase data and on the module itself AND your planetary systems will be reprinted
Dev Notes
Then write an update function that will take a planetary system Id and the value of an updated planetary system, and pass both through an
axios.put
function to recognize the selected planet system's id, and pass in the new values entered into the modal that will pop up on clicking the "Edit" button for each card, and update those new values in Firebase:const editSystem = (id, updatedSystem) => axios.put(
${baseUrl}/planetSystems/${id}.json, updatedSystem);
Create a function in planetSystem.js to pass through the value of the new edited sector, based on the value of the text in the input form of the modal referenced in ticket #77. Code should look something along the lines of:
editedSector
function created above:displayAllSectors
that will pull all the functions above together by callingupdateSectorValues
on click of the "Edit" button:$(document.body).on('click', '.edit-sector', updateSystemValues);