UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

84 lines 3.35 kB
/** * 2024-09-06: Migrated from same folder fps-library-v2\src\pnpjs\SourceItems * * Local imports import { getExpandColumns, ISourceProps, makeid } from '../../fpsReferences'; import { createSeriesSort } from '@mikezimm/fps-core-v7/lib/components/molecules/source-props/createOrderBy'; import { CurrentTenant } from '@mikezimm/fps-core-v7/lib/components/molecules/source-props/WindowLocationConstants'; import { GroupSelectsFull } from '@mikezimm/fps-core-v7/lib/restAPIs/sites/groups/GroupSelects'; */ import { createSeriesSort } from '../../createOrderBy'; import { makeid } from '../../../../../logic/Strings/guids'; import { getSiteCollectionUrlFromLink } from '../../../../../logic/Strings/getSiteCollectionUrlFromLink'; import { CurrentTenant } from '../../WindowLocationConstants'; export const MinWebSelects = ['Title', 'Id', 'ServerRelativeUrl', 'Url', 'SiteLogoUrl', 'Description',]; export const MinWebRolesSelects = [...MinWebSelects, 'HasUniqueRoleAssignments']; /** * Create sourceProps object for fetching a web * use minRoles to replace pnp2: fetchWebInfoIncludingUniqueD * * gets site and web source: * import { createWebSource, createSiteSource, DefaultSiteSource } from '@mikezimm/fps-core-v7/lib/components/molecules/source-props/createSources/Sites/createSiteSource'; * * use with * import { getSiteAPI, getWebAPI, getSubsitesAPI } from '@mikezimm/fps-core-v7/lib/restAPIs/sites/sites/getSiteAPI'; * * * @param webUrl * @param fpsSpService * @param selects * @returns */ export function createWebSource(webUrl, fpsSpService, selects) { let Source = JSON.parse(JSON.stringify(DefaultSiteSource)); Source.webUrl = webUrl; Source.absoluteWebUrl = getSiteCollectionUrlFromLink(webUrl); Source.key = 'webs'; Source.defType = 'web'; Source.fpsContentType = ['web']; if (Source.performanceSettings) Source.performanceSettings.label = 'Web'; Source.fpsSpService = fpsSpService; if (selects === 'minRoles') { Source.columns = MinWebRolesSelects; Source.searchProps = MinWebRolesSelects; Source.selectThese = MinWebRolesSelects; } return Source; } /** * create sourceProps object for fetching a site * @param webUrl * @param fpsSpService * @param selects * @returns */ export function createSiteSource(webUrl, fpsSpService, selects = 'full') { let Source = createSiteOrWebSource(webUrl, fpsSpService); return Source; } function createSiteOrWebSource(webUrl, fpsSpService) { let Source = JSON.parse(JSON.stringify(DefaultSiteSource)); Source.webUrl = webUrl; Source.absoluteWebUrl = getSiteCollectionUrlFromLink(webUrl); Source.fpsSpService = fpsSpService; return Source; } export const DefaultSiteSource = { refreshId: makeid(5), key: 'sites', defType: 'Site', fpsContentType: ['site'], tenant: CurrentTenant, webUrl: ``, webRelativeLink: '', viewItemLink: ``, columns: ['*'], searchProps: ['*'], selectThese: ['*'], expandThese: ['*'], defSearchButtons: [], orderBy: createSeriesSort('Title'), performanceSettings: { label: 'Site', updateMiliseconds: true, includeMsStr: true, op: 'fetch' }, }; //# sourceMappingURL=createSiteSource.js.map