Manual Reference Source Test

src/utilities/mixins/Statable.js

import StatusService from '../../services/StatusService';
import Client from '../../Client';
/**
 * A mixin for classes that have statuses.  Currently the following types are statable:
 * Content, Flow, Sections
 */
class Statable {
  /**
   * Initializer for the mixin class
   */
  initializer() { }

  /**
   * Gets and updates the status of an object if it's a json api type.
   *
   * @param {Object} owner      - This is an object to which get the status of.
   * @param {String} owner.type - This is the type of object
   * @return {Promise<any>}     - Returns the status from StatusService given the owner type and sets the owner.status to its value.
   */
  getStatus(owner = {}) {
    const ownerType = owner.type || Client.instance.user.type;
    const ownerId = owner.id;

    return (new StatusService()).getStatus(this.type, this.id, ownerType, ownerId).then((d) => {
      /** @type {String} Status of the service */
      this.status = d.status.value;
    });
  }
}

export default Statable;