Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

As per the vocabulary, the Registry is designed as a storage place for apps outside of ui-dashboard to register resources. These will then become available to dashboard for the purposes of dynamic interactions between different frontend apps.

...

A RegistryResource is a class containing information about a particular resource of the registry. It has fields that are technically publically available, but they should only be accessed through the requisite getters and setters.

Once https://github.com/tc39/proposal-private-methods#private-methods-and-fields or equivalent become available and supported, these fields should be made private. This class contains the following methods with which to interact with it:
 

Warning

The templating parts below are not yet implemented and are likely to change as the project iterates forwards.

...

This function sets a string field "viewAll", which should reflect a basic URL path for a "view all" page for the resource. In the case of agreements it would be "/erm/agreements/"

addViewAllTemplate(template)

Sets a function field "viewAllTemplate", which should take some parameters, such as filterList, or a backend search query, and returns a URL which reflects that search in the frontend.

addViewTemplate(template)

Sets a function field, "viewTemplate" which will take an object representing the resource in question and wiwill return a URL to find that resource in the frontend. For example agreements would take an agreement, and use its ID field to return something of the form "/erm/agreements/03b7f730-66fe-4bfa-9838-062e903d36fa"

getViewAll()

saffsaReturns the viewAll field above.

getViewAllTemplate()

adsgsdgReturns the "viewAllTemplate" field above

getViewTemplate()

dagagReturns the "viewTemplate" field above

addLookupComponent(component)

...

Takes in a react component and assigns it to the field "lookupComponent".

This component can make use of the following props:

  • disabled: a boolean reflecting whether the lookup component ought to be active or not
  • id: a string to ensure uniqueness within the React component heirachy. For example SimpleSearch uses the LookupComponent in its "filters" FieldArray and so passes the id

    Code Block
     "`simple-search-filter-field-card[${index}]`"


  • input: an object passed by Final Form fields. This is to enable the lookup component to be used within forms.


  • onResourceSelected: a function which handles what to do when the selected resource changes
  • resource: The currently selected resource as handled by the component calling the LookupComponent, can be used for display purposes. 


getLookupComponent()

asdgadgdsReturns the lookupComponent above.

setRenderFunction(name, func)

...

Sets a new key in a Map field "renderFunctionMap", and assigns it a function "func" as a value. This can be used to calculate/display fields in a complicated manner. 
For example "agreements" might declare:

Code Block
agreementReg.setRenderFunction('currentPeriodStartDate', record => {
  const date = record.periods.find(p => p.periodStatus === 'current')?.startDate;
  return date ?
    <FormattedUTCDate value={date} /> :
    <NoValue />;
});


getRenderFunction(name)

sfahf