@mikezimm/fps-library-v2
Version:
Library of reusable typescript/javascript functions, interfaces and constants
91 lines (89 loc) • 3.91 kB
JavaScript
/**
* CodeAnalizerComment: Updated 4 imports on 2024-09-22 14:49:52
* Update:: import { IPropertyPaneGroup } to '@mikezimm/fps-core-v7/lib/types/@msft/1.15.2/sp-property-pane;'
* Update:: import { IPropertyPaneField } to '@mikezimm/fps-core-v7/lib/types/@msft/1.15.2/sp-property-pane;'
* Update:: import { IThisFPSWebPartClass } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;'
* Update:: import { IMinWPBannerProps } to '@mikezimm/fps-core-v7/lib/banner/interfaces/MinWP/IMinWPBannerProps;'
*/
/**
* CodeAnalizerComment: Updated 2 imports on 2024-09-21 23:07:24
* Update:: import { IThisFPSWebPartClass } to '@mikezimm/fps-core-v7/lib/banner/FPSWebPartClass/IThisFPSWebPartClass1152;'
* Update:: import { IMinWPBannerProps } to '@mikezimm/fps-core-v7/lib/banner/interfaces/MinWP/IMinWPBannerProps;'
*/
import { PropertyPaneLabel, PropertyPaneTextField, PropertyPaneToggle, } from '@microsoft/sp-property-pane';
/**
*
* @param thisWPClass
* @returns
*/
export function LockPropsEditGroup(thisWPClass) {
let fields = [];
const wpProps = thisWPClass.properties;
const { enableLockProps, } = wpProps;
fields.push(PropertyPaneToggle('enableLockProps', {
label: 'Lock Props',
offText: 'Off',
onText: 'On',
}));
const message1 = `Locking ONLY makes it a little harder to break your setup. Any page editor can come here and disable this toggle to edit properties.`;
const message2 = `Unlock ONLY IF YOU KNOW WHAT YOU ARE DOING. If you break it, we will know who did it :)`;
fields.push(PropertyPaneLabel('lockedX', {
text: enableLockProps === true ? message2 : message1,
}));
fields.push(...addLockedStamps(wpProps));
['lockedMess1', 'lockedMess2', 'lockedMess3'].map(keyProp => {
// const propVal: string = wpProps[ keyProp as 'lockedMess1'];
fields.push(PropertyPaneTextField(keyProp, {
disabled: enableLockProps === true ? true : false,
label: `Add ${keyProp}`,
description: 'Message shown in prop pane when locked',
multiline: true,
}));
});
const optionsGroup = { groupName: 'Lock Props Group',
isCollapsed: true,
groupFields: fields
};
return optionsGroup;
}
function addLockedStamps(wpProps) {
let fields = [];
[`${wpProps.lockedTime}`, ` - - - - - - - `, `Locked By:`, `${wpProps.lockedByUser}`,].map(str => {
fields.push(PropertyPaneLabel('lockedTime', {
text: str,
}));
});
return fields;
}
export function LockPropsMessageGroup(thisWPClass) {
let fields = [];
const wpProps = thisWPClass.properties;
const { enableLockProps, lockedByUser, lockedTime, lockedMess1, lockedMess2, lockedMess3, lockedHTML1 } = wpProps;
if (enableLockProps !== true) {
fields.push(PropertyPaneLabel('nothing', {
text: 'This should NOT be visible in webpart'
}));
}
else {
[``, `Property Pane was locked in order to prevent accidental changes :)`,
`Please contact the person listed below or IT in order to get assistance!`,].map(str => {
fields.push(PropertyPaneLabel('xyz', {
text: str,
}));
});
fields.push(...addLockedStamps(wpProps));
['lockedMess1', 'lockedMess2', 'lockedMess3'].map(keyProp => {
const propVal = wpProps[keyProp];
if (propVal)
fields.push(PropertyPaneLabel(keyProp, {
text: `${propVal}`,
}));
});
}
let optionsGroup = { groupName: 'Lock Props Message',
isCollapsed: enableLockProps === true ? false : true,
groupFields: fields
};
return optionsGroup;
}
//# sourceMappingURL=LockPropsGroup.js.map