コード例 #1
0
/**
 * Get the facet values of a specified attribute from a SearchResults object.
 * @private
 * @param {SearchResults} results the search results to search in
 * @param {string} attribute name of the facetted attribute to search for
 * @return {array|object} facet values. For the hierarchical facets it is an object.
 */
function extractNormalizedFacetValues(results, attribute) {
  var predicate = {name: attribute};
  if (results._state.isConjunctiveFacet(attribute)) {
    var facet = find(results.facets, predicate);
    if (!facet) return [];

    return map(facet.data, function(v, k) {
      return {
        name: k,
        count: v,
        isRefined: results._state.isFacetRefined(attribute, k)
      };
    });
  } else if (results._state.isDisjunctiveFacet(attribute)) {
    var disjunctiveFacet = find(results.disjunctiveFacets, predicate);
    if (!disjunctiveFacet) return [];

    return map(disjunctiveFacet.data, function(v, k) {
      return {
        name: k,
        count: v,
        isRefined: results._state.isDisjunctiveFacetRefined(attribute, k)
      };
    });
  } else if (results._state.isHierarchicalFacet(attribute)) {
    return find(results.hierarchicalFacets, predicate);
  }
}
コード例 #2
0
ファイル: BpmnCopyPasteSpec.js プロジェクト: JJediny/bpmn-js
    it('copying participant should copy process as well', inject(function(elementRegistry, copyPaste, canvas) {

      // given
      var participants = map([ 'Participant_Input', 'Participant_Output' ], function(e) {
        return elementRegistry.get(e);
      });
      var rootElement = canvas.getRootElement();

      // when
      copyPaste.copy(participants);

      copyPaste.paste({
        element: rootElement,
        point: {
          x: 4000,
          y: 4500
        }
      });

      // then
      var elements = elementRegistry.filter(function(element) {
        return element.type === 'bpmn:Participant';
      });

      var processIds = map(elements, function(e) {
        return e.businessObject.processRef.id;
      });

      expect(uniq(processIds)).to.have.length(4);
    }));
コード例 #3
0
ファイル: index.js プロジェクト: jmarceli/tap-webpack-plugin
function run (options, compilation, callback) {
  var entry = filter(compilation.chunks, 'entry')
  var files = map(entry, function (c) { return c.files[0] })
  var assets = map(files, function (f) { return compilation.assets[f] })
  var source = map(assets, function (a) { return a.source() }).join('\n')

  var proc = spawn(process.execPath, { stdio: ['pipe', 'pipe', 'inherit'] })
  proc.stdin.end(source, 'utf8')
  return runParallel([
    options.reporter ? report : parse,
    exit
  ], callback)

  function report (callback) {
    var reporter = execSpawn(options.reporter,
      { stdio: ['pipe', 'inherit', 'inherit'] })
    proc.stdout.pipe(reporter.stdin)
    reporter.on('exit', exited)

    function exited (code) {
      if (code !== 0) addError('test reporter non-zero exit code')
      return callback()
    }
  }

  function parse (callback) {
    proc.stdout.pipe(tapOut(parsed))

    function parsed (err, results) {
      if (err) {
        addError('could not parse TAP output')
      } else if (results.fail.length > 0) {
        forEach(map(results.fail, getError), addError)
      }
      return callback()

      function getError (f) {
        return getMessage(results.tests[f.test - 1], f)
      }
    }
  }

  function exit (callback) {
    proc.on('exit', exited)

    function exited (code) {
      if (code !== 0) addError('tests failed')
      return callback()
    }
  }

  function addError (message) {
    compilation.errors.push(new Error(message))
  }
}
コード例 #4
0
    render: function render() {
        var _this3 = this;

        // If there is no result, render the given empty component
        if (0 === this.props.totalCount) {
            return this._renderEmptyResults();
        }
        // Filter groups with no results
        var resultsMap = omit(this.props.resultsMap, function (list) {
            return 0 === list.length;
        });
        // Get the count for each group
        var groupCounts = this._getGroupCounts(this.props.resultsMap);
        // Check if there is only one group left
        if (1 === keys(resultsMap).length) {
            var key = keys(resultsMap)[0];
            var list = resultsMap[key];
            var count = groupCounts[key].count;
            return this._renderSingleGroup(list, key, count, true);
        } else {
            return React.createElement(
                'div',
                { 'data-focus': 'search-results' },
                map(resultsMap, function (list, key) {
                    var count = groupCounts[key];
                    return _this3._renderSingleGroup(list, key, count);
                })
            );
        }
    }
コード例 #5
0
ファイル: dispatcher.js プロジェクト: mmpro/fluxxor
  _forOwn(this.waitingToDispatch, function(value, key) {
    dispatch          = this.currentDispatch[key];
    canBeDispatchedTo = !dispatch.waitingOn.length ||
                        !_intersection(dispatch.waitingOn, _keys(this.waitingToDispatch)).length;
    if(canBeDispatchedTo) {
      if(dispatch.waitCallback) {
        var stores            = _map(dispatch.waitingOn, function(key) {
          return this.stores[key];
        }, this);
        var fn                = dispatch.waitCallback;
        dispatch.waitCallback = null;
        dispatch.waitingOn    = [];
        dispatch.resolved     = true;
        fn.apply(null, stores);
        wasHandled = true;
      } else {
        dispatch.resolved = true;
        var handled       = this.stores[key].__handleAction__(action);
        if(handled) {
          wasHandled = true;
        }
      }

      dispatchedThisLoop.push(key);

      if(this.currentDispatch[key].resolved) {
        removeFromDispatchQueue.push(key);
      }
    }
  }, this);
コード例 #6
0
PasteHandler.prototype._createConnection = function(element, parent, parentCenter, tree) {
  var modeling = this._modeling,
      rules = this._rules;

  var connection, source, target, canPaste;

  element.waypoints = map(element.waypoints, function(waypoint, idx) {
    return {
      x: Math.round(parentCenter.x + element.delta[idx].x),
      y: Math.round(parentCenter.y + element.delta[idx].y)
    };
  });

  source = this._getCreatedElement(element.source, tree);
  target = this._getCreatedElement(element.target, tree);

  if (!source || !target) {
    return null;
  }

  canPaste = rules.allowed('element.paste', {
    source: source,
    target: target
  });

  if (!canPaste) {
    return null;
  }

  removeProperties(element, [ 'id', 'parent', 'delta', 'source', 'target', 'width', 'height', 'priority' ]);

  connection = modeling.createConnection(source, target, element, parent);

  return connection;
};
コード例 #7
0
ファイル: index.js プロジェクト: Peccer/ga-dev-tools
/**
 * Invoked when a user submits the <QueryForm>.
 * @param {Event|Object} e The native or React event.
 */
function handleSubmit(e) {
  e.preventDefault();

  let paramsClone = clone(params.get());

  // Construct a "Query Parameter" dimension string based off this report
  let paramsToTrack = pick(paramsClone,
      ['start-date', 'end-date', 'metrics', 'dimensions']);
  // Don't run `encodeURIComponent` on these params because the they will
  // never contain characters that make parsing fail (or be ambiguous).
  // NOTE: Manual serializing is requred until the encodeURIComponent override
  // is supported here: https://github.com/Gozala/querystring/issues/6
  let serializedParamsToTrack = map(paramsToTrack,
      (value, key) => `${key}=${value}`).join('&');

  // Set it on the tracker so it gets sent with all Query Explorer hits.
  ga('set', 'dimension2', serializedParamsToTrack);

  state.set({
    isQuerying: true,
    report: {
      params: paramsClone
    }
  });
}
コード例 #8
0
ファイル: BpmnSearchProvider.js プロジェクト: JJediny/bpmn-js
BpmnSearchProvider.prototype.find = function(pattern) {
  var rootElement = this._canvas.getRootElement();

  var elements = this._elementRegistry.filter(function(element) {
    if (element.labelTarget) {
      return false;
    }
    return true;
  });

  // do not include root element
  elements = filter(elements, function(element) {
    return element !== rootElement;
  });

  elements = map(elements, function(element) {
    return {
      primaryTokens: matchAndSplit(labelUtil.getLabel(element), pattern),
      secondaryTokens: matchAndSplit(element.id, pattern),
      element: element
    };
  });

  // exclude non-matched elements
  elements = filter(elements, function(element) {
    return hasMatched(element.primaryTokens) || hasMatched(element.secondaryTokens);
  });

  elements = sortBy(elements, function(element) {
    return labelUtil.getLabel(element.element) + element.element.id;
  });

  return elements;
};
コード例 #9
0
ファイル: app.js プロジェクト: brayancruces/codebasket
  render: function() {
    var codeBasket = this.props.codeBasket,
        userDefinedSidebarSize = (this.state.sidebarSize === undefined) ? 200 : this.state.sidebarSize,
        sidebarSize = (this.state.isSidebarVisible ? userDefinedSidebarSize : 0.1),
        sidebarActions = map(codeBasket.sidebarActions, this.renderSidebarAction),
        brand = codeBasket.brand ? <Brand brand={codeBasket.brand} width={userDefinedSidebarSize + 1} /> : undefined,
        hasUsersList = (codeBasket.users !== undefined),
        usersList = (hasUsersList ? <UsersList currentUser={codeBasket.currentUser} users={codeBasket.users} /> : undefined),
        permanentStatus = codeBasket.permanentStatus || '';

    return (
      <main ref="main" className="console-container" onClick={this.hideOptionsList}>
        <div className="console-container-wrapper">
          <section className="console-wrapper">
            <SplitPane split="vertical" minSize={200} defaultSize={sidebarSize} onChange={this.onChangeSidebarSize}>
              <aside className="console-sidebar-container" ref="sidebar-container">
                <nav className="console-sidebar-actions">
                  {sidebarActions}
                </nav>
                <Sidebar ref="sidebar" app={codeBasket} items={codeBasket.sidebarItems} parentView={this} />
              </aside>
              {this.renderTabsContainer()}
            </SplitPane>
          </section>
          <footer className={'console-footer' + (this.state.isFullScreen ? ' collapsed' : '')}>
            {brand}
            <span className="console-footer-permanent-status">{permanentStatus}</span>
            {usersList}
            <span className="console-footer-status" title={codeBasket.status}>{codeBasket.status}</span>
            <progress className={'console-footer-progress' + (this.state.isProgressBarVisible ? ' visible' : '')} max="100"></progress>
          </footer>
        </div>
      </main>
    );
  }
コード例 #10
0
test('Should encode all the properties of AlgoliaSearchHelper properly', function(t) {
  var ks = keys(new SearchParameters());
  var encodedKs = uniq(map(ks, shortener.encode));
  t.equals(
    encodedKs.length,
    ks.length,
    'Once all the properties converted and dedup, their length should be equal'
  );
  var decodedKs = map(encodedKs, shortener.decode);
  t.deepEquals(
    decodedKs,
    ks,
    'Encode then decode should be the initial value'
  );
  t.end();
});
コード例 #11
0
ファイル: userTable.js プロジェクト: swufewyd/portal-local
    render:function() {
        var that = this;
        return (
            <div>
                <CustomModalTrigger text={this.state.modalText} ref="triggerBtn" />
                <Table responsive striped bordered condensed hover>
                   <thead>
                     <tr>
                       <th>#</th>
                       <th>姓名▲</th>
                       <th>邮箱</th>
                       <th><a onClick={this.handleOrder} className="hover-order">橙信分</a></th>
                       <th>最近登录</th>
                       
                     </tr>
                   </thead>
                   <tbody>

                                {lodashMap(this.props.userObjs, function(obj,i) {
                                    return   <tr onClick={that.handleClick}>
                                                   <td >{i+1}</td>
                                                   <td>{obj.name}</td>
                                                   <td>{obj.email}</td>
                                                   <td>{obj.score}</td>
                                                   <td>{obj.lastLogin}</td>
                                                 </tr>
                                })}
                     
                   </tbody>
                 </Table>
                 </div>
                 )
    }
コード例 #12
0
ファイル: checkbox.js プロジェクト: peter-hst/helloscala-site
    render: function () {
        var items = __map(this.props.options, function (option, i) {
            var checked = __includes(this.props.value, option.value);

            if (this.props.className) {
                return (
                    <label className={this.props.className} key={'c' + i}>
                        <input {...this.props} type="checkbox" value={option.value} checked={checked}
                                               onChange={this.onChange}/>
                        {option.label}
                    </label>
                );
            } else {
                return (
                    <div className="col-xs-12 col-md-6 col-lg-4" key={'c' + i}>
                        <div className="checkbox" style={{marginTop:0,marginBottom:0}}>
                            <label>
                                <input {...this.props} type="checkbox" value={option.value} checked={checked}
                                                       onChange={this.onChange}/>
                                {option.label}
                            </label>
                        </div>
                    </div>
                );
            }
        }.bind(this));

        var className = 'row';
        if (this.props.className) {
            className = null;
        }

        return (<div className={className}>{items}</div>)
    }
コード例 #13
0
export default function (query) {
  var keyValuePairs = map(query, (value, key) => {
    return [key, value].join('=');
  });

  window.location.replace('#' + keyValuePairs.join('&'));
}
コード例 #14
0
function propTypesToNames(props) {
    let ret = {};
    map(props, function (v, k) {
        ret[k] = propTypeToName(v);
    });
    return ret;
}
コード例 #15
0
    this.files.forEach(function(f) {
      // Concat specified files.
      var expandedPaths = f.src.filter(function(filepath) {
        // Warn on and remove invalid source files (if nonull was set).
        if (!grunt.file.exists(filepath)) {
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return false;
        } else {
          return true;
        }
      });

      var source = expandedPaths.map(function(filepath) {
        // Read file source.
        return grunt.file.read(filepath);
      });

      /**
       * Read configuration file.
       */
      var config = {};
      if(options.config) {
        var configFile = path.resolve(options.config);

        // The file must exist!
        if(!fs.existsSync(configFile)) {
          grunt.log.exit('Config file "' + configFile + '" not found.');
          process.exit(1);
        }

        config = JSON.parse(fs.readFileSync(configFile, 'utf-8'));
      } else {
        var dir = findParentDir.sync(process.cwd(), '.sasslint.json');
        if(dir) {
          config = JSON.parse(fs.readFileSync(dir + '/.sasslint.json', 'utf-8'));
        } else {
          grunt.log.error('Config file not found.');
          process.exit(1);
        }
      }

      /**
       * Run Sasslint!
       */
      var runner = new Runner(config);
      var lints = map(source, function(sass) {
        return runner.lint(sass, options);
      });


      lints.forEach(function(lint, index) {
        if(lint.length) {
          reporter.report(lint, f.src[index]);
        }

        if(lint.length) hadErrors = true;
      });
    });
コード例 #16
0
    helper.on('result', function(content) {
      calls++;

      if (calls === 1) {
        t.equal(content.hits.length, 4, 'No tags: 3 results');
        t.deepEqual(map(content.hits, hitsToParsedID).sort(),
          [0, 1, 2, 3],
          'No tags expected ids: 0, 1, 2, 3');
        helper.addTag('t1').search();
      }

      if (calls === 2) {
        t.equal(content.hits.length, 2, 'One tag (t1): 2 results');
        t.deepEqual(map(content.hits, hitsToParsedID).sort(),
          [0, 1],
          'One tag (t1) expected ids: 0, 1');
        helper.addTag('t2').search();
      }

      if (calls === 3) {
        t.equal(content.hits.length, 1, 'Two tags (t1, t2): 1 result');
        t.deepEqual(map(content.hits, hitsToParsedID).sort(),
          [0],
          'Two tags (t1, t2) expected ids: 0');
        helper.removeTag('t2').toggleTag('t3').toggleTag('t1').search();
      }

      if (calls === 4) {
        t.equal(content.hits.length, 3, 'One tag (t3): 3 results');
        t.deepEqual(map(content.hits, hitsToParsedID).sort(),
          [1, 2, 3],
          'One tag (t3) expected ids: 1, 2, 3');
        helper.clearTags().setQueryParameter('tagFilters', 't3,(t1,t2)').search();
      }

      if (calls === 5) {
        t.equal(content.hits.length, 2, 'filter should result in two item again');
        t.deepEqual(map(content.hits, hitsToParsedID).sort(), [1, 2]);
        client.deleteIndex(indexName);
        if (!process.browser) {
          client.destroy();
        }
        t.end();
      }
    });
コード例 #17
0
ファイル: actions.js プロジェクト: KevinEverywhere/wp-calypso
export function fetchSitePlansCompleted( siteId, data ) {
	data = reject( data, '_headers' );

	return {
		type: SITE_PLANS_FETCH_COMPLETED,
		siteId,
		plans: map( data, createSitePlanObject )
	};
}
コード例 #18
0
/**
 * Sort nodes of a hierarchical facet results
 * @param {HierarchicalFacet} node node to upon which we want to apply the sort
 */
function recSort(sortFn, node) {
  if (!node.data || node.data.length === 0) {
    return node;
  }
  var children = map(node.data, partial(recSort, sortFn));
  var sortedChildren = sortFn(children);
  var newNode = merge({}, node, {data: sortedChildren});
  return newNode;
}
コード例 #19
0
ファイル: poll-report.js プロジェクト: naholyr/orga.xyz
  render() {
    const selections = sort(this.props.selections, ["workshop", "hour"])

    if (!selections.length) {
      return <p>Aucune sélection</p>
    }

    return <ul>{ map(selections, s => this.renderSelection(s)) }</ul>
  }
コード例 #20
0
function sortBySelector({
    container,
    indices,
    cssClasses: userCssClasses = {},
    autoHideContainer = false
  } = {}) {
  if (!container || !indices) {
    throw new Error(usage);
  }

  let containerNode = utils.getContainerNode(container);
  let Selector = require('../../components/Selector.js');
  if (autoHideContainer === true) {
    Selector = autoHideContainerHOC(Selector);
  }

  let selectorOptions = map(indices, function(index) {
    return {label: index.label, value: index.name};
  });

  return {
    init: function({helper}) {
      let currentIndex = helper.getIndex();
      let isIndexInList = findIndex(indices, {name: currentIndex}) !== -1;
      if (!isIndexInList) {
        throw new Error('[sortBySelector]: Index ' + currentIndex + ' not present in `indices`');
      }
    },

    setIndex: function(helper, indexName) {
      helper.setIndex(indexName);
      helper.search();
    },

    render: function({helper, results}) {
      let currentIndex = helper.getIndex();
      let hasNoResults = results.nbHits === 0;
      let setIndex = this.setIndex.bind(this, helper);

      let cssClasses = {
        root: cx(bem(null), userCssClasses.root),
        item: cx(bem('item'), userCssClasses.item)
      };
      ReactDOM.render(
        <Selector
          cssClasses={cssClasses}
          currentValue={currentIndex}
          options={selectorOptions}
          setValue={setIndex}
          shouldAutoHideContainer={hasNoResults}
        />,
        containerNode
      );
    }
  };
}
コード例 #21
0
ファイル: render.js プロジェクト: guitao/rune.js
 polygonToSVG: function(polygon) {
   var attr = {
     points: map(polygon.vars.vectors, function(vec) {
       return vec.x + " " + vec.y;
     }).join(" ")
   };
   this.transformAttribute(attr, polygon);
   this.styleableAttributes(polygon, attr);
   return svg('polygon', attr);
 },
コード例 #22
0
ファイル: ListViewRow.js プロジェクト: hareeqi/youtube-music
 /**
  * @returns {XML}
  */
 renderActions() {
   var {actions} = this.props;
   if (isArray(actions)) {
     return (
       <View>
         {map(actions, (component, index) => <View key={index}>{component}</View>)}
       </View>
     );
   }
 }
コード例 #23
0
 forEach(values, function(value) {
   if (isArray(value)) {
     var vs = map(value, function(v) {
       return attribute + operator + v;
     });
     numericFilters.push(vs);
   } else {
     numericFilters.push(attribute + operator + value);
   }
 });
コード例 #24
0
/**
 * Dialog filters based on file type(s).
 *
 * The passed argument can be a single string or a list of strings
 * for which extension filter objects are being returned.
 *
 * @param {String|Array} types
 *
 * @return {Array<Object>} extension filters
 */
function getFilters(types) {

  if (typeof types === 'string') {
    types = [ types ];
  }

  return map(types, function(fileType) {
    return EXTENSIONS[fileType];
  });
}
コード例 #25
0
  render() {
    const fieldDefinition = this.props.config.fields[this.props.field];
    const options = map(fieldDefinition.options, (label, value) =>
      <option key={value} value={value}>{label}</option>
    );

    return (
      <select autoFocus={this.props.delta === 0} ref="select" value={this.props.value} onChange={this.handleChange.bind(this)}>{options}</select>
    );
  }
コード例 #26
0
function dataPointTest(series, filterTest, someTest) {
	// A function to systemitize looping through every datapoint
	var vals = map(series, function(d,i) {
		return filter(d.values, filterTest);
	});

	return some(vals, function(n) {
		return someTest(n,vals);
	});
}
コード例 #27
0
ファイル: view.js プロジェクト: Happy0/lila
function renderDifficulty(ctrl) {
  return m('div.difficulty.buttonset', map(ctrl.data.difficulty.choices, function(dif) {
    var id = dif[0],
      name = dif[1];
    return m('a.button' + (id == ctrl.data.difficulty.current ? '.active' : ''), {
      disabled: id == ctrl.data.difficulty.current,
      onclick: partial(xhr.setDifficulty, ctrl, id)
    }, name);
  }));
}
コード例 #28
0
AlgoliaSearchHelper.prototype.getHierarchicalFacetBreadcrumb = function(facetName) {
  return map(
    this
      .state
      .getHierarchicalRefinement(facetName)[0]
      .split(this.state._getHierarchicalFacetSeparator(
        this.state.getHierarchicalFacetByName(facetName)
      )), function trimName(facetValue) { return trim(facetValue); }
  );
};
コード例 #29
0
	_applySettingsToData: function(_chartProps, additional) {
		return map(_chartProps.data, function(d, i) {
			var series = {};
			series.key = d.name;
			if (additional) {
				series = assign(series, additional);
			}
			return assign(series, d, _chartProps.chartSettings[i]);
		});
	},
コード例 #30
0
ファイル: BpmnCopyPaste.js プロジェクト: tao-gong/bpmn-js
  copyPaste.registerDescriptor(function(element, descriptor) {
    var businessObject = getBusinessObject(element),
        conditionExpression,
        eventDefinitions;

    descriptor.type = element.type;

    if (element.type === 'label') {
      return descriptor;
    }

    setProperties(descriptor, businessObject, [
      'name',
      'text',
      'processRef',
      'isInterrupting',
      'isForCompensation',
      'associationDirection'
    ]);

    if (businessObject.default) {
      descriptor.default = businessObject.default.id;
    }

    if (businessObject.loopCharacteristics) {

      descriptor.loopCharacteristics = {
        type: businessObject.loopCharacteristics.$type,
        isSequential: businessObject.loopCharacteristics.isSequential
      };
    }

    setProperties(descriptor, businessObject.di, [ 'isExpanded' ]);

    if (is(businessObject, 'bpmn:SequenceFlow')) {
      conditionExpression = businessObject.get('conditionExpression');

      if (conditionExpression) {
        descriptor.conditionExpression = {
          type: conditionExpression.$type,
          body: conditionExpression.body
        };
      }
    }

    eventDefinitions = businessObject.get('eventDefinitions') || [];

    if (eventDefinitions.length) {
      descriptor.eventDefinitions = map(eventDefinitions, function(defs) {
        return defs.$type;
      });
    }

    return descriptor;
  });