Configurator

Configurator

Creates a new equipment configurator.

Constructor

new Configurator(skv_config, skv_data)

Source:
Parameters:
Name Type Description
skv_config struct
skv_data struct

Most likely data taken directly from Pluto

Members

equipment_data

Source:

All the equipment data

selected_options

Source:

Loop over the equipment to see which options are selected, run after dependencies have been handled

totals

Source:

Loop through all equipment and add up totals

totals_data

Source:

Totals of options, co2 etc

Methods

(static) calculateLeaseCost(price, skv_lease_terms) → {number}

Source:

Calculate lease cost

Parameters:
Name Type Description
price number
skv_lease_terms struct
Returns:
Type
number

(static) calculateSalsacCost(skv_equipment, skv_lease_terms) → {number}

Source:

Calculate Salsac cost

Parameters:
Name Type Description
skv_equipment struct
skv_lease_terms struct
Returns:
Type
number

(static) createGroupId(str_name) → {string}

Source:

Build a group id based on the mf group name

Parameters:
Name Type Description
str_name string

Name of group

Returns:

id

Type
string

(static) getDisplayCost(skv_equipment, skv_config) → {number}

Source:

Get the cost depending on whether we want net or gross, calculate effect of lease terms if present, do some rounding to 2 dp

Parameters:
Name Type Description
skv_equipment object

Equipment object

skv_config struct

Struct of config set in constructor but may subsequently be updated

Returns:
Type
number

(static) getStructuredMFgroupData(arr_flat_equipment, panel_id) → {array}

Source:

Loop through looking at panel group and whether its a standard or option

Parameters:
Name Type Description
arr_flat_equipment array

Array of unordered equipment

panel_id string

String of panel id e.g paint or options-list

Returns:

Array of groups (with their items) based on the panel group

Type
array

(static) removeNotAllowedEquipment(skv_config, arr_equipment) → {array}

Source:

remove equipment that isn't allowed for example those that fall outside option price limiting

Parameters:
Name Type Description
skv_config struct
arr_equipment array

Flatted array of equipment structs (standards and options)

Returns:

Array of any remaining equipment items

Type
array

(static) updatePackedEquipmentCost(equipment) → {struct}

Source:

packed equipment may need its price modifying due to tax or finance

Parameters:
Name Type Description
equipment array
Returns:
Type
struct

action(payload)

Source:

action

Parameters:
Name Type Description
payload struct

Type of action (click, update etc), id of equipment

addAdditionalStateData(str_state)

Source:

Get the specified state data and do any calculating required

Parameters:
Name Type Description
str_state string

current / undo / initial

cloneState(state_name) → {object}

Source:

Deep clone State

Parameters:
Name Type Description
state_name string

Which state to clone?

Returns:

State object

Type
object

createEquipmentObjectsAndMap(skv_config, arr_equipment) → {array}

Source:

Add any required properties for the initial setup

Parameters:
Name Type Description
skv_config struct
arr_equipment array

Flatted array of equipment structs (standards and options)

Returns:

Array of any additional or tweaked equipment structs

Type
array

dependencyToggle(payload)

Source:

dependency button clicked

Parameters:
Name Type Description
payload struct

dispatch()

Source:

Send out the current state of the equipment

Fires:
  • EQUIPMENT:STATE_CHANGE

equipmentClicked(payload)

Source:

Starting point to handle the equipment click

Parameters:
Name Type Description
payload struct

Type of interaction and id of equipment interacted with

getInfoOrDependencyState(id) → {boolean}

Source:

Find whether an info or dependency button is open

Parameters:
Name Type Description
id number

Equipment id

Returns:
Type
boolean

getPanels(skv_data) → {array}

Source:
Parameters:
Name Type Description
skv_data struct

Struct of standards and options structured to match the API call

Returns:

Array of panels that have standards and options split up according to their panel group

Type
array

infoToggle(payload)

Source:

info button clicked

Parameters:
Name Type Description
payload struct

setupData(skv_config) → {struct}

Source:

Combine the data in to one single equipment array

Parameters:
Name Type Description
skv_config struct
Returns:

Pluto API data

Type
struct

undoOptionSelection()

Source:

Undo options selection

updateConfig(payload)

Source:

Update config

Parameters:
Name Type Description
payload