Skip to content

Commit

Permalink
headerFields instead of IGNORE_FIELDS
Browse files Browse the repository at this point in the history
  • Loading branch information
erasta committed Dec 17, 2024
1 parent b219627 commit 6eb40b4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion client/src/IO/UploadDevices/UploadDevicesFieldsDialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { groupBy } from "lodash";
import { UploadDevicesTypeFieldsMatcher } from "./UploadDevicesTypeFieldsMatcher";
import { useState } from "react";
import { changeDeviceOnTrial } from "./changeDeviceOnTrial";
import { FIELD_MAPNAME, FIELD_TYPE, FIELD_UNASSIGNED, LOCATION_FIELDS } from "./uploadDefs";
import { FIELD_MAPNAME, FIELD_NAME, FIELD_TYPE, FIELD_UNASSIGNED, LOCATION_FIELDS } from "./uploadDefs";

export const UploadDevicesFieldsDialog = ({ devicesToUpload, setDevicesToUpload, data, setData, experiment }) => {

Expand Down Expand Up @@ -54,6 +54,7 @@ export const UploadDevicesFieldsDialog = ({ devicesToUpload, setDevicesToUpload,
setAttrMatch={updater => {
setAttrMatch(prev => ({ ...(prev || {}), [deviceTypeName]: updater((prev || {})[deviceTypeName]) }));
}}
headerFields={[FIELD_TYPE, FIELD_NAME]}
/>
}
</Paper>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Grid, Stack, Typography } from "@mui/material"
import { SelectProperty } from "../../Property/SelectProperty";
import { useEffect } from "react";
import { FIELD_MAPNAME, FIELD_UNASSIGNED, IGNORE_FIELDS, LOCATION_FIELDS } from "./uploadDefs";
import { FIELD_MAPNAME, FIELD_UNASSIGNED, LOCATION_FIELDS } from "./uploadDefs";
import React from "react";
import { RealMapName } from "../../constants/constants";

Expand Down Expand Up @@ -53,14 +53,15 @@ const UploadDevicesTypeFieldsMatcherOne = ({ oneMatch, setOneMatch, attrName, at
)
}

export const UploadDevicesTypeFieldsMatcher = ({ devicesDetails, deviceType, attrMatch, setAttrMatch }: {
export const UploadDevicesTypeFieldsMatcher = ({ devicesDetails, deviceType, attrMatch, setAttrMatch, headerFields }: {
devicesDetails: { [key: string]: any }[],
deviceType: { attributeTypes: { name: string }[] },
attrMatch: { [key: string]: string },
setAttrMatch: (updater: (prev: { [key: string]: string }) => { [key: string]: string }) => void,
headerFields: string[],
}) => {
const fieldNamesOnDetails = uniq(devicesDetails.flatMap(x => {
return Object.keys(x).filter(f => !IGNORE_FIELDS.includes(f));
return Object.keys(x).filter(f => !headerFields.includes(f));
}));

const attributeTypeNames = deviceType?.attributeTypes?.map(x => x.name) || [];
Expand Down
1 change: 0 additions & 1 deletion client/src/IO/UploadDevices/uploadDefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ export const FIELD_NAME = 'name';
export const FIELD_MAPNAME = 'MapName';
export const FIELD_LATITUDE = 'Latitude';
export const FIELD_LONGITUDE = 'Longitude';
export const IGNORE_FIELDS = [FIELD_TYPE, FIELD_NAME];
export const LOCATION_FIELDS = [FIELD_LATITUDE, FIELD_LONGITUDE, FIELD_MAPNAME];

0 comments on commit 6eb40b4

Please sign in to comment.