SHARE
TWEET

Untitled

a guest Oct 14th, 2016 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.       mappedSections: (Restangular, sourceId, eventId, priceCategories) => {
  2.         const mappedSections = new Map();
  3.         const promises = []
  4.         //this.prices.forEach((price) => {
  5.         //  this.priceCategoryNames.push(price.category);
  6.         //});
  7.         //
  8.         //this.priceCategories.forEach((price) => {
  9.         //  priceIndexes.push(this.priceCategoryNames.indexOf(price.category));
  10.         //});
  11.  
  12.         priceCategories.forEach((price, index) => {
  13.           const promise = Restangular
  14.             .all('events')
  15.             .all(eventId)
  16.             .all('allocated-sections')
  17.             .all(sourceId)
  18.             .get(price.category.split('P')[1]);
  19.  
  20.           promise.then((sectionArray) => {
  21.             sectionArray.filter(section =>
  22.                 section.is_ga
  23.             );
  24.             // Set default blank value to display as '-- Any --'
  25.             sectionArray.unshift({
  26.               is_ga: true,
  27.               name: '-- Any --',
  28.               id: null,
  29.             });
  30.             return sectionArray;
  31.           }).then((sectionArray) => {
  32.             mappedSections.set(priceCategories[index], sectionArray);
  33.           });
  34.  
  35.           promises.push(promise);
  36.         });
  37.  
  38.         console.log(promises)
  39.         return Promise.all(promises).then(() => {return mappedSections});
  40.       },
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