UNPKG

@mikezimm/fps-core-v7

Version:

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

48 lines (47 loc) 2.79 kB
/** * CodeAnalizerComment: Updated 1 imports on 2024-09-22 02:56:43 * Update:: import { fetchFileList } to '@mikezimm/fps-core-v7/lib/banner/components/ItemPicker/functions/fetchFileList;' */ import { fetchFileList } from "../../ItemPicker/functions/fetchFileList"; // import { IThisFPSWebPartClass } from "../../../FPSWebPartClass/IThisFPSWebPartClass"; // eslint-disable-next-line @typescript-eslint/no-explicit-any export async function onListPickerChanged(thisWPClass, includeItem, propertyPath, oldValue, newValue, idx) { // 2024-10-21: For the sake of reusability and type definition ease, casting as IFPSListItemPickerWPProps but can be used as IFPSListItemPickerWPProps2 with the 'as ...' const wpProps = thisWPClass.properties; if ((propertyPath === 'listPickerValue' || propertyPath === 'listPickerValue2') && (newValue)) { thisWPClass._fetchInstance = Math.floor(Math.random() * 79797979).toString(); // get previously selected item const previousItem = wpProps[`listItemPickerValue${idx}`]; // reset selected item wpProps[`listItemPickerValue${idx}`] = ""; // disable item selector until new items are loaded thisWPClass[`_itemsDropdownDisabled${idx}`] = true; // push new item value await thisWPClass.onPropertyPaneFieldChanged(`listItemPickerValue${idx}`, previousItem, wpProps[`listItemPickerValue${idx}`]); let libIndex = -1; thisWPClass[`_listPickerList${idx}`].map((lib, idxX) => { if (lib.key === newValue) { libIndex = idxX; } }); // 2024-09-22: Added undefined as any to pass type error const selectedLibrary = libIndex > -1 ? thisWPClass[`_listPickerList${idx}`][libIndex] : null; thisWPClass.refreshPaneReRender(); if (!includeItem) { // ADDED 2024-10-15 thisWPClass.refreshPaneReRender(); } else { // 2025-02-13: Fixed: https://github.com/fps-solutions/Core-FPT1.20.X/issues/1Z // eslint-disable-next-line @typescript-eslint/no-floating-promises, @typescript-eslint/no-explicit-any fetchFileList(thisWPClass._fpsSpService, selectedLibrary, thisWPClass[`_approvedFilePickerTypes${idx}`]) .then((results) => { console.log(`onPropertyPaneConfigurationStart: files${idx}`, results); thisWPClass[`_listItemsPickerList${idx}`] = results.items; // enable item selector thisWPClass[`_itemsDropdownDisabled${idx}`] = false; thisWPClass.refreshPaneReRender(); }); // END: thisWPClass.getLibraryItemsList } } } //# sourceMappingURL=onListPickerChanged.js.map