informatics-isi-edu / ermrestjs

ERMrest client library in JavaScript
Apache License 2.0
4 stars 3 forks source link

Review the self-link syntax #950

Open RFSH opened 2 years ago

RFSH commented 2 years ago

In the visible-columns list, we have a concept of "self-link". The defined column directive should display a rowname and link to the current row. This is mainly useful in the recordset page where we want to have an alternative linkable target to the "view details" button.

This can be achieved by defining the key's constraint name using the old syntax. For example, if we have the following keys definition:

{
  "names": ["schema", "key_constraint"]
  "unique_columns": ["name"]
}

Then using ["schema", "key_constraint"] will show the self-link. The same thing can be achieved by defining a source like this:

{"source": "name", "self_link": true}

While this works, it's more limited than the old syntax:

  1. You cannot refer to a specific key if multiple keys are based on the same column.
  2. It doesn't support composite keys.

Therefore, we should see if we can develop a better syntax. And as a result, see if we want to deprecate the syntax entirely.

This came up when we talked about the possibility of changing these column directives' behavior in here.

The following are the other things that came up:

  1. Shouldn't the explicit visible column syntax be able to say "use this pattern to get the anchor text" and "use this constraint for the record identity" and fully configure it, but then heuristics might be able to choose row-name and shortest key for these two purposes
  2. If we can access the current rowname and URL the way it's described here, we should be able to mimic the same behavior as a "self-link". And then we might not need the customized "self-link" behavior of the source syntax.
  3. What about customizing the sort behavior?
  4. In regards to old syntax vs. general syntax:
    1. We ought to think in terms of deprecating some of the old syntax, and just implement it in interim however is easiest.
    2. the more general syntax ought to be simple to use to explicitly ask for the heuristic behavior while overriding it piecemeal.
    3. If the most general column directive syntax is now powerful enough, we shouldn't need to keep having so many other magic special syntax either.

We should add any other issues/changes regarding self-link here.