1

I have this code that works great, to be able to set some parameters from outside Roomle...

import RoomleConfiguratorApi from './roomle-configurator-api.es.min.js';
(async () => {
    
  const objectToLoadId =
    "racksystems_test:sub_root:557BB1CED71F812FE72CE16E567A38B0A6D7A620EE6C70BD219163B92778C0CB";
  const configuratorId = "demoConfigurator";
  const domElement1 = document.getElementById("configurator-container");
    
  const configurator1 = await RoomleConfiguratorApi.create(
    configuratorId,
    domElement1,
    {}
    );

  await configurator1.ui.loadObject(objectToLoadId);
  const params = await configurator1.extended.getParametersOfRootComponent();
  console.log(params);
  const viewParam = params.find(({ key }) => key === "version");
  const viewCompany = params.find(({ key }) => key === "company");

  console.log(viewParam);
  console.log(viewCompany);
  configurator1.extended.setParameterOfRootComponent(viewParam, 'Rack')
  configurator1.extended.setParameterOfRootComponent(viewCompany, 'Rack Systems')
  
})();

but when I add any other code it seems to be ignored, this seems to ignore the options of just simply renaming a button, have I got the sequence wrong...

import RoomleConfiguratorApi from './roomle-configurator-api.es.min.js';
(async () => {

   const options = {
         translations: {
            en: {
                    params: {
                    'request-product': 'Save Configuration'
                    }
                }
            }
   };

  const objectToLoadId =
    "racksystems_test:sub_root:557BB1CED71F812FE72CE16E567A38B0A6D7A620EE6C70BD219163B92778C0CB";
  const configuratorId = "demoConfigurator";
  const domElement1 = document.getElementById("configurator-container");
    
  const configurator1 = await RoomleConfiguratorApi.create(
    configuratorId,
    domElement1,
    {}
    );

  await configurator1.ui.loadObject(objectToLoadId);
  const params = await configurator1.extended.getParametersOfRootComponent();
  console.log(params);
  const viewParam = params.find(({ key }) => key === "version");
  const viewCompany = params.find(({ key }) => key === "company");

  console.log(viewParam);
  console.log(viewCompany);
  configurator1.extended.setParameterOfRootComponent(viewParam, 'Rack')
  configurator1.extended.setParameterOfRootComponent(viewCompany, 'Rack Systems')
  
})();

I've tried placing the code in different orders but can't seem to get it to work at all

Michael Todd
  • 211
  • 1
  • 3

1 Answers1

1

It seems you are not using the defined options. You have to pass them into create like this:

RoomleConfiguratorApi.create(
    configuratorId,
    domElement1,
    options
);
teh.fonsi
  • 3,040
  • 2
  • 27
  • 22