SHARE
TWEET

Untitled

a guest Feb 27th, 2020 87 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { setHiddenAttribute } from 'uims/api/collection';
  2. import { setCollectionAttributeAction, setCollectionViewAction } from 'uims/redux/actions/collectionsStorage';
  3. import { IThunkActionCreator, TThunkDispatch } from 'uims/types/redux';
  4. import { notify } from 'uims/utils/notify';
  5. import { successCodes } from 'uims/utils/requestAnswersArray';
  6. import { processCollectionViewData } from '../../../utils/collection';
  7.  
  8. export const setCollectionAttributesAction = (ids: string[], hidden: boolean[]): IThunkActionCreator<Promise<void>> => {
  9.     return async (dispatch: TThunkDispatch, getState, { networkService }) => {
  10.         const { applicationView: {selectedSheetId, selectedCollectionId}, collectionData, concurrentUsers } = getState();
  11.         dispatch(setCollectionAttributeAction({ids, hidden, sheetId: selectedSheetId}));
  12.         const sheetData = collectionData.sheets[selectedSheetId];
  13.         const collectionViewData = processCollectionViewData(sheetData, concurrentUsers);
  14.         dispatch(setCollectionViewAction(collectionViewData));
  15.  
  16.         const dataObj: any = {};
  17.  
  18.         ids.forEach((id, idx) => {
  19.             dataObj[id] = {
  20.                 hide: hidden[idx],
  21.             };
  22.         });
  23.  
  24.         const responseSetHideAttribute = await setHiddenAttribute(
  25.             networkService, selectedCollectionId, selectedSheetId, dataObj,
  26.         );
  27.  
  28.         const { status } = responseSetHideAttribute;
  29.         if (!successCodes.includes(status)) {
  30.             notify(status);
  31.         }
  32.     };
  33. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top