client/public/elements/pages/person/rp-page-person.js
/**
   * @method _doPubOverviewQuery
   * @description Gets aggregation counts of all publication types for this individual.
   * Kicks off further queries for the actual publication records if applicable.
   *
   * @param {String} id - The individual's id
   *
   * @returns {Promise}
   */
@method _doPubOverviewQuery
@description Gets aggregation counts of all publication types for this individual.
Kicks off further queries for the actual publication records if applicable.

@param {String} id - The individual's id

@returns {Promise}
@method _doPubOverviewQuery @description Gets aggregation counts of all publication types for this individual . Kicks off further queries for the actual publication records if applicable . @param { String } id - The individual ' s id @returns { Promise }
async _doPubOverviewQuery(id) {
    this.publicationOverviewStatus = 'loading';
    let data = await this.PersonModel.getPubOverview(id);
    if( data.state === 'error' ) {
      this.publicationOverviewStatus = 'error';
      return;
    }
    if (data.state != 'loaded') {
      return;
    }
    if (config.verbose) console.log('pub overview:', data);
    let totalPubs = 0;
    let pubTypes = {};
    for (let possiblePubType of this.PersonModel.getPublicationTypes()) {
      let ct = data.payload.aggregations.facets['@type'][possiblePubType.es];
      if (ct) {
        totalPubs += ct;
        pubTypes[possiblePubType.id] = {
          ...possiblePubType,
          ct: ct,
          displayedOffset: 0,
          dataStatus: 'loading'};
      }
    }
    this.hasMultiplePubTypes = Object.keys(pubTypes).length > 1;
    for (let pubType in pubTypes) {
      pubTypes[pubType].displayedOffset = this.hasMultiplePubTypes ? 5 : 10;
    }
    this.totalPublications = totalPubs;
    this.publicationOverview  = pubTypes;
    await Promise.all(Object.values(pubTypes).map(pt => this._doPubQuery(pt)));
    if ( this.publicationOverviewStatus !== 'error' ) {
      this.publicationOverviewStatus = 'loaded';
    }
  }
async _doPubOverviewQuery ( id ) { this . publicationOverviewStatus = 'loading' ; let data = await this . PersonModel . getPubOverview ( id ) ; if ( data . state === 'error' ) { this . publicationOverviewStatus = 'error' ; return ; } if ( data . state != 'loaded' ) { return ; } if ( config . verbose ) console . log ( 'pub overview:' , data ) ; let totalPubs = 0 ; let pubTypes = { } ; for ( let possiblePubType of this . PersonModel . getPublicationTypes ( ) ) { let ct = data . payload . aggregations . facets [ '@type' ] [ possiblePubType . es ] ; if ( ct ) { totalPubs += ct ; pubTypes [ possiblePubType . id ] = { ... possiblePubType , ct : ct , displayedOffset : 0 , dataStatus : 'loading' } ; } } this . hasMultiplePubTypes = Object . keys ( pubTypes ) . length > 1 ; for ( let pubType in pubTypes ) { pubTypes [ pubType ] . displayedOffset = this . hasMultiplePubTypes ? 5 : 10 ; } this . totalPublications = totalPubs ; this . publicationOverview = pubTypes ; await Promise . all ( Object . values ( pubTypes ) . map ( pt => this . _doPubQuery ( pt ) ) ) ; if ( this . publicationOverviewStatus !== 'error' ) { this . publicationOverviewStatus = 'loaded' ; } }
@method _doPubOverviewQuery
 @description Gets aggregation counts of all publication types for this individual.
@method _doPubOverviewQuery @description Gets aggregation counts of all publication types for this individual .