Page tree

Versions Compared

Key

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

...

Code Block
languagexml
titleHTML page example
<html>
<head>
  <title>HydraOMS Widget</title>
  <script type="text/javascript" src="${hbw_public_path}/assets/hbw.js"></script>
  <link rel="stylesheet" type="text/css" href="${hbw_public_path}/assets/hbw.css">
</head>
<body>
  <div class="hbw-styles">
   <div id='hbw-container'>
   </div>
  </div>
  <script type="text/javascript">
    var config = {
      widgetURL: 'https://homs.some.domain', // hbw_public_path, important for WebSocket connection
      entity_class: 'crm_account',
      entity_type: 'customer',
      container_id: 'hbw-container', // Same as <div> id
      userIdentifier: 'user@example.com', // user identifier for Web-Socket connection
      locale: {
        code: 'en', // locale code
        dateTimeFormat: 'MM/DD/YYYY' // date-fns fomat
      }
    };
    var entityId = ...; // Set here id or other uniq value of entity, like customerId
 
    window.hbw_widget = new (modulejs.require('HBW'))({
      userIdentifier: config.userIdentifier,
      widgetContainer: `#${config.container_id}`,
      widgetURL: config.widgetURL,
      widgetPath: '/widget',
      entity_class: config.entity_class,
      entity_type: config.entity_type,
      entity_code: `${entityId}`,
      locale: config.locale,
      payload: {
        variables: {
          someInitialVariable: { // You can pass other useful information to process initial _variables
            value: 'initialValue',
            type: 'string'
          }
        }
      }
    });
 
    window.hbw_widget.render();
 
    // If you use some kind ot SPA (Single Page Application), call this before exiting current page:
    // window.hbw_widget.unmountWidget();
  </script>
</body>
</html>

...