UNPKG

cluedin-widget

Version:

This project contains all the pages needed for browsing entities and searching them. The aim is to replace the CluedIn.Webapp project with this one when all the pages ( including the Admin page ) will be ported to REACT.

70 lines (64 loc) 1.94 kB
var iso = require('../iso'); var layoutsConfig = __cluedIn.layouts; var entitiesConfig = __cluedIn.widgetConfiguration; const defaultEntityConfig = { entityType: 'default', isDefault: true, includeSuggestedSearches: true, placeSuggestedSearches: 'main', suggestedSearchFilter: [], layout: { name: 'Standard' }, widgets: [ {name: 'EntityHeader', place: 'header'}, {name: 'EntityProperty', place: 'main'/*, size: '8'*/}, {name: 'EntitySourceAndProfile', place: 'main'} ] }; const defaultLayoutConfig = { code: 'Standard', isDefault: true, children: [ { type: 'row', columns: [ { size: 12, name: 'header', }, ], }, { type: 'grid', size: 4, name: 'main', }, ], }; module.exports = { getAllWidgetConfiguration: () => { return entitiesConfig; }, getEntityConfiguration: (entityType) => { return iso.collection.find(entitiesConfig, (entityConfig)=> { return entityConfig.entityType.toLowerCase() === entityType.toLowerCase(); }); }, getWidgetConfiguration: (entityType, org) => { let widgetConfigForOrg = iso.collection.find(entitiesConfig, (entityConfig)=> { return (entityConfig.entityType.toLowerCase() === entityType.toLowerCase() && entityConfig.owner === org); }); if (!widgetConfigForOrg) { widgetConfigForOrg = iso.collection.find(entitiesConfig, (entityConfig)=> { return entityConfig.entityType.toLowerCase() === entityType.toLowerCase(); }); } return (widgetConfigForOrg && widgetConfigForOrg.widgets && widgetConfigForOrg.widgets.length > 0) ? widgetConfigForOrg : defaultEntityConfig; }, getLayout: (layoutCode) => { let layoutConfig = iso.collection.find(layoutsConfig, (layoutConfig) => { return layoutConfig.code === layoutCode; }); return (layoutConfig) ? layoutConfig : defaultLayoutConfig; } };