awx/ui_next/src/util/qs.js
/**
 * Removes params from the search string and returns the updated list of params
 * @param {object} qs config object (used for getting defaults, current query params etc.)
 * @param {object} object with params from existing search
 * @param {object} object with new params to remove
 * @return {object} query param object
 */
Removes params from the search string and returns the updated list of params
@param {object} qs config object (used for getting defaults, current query params etc.)
@param {object} object with params from existing search
@param {object} object with new params to remove
@return {object} query param object
Removes params from the search string and returns the updated list of params @param { object } qs config object ( used for getting defaults current query params etc . ) @param { object } object with params from existing search @param { object } object with new params to remove @return { object } query param object
function removeParams(config, oldParams, paramsToRemove) {
  const paramsEntries = [];
  Object.entries(oldParams).forEach(([key, value]) => {
    if (Array.isArray(value)) {
      value.forEach(val => {
        paramsEntries.push([key, val]);
      });
    } else {
      paramsEntries.push([key, value]);
    }
  });
  const paramsToRemoveEntries = Object.entries(paramsToRemove);
  const remainingEntries = paramsEntries.filter(
    ([key, value]) =>
      paramsToRemoveEntries.filter(
        ([newKey, newValue]) => key === newKey && value === newValue
      ).length === 0
  );
  const remainingObject = toObject(remainingEntries);
  const defaultEntriesLeftover = Object.entries(config.defaultParams).filter(
    ([key]) => !remainingObject[key]
  );
  const finalParamsEntries = remainingEntries;
  defaultEntriesLeftover.forEach(value => {
    finalParamsEntries.push(value);
  });
  return toObject(finalParamsEntries);
}
function removeParams ( config , oldParams , paramsToRemove ) { const paramsEntries = [ ] ; Object . entries ( oldParams ) . forEach ( ( [ key , value ] ) => { if ( Array . isArray ( value ) ) { value . forEach ( val => { paramsEntries . push ( [ key , val ] ) ; } ) ; } else { paramsEntries . push ( [ key , value ] ) ; } } ) ; const paramsToRemoveEntries = Object . entries ( paramsToRemove ) ; const remainingEntries = paramsEntries . filter ( ( [ key , value ] ) => paramsToRemoveEntries . filter ( ( [ newKey , newValue ] ) => key === newKey && value === newValue ) . length === 0 ) ; const remainingObject = toObject ( remainingEntries ) ; const defaultEntriesLeftover = Object . entries ( config . defaultParams ) . filter ( ( [ key ] ) => ! remainingObject [ key ] ) ; const finalParamsEntries = remainingEntries ; defaultEntriesLeftover . forEach ( value => { finalParamsEntries . push ( value ) ; } ) ; return toObject ( finalParamsEntries ) ; }
Removes params from the search string and returns the updated list of params
 @param {object} qs config object (used for getting defaults, current query params etc.)
Removes params from the search string and returns the updated list of params @param { object } qs config object ( used for getting defaults current query params etc . )