As a user, I should be able to add Personnel to a Mission.boards.
AC
WHEN the page loads I should see all boards
THEN click a button to see all pins
AND click a button to return back to my boards
WIREFRAMES
DEV NOTES
// 1. make smash function called getMissionsPersonnel
// 2. move missionData.getMissions into that smash function - nothing should look different
// 3. in smash function - getMissionPersonnel, getAllPersonnel
// 4. smash function to return an array of mission objects- each mission object should have an
// array of personnel. Each personnel should have a boolean isChecked (true if that personnel is on that mission)
// 5. modify domstring to show checkboxes
// 6. when a checkbox is checked - POST to missionPersonnel collection
// 7. when a checkbox is unchecked - DELETE to missionPersonnel collection
Create a controller function:
const missionPersonnelController = (e) => {
e.preventDefault();
// console.log(e.target.dataset);
if (e.target.checked) {
// create a new missionPersonnel
const newmissionPersonnel = {
missionId: e.target.closest('.card').id,
personnelId: e.target.dataset.personnelId // data-personnel-id
};
missionPersonnelData.addmissionPersonnel(newmissionPersonnel)
.then(() => {
// eslint-disable-next-line no-use-before-define
buildMissions();
utils.printToDom('new-mission', '');
utils.printToDom('personnel-div', '');
})
.catch((err) => console.error('could not create mission personnel', err));
} else {
// delete a missionPersonnel
const missionPersonnelId = e.target.id;
missionPersonnelData.deletemissionPersonnel(missionPersonnelId)
.then(() => {
// eslint-disable-next-line no-use-before-define
printPersonnel();
utils.printToDom('new-mission', '');
utils.printToDom('personnel-div', '');
})
.catch((err) => console.error('could not delete mission personnel', err));
}
};
USER STORY
As a user, I should be able to add Personnel to a Mission.boards.
AC
WHEN the page loads I should see all boards THEN click a button to see all pins AND click a button to return back to my boards
WIREFRAMES
DEV NOTES
RELATED TICKETS
EX. #1