UNPKG

@mikezimm/fps-library-v2

Version:

Library of reusable typescript/javascript functions, interfaces and constants

133 lines (131 loc) 11.1 kB
/** * CodeAnalizerComment: Updated 4 imports on 2024-09-22 14:49:52 * Update:: import { applyPresetCollectionDefaults } to '@mikezimm/fps-core-v7/lib/common/PropPaneHelp/preconfig/ApplyPresets;' * Update:: import { getFPSUser } to '@mikezimm/fps-core-v7/lib/logic/Users/FPSUser;' * Update:: import { createFPSEnviroOnWindow } to '@mikezimm/fps-core-v7/lib/banner/features/FPSDOM/FPSEnviro;' * Update:: import { IThisFPSWebPartClass } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;' */ /** * CodeAnalizerComment: Updated 14 imports on 2024-09-21 23:07:24 * Update:: import { check4This } to '@mikezimm/fps-core-v7/lib/logic/Links/CheckSearch;' * Update:: import { IPageLayoutType } to '@mikezimm/fps-core-v7/lib/types/@msft/1.15.2/layout;' * Update:: import { ISupportedHost } to '@mikezimm/fps-core-v7/lib/types/@msft/1.15.2/layout;' * Update:: import { applyPresetCollectionDefaults } to '@mikezimm/fps-core-v7/lib/common/PropPaneHelp/preconfig/ApplyPresets;' * Update:: import { IAllPreConfigSettings } to '@mikezimm/fps-core-v7/lib/common/PropPaneHelp/preconfig/IPreConfig;' * Update:: import { createBasePerformanceInit } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/functions;' * Update:: import { startPerformOp } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/functions;' * Update:: import { updatePerformanceEnd } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/functions;' * Update:: import { getFPSUser } to '@mikezimm/fps-core-v7/lib/logic/Users/FPSUser;' * Update:: import { createFPSEnviroOnWindow } to '@mikezimm/fps-core-v7/lib/banner/features/FPSDOM/FPSEnviro;' * Update:: import { getWebPartHistoryOnInit } to '@mikezimm/fps-core-v7/lib/banner/features/WebPartHistory/OnInit;' * Update:: import { IThisFPSWebPartClass } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;' * Update:: import { IFPSCert } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IFPSCert;' * Update:: import { getCert } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/getCert;' */ import { check4This, Check4 } from '@mikezimm/fps-core-v7/lib/logic/Links/CheckSearch'; import { applyPreConfiguredProps, applyPreConfiguredClass } from '@mikezimm/fps-core-v7/lib/common/PropPaneHelp/preconfig/ApplyPresets'; import { getThisSitesPreConfigProps } from '@mikezimm/fps-core-v7/lib/common/PropPaneHelp/preconfig/getThisSitesPreConfigProps'; import { addCanvasBGImageComponent } from '../../components/molecules/FullPageBackGround/addCanvasBGImageComponent'; import { createBasePerformanceInit, startPerformOp, updatePerformanceEnd } from '@mikezimm/fps-core-v7/lib/components/molecules/Performance/functions'; import { getFPSUser } from '@mikezimm/fps-core-v7/lib/components/atoms/Users/FPSUser'; import { expandoOnInit } from '../features/Expando/oninit'; import { createFPSEnviroOnWindow } from '@mikezimm/fps-core-v7/lib/banner/features/FPSDOM/FPSEnviro'; import { updateBannerThemeStyles } from '../features/PageStyle/bannerThemes'; import { renderCustomStyles } from '../features/PageStyle/renderCustStyles'; import { getWebPartHistoryOnInit } from '@mikezimm/fps-core-v7/lib/banner/features/WebPartHistory/OnInit'; import { updateSectionBGStyles } from '../../components/molecules/FullPageBackGround/SectionStyles'; import { getCert } from '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/getCert'; import { tagOOTBWebPartTitleSection, tagParentElementByClass } from '@mikezimm/fps-core-v7/lib/logic/DOM/Search/tagParentSection'; import FpsSpHttpService from './FpsSpHttpService'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function runFPSSuperOnInit(thisWPClass, PreConfiguredProps, SPPermission, Environment) { /** * NOTE FROM TESTING, Only deconstruct things that do NOT change. * If I deconstructed _performance, _sitePresets, _FPSUser, then in main web part it would not return the actual values back. */ // let { _performance, _sitePresets, _FPSUser, } = thisWPClass; const { displayMode, context, properties, domElement, _wpInstanceID, _trickyApp, } = thisWPClass; // https://github.com/mikezimm/fps-library-v2/issues/203 // Always set to false on each web part load properties.enableForceOverRide = false; /*** * .d88b. d8b db d888888b d8b db d888888b d888888b d8888b. db db .d8b. .d8888. d88888b .d888b. * .8P Y8. 888o 88 `88' 888o 88 `88' `~~88~~' 88 `8D 88 88 d8' `8b 88' YP 88' VP `8D * 88 88 88V8o 88 88 88V8o 88 88 88 88oodD' 88ooo88 88ooo88 `8bo. 88ooooo odD' * 88 88 88 V8o88 88 88 V8o88 88 88 88~~~ 88~~~88 88~~~88 `Y8b. 88~~~~~ .88' * `8b d8' 88 V888 .88. 88 V888 .88. 88 88 88 88 88 88 db 8D 88. j88. * `Y88P' VP V8P Y888888P VP V8P Y888888P YP 88 YP YP YP YP `8888Y' Y88888P 888888D * * */ // https://github.com/mikezimm/drilldown7/issues/352 // 2023-09-26: Moved this above the updateSectionBGStyles and addCanvasBGImageComponent so it can be passed in to it for SPA Background. //This indicates if its SPA, Teams etc.... always keep. // eslint-disable-next-line @typescript-eslint/no-explicit-any const pageLayout = context['_pageLayoutType'] ? context['_pageLayoutType'] : context['_pageLayoutType']; thisWPClass.properties.pageLayout = pageLayout; if (pageLayout === 'SingleWebPartAppPageLayout') { thisWPClass._isSPA = true; thisWPClass._allowPinMe = false; } // https://github.com/mikezimm/Slick-Sections/issues/98 tagOOTBWebPartTitleSection(); tagParentElementByClass(thisWPClass.domElement, 10, 'CanvasZone', `parent-to-${thisWPClass._FPSId}`); // DEFAULTS SECTION: Performance <<< ================================================================ thisWPClass._performance = createBasePerformanceInit(displayMode, false); thisWPClass._performance.ops.superOnInit = startPerformOp('superOnInit', displayMode, true); // https://github.com/mikezimm/Slick-Sections/issues/69 if (Environment.type === 3) { thisWPClass._allowPandoramic = false; // https://github.com/mikezimm/pivottiles7/issues/325 thisWPClass._allowFullPageBG = false; // https://github.com/mikezimm/pivottiles7/issues/326 thisWPClass._allowPinMe = false; // https://github.com/mikezimm/pivottiles7/issues328 } const { enableSUL, sUCode } = thisWPClass.properties; // https://github.com/mikezimm/fps-library-v2/issues/180 const fpsCert = getCert(thisWPClass._IFPSCert, enableSUL, sUCode, thisWPClass._repoLink.cCode); thisWPClass._IFPSCert = [fpsCert]; thisWPClass._trickyEmailsAll = [...thisWPClass._trickyEmailsWP]; if (fpsCert.trickyEmails && fpsCert.trickyEmails.length > 0) thisWPClass._trickyEmailsAll = [...thisWPClass._trickyEmailsAll, ...fpsCert.trickyEmails]; const FullPreConfiguredProps = JSON.parse(JSON.stringify(PreConfiguredProps)); if (fpsCert.forced && fpsCert.forced.length > 0) FullPreConfiguredProps.forced.push(...fpsCert.forced); // Add forced TO END so cert specific ones apply if (fpsCert.preset && fpsCert.preset.length > 0) FullPreConfiguredProps.preset.unshift(...fpsCert.preset); // Add preset TO BEGINNING so cert specific ones apply if (fpsCert._class && fpsCert._class.length > 0) FullPreConfiguredProps._class.unshift(...fpsCert.preset); // Add preset TO BEGINNING so cert specific ones apply const _baseSitePresets = getThisSitesPreConfigProps(FullPreConfiguredProps, thisWPClass.properties, context.pageContext.web.serverRelativeUrl); const _classPreConfig = applyPreConfiguredClass(_baseSitePresets, thisWPClass); //NEED TO APPLY THIS HERE as well as follow-up in render for it to not visibly change thisWPClass._sitePresets = applyPreConfiguredProps(_baseSitePresets, thisWPClass.properties, thisWPClass); thisWPClass._sitePresets._class = _classPreConfig._class; thisWPClass._sitePresets._webpart = _classPreConfig._webpart; // Migrated this from SlickSections thisWPClass._performance.ops.process0 = updateSectionBGStyles('BGStylesI', thisWPClass); // https://github.com/mikezimm/drilldown7/issues/352 // https://github.com/mikezimm/Slick-Sections/issues/27 // NOTE: In SlickSections, this was run in the protected async onInit BEFORE super.onInit which this is called from... so a little later in the life-cycle. // Here it is also run AFTER applying preset colletion defaults which is a slight change. Don't think it matters but it is what it is. // https://github.com/mikezimm/pivottiles7/issues/456 - Does not run and white out BG Image if none is in props if (thisWPClass._allowFullPageBG !== false && thisWPClass.properties.fullPageImage) addCanvasBGImageComponent(thisWPClass.properties, 0, thisWPClass._isSPA); // https://github.com/mikezimm/Slick-Sections/issues/27 thisWPClass._FPSEnviro = createFPSEnviroOnWindow(thisWPClass, Environment); // _urlParameters = getUrlVars(); // eslint-disable-next-line @typescript-eslint/no-explicit-any thisWPClass._FPSUser = getFPSUser(context, thisWPClass._trickyEmailsAll, _trickyApp, SPPermission); // spread out siteThemes to specific classes thisWPClass._fpsSiteThemeDark = thisWPClass._fpsSiteThemeDark ? thisWPClass._fpsSiteThemeDark : thisWPClass._fpsSiteThemes.fpsSiteThemeDark; thisWPClass._fpsSiteThemeLight = thisWPClass._fpsSiteThemeLight ? thisWPClass._fpsSiteThemeLight : thisWPClass._fpsSiteThemes.fpsSiteThemeLight; thisWPClass._fpsSiteThemePrimary = thisWPClass._fpsSiteThemePrimary ? thisWPClass._fpsSiteThemePrimary : thisWPClass._fpsSiteThemes.fpsSiteThemePrimary; if (check4This(Check4.fpsInitRender_Eq_true) === true) console.log('FPSUser: ', thisWPClass._FPSUser); expandoOnInit(properties, context.domElement, displayMode); const bannerStyleChoice = properties.bannerStyleChoice ? properties.bannerStyleChoice : 'corpDark1'; updateBannerThemeStyles(properties, bannerStyleChoice, true, properties.defPinState, thisWPClass._sitePresets.forces); thisWPClass.properties.webpartHistory = getWebPartHistoryOnInit(context.pageContext.user.displayName, properties.webpartHistory); renderCustomStyles({ wpInstanceID: _wpInstanceID, domElement: domElement, wpProps: properties, displayMode: displayMode, doHeadings: thisWPClass._doHeadingStyles, fpsid: thisWPClass._FPSId }); //doHeadings is currently only used in PageInfo so set to false. thisWPClass._fpsSpService = new FpsSpHttpService(thisWPClass.context.spHttpClient); thisWPClass._performance.ops.superOnInit = updatePerformanceEnd(thisWPClass._performance.ops.superOnInit, true, 666); } //# sourceMappingURL=runSuperOnInit.js.map