SHARE
TWEET

Untitled

a guest Oct 14th, 2016 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import addMarkbackRequestTemplate from './add_markback_request.html';
  2. import waitForAll from '../utils/async';
  3.  
  4. export default function routeConfig($stateProvider) {
  5.   'ngInject';
  6.  
  7.   $stateProvider
  8.     .state('event.add_markback_request', {
  9.       url: '/add_markback_request/seller/:sellerId',
  10.       template: addMarkbackRequestTemplate,
  11.       controller: 'AddMarkbackRequestController',
  12.       controllerAs: 'addMarkbackRequest',
  13.       resolve: {
  14.         mappedSections: (Restangular, sourceId, eventId, priceCategories) => {
  15.           const promises = []
  16.  
  17.           priceCategories.forEach((price, index) => {
  18.             const promise = Restangular
  19.               .all('events')
  20.               .all(eventId)
  21.               .all('allocated-sections')
  22.               .all(sourceId)
  23.               .get(price.category.split('P')[1]);
  24.  
  25.             promise.then((sectionArray) => {
  26.               sectionArray.filter(section =>
  27.                   section.is_ga
  28.               );
  29.               // Set default blank value to display as '-- Any --'
  30.               sectionArray.unshift({
  31.                 is_ga: true,
  32.                 name: '-- Any --',
  33.                 id: null,
  34.               });
  35.               return sectionArray;
  36.             });
  37.             promises.push(promise);
  38.           });
  39.  
  40.           return Promise.all(promises).then((sectionArrays) => {
  41.             const mappedSections = new Map();
  42.             sectionArrays.forEach((sectionArray, index) => {
  43.               mappedSections.set(priceCategories[index], sectionArray);
  44.             });
  45.             console.log(mappedSections)
  46.             return mappedSections;
  47.           });
  48.         },
  49.  
  50.       },
  51.     });
  52. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top