Ejemplo n.º 1
0
 const _filterConfigurableHelper = () => {
   if (product.type_id === 'configurable' && product.configurable_children) {
     const stockItems = []
     let confChildSkus = product.configurable_children.map((c) => { return c.sku })
     for (const confChild of product.configurable_children) {
       const stockCached = context.rootState.stock.cache[confChild.id]
       if (stockCached) {
         stockItems.push(stockCached)
         confChildSkus = remove(confChildSkus, (skuToCheck) => skuToCheck === confChild.sku)
       }
     }
     console.debug('Cached stock items and delta', stockItems, confChildSkus)
     if (confChildSkus.length > 0) {
       context.dispatch('stock/list', { skus: confChildSkus }, {root: true}).then((task) => {
         if (task && task.resultCode === 200) {
           const diffLog = []
           _filterChildrenByStockitem(context, union(task.result, stockItems), product, diffLog)
           console.debug('Filtered configurable_children with the network call', diffLog)
           resolve()
         } else {
           console.error('Cannot sync the availability of the product options. Please update the vue-storefront-api or switch on the Internet :)')
         }
       }).catch(err => {
         console.error(err)
       })
     } else {
       const diffLog = []
       _filterChildrenByStockitem(context, stockItems, product, diffLog)
       console.debug('Filtered configurable_children without the network call', diffLog)
       resolve()
     }
   } else {
     resolve()
   }
 }
Ejemplo n.º 2
0
Archivo: combo.js Proyecto: slhh/iD
 function removeMultikey(d) {
     d3_event.stopPropagation();
     var t = {};
     if (isMulti) {
         t[d.key] = undefined;
     } else if (isSemi) {
         _remove(_multiData, function(md) { return md.key === d.key; });
         var arr = _multiData.map(function(md) { return md.key; });
         arr = _compact(_uniq(arr));
         t[field.key] = arr.length ? arr.join(';') : undefined;
     }
     dispatch.call('change', this, t);
 }