@mikezimm/fps-library-v2
Version:
Library of reusable typescript/javascript functions, interfaces and constants
137 lines (136 loc) • 7.68 kB
JavaScript
/**
* CodeAnalizerComment: Updated 4 imports on 2024-09-22 14:49:52
* Update:: import { onFPSFilterButtonFieldChanged } to '@mikezimm/fps-core-v7/lib/components/atoms/FilterButtons/functions/onFPSFilterButtonFieldChanged;'
* Update:: import { validateDocumentationUrl } to '@mikezimm/fps-core-v7/lib/components/atoms/Links/ValidateLinks;'
* Update:: import { IMinWPBannerProps } to '@mikezimm/fps-core-v7/lib/banner/interfaces/MinWP/IMinWPBannerProps;'
* Update:: import { IThisFPSWebPartClass } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;'
*/
import { EasyIconDefaultKeys } from "@mikezimm/fps-core-v7/lib/components/atoms/easy-icons/interfaces/eiTypes";
import { onFPSFilterButtonFieldChanged } from "@mikezimm/fps-core-v7/lib/components/atoms/FilterButtons/functions/onFPSFilterButtonFieldChanged";
import { validateDocumentationUrl } from "@mikezimm/fps-core-v7/lib/components/atoms/Links/ValidateLinks";
import { getStringArrayFromStringNoDups } from "@mikezimm/fps-core-v7/lib/logic/Strings/arraysFromString";
import { DefaultEasyPagesTabs, DefaultOverflowTab } from "@mikezimm/fps-core-v7/lib/components/atoms/easy-pages/interfaces/epTypes";
import { updateFpsImportProps } from "../features/ImportExport/ImportFunctions";
import { refreshBannerStylesOnPropChange, updateBannerThemeStyles } from "../features/PageStyle/bannerThemes";
import { updateWebpartHistoryV2 } from "@mikezimm/fps-core-v7/lib/banner/features/WebPartHistory/Functions";
/**
* 2024-05-11: MAJOR CHANGE ? WHY IS THERE thisWPClass here? Should be thisWPClass.properties!
* @param thisWPClass
* @param propertyPath
* @param oldValue
* @param newValue
*/
export async function onFPSPropPaneCHanged(thisWPClass, propertyPath, oldValue, newValue) {
thisWPClass._lastPropPaneChange = propertyPath;
const wpProps = thisWPClass.properties;
try {
await validateDocumentationUrl(wpProps, propertyPath, newValue);
}
catch (e) {
alert('unable to validateDocumentationUrl');
}
const user = thisWPClass.context.pageContext.user;
const { displayName, email, loginName } = user;
wpProps.webpartHistory = updateWebpartHistoryV2(wpProps.webpartHistory, propertyPath, newValue, displayName, [], []);
if (propertyPath === 'fpsImportProps') {
thisWPClass._importErrorMessage = updateFpsImportProps(wpProps, thisWPClass._importBlockPropsWP, propertyPath, newValue, thisWPClass.context.propertyPane.refresh, thisWPClass.onPropertyPaneConfigurationStart, thisWPClass._exitPropPaneChanged);
// https://github.com/mikezimm/pivottiles7/issues/383
}
else if (propertyPath === 'easyIconKeys' && (!newValue || newValue === 'RESET_DEFAULTS')) {
//https://github.com/mikezimm/pivottiles7/issues/356
wpProps.easyIconKeys = EasyIconDefaultKeys.join(' ; ');
if (newValue === 'RESET_DEFAULTS') {
thisWPClass.refreshPaneReRender();
}
}
else if (propertyPath === 'enableLockProps') {
// https://github.com/mikezimm/pivottiles7/issues/356
if (newValue === true) {
const checkthis = 'I know what I am doing';
const test = prompt(`Please type "${checkthis}" in order to LOCK the props :)`);
if (test && test.toLowerCase() === checkthis.toLowerCase()) {
wpProps.lockedByUser = `${displayName}`;
if (email)
wpProps.lockedByUser += ` | ${email}`;
wpProps.lockedTime = `Locked @ ${new Date().toUTCString()}`;
}
else {
wpProps.enableLockProps = false;
}
}
else if (newValue === false) {
const checkthis = 'I know what I am doing';
const test = prompt(`Please type "${checkthis}" in order to UNLOCK the props :)`);
if (test && test.toLowerCase() === checkthis.toLowerCase()) {
wpProps.lockedByUser = `Unlocked by ${displayName ? displayName : loginName}`;
wpProps.lockedTime = `Unlocked @ ${new Date().toUTCString()}`;
}
else {
wpProps.enableLockProps = true;
}
}
}
else if (propertyPath === 'enableForceOverRide') {
// https://github.com/mikezimm/fps-library-v2/issues/203
if (newValue === true) {
const checkthis = 'I know what I am doing';
const test = prompt(`Please type "${checkthis}" in order to OVERRIDE the props :)`);
if (test && test.toLowerCase() === checkthis.toLowerCase()) {
wpProps.overrideByUser = `${displayName}`;
if (email)
wpProps.overrideByUser += ` | ${email}`;
wpProps.overrideTime = `Override @ ${new Date().toUTCString()}`;
}
else {
wpProps.enableForceOverRide = false;
}
// } else if ( newValue === false ) {
// const checkthis: string = 'I know what I am doing';
// const test: string = prompt(`Please type "${checkthis}" in order to UNLOCK the props :)`);
// if ( test && test.toLowerCase() === checkthis.toLowerCase() ) {
// wpProps.overrideByUser = `Override by ${ displayName ? displayName : loginName }`;
// wpProps.overrideTime = `Override @ ${ new Date().toUTCString() }`;
// } else {
// wpProps.enableLockProps = true;
// }
}
}
else if (propertyPath === 'overrideProps') {
wpProps.overrideKeys = getStringArrayFromStringNoDups(newValue, `;`, true, 'asc', true);
}
else if (propertyPath === 'EasyPageTabsC' && !newValue) {
//https://github.com/mikezimm/Pnpjs-v2-Upgrade-sample/issues/59
wpProps.EasyPageTabsC = DefaultEasyPagesTabs.join(' ; ');
}
else if (propertyPath === 'EasyPageTabsP' && !newValue) {
//https://github.com/mikezimm/Pnpjs-v2-Upgrade-sample/issues/59
wpProps.EasyPageTabsP = DefaultEasyPagesTabs.join(' ; ');
}
else if (propertyPath === 'EasyPageTabsA' && !newValue) {
//https://github.com/mikezimm/Pnpjs-v2-Upgrade-sample/issues/59
wpProps.EasyPageTabsA = DefaultEasyPagesTabs.join(' ; ');
}
else if (propertyPath === 'EasyPageTabsB' && !newValue) {
//https://github.com/mikezimm/Pnpjs-v2-Upgrade-sample/issues/59
wpProps.EasyPageTabsB = DefaultEasyPagesTabs.join(' ; ');
}
else if (propertyPath === 'EasyPageOverflowTab' && !newValue) {
wpProps.EasyPageOverflowTab = DefaultOverflowTab;
}
else if (propertyPath === 'bannerStyle' || propertyPath === 'bannerCmdStyle') {
refreshBannerStylesOnPropChange(wpProps, propertyPath, newValue, thisWPClass.context.propertyPane.refresh);
}
else if (propertyPath === 'bannerStyleChoice') {
// bannerThemes, bannerThemeKeys, makeCSSPropPaneString
updateBannerThemeStyles(wpProps, newValue, true, wpProps.defPinState, thisWPClass._sitePresets.forces);
if (newValue === 'custom' || newValue === 'lock') {
//Do nothing for these cases.
}
else {
//Reset main web part styles to defaults
}
}
onFPSFilterButtonFieldChanged(wpProps.QFButtons, propertyPath, oldValue, newValue, thisWPClass.context.propertyPane.refresh);
console.log('onFPSPropPaneCHanged applied these changes = Path, old, new: ', propertyPath, oldValue, newValue);
}
//# sourceMappingURL=runOnPropChange.js.map