Versions Compared

Key

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

...

Code Block
languagehtml
<html>
<head>
  <script src="https://dev-meglerpakke.ambita.com/package/mflex.umd.js" charset="utf-8"></script>
</head>
<body>
  <h1>
    Welcome to Ambita Infoland components!
  </h1>
  <div id="search" style="height: 75px"></div>
  <div id="product-list"></div>
  <button id="confirm">Confirm order</button>

  <script>
    document.addEventListener('DOMContentLoaded', () => {
      window.Ambita.mFlex.init({
        environment: 'beta',
        token: {
          access_token: '74246ace-f71f-423f-951a-8a9816a3319a',
          token_type: 'Bearer',
          expires_in: 3600,
          refresh_token: '80194947-73f6-47f6-92ca-66803abb7686',
          scope:['infoland.flex'],
          expires_at: '2022-09-27T07:47:49.774Z'
        },
        reference: 'test'
      });

      window.Ambita.mFlex.search.onSearchResult = (result) => {
        console.log(result);
      };

      window.Ambita.mFlex.search.load('#search');

      window.Ambita.mFlex.productList.load('#product-list', {
        share:{},
        cadastre:{
          knr: '0301',
          gnr: '224',
          bnr: '64',
          snr: '18'
        }
      });

      const confirmButton = document.getElementById('confirm');
      confirmButton.addEventListener('click', async () => {
        const orderNumber = await window.Ambita.mFlex.productList.confirmOrder();

        console.log(orderNumber);
      });
    });
  </script>
</body>
</html>

Component set up

Ambita.mFlex.receipt

This function will load the receipt component. Which shows current status about the products, the propertydata the documents were ordered on. As well as the possibility to download the files on the product.

...

Additional component setup

Ambita.mFlex.init

This is used for configuration and injection of the components

...

Name

Required

Type

Options

Description

environment

True

string

beta & prod

The environment you want connect to

token

True

object / string

This is where you pass in the token object for the logged in user, returned from the authentication service, see Authentication for more information.

reference

True

string

The reference property is added to the order when placed. This must be something that connects the order to the entity in your application that the user can relate to and have an understanding of. Could be an ID or key unique to an assignment or a project. The reference will show up on the invoices from Ambita

technicalReference

False

string

The technical reference is added to the order and can be used by your application, in case you want to track the orders. We recommend using this when handling file deliveries, see File deliveries .

externalDepartmentId

False

number

Used in spesial cases only

Ambita.mFlex.productList.load

This function will load product list and takes in a json object as a search query.

...

Name

Description

key

If you have used the search to find the property, the object from the result will contain a address key, add it here, some properties has multiple addresses.

Anchor
order
order
Ambita.mFlex.productList.confirmOrder

This function will confirm the order with selected products

Code Block
(async () => {
  try {
    const orderNumber = await window.Ambita.mFlex.productList.confirmOrder();
    // do something with orderNumber
  } catch(error) {
    notifyCustomer(error.message);
  }
})();

Ambita.mFlex.search.load

This function will load the search inside a element

Code Block
window.Ambita.mFlex.search.load('query-selector');

Ambita.mFlex.search.onSearchResult

Set this property to a function, this will be triggered whenever the user finish the search

...