import { IModel , getProp } from "@esri/hub-common" ; param { Object } siteModel param { Objet } pageModel export function ensurePageHasSiteEntry ( siteModel , pageModel ) { const siteId = siteModel . item . id ; const parentInitiativeId = getProp ( siteModel , "item.properties.parentInitiativeId" ) ; if ( parentInitiativeId ) { const currentSites = getProp ( pageModel , "data.values.sites" ) ; const initiativeEntry = currentSites . find ( ( e ) => { return e . id === parentInitiativeId ; } ) ; if ( initiativeEntry ) { initiativeEntry . id = siteId ; } } const sites = getProp ( pageModel , "data.values.sites" ) ; const siteEntry = sites . find ( ( e ) => { return e . id === siteId ; } ) ; if ( ! siteEntry ) { pageModel . data . values . sites . push ( { id : siteId , title : "Current Site to ensure clean removal" } ) ; } return pageModel ; }