UNPKG

@mikezimm/fps-library-v2

Version:

Library of reusable typescript/javascript functions, interfaces and constants

294 lines (292 loc) 17.5 kB
/** * CodeAnalizerComment: Updated 7 imports on 2024-09-22 14:49:52 * Update:: import { IFPSEnviro } to '@mikezimm/fps-core-v7/lib/banner/features/FPSDOM/IFPSEnviro;' * Update:: import { webpartInstance } to '@mikezimm/fps-core-v7/lib/banner/features/FPSDOM/FPSDocument;' * Update:: import { IFPSSiteThemes } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;' * Update:: import { IFieldPanelMode } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;' * Update:: import { AnalyticsWeb } to '@mikezimm/fps-core-v7/lib/components/atoms/easy-analytics/interfaces/constants;' * Update:: import { IPropertyPaneDropdownOption } to '@mikezimm/fps-core-v7/lib/types/@msft/1.15.2/sp-property-pane;' * Update:: import { IFPSListItemPropPaneDropDownOption } to '@mikezimm/fps-core-v7/lib/banner/components/ItemPicker/interfaces/IFPSListItemPropPaneDropDownOption;' */ /** * CodeAnalizerComment: Updated 18 imports on 2024-09-21 23:07:24 * Update:: import { DisplayMode } to '@mikezimm/fps-core-v7/lib/types/@msft/1.15.2/displayMode;' * Update:: import { IFPSEnviro } to '@mikezimm/fps-core-v7/lib/banner/features/FPSDOM/IFPSEnviro;' * Update:: import { ISitePreConfigProps } to '@mikezimm/fps-core-v7/lib/common/PropPaneHelp/preconfig/IPreConfig;' * Update:: import { IRepoLinks } to '@mikezimm/fps-core-v7/lib/components/atoms/Links/IRepoLinks;' * Update:: import { IFieldPanelDesignMode } to '@mikezimm/fps-core-v7/lib/components/molecules/FieldPanel/interfaces/IMinWPFieldPanelProps;' * Update:: import { ILoadPerformance } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/IPerformance;' * Update:: import { ILoadPerformanceOps } to '@mikezimm/fps-core-v7/lib/components/molecules/Performance/IPerformance;' * Update:: import { IFPSUser } to '@mikezimm/fps-core-v7/lib/logic/Users/IUserInterfaces;' * Update:: import { webpartInstance } to '@mikezimm/fps-core-v7/lib/banner/features/FPSDOM/FPSDocument;' * Update:: import { IFPSSiteThemes } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;' * Update:: import { IFieldPanelMode } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;' * Update:: import { IFPSCert } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IFPSCert;' * Update:: import { IFullBackgroundMode } to '@mikezimm/fps-core-v7/lib/components/molecules/FullPageBackGround/interfaces/IFPSPageBGWPProps;' * Update:: import { AnalyticsWeb } to '@mikezimm/fps-core-v7/lib/components/atoms/easy-analytics/interfaces/constants;' * Update:: import { IPropertyPaneDropdownOption } to '@mikezimm/fps-core-v7/lib/types/@msft/1.15.2/sp-property-pane;' * Update:: import { IFPSListItemPropPaneDropDownOption } to '@mikezimm/fps-core-v7/lib/banner/components/ItemPicker/interfaces/IFPSListItemPropPaneDropDownOption;' * Update:: import { setSearchParamToUrl } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/functions/updateUrlParam;' * Update:: import { makeid } to '@mikezimm/fps-core-v7/lib/logic/Strings/guids;' */ import { DisplayMode } from '@mikezimm/fps-core-v7/lib/types/@msft/1.15.2/displayMode'; import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base'; import { webpartInstance } from '@mikezimm/fps-core-v7/lib/banner/features/FPSDOM/FPSDocument'; import { onFPSPropPaneClosed } from './runOnPropPaneCompleted'; import { updateSectionBGStyles } from '../../components/molecules/FullPageBackGround/SectionStyles'; import { setSearchParamToUrl } from '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/functions/updateUrlParam'; import { makeid } from '@mikezimm/fps-core-v7/lib/logic/Strings/guids'; // import { EasyIconDefaultKeys } from '../../components/atoms/EasyIcons/interfaces/eiTypes'; import { onFPSPropPaneCHanged } from './runOnPropChange'; import { AnalyticsWeb } from '@mikezimm/fps-core-v7/lib/restAPIs/logging/interfaces/constants'; import { DefaultGetStarted, DefaultHelpSite, DefaultPolicies, DefaultTop5, FPSDefaultYoutubeHelp, FPSDefaultYoutubeUrl, FPSYoutubeFirst5Url, FPSYoutubeGetStartedUrl } from '@mikezimm/fps-core-v7/lib/components/atoms/Links/CommonDevUrls'; /** * REQUIREMENT: Update wepbart's tsconfig to target 'es6' or higher * * The purpose of this class is to easily add all required setup to use the banner. * Then minimal set up is required in each webpart project * * * WARNING: THIS SHOULD MATCH THE Interface in IThisFPSWebPartClass * It is intended to mirror the class and is used for type checking in various functions including: * - BuildBannerProps * - runOnPropChange * - runOnSuperOnInit * - runWebPartRender * */ /** * These are analytics presets for analyticsPage. * Each webpart will get them as a baseline but can modify if needed */ const bannerStyleChoice = 'FPSPropsObj.BannerTheme.bannerStyleChoice'; const wpTDBaseLeft = `performanceObj.ops.fetch9`; const wpTDLeft = [`${wpTDBaseLeft}.ms`, `${wpTDBaseLeft}.c`]; const easyMode = 'FPSPropsObj.easyMode'; const wpTDRight = [easyMode, bannerStyleChoice, 'zzzText7']; const wpFilterProps = [easyMode, bannerStyleChoice, 'FPSPropsObj.LockProps.enableLockProps']; export class FPSBaseClass extends BaseClientSideWebPart { constructor() { super(...arguments); /** * These are intended to be set or adjusted right at the beginning of the main webpart class */ this._repoLink = null; //Set as any but will get created in FPSSuperOnOnit this._exportIgnorePropsWP = []; this._importBlockPropsWP = []; this._trickyApp = 'FPS UPDATE FPSBaseClass'; this._trickyEmailsWP = []; // These are emails that get tricky functionality for this specific web part this._panelVersion = `202X-XX-79 - UPDATE CLASS`; // this._analyticsListX = `WebPartTesting`; // Used for fetching tricky analytics this._analyticsWebX = AnalyticsWeb; // Used for fetching tricky analytics this._analyticsOptionsX = ['']; // Used for fetching tricky analytics this._wpTDLeft = wpTDLeft; // https://github.com/mikezimm/pivottiles7/issues/415 // https://github.com/mikezimm/drilldown7/issues/473 this._wpTDRight = wpTDRight; this._wpFilterProps = wpFilterProps; this._fpsSpService = null; this._fpsSiteThemes = null; this._fpsSiteThemeDark = ''; this._fpsSiteThemeLight = ''; this._fpsSiteThemePrimary = ''; /** * Help Page Links for _class PreConfigProps */ this._tenantHelpUrl = DefaultHelpSite; this._tenanatFirst5 = DefaultTop5; this._tenantGetStartedUrl = DefaultGetStarted; this._tenantPolicies = DefaultPolicies; this._youtubeChannel = FPSDefaultYoutubeUrl; this._youtubeFirst5 = FPSYoutubeFirst5Url; this._youtubeHelp = FPSDefaultYoutubeHelp; this._youtubeGetStarted = FPSYoutubeGetStartedUrl; /** * These are preset but likely to be adjusted in each webpart as needed */ this._allowPinMe = false; /** * These are preset and NOT Likely to need adjustments */ this._forceBanner = true; this._modifyBannerTitle = true; this._modifyBannerStyle = true; this._keysToShow = []; this._allowQuickLaunchHide = true; // Removed this for https://github.com/mikezimm/pivottiles7/issues/392 // protected _allowPageHeaderHide: boolean = true; this._allowSocialBarHide = true; this._allowToolBarHide = true; this._allowAllSectWidth = true; this._allowBeAUser = true; this._allowFeedback = true; this._allowPandoramic = true; this._allowSiteThemeChoice = true; this._allowEasyPages = true; this._allowFullPageBG = 'Auto'; // https://github.com/mikezimm/Slick-Sections/issues/27 this._allowFieldPanel = 'Disabled'; // Be SURE TO Map ( via _FieldPanelWebProp, _FieldPanelListProp ) to field panel if not in Auto mode this._allowPropsEasyMode = false; // Allows for Prop Pane Easy Mode if enabled in onInit... Default currently off https://github.com/mikezimm/pivottiles7/issues/246 this._expandPropsEasyModeCount = 2; // this._wpInfoGroupExpanded = false; // Allows for auto expanding WebPartInfoGroup on opening the prop pane if desired this._lastPropPaneChange = ''; // Feature specific presets this._FieldPanelDesignMode = 'Disabled'; // If Enabled, targets which web part for compatibility this._FieldPanelWebProp = 'webUrl'; // Other web part prop that will get mapped to the FieldPanelProps - in case it's different property name for retro compatibility this._FieldPanelListProp = 'listTitle'; // Other web part prop that will get mapped to the FieldPanelProps - in case it's different property name for retro compatibility this._doHeadingStyles = false; // added for use in renderCustomStyles for PageInfo web part // Added for potential future branding options this._imageWPInfo = ''; // Added for future use in Property Pane this._imagePlace = ''; // Added for future use in Placeholder component //Set this to true if webpart has a search bar and you want the user to be able to turn it on or off this._allowShowSearch = false; /** * These are updated later in the code */ // eslint-disable-next-line @typescript-eslint/no-explicit-any this._performance = null; //Set as any but will get created in FPSSuperOnOnit // eslint-disable-next-line @typescript-eslint/no-explicit-any this._sitePresets = null; //Set as any but will get created in FPSSuperOnOnit // eslint-disable-next-line @typescript-eslint/no-explicit-any this._FPSUser = null; //Set as any but will get created in FPSSuperOnOnit this._FPSEnviro = null; //Set as any but will get created in FPSSuperOnOnit this._IFPSCert = []; /** * These are preset and should be managed by the code... do not change in main webpart class */ this._wpInstanceID = webpartInstance(this._trickyApp); this._FPSId = makeid(7); // https://github.com/mikezimm/Slick-Sections/issues/98 this._exitPropPaneChanged = false; this._importErrorMessage = ''; this._trickyEmailsAll = []; // These are emails that get tricky functionality for this specific web part this._isSPA = false; // This is set properly in runSuperOnInit // eslint-disable-next-line @typescript-eslint/no-explicit-any this._urlParameters = {}; //2022-04-07: Intent of this is a one-time per instance to 'become a reader' level user. aka, hide banner buttons that reader won't see this._beAReader = false; this._listPickerValue = ''; this._webUrlPickerValue = ''; this._webUrlPickerValueApproved = false; this._listItemPickerValue = ''; this._runSandbox = false; // Dropdown gets disabled while retrieving items asynchronously //Created in SecureScript7 this._listsDropdownDisabled = true; // Copied from CherryPickedCE this._itemsDropdownDisabled = true; // Files in the selected library this._listItemsPickerList = []; //Added in Secure Script 7 this._listPickerList = []; this._approvedLists = []; // File types you want available in the picker. Use * for all extensions this._approvedFilePickerTypes = ['html', 'js']; this._fetchInstance = Math.floor(Math.random() * 79797979).toString(); this._hardExpire = true; this._renderItemsRow = null; this._renderBarsRow = null; } /** * These are functions used in the class */ _beAUserFunction() { console.log('beAUserFunction:'); if (this.displayMode === DisplayMode.Edit) { alert("'Be a regular user' mode is only available while viewing the page. \n\nOnce you are out of Edit mode, please refresh the page (CTRL-F5) to reload the web part."); } else { this._beAReader = this._beAReader === true ? false : true; this.render(); } } /** * This was added per https://github.com/mikezimm/Slick-Sections/issues/27 * Basically took functionality developed in SlickSections and rolling it up into class so it can be used anywhere * * export type ICallbackAddParamToUrl = ( newParamStr: string, reRender: boolean, newTab: boolean ) => void; * * @param newParamStr * @param reRender * @param newTab */ _addParamToUrl(newParamStr, reRender = true, newTab = false) { // 2023-11-24: Externalized this function to it's own file and also added deleteSearchParamFromUrl // Since this is buried in a lot of functions and I'm not sure why I really needed to bring into the class... // Going to just keep in class like this so I do not break anything :) setSearchParamToUrl(newParamStr, reRender, newTab); // eslint-disable-next-line @typescript-eslint/no-explicit-any // const url = new URL( window.location.href ); // .href includes search params // const search_params: URLSearchParams = url.searchParams; // const newParam: string[] = newParamStr.split( '=' ); // search_params.set( newParam[0], newParam[1] ); // const nextTitle = 'Slick Sections -Try Style'; // const nextState = { additionalInformation: `Added new paramter to Url and refreshed the page: ${newParam}` }; // console.log( `oldWindow`, window.location ); // const newUrl: string = `${window.location.pathname}?${ newParamStr === `clearAllParams=true` ? '' : search_params.toString()}`; // window.history.pushState(nextState, nextTitle, newUrl); // console.log( `newWindow`, window.location ); // if ( reRender === true ) this.render(); // if ( newTab === true ) window.open( newUrl, '_blank' ); } _refreshBGStyles() { // eslint-disable-next-line @typescript-eslint/no-explicit-any this._performance.ops.process2 = updateSectionBGStyles('BGStylesRefresh', this); } _resetEasyIcons() { // eslint-disable-next-line @typescript-eslint/no-explicit-any onFPSPropPaneCHanged(this, 'easyIconKeys', 'RESET_DEFAULTS', 'RESET_DEFAULTS'); } _saveFieldPanelViewsFunction(viewsProps) { console.log('_saveFieldPanelViewsFunction:'); if (this._allowFieldPanel === 'Manual') { alert(`Unable to save Views when _allowFieldPanel = ${this._allowFieldPanel} Mode`); } else if (this._FieldPanelDesignMode === 'Disabled') { alert("Unable to save Views when _FieldPanelDesignMode === 'Disabled'"); } else if (this._allowFieldPanel === 'Auto') { alert("FUTURE MESSAGE: Your Views design was copied to the web part properties but you will need to SAVE THE PAGE"); //Eventually update web part props per the design // Also remind user to save property pane and Publish the page this.render(); } else { alert(`_saveFieldPanelViewsFunction is DISABLED: _allowFieldPanel= ${this._allowFieldPanel} _FieldPanelDesignMode = ${this._FieldPanelDesignMode}`); } } _saveFieldPanelCommandsFunction(commands) { console.log('_saveFieldPanelCommandsFunction:'); if (this._allowFieldPanel === 'Manual') { alert(`Unable to save Commands when _allowFieldPanel = ${this._allowFieldPanel} Mode`); } else if (this._FieldPanelDesignMode === 'Disabled') { alert("Unable to save Commands when _FieldPanelDesignMode === 'Disabled'"); } else if (this._allowFieldPanel === 'Auto') { alert("FUTURE MESSAGE: Your Commands design was copied to the web part properties but you will need to SAVE THE PAGE"); //Eventually update web part props per the design // Also remind user to save property pane and Publish the page this.render(); } else { alert(`_saveFieldPanelCommandsFunction is DISABLED: _allowFieldPanel= ${this._allowFieldPanel} _FieldPanelDesignMode = ${this._FieldPanelDesignMode}`); } } //This was added in order to solve this issue: Auto add currnet person to Support Conacts if props are closed and field is empty // https://github.com/mikezimm/SecureScript7/issues/98 onPropertyPaneConfigurationComplete() { onFPSPropPaneClosed(this); } // https://github.com/mikezimm/pivottiles7/issues/383 refreshPaneReRender() { this.context.propertyPane.refresh(); // eslint-disable-next-line @typescript-eslint/no-floating-promises this.render(); } // https://github.com/mikezimm/pivottiles7/issues/383 _forceMainRender() { // this.context.propertyPane.refresh(); // eslint-disable-next-line @typescript-eslint/no-floating-promises this.render(); } } //# sourceMappingURL=FPSBaseClass.js.map