UNPKG

@mikezimm/fps-library-v2

Version:

Library of reusable typescript/javascript functions, interfaces and constants

549 lines (541 loc) 34.2 kB
/** * CodeAnalizerComment: Updated 8 imports on 2024-09-22 14:49:52 * Update:: import { IDrillItemInfo } to '@mikezimm/fps-core-v7/lib/components/webparts/Drilldown/IDrillItem;' * Update:: import { CommandCancelRequired } to '@mikezimm/fps-core-v7/lib/components/webparts/Drilldown/QuickCommands/IQuickCommands;' * Update:: import { CommandEmptyCommentMessage } to '@mikezimm/fps-core-v7/lib/components/webparts/Drilldown/QuickCommands/IQuickCommands;' * Update:: import { CommandEnterCommentString } to '@mikezimm/fps-core-v7/lib/components/webparts/Drilldown/QuickCommands/IQuickCommands;' * Update:: import { CommandItemNotUpdatedMessage } to '@mikezimm/fps-core-v7/lib/components/webparts/Drilldown/QuickCommands/IQuickCommands;' * Update:: import { CommandUpdateFailedMessage } to '@mikezimm/fps-core-v7/lib/components/webparts/Drilldown/QuickCommands/IQuickCommands;' * Update:: import { IQuickButton } to '@mikezimm/fps-core-v7/lib/components/webparts/Drilldown/QuickCommands/IQuickCommands;' * Update:: import { getInitials } to '@mikezimm/fps-core-v7/lib/logic/Strings/drillParse/getWords;' */ /** * CodeAnalizerComment: Updated 3 imports on 2024-09-21 23:07:24 * Update:: import { getHelpfullError } to '@mikezimm/fps-core-v7/lib/logic/Errors/friendly;' * Update:: import { IUser } to '@mikezimm/fps-core-v7/lib/logic/Users/IUserInterfaces;' * Update:: import { removeItemFromArrayAll } to '@mikezimm/fps-core-v7/lib/logic/Arrays/manipulation;' */ import { getHelpfullError, } from "@mikezimm/fps-core-v7/lib/logic/Errors/friendly"; import { removeItemFromArrayAll } from "@mikezimm/fps-core-v7/lib/logic/Arrays/manipulation"; import { CommandCancelRequired, CommandEmptyCommentMessage, CommandEnterCommentString, CommandItemNotUpdatedMessage } from "@mikezimm/fps-core-v7/lib/components/webparts/Drilldown/QuickCommands/IQuickCommands"; import { getInitials } from "@mikezimm/fps-core-v7/lib/logic/Strings/drillParse/getWords"; import { updateCommandItemAPI } from '@mikezimm/fps-core-v7/lib/restAPIs/lists/items/updateCommandItemAPI'; import { CurrentOrigin } from "@mikezimm/fps-core-v7/lib/components/molecules/source-props/WindowLocationConstants"; // import { getInitials } from "@fluentui/react"; // EVENTUALLY MOVE THIS TO npmFunctions export const CaptchaRegex = /{{|captcha[\^]?|}}|=|\?/g; //MOVE TO IQuickCommands in npmFunctions export const CommandCaptchaTestFailed = 'Failed Captcha test. Not saving'; export const CommandCaptchaRequiredFailed = 'Failed Captcha test - item missing comparison. Not saving'; /** * * 2024-12-09: Migrated updateCommandItems to updateCommandItemAPI in core-v7 * Code was migrated and updated but not yet tested with Drilldown. * use import { updateCommandItemAPI, } from '@mikezimm/fps-core-v7/lib/restAPIS/lists/items/updateCommandItemAPI'; * * @param webUrl * @param listTitle * @param Id * @param thisButtonObject * @param sourceUserInfo * @param panelItem * @returns */ export async function updateReactListItem(fpsSpService, webUrl, listTitle, Id, thisButtonObject, sourceUserInfo, panelItem) { //lists.getById(listGUID).webs.orderBy("Title", true).get().then(function(result) { //let allItems : IDrillItemInfo[] = await sp.web.webs.get(); /** * https://github.com/mikezimm/drilldown7/issues/461 * Modified handling of dates so that if it is within "DoubleQuotes", it gets converted toISOString because it is likely a date column */ const today = new Date(); const currentTimeLocal = today.toLocaleString(); const currentTimeIso = today.toISOString(); // let results : any[] = []; let failedRequiredUpdate = false; let failedCaptchaTest = false; let failedCaptchaRequired = false; let failureMessage = []; let newUpdateItem = JSON.stringify(thisButtonObject.updateItem); //Replace [Today] with currect time // newUpdateItem = newUpdateItem.replace(/\B\[Today\]\B/gi, currentTime); // First replace all the "DateInDoubleQuotes" (likely date fields), then sub in normal strings /** * https://github.com/mikezimm/drilldown7/issues/461 * Modified handling of dates so that if it is within "DoubleQuotes", it gets converted toISOString because it is likely a date column * * https://github.com/mikezimm/drilldown7/issues/244 * Added optional || before the date to only fill in the date if there was not already a number. * || is left in place and is handled at the end of the loop. * If the current item has a value, this key is removed. * If the current item does NOT have a value in the key, the leading || is removed from the new item before it's saved. * * OVERALL Process order * 1. find all DateColumn updates "||[Today+9]" with || with or without +/=X * 2. Then find all DateColumn updates with optional || "[Today+9]" with or without +/=X * 3. Finally replace [Today] without any quotes (aka text) with local string */ // newUpdateItem = newUpdateItem.replace(/"(\|\|)?\[Today\]"/gi, `"${currentTimeIso}"`).replace(/\B\[Today\]\B/gi, currentTimeLocal); newUpdateItem = newUpdateItem.replace(/"(\|\|)\[Today([+-]?\d+)?\]"/gi, (match, doublePipe, offset) => { const today = new Date(); const offsetNumber = offset ? parseInt(offset, 10) : 0; today.setDate(today.getDate() + offsetNumber); const formattedDate = today.toISOString(); return `"${doublePipe}${formattedDate}"`; }); // Calculate the new date // https://github.com/mikezimm/drilldown7/issues/244 let newUpdateItem2 = newUpdateItem.replace(/"(\|\|)?\[Today([+-]?\d+)?\]"/gi, (match, doublePipe, offset) => { // Extract the offset, default to 0 if no number is present const innerMatch = match.match(/\[Today\s*([+-]?\d+)?\]/i); // Match inside [Today...] const offsetNumber = innerMatch && innerMatch[1] ? parseInt(innerMatch[1], 10) : 0; // Default to 0 if no number const newDate = new Date(); newDate.setDate(today.getDate() + offsetNumber); // Apply the offset // Format the date as 'YYYY-MM-DDTHH:mm:ssZ' (SharePoint's Edm.DateTimeOffset format) const formattedDate = newDate.toISOString().replace(/\.\d{3}Z$/, "Z"); // Remove milliseconds // If || exists, keep it, else return the formatted date without || if (doublePipe) { return `"${doublePipe}${formattedDate}"`; // Keep || intact } else { return `"${formattedDate}"`; // No ||, just the formatted date } }).replace(/\B\[Today\]\B/gi, currentTimeLocal); // let newUpdateItem2 = newUpdateItem.replace(/"(\|\|)?\[Today(.*?)\]"/gi, (match) => { // // let newUpdateItem2 = newUpdateItem.replace(/"\[Today(.*?)\]"/gi, (match) => { // // Extract the number (if any) after "[Today" // const innerMatch = match.match(/\[Today\s*([+-]?\d+)?\]/i); // Match inside [Today...] // const offset = innerMatch && innerMatch[1] ? parseInt(innerMatch[1], 10) : 0; // Default to 0 if no number is present // const newDate = new Date(); // newDate.setDate(today.getDate() + offset); // // Convert to ISO string // const newDateString = newDate.toISOString(); // // Return the replacement string wrapped in quotes // return `"${newDateString}"`; // }); //Regex looks for anything matching [Today-+xxx] and replaces with date string newUpdateItem2 = newUpdateItem2.replace(/\[Today(.*?)\]/gi, (match => { let offset = parseInt(match.toLowerCase().substring(6).replace("]", ""), 10); var newdate = new Date(); newdate.setDate(today.getDate() + offset); let newDateString = newdate.toLocaleString(); return newDateString; })); /** * JUST IN CASE, this is exactly what I had in the local version of this function while testing in Drilldown: * DELETE comment after July 2025. * const currentTimeLocal = new Date().toLocaleString(); const currentTimeIso = new Date().toISOString(); // let results : any[] = []; let failedRequiredUpdate = false; let failedCaptchaTest = false; let failedCaptchaRequired = false; let failureMessage = []; let newUpdateItem = JSON.stringify(thisButtonObject.updateItem); //Replace [Today] with currect time newUpdateItem = newUpdateItem.replace(/"\[Today\]"/gi, `"${currentTimeIso}"`).replace(/\B\[Today\]\B/gi, currentTimeLocal); const today = new Date(); let newUpdateItem2 = newUpdateItem.replace(/"\[Today(.*?)\]"/gi, (match) => { // Extract the number (if any) after "[Today" // const numberMatch = match.match(/\[Today\s*(-?\d+)?\]/i); const innerMatch = match.match(/\[Today\s*([+-]?\d+)?\]/i); // Match inside [Today...] // Extract the offset, default to 0 if no number is present const offset = innerMatch && innerMatch[1] ? parseInt(innerMatch[1], 10) : 0; const newDate = new Date(); newDate.setDate(today.getDate() + offset); // Format the date as 'YYYY-MM-DDTHH:mm:ssZ' (SharePoint's Edm.DateTimeOffset format) const formattedDate = newDate.toISOString().replace(/\.\d{3}Z$/, "Z"); // Remove milliseconds // Convert to ISO string const newDateString = newDate.toISOString(); // Return the replacement string wrapped in quotes return `"${newDateString}"`; }); //Regex looks for anything matching [Today-+xxx] and replaces with date string newUpdateItem2 = newUpdateItem2.replace(/\[Today(.*?)\]/gi, (match => { let offset = parseInt(match.toLowerCase().substring(6).replace("]", ""), 10); var newdate = new Date(); newdate.setDate(today.getDate() + offset); let newDateString = newdate.toLocaleString(); return newDateString; })); */ // Fix https://github.com/mikezimm/drilldown7/issues/225 // Replace [MyName] with userId.Title newUpdateItem2 = sourceUserInfo && sourceUserInfo.Title ? newUpdateItem2.replace(/\[MyName\]/gi, sourceUserInfo.Title) : newUpdateItem2; let newUpdateItemObj = JSON.parse(newUpdateItem2); //Replace {Me} Object.keys(newUpdateItemObj).map(k => { let thisColumn = newUpdateItemObj[k]; if (typeof thisColumn === 'string') { const thisColumnLC = thisColumn === null || thisColumn === void 0 ? void 0 : thisColumn.toLowerCase(); //Single value set to current user // const CommentCommands = [ 'append rich text', 'new rich text', 'append rich stamp', 'new rich stamp' ].map( ( cmd: string ) => { return cmd.toLowerCase() }); const isSpecial = thisColumnLC.indexOf('{{') === 0 && thisColumnLC.indexOf('}}') > 2 ? true : false; if (isSpecial === true) { const isCaptcha = thisColumnLC.indexOf('captcha') > 0 ? true : false; // Replaces current value if it doesn't find append if (isCaptcha === true) { //Get paramters from thisColumn, trim extra spaces, filter to only show elements with str length > 0 const CaptchaSplit = thisColumn.split(CaptchaRegex).map((s) => { return s.trim(); }).filter((s) => { return s.length > 0; }); if (CaptchaSplit.length === 2 || CaptchaSplit.length === 3) { const CaptchaCase = thisColumnLC.indexOf('captcha^') > 0 ? true : false; const RequiredField = CaptchaSplit[0] === '*' ? true : false; //Checks if there is an * after the captcha. If so, that field MUST have a value to test against const InternalName = CaptchaSplit[RequiredField === true ? 1 : 0].replace(`/`, ''); const TextPrompt = CaptchaSplit[RequiredField === true ? 2 : 1] ? CaptchaSplit[RequiredField === true ? 2 : 1] : `Please confirm you are human`; if (panelItem[InternalName]) { // column was deteched proceed with test if (typeof panelItem[InternalName] === 'string') { let userComment = prompt(`CAPTCHA ${InternalName} - ${TextPrompt} ${CaptchaCase === true ? 'Case Sensitive!' : ''} - IS REQUIRED to Save' : '' }`, ''); if (!userComment) { failedCaptchaTest = true; failureMessage.push(` You did not enter required Captcha in order to save.\n`); } else if (CaptchaCase === true && userComment !== panelItem[InternalName]) { failedCaptchaTest = true; failureMessage.push(`${userComment} did not match ${panelItem[InternalName]} ( proper cased )\n`); } else if (userComment.toLowerCase() !== panelItem[InternalName].toLowerCase()) { failedCaptchaTest = true; failureMessage.push(`${userComment} did not match ${panelItem[InternalName]}\n`); } if (failedCaptchaTest === false) thisColumn = userComment; } else { console.log('CAPTCHA code ~ 240 - Item not string, not testing', panelItem[InternalName]); } } else if (RequiredField === true) { // Item does not have this value to compare to.... handle exception? failedCaptchaRequired = true; failureMessage.push(`This item did not have required Captcha requirements... ${InternalName}\n`); } } else { //This does not have correct syntax. failedCaptchaTest = true; failureMessage.push(`This button's Captcha requirements were not set up correctly.\n`); } } else { // Added spoLink && makeLink for https://github.com/mikezimm/drilldown7/issues/328 const spoLink = thisColumnLC.indexOf('spo') > -1 ? true : false; // Replaces current value if it doesn't find append const makeLink = spoLink === true || thisColumnLC.indexOf('link') > -1 ? true : false; // Replaces current value if it doesn't find append const makeNew = thisColumnLC.indexOf('append') < 0 ? true : false; // Replaces current value if it doesn't find append const addStamp = thisColumnLC.indexOf('stamp') > 1 ? true : false; // Replaces current value if it doesn't find append const requireComment = thisColumnLC.indexOf('require') > 1 ? true : false; // Will NOT save anything unless a valid comment is entered const detectedRich = typeof panelItem[k] === 'string' && panelItem[k].indexOf('<div class="ExternalClass') === 0 ? true : null; // Treats as rich text if finds rich const detectedPlain = typeof panelItem[k] === 'string' && panelItem[k].indexOf('<div class="ExternalClass') !== 0 ? true : null; // Treats as rich text if finds rich // If existing data says it's rich or plain, goes with that. Else goes by command const makeRich = detectedRich === true ? true : detectedPlain === true ? false : thisColumnLC.indexOf('rich') > 1 ? true : false; const lineFeed = makeRich === true || detectedRich === true ? '<br>' : `\n`; let timeStamp = ''; if (addStamp === true) { //Add User Intials and Date Stamp const userInitals = (sourceUserInfo === null || sourceUserInfo === void 0 ? void 0 : sourceUserInfo.Title) ? getInitials(sourceUserInfo.Title, true, false) : ''; if (makeRich === true) { timeStamp = `<span style="font-weight:bold">${userInitals} - ${currentTimeLocal}</span>${lineFeed}`; } else { timeStamp = `${userInitals} - ${currentTimeLocal}${lineFeed}`; } } /** * ORIGINAL CODE from v1.0.88 */ // let userComment = prompt(`Add comment to: ${k} - ${timeStamp ? 'Is auto-date-stamped :)' : ''} ${requireComment ? ' - IS REQUIRED to Save' : ''}`, ''); // if (requireComment === true && (userComment === CommandEnterCommentString || !userComment)) { // failedRequiredUpdate = true; // failureMessage.push(`You need to add a comment to save.\n`); // } // https://github.com/mikezimm/drilldown7/issues/215 // if (makeRich === true) // userComment = `<span>${userComment}</span>`; // if (makeNew === false) // userComment = `${userComment}${lineFeed}${lineFeed}`; // console.log('timeStamp: ', timeStamp); // console.log('userComment:', userComment); // If user presses 'Ok' and it's not required, use the default message. // if (userComment === '') // userComment = CommandEmptyCommentMessage; // https://github.com/mikezimm/drilldown7/issues/233 // if (userComment === CommandEnterCommentString) { // Later on if the value is the same then do not do anything.... like canceling this prompt // thisColumn = CommandEnterCommentString; // } else if (userComment && makeNew === false) { //Append else make new // thisColumn = panelItem[k] ? `${timeStamp}${userComment}${lineFeed}${panelItem[k]}` : `${timeStamp}${userComment}`; // https://github.com/mikezimm/drilldown7/issues/215 // } else if (userComment) { thisColumn = `${timeStamp}${userComment}`; } // } // else : ( isCaptcha === true ) { // console.log('thisColumn:', thisColumn); // } else if (thisColumnLC === '[me]') { // if userComment === null, Cancel was pressed... if userComment === "", Ok was pressed. const isALink = panelItem[k] && panelItem[k].Url ? true : false; const currentUrl = panelItem[k] && panelItem[k].Url ? `${panelItem[k].Url}` : null; let userComment = makeLink === true ? // Adding hasValue to set the prompt to current value instead of adding other complexity. prompt(`Enter a valid ${spoLink === true ? 'SharePoint' : ''} Url: Must begin with ${spoLink === true ? `${CurrentOrigin}` : 'http...'}`, currentUrl ? currentUrl : '') : prompt(`Add comment to: ${k} - ${timeStamp ? 'Is auto-date-stamped :)' : ''} ${requireComment ? ' - IS REQUIRED to Save' : ''}`, ''); if (requireComment === true && (userComment === CommandEnterCommentString || !userComment)) { failedRequiredUpdate = true; failureMessage.push(`You need to add a ${makeLink === true ? 'VALID link' : 'comment'} to save.\n`); } else if (requireComment !== true && userComment === null) { // https://github.com/mikezimm/drilldown7/issues/315 // User pressed cancel... assume they want to cancel the update entirely. failedRequiredUpdate = true; failureMessage.push(`You canceled this update... No item will save.\n`); } // Added spoLink && makeLink for https://github.com/mikezimm/drilldown7/issues/328 if (userComment && makeLink === true) { if (spoLink === true && userComment.toLocaleLowerCase().indexOf(CurrentOrigin)) { failedRequiredUpdate = true; failureMessage.push(`You need to add a valid SharePoint Url to save.\n`); } else if (userComment.toLocaleLowerCase().indexOf('http') !== 0) { failedRequiredUpdate = true; failureMessage.push(`You need to add a valid link to save.\n`); } } if (failedRequiredUpdate !== true) { // Run this when you want to actually do the update... failedRequiredUpdate !== true /** * Cover 4 scenarios here: * * 1. Is Rich, Has Comment, Append * 2. Is Rich, Has Comment, MakeNew * * 3. Is Rich, NO Comment, Append * 4. Is Rich, NO Comment, MakeNew * * * 5. Is Text, Has Comment, Append * 6. Is Text, Has Comment, MakeNew * * 7. Is Text, NO Comment, Append * 8. Is Text, NO Comment, MakeNew * */ const hasCurrentValue = panelItem[k] ? true : false; // Added spoLink && makeLink for https://github.com/mikezimm/drilldown7/issues/328 if (makeLink === true) { thisColumn = { Url: `${userComment}`, Description: userComment.replace(CurrentOrigin, '').replace(`/sites`, ''), }; } else if (makeRich === true) { // Set default comment if none was provided. if (!userComment) userComment = `<span>${CommandEmptyCommentMessage}</span>`; if (makeNew === false) { // 1. Is Rich, Has Comment, Append || 3. Is Rich, NO Comment, Append userComment = `${timeStamp}${userComment}${lineFeed}${lineFeed}`; thisColumn = hasCurrentValue === true ? `${userComment}${lineFeed}${panelItem[k]}` : userComment; } else if (makeNew === true) { // 2. Is Rich, Has Comment, MakeNew || 4. Is Rich, NO Comment, MakeNew userComment = `${timeStamp}${userComment}`; thisColumn = userComment; } } else { // Should be normal text // Set default comment if none was provided. if (!userComment) userComment = CommandEmptyCommentMessage; if (makeNew === false) { // 5. Is Text, Has Comment, Append || 7. Is Text, NO Comment, Append userComment = `${timeStamp}${userComment}${lineFeed}${lineFeed}`; thisColumn = hasCurrentValue === true ? `${userComment}${lineFeed}${panelItem[k]}` : userComment; } else if (makeNew === true) { // 6. Is Text, Has Comment, MakeNew || 8. Is Text, NO Comment, MakeNew userComment = `${timeStamp}${userComment}`; thisColumn = userComment; } } // 2023-09-25 OLD CODE REPLACE BY ABOVE LOGIC // if ( requireComment !== true ) { // // https://github.com/mikezimm/drilldown7/issues/215 // if (makeRich === true ) { // // https://github.com/mikezimm/drilldown7/issues/315 // if ( !userComment ) { // userComment = CommandEmptyCommentMessage; // userComment = `<span>${userComment}</span>`; // } // } else { // Not rich text // userComment = CommandEmptyCommentMessage; // } // } // if ( makeNew === false ) // userComment = `${userComment}${lineFeed}${lineFeed}`; // console.log('timeStamp: ', timeStamp); // console.log('userComment:', userComment); // // https://github.com/mikezimm/drilldown7/issues/315 // //If user presses 'Ok' and it's not required, use the default message. // if ( requireComment !== true && userComment === '') userComment = CommandEmptyCommentMessage; // // https://github.com/mikezimm/drilldown7/issues/233 // if (userComment === CommandEnterCommentString ) { // //Later on if the value is the same then do not do anything.... like canceling this prompt // thisColumn = CommandEnterCommentString; // } else if (userComment && makeNew === false) { //Append else make new // thisColumn = panelItem[k] ? `${timeStamp}${userComment}${lineFeed}${panelItem[k]}` : `${timeStamp}${userComment}`; // https://github.com/mikezimm/drilldown7/issues/215 // } else if (userComment) { thisColumn = `${timeStamp}${userComment}`; } } } // else : ( isCaptcha === true ) { console.log('thisColumn:', thisColumn); } else if (thisColumnLC === '{me}') { thisColumn = sourceUserInfo.Id; console.log('thisColumn is: ', thisColumn); } else if (thisColumnLC === '||{me}') { if (!panelItem[k]) { thisColumn = sourceUserInfo.Id; } else { delete newUpdateItemObj[k]; } console.log('thisColumn is: ', thisColumn); //Single value only remove you } else if (thisColumnLC === '{-me}') { thisColumn = panelItem[k] === sourceUserInfo.Id ? null : panelItem[k]; //Multi value set to current user } else if (thisColumnLC === '[me]') { /** * 2025-01-28: Based on testing, no longer need results object with Odata 4.0. * https://github.com/mikezimm/drilldown7/issues/469 * WILL NEED if this is used for Odata3.0 such as in SE * thisColumn = { results: [sourceUserInfo.Id] }; */ thisColumn = [sourceUserInfo.Id]; //Multi value add current user //Multi value set to current user } else if (thisColumnLC === '||[me]') { if (!panelItem[k] || panelItem[k].length === 0) { /** * 2025-01-28: Based on testing, no longer need results object with Odata 4.0. * https://github.com/mikezimm/drilldown7/issues/469 * WILL NEED if this is used for Odata3.0 such as in SE * thisColumn = { results: [sourceUserInfo.Id] }; */ thisColumn = [sourceUserInfo.Id]; } else { delete newUpdateItemObj[k]; } //Multi value add current user } else if (thisColumnLC === '[+me]' || thisColumnLC === '||[+me]') { const hasCurrentUser = panelItem[k] && panelItem[k].length > 0 ? true : false; // Do this loop if there is a value and you want to add yourself if (!panelItem[k]) { thisColumn = [sourceUserInfo.Id]; } else if (hasCurrentUser && thisColumnLC === '[+me]') { try { //thisColumn = panelItem[k].results.push( sourceUserInfo.Id ); //Errored out thisColumn = panelItem[k]; if (thisColumn.indexOf(sourceUserInfo.Id) < 0) { thisColumn.push(sourceUserInfo.Id); } // thisColumn = { results: thisColumn }; } catch (e) { let err = getHelpfullError(e); alert(`Error updating item Column ${k} : \n\n${err}`); console.log(`Error updating item Column ${k} :`, err); } } else if (hasCurrentUser === false && thisColumnLC === '||[+me]') { /** * 2025-01-28: Based on testing, no longer need results object with Odata 4.0. * https://github.com/mikezimm/drilldown7/issues/469 * WILL NEED if this is used for Odata3.0 such as in SE * thisColumn = { results: [sourceUserInfo.Id] }; */ thisColumn = [sourceUserInfo.Id]; } else { console.log(`Skipped adding you to ${k}... ~526 here's current value:`, panelItem[k]); } //Multi value remove current user } else if (thisColumnLC === '[-me]') { if (panelItem[k]) { try { thisColumn = panelItem[k]; thisColumn = removeItemFromArrayAll(thisColumn, sourceUserInfo.Id); // thisColumn = { results: thisColumn }; } catch (e) { let err = getHelpfullError(e); alert(`Error updating item Column ${k} : \n\n${err}`); console.log(`Error updating item Column ${k} :`, err); } } { console.log(`Did not find Column ${k} and could not remove you from it.`, panelItem); console.log(`Here's the full panelItem:`, panelItem); } } // https://github.com/mikezimm/drilldown7/issues/233 if (thisColumn !== CommandEnterCommentString) newUpdateItemObj[k] = thisColumn; } // END This key value is string }); // https://github.com/mikezimm/drilldown7/issues/244 Object.keys(newUpdateItemObj).map(key => { if (typeof newUpdateItemObj[key] === 'string' && newUpdateItemObj[key].trim().indexOf('||') === 0) { if (!panelItem[key]) { newUpdateItemObj[key] = newUpdateItemObj[key].slice(2).trim(); } else { delete newUpdateItemObj[key]; } } }); let errMessage = ''; if (failedRequiredUpdate === true) { errMessage = `${CommandCancelRequired} - ${failureMessage.join('')}`; } else if (failedCaptchaTest === true) { errMessage = `${CommandCaptchaTestFailed} - ${failureMessage.join('')}`; } else if (failedCaptchaRequired === true) { errMessage = `${CommandCaptchaRequiredFailed} - ${failureMessage.join('')}`; } else if (Object.keys(newUpdateItemObj).length === 0) { errMessage = `${CommandItemNotUpdatedMessage} - ${failureMessage.join('')}`; } console.log('newUpdateItemObj', newUpdateItemObj); const updateProps = { fpsSpService: fpsSpService, webUrl: webUrl, listTitle: listTitle, Id: Id, itemUpdate: newUpdateItemObj, alertMe: thisButtonObject.alert, consoleLog: thisButtonObject.console, }; let result = null; if (errMessage) { result = { response: null, errorInfo: { returnMess: errMessage, friendly: errMessage, result: errMessage, errObj: errMessage, }, webUrl: webUrl, listTitle: listTitle, Id: Id, e: null, errorInput: null, status: 'RuleBreak', ok: null, unifiedPerformanceOps: null }; } else { result = await updateCommandItemAPI(updateProps); } // https://github.com/mikezimm/fps-library-v2/issues/14 // https://github.com/mikezimm/fps-library-v2/issues/16 return result; } //# sourceMappingURL=updateReactListItem.js.map