@mikezimm/fps-core-v7
Version:
Library of reusable core interfaces, types and constants migrated from fps-library-v2
65 lines (64 loc) • 2.86 kB
JavaScript
/**
* CodeAnalizerComment: Updated 2 imports on 2024-09-22 14:49:52
* Update:: import { IFpsItemsReturn } to '@mikezimm/fps-core-v7/lib/components/molecules/process-results/CheckItemsResults;'
* Update:: import { processSharedItems } to '@mikezimm/fps-core-v7/lib/components/atoms/SharedItems/processSharedItems;'
*/
import { getExpandColumns } from "../../../components/molecules/source-props/Lists/getVX/getExpandV2";
import { CurrentTenant } from "../../../components/molecules/source-props/WindowLocationConstants";
import { makeid } from "../../../logic/Strings/guids";
import { getSourceItemsAPI } from "./getSourceItemsAPI";
/**
*
* * 2024-12-15: Migrated from fps-library-v2: src\components\atoms\SharedItems\getOnlySharedItems.ts
*
* NOTE: You can get attachments directly from getSourceItems by passing in [ 'AttachmentFiles' ] as an expandFormat
* This works only on a single list item Id like in the Panel component.
* It returns the item with Title, Id and AttachmentFiles array of attachments
*
* @param webURL
* @param listTitle
* @param Id
* @param fpsSpService
* @param selects
* @returns
*/
export async function getItemAttachmentsFlatAPI(webURL, listTitle, Id, fpsSpService, selects = []) {
/**
* 2025-01-29: was missing Attachment info, added to selects, and exapand
* NOTE: also had to remove from the function params and also set autoExpand to false
* https://github.com/mikezimm/drilldown7/issues/460
*/
const selectThese = selects.length > 0 ? selects : ['Title', 'Id'];
selectThese.push('AttachmentFiles');
const expandThese = getExpandColumns(selectThese);
const SourceProps = {
tenant: CurrentTenant,
refreshId: makeid(5),
webUrl: webURL,
listTitle: listTitle,
fetchCount: null,
selectThese: selectThese,
expandThese: [...expandThese, 'AttachmentFiles'],
restFilter: '',
fpsSpService: fpsSpService,
/**
* 2025-01-29: Do NOT use orderBy in this API
* https://github.com/mikezimm/drilldown7/issues/460
*/
orderBy: null,
};
/**
* 2025-01-29: was missing Attachment info, added to selects, and exapand
* NOTE: also had to remove from the function params and also set autoExpand to false
* https://github.com/mikezimm/drilldown7/issues/460
*/
const results = await getSourceItemsAPI(SourceProps, false, false, true, [], Id);
// const newItems: IAnySourceItem[] = [];
// results.items?.map( ( item: IAnySourceItem ) => {
// newItems.push({ ...item, ...item.AttachmentFiles });
// });
// if ( results.item ) results.item
// results.items = newItems;
return results;
}
//# sourceMappingURL=getItemAttachmentsFlatAPI.js.map