Versions Compared

Key

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

If the Claim module provides by default a "searcher" on id (of course this is not realistic... but this is not the point, here):Image Removed

...

The result of the search is a list of claims... in which insuree information is contributed by the "insuree" plugin:

extract

...

of

...

plugins/claims/ClaimList.js

...

(React

...

Component):

render() {

  const { classes } = this.props;

  return (

    <divclassName={classes.root}>

      <Listcomponent="nav">

        {this.state.claims.map((claim, index) => (

          <ClaimListItemclaim={claim}key={`claim${index}`}/>

        ))}

      </List>

    </div>

  );

}


extract

...

of

...

plugins/claims/ClaimListItem.js

...

(React

...

Component):

render() {

  const { claim } =this.props;

  return (

    <ListItem

...

buttononClick={this.handleClick}>

      <ContributedComponent {...claim}contributionKey="claims.claim.listItem">

        <ListItemText primary={`${claim.declaration_date} [${claim.id}]`}/>

      </ContributedComponent>

    </ListItem>

  );

}

The ContributedComponent component is a openIMIS Web FE core component, that enables other plugins (modules) to contribute. In this example, the contribution key is claims.claim.listItem.

So the insuree plugin can contribute by implementing

plugins/insurees/InsureeListItemContribution.js

functionInsureeListItemContribution(props) {

  if (!props.insuree) returnnull;

  return (

    props.insuree.name " " props.insuree.surname " " + props.insuree.birth_date

  );

}


exportdefaultInsureeListItemContribution;

... which gives the above (screenshot) result.

The key in such mechanism is that, while the claim module (list) displays insuree information, it doesn't have any explicite reference to it. 

So if another implementation of the insuree module provide another "list item contribution", the claim module will display it, without noticing.

Example, if, for a country we have "middle names", the insuree plugin can be adpated to provide the following contribution:

plugins/insurees/InsureeListItemContribution.js

functionInsureeListItemContribution(props) {

  if (!props.insuree) returnnull;

  return (

    props.insuree.name " " +

    (!!props.insuree.extended_attributes ? props.insuree.extended_attributes["middlename"] + " " : "" ) +

    props.insuree.surname + " " +

    props.insuree.birth_date

  );

}


exportdefaultInsureeListItemContribution;

... resulting in:

...

 (where "Roberts" is the middle name of John Doe,...)