solid-ui-react icon indicating copy to clipboard operation
solid-ui-react copied to clipboard

Fallback properties in TableColumn (and elsewhere ?)

Open calummackervoy opened this issue 4 years ago • 2 comments

Feature suggestion

At times there are multiple properties which data could include for the same information, e.g. VCARD.FN and FOAF.name for my name column

Expected functionality/enhancement

It would be great if I could define some fallback settings in the props of the TableComponent which allows me to say "try this list of priorities to display the name"

Actual functionality/enhancement

I believe that I'm bound by one property option -> one column per table. If I want to display different options, I need to use multiple tables with duplicate data or couple my code to the datasets I want to use

Use Cases

I want to write my Table to display a list of objects which have names, but I want to support common name definitions so that it can be flexible to the choices of data providers

There is also a case where a particular ontology may have multiple versions, for example http://www.w3.org/2006/vcard/ns#fn and http://www.w3.org/2001/vcard-rdf/3.0#FN, and currently the one is not displayed with the other. The dream scenario would be if the TableComponent could be permissive between different versions of the same ontology, but I see that there would be many complexities in implementing this or even hacking around it

There will be similar use cases in other components, I haven't suggested a generalised solution here because I lack the knowledge

Additional information

I started coding in React a few weeks ago using the Inrupt SDK so my experience in the framework is extremely limited, I'd be happy to attempt a PR for this but I might need help. It's also for a hobby project and my paid work naturally eats up my time, so I might be a bit slow

calummackervoy avatar Jan 20 '21 11:01 calummackervoy

Hi @calummackervoy,

We're working through a couple of different edge cases with the table display, but for now you can work around it by using a custom body component for the TableColumn. Each "body" component is wrapped in a Dataset and Thing provider, so you can use a Text, Value, or other component - each of which do implement a fallback array, and allow them to just pull the dataset/thing from context:

<Table things={[...]}>
  <TableColumn
      property="http://www.w3.org/2006/vcard/ns#fn"
      body={() => (
        <Text properties=["http://www.w3.org/2006/vcard/ns#fn", "http://www.w3.org/2001/vcard-rdf/3.0#FN"] />
      )}
  />
</Table>

We do plan on implementing this in Table at some point - I'll leave this issue open until then, but this workaround should help out.

(Also a ping for @VirginiaBalseiro who I was just talking to about this.)

ajacksified avatar Jan 26 '21 13:01 ajacksified

Thanks !

calummackervoy avatar Jan 26 '21 16:01 calummackervoy