MEng-Team-Project / MEng-Team-Project-Web

(Industrial Project) React Frontend and Node.js Backend for Traffic Analysis.
MIT License
1 stars 1 forks source link

#8 #12 #13 - Adding (+Deleting) and Updating Filters & Separate filters from Sidebar component #17

Closed Alvie closed 1 year ago

Alvie commented 1 year ago

This pull request involves changes related to issues: #8 #12 and #13 .

The filters state has been adjusted from an array of integers to an array of JS Objects that contain:

The deleteFilter function now takes the id to be deleted rather than the int value as it has been previously.

The addFilter function appends a JS Object to filters with:

The updateFilter function takes in an id to be updated, an an update object that contains the keys and values to be assigned to the filter. The update object can update one or many values of the filter.

For example if the filter is currently:

{
    id: 0.
    value: null,
    dataSrc: null
}

If the update object is :

{ value: {  meta: "...", data: "..." } }

the filter becomes:

{
    id: 0.
    value: {  meta: "...", data: "..." } ,
    dataSrc: null
}

or if the update object is:

{
    value: {  meta: "abc", data: "123" },
    dataSrc: {  meta: "xyz", data: "456" }
}

the filter becomes:

{
    id: 0.
    value: {  meta: "abc", data: "123" } ,
    dataSrc: {  meta: "xyz", data: "456" }
}