Improvement for device, users and group connections page

brianara year ago

Hello, I wanted to make a small contribution that might be helpful to someone. The connection pages (which we use, for example, when assigning a notification or geofence to a specific device) don't display the already assigned data until they are clicked. In other words, only when clicked, all the values, both assigned and unassigned, are shown. However, before clicking, it appears as if nothing is assigned, when many times it actually is.

I just modified the LinkField.js file to allow the data to be "previewed" without the need to click anything. The goal is to continue displaying the values when clicked, but also to load them in advance, so that when going to the connection page, one can already see what is already assigned.

Here is the modified part in LinkField.js (line 15):

/* PREVIOUS CODE */
const LinkField = ({
    label,
    endpointAll,
    endpointLinked,
    baseId,
    keyBase,
    keyLink,
    keyGetter = (item) => item.id,
    titleGetter = (item) => item.name,
}) => {
    const [active, setActive] = useState(true); // THIS LINE HAS BEEN MODIFIED, IT WAS PREVIOUSLY FALSE.
    const [open, setOpen] = useState(false);
    const [items, setItems] = useState();
    const [linked, setLinked] = useState();

    useEffectAsync(async () => {
/* REMAINING CODE */

That's all, it's just one line that changes from having a value of 'false' to a value of 'true'.

The previous line was:

const [active, setActive] = useState(true);

And the new one is:

const [active, setActive] = useState(true);
Track-trace2a year ago

Im sure you mean;

The previous line was:

const [active, setActive] = useState(false);

I'm going to try it to see what it does.

Anton Tananaeva year ago

It is intentional that we don't preload all the data. It will require a lot of API calls, most of which are unnecessary.

brianara year ago

Thank you, Track-trace2, for the response. Yes, I did mean 'false', my mistake. And thank you, Anton, as well for your response. The system works great, and this modification is minor but specifically beneficial for us. Regards!