advweb-grp1 / advanced-web-final-year-project

Final year advanced web develop unit project
MIT License
1 stars 0 forks source link

Delete Data #9

Closed rwx-yxu closed 1 year ago

rwx-yxu commented 1 year ago

Summary

The user wants to delete their experimental data from the repository.

Basic Path

  1. The use case starts when a user indicates that he/she wants to delete data from the system.
  2. The system presents a dialog for the user to enter details regarding the data.
  3. The system checks that the data exists.
  4. The system authenticates and verifies the user credentials against the data.
  5. The system retrieves the data.
  6. The system asks for final confirmation from the user.
  7. The system deletes the data.
  8. The system records a timestamp.
  9. The system displays a deletion confirmation message and sends a confirmation email to the user.

    Alternative Paths

    Step 4: If the system is unable to verify the user’s credentials against the stored data, the system displays a message and repeats step 2. Step 3: If the data does not exist, the system displays a message and repeats step 2.

    Exception Paths

    The user can cancel the operation before step 7.

    Preconditions

    The data exists in the repository.

    Postconditions

    The data no longer exists in the repository.

LiamSingh64 commented 1 year ago

I will be assuming the User has made a query that has returned data (either Heart or Personal) in a table format. When this table component is being generated, i'm thinking a simple button can be added onto the end of the table row, that may either have data associated with it or grabs data from the row it is on, and when clicked it uses that data (user_id/document_id) to delete the row. I think this will look quite streamlined.

Or, when the user click on some data/row, a modal appears with maybe the same form they used when inputting the data (for consistency) that is prepopulated with that data. And an Update and Delete button is there.

In terms of components, I don't think I will need anything massive, rather the allowance of a button in however we decide to show/display the data.

advweb-grp1 commented 1 year ago

Prerequisite component assume would be a grid table of that lists out the data.

LiamSingh64 commented 1 year ago
LiamSingh64 commented 1 year ago

Deleting a Document

Imports

import { firebaseStore } from "@/firebase/database"; import { doc, getDoc } from "firebase/firestore";

Get Document

const doc_ref = doc(firebaseStore, "collection_name", "test_document_id"); const docSnap = await getDoc(doc_ref);

Delete a Document

docSnap.exists() returns True if document is found deleteDoc(docSnap.ref) Deletes document

LiamSingh64 commented 1 year ago

Composable Attempt

async function deleteDocument(doc_id){ const doc_ref = doc(firebaseStore, "hcm", doc_id); const docSnap = await getDoc(doc_ref); if( docSnap.exists() ){ deleteDoc(docSnap.ref); } }

advweb-grp1 commented 1 year ago

Do not need to send confirmation email to user. Spec page 4 heading 8

advweb-grp1 commented 1 year ago

Delete buttons should only appear on data that the user has added only.

advweb-grp1 commented 1 year ago

Done