nss-evening-cohort-10 / nutshell-star-destroyer

0 stars 1 forks source link

Mission Weapons: Update #93

Closed John-Ryan-Johnson closed 4 years ago

John-Ryan-Johnson commented 4 years ago

User Story

As a user, I should be able to edit a mission weapon.

AC

GIVEN the user is logged in and visits the Missions page WHEN the user clicks the edit button on the Mission Weapons card THEN a modal will pop up with prepopulated fields for the mission weapon

WHEN the save button on the modal is clicked THEN the updated object is sent to firebase AND the dom is updated

Dev Notes

The function should look like something along the lines of the following:

import missionWeaponsData from '../helpers/data/missionWeaponsData.js'

const updateMissionWeaponFromModal = (e) => { const missionWeaponId = e.target.whereverYouPlantToAttachTheID; const newMissionWeapon = { name: $('#weapon-name').val(), isActive: isCurrentWeaponActive, teamSize: $('#team-size').val() * 1, type: $('#weapon-use').val(), img: $('#weapon-image-url').val(), }; missionWeaponsData.updateMissionWeapon(missionWeaponId, updatedMissionWeapon) .then(() => { $('#modalID').modal('hide'); // eslint-disable-next-line no-use-before-define createMissionWeaponCard(); }) .catch((error) => console.error(error)); };

create an event listener that targets the id of the "Save" button from the modal, and calls updateMissionWeaponFromModal on click of the "Save" button

Missions3

gregkorte commented 4 years ago

In dev notes: Bullet 1: URL: ${databaseURL}/crew/$missionWeaponId}.json should read URL: ${databaseURL}/missionWeapon/$missionWeaponId}.json