UNPKG

@mikezimm/fps-core-v7

Version:

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

86 lines 4.34 kB
import { getWebUrlFromLink, makeListLink } from '../../../logic/Links/UrlFunctions'; import { prepSourceColumns } from '../../../components/molecules/source-props/prepSourceColumns'; import { createSeriesSort } from '../../../components/molecules/source-props/createOrderBy'; import { CurrentOrigin, CurrentTenant } from '../../../components/molecules/source-props/WindowLocationConstants'; import { makeid } from '../../../logic/Strings/guids'; import { createAnalyticsSourceProps } from '../../../components/atoms/easy-analytics/functions/createAnalyticsSourceProps'; import { postSourceItemAPI } from '../../../restAPIs/lists/items/postSourceItemAPI'; import { makeAbsoluteUrl } from '../../../logic/Strings/getSiteCollectionUrlFromLink'; import { RequestListList, RequestListSite } from '../../../restAPIs/logging/interfaces/constants'; /** * 2025-01-03: Migrated from fps-library-v2/lib/pnpjs/Logging, postSourceItemAPI * combination of v2: saveAssistD * * This function is for automatically creating a item in our Teams' request list in SharePoint. * Initially it's fired upon completing rail functions to auto-document support incidents. * * So it's only going to execute in certain tenanats. * If you see this and want to re-purpose it, update the function to suit your needs and adjust the window.location.origin check * * Best practice is just to update your site and list Url in strings: * Or just create the site: SharePointAssist * And create the list: Assists * And add the columns listed below in the save item "requestListSite": "/sites/SharePointAssist", "requestListList": "Assists", * */ export async function saveAssist(fpsSpService, SiteLink, saveTitle, TargetList, itemInfo2, RichTextJSON1) { if (CurrentOrigin.indexOf('utoliv.sharepoint.com') < 0 && CurrentOrigin.indexOf('clickster.sharepoint') < 0) { return; } if (!SiteLink) { return; } if (!saveTitle) { return; } SiteLink = getWebUrlFromLink(SiteLink, 'abs'); const location = makeListLink(TargetList, SiteLink); // let startTime = makeSmallTimeObject( null ); // let localTimeString = startTime.theTime; const localTimeString = new Date(); // let StatusComments = RichTextJSON1 ? typeof RichTextJSON1 === 'string' ? RichTextJSON1 : JSON.stringify(RichTextJSON1).replace('\"','') : null; const StatusComments = RichTextJSON1 ? typeof RichTextJSON1 === 'string' ? RichTextJSON1 : JSON.stringify(RichTextJSON1).replace('"', '') : null; const ScopeArray = itemInfo2; const saveItem = { Title: saveTitle, Scope: { results: ScopeArray }, Status: '4. Completed', Complexity: '0 Automation', StatusComments: StatusComments, StartDate: localTimeString, EndDate: localTimeString, TargetCompleteDate: localTimeString, Location: location, //Link }; // https://github.com/mikezimm/pivottiles7/issues/417 const sourceProps = createAnalyticsSourceProps(fpsSpService, `${RequestListList}`, RequestListSite); // 2024-12-22: digestValue not required when using SpHTTPClient // sourceProps.digestValue = await getThisFPSDigestValueFromUrl(RequestListSite); const result = await postSourceItemAPI(sourceProps, saveItem, false, true); // saveThisLogItem( RequestListSite + '', RequestListList + '', saveItem ); } const assist = 'assist'; export const AssistSourceProps = prepSourceColumns({ fpsSpService: null, key: assist, refreshId: makeid(5), defType: assist, tenant: CurrentTenant, webUrl: makeAbsoluteUrl(RequestListSite), webRelativeLink: `/lists/${RequestListList}`, searchSource: assist, searchSourceDesc: assist, listTitle: `${RequestListList}`, columns: ['*',], searchProps: ['ID', 'Author/Title', 'Author/Office', 'SiteTitle', 'language', 'CodeVersion'], selectThese: ['*', 'Author/Title', 'Author/Office', 'performance'], isModern: true, defSearchButtons: [], orderBy: createSeriesSort('Id', false), fetchCount: 5000, performanceSettings: { label: 'assists', updateMiliseconds: true, includeMsStr: true, op: 'fetch' }, fpsContentType: ['item'], }, ''); //# sourceMappingURL=saveAssist.js.map