<commit_before>var registerComponent = require('../core/component').registerComponent;
var bind = require('../utils/bind');
var isControllerPresent = require('../utils/tracked-controls').isControllerPresent;

var TOUCH_CONTROLLER_MODEL_BASE_URL = 'https://cdn.aframe.io/controllers/oculus/vr_controller_oculus_touch_';
var TOUCH_CONTROLLER_MODEL_OBJ_URL_L = TOUCH_CONTROLLER_MODEL_BASE_URL + 'left.obj';
var TOUCH_CONTROLLER_MODEL_OBJ_MTL_L = TOUCH_CONTROLLER_MODEL_BASE_URL + 'left.mtl';
var TOUCH_CONTROLLER_MODEL_OBJ_URL_R = TOUCH_CONTROLLER_MODEL_BASE_URL + 'right.obj';
var TOUCH_CONTROLLER_MODEL_OBJ_MTL_R = TOUCH_CONTROLLER_MODEL_BASE_URL + 'right.mtl';

var GAMEPAD_ID_PREFIX = 'Oculus Touch';

var PIVOT_OFFSET = {x: 0, y: -0.015, z: 0.04};

// currently, browser bugs prevent capacitive touch events from firing on trigger and grip;
// however those have analog values, and this (below button-down values) can be used to fake them
var EMULATED_TOUCH_THRESHOLD = 0.001;

/**
 * Oculus Touch Controls Component
 * Interfaces with Oculus Touch controllers and maps Gamepad events to
 * common controller buttons: trackpad, trigger, grip, menu and system
 * It loads a controller model and highlights the pressed buttons
 */
module.exports.Component = registerComponent('oculus-touch-controls', {
  schema: {
    hand: {default: 'left'},
    buttonColor: {default: '#FAFAFA'},          // Off-white.
    buttonHighlightColor: {default: '#22D1EE'}, // Light blue.
    model: {default: true},
    rotationOffset: {default: 0} // no default offset; -999 is sentinel value to auto-determine based on hand
  },

  // buttonId
  // 0 - thumbstick
  // 1 - trigger ( intensity value from 0.5 to 1 )
  // 2 - grip
  // 3 - menu ( dispatch but better for menu options )
  // 4 - system ( never dispatched on this layer )
  mapping: {
    'left': {
      axis0: 'thumbstick',
      axis1: 'thumbstick',
      button0: 'thumbstick',
      button1: 'trigger',
      button2: 'grip',
      button3: 'X',
      button4: 'Y',
      button5: 'surface'
    },
    'right': {
      axis0: 'thumbstick',
      axis1: 'thumbstick',
      button0: 'thumbstick',
      button1: 'trigger',
      button2: 'grip',
      button3: 'A',
      button4: 'B',
      button5: 'surface'
    }
  },

  bindMethods: function () {
    this.onModelLoaded = bind(this.onModelLoaded, this);
    this.onControllersUpdate = bind(this.onControllersUpdate, this);
    this.checkIfControllerPresent = bind(this.checkIfControllerPresent, this);
    this.removeControllersUpdateListener = bind(this.removeControllersUpdateListener, this);
    this.onGamepadConnected = bind(this.onGamepadConnected, this);
    this.onGamepadDisconnected = bind(this.onGamepadDisconnected, this);
  },

  init: function () {
    var self = this;
    this.animationActive = 'pointing';
    this.onButtonChanged = bind(this.onButtonChanged, this);
    this.onButtonDown = function (evt) { self.onButtonEvent(evt.detail.id, 'down'); };
    this.onButtonUp = function (evt) { self.onButtonEvent(evt.detail.id, 'up'); };
    this.onButtonTouchStart = function (evt) { self.onButtonEvent(evt.detail.id, 'touchstart'); };
    this.onButtonTouchEnd = function (evt) { self.onButtonEvent(evt.detail.id, 'touchend'); };
    this.controllerPresent = false;
    this.everGotGamepadEvent = false;
    this.lastControllerCheck = 0;
    this.previousButtonValues = {};
    this.bindMethods();
    this.isControllerPresent = isControllerPresent; // to allow mock
  },

  addEventListeners: function () {
    var el = this.el;
    el.addEventListener('buttonchanged', this.onButtonChanged);
    el.addEventListener('buttondown', this.onButtonDown);
    el.addEventListener('buttonup', this.onButtonUp);
    el.addEventListener('touchstart', this.onButtonTouchStart);
    el.addEventListener('touchend', this.onButtonTouchEnd);
    el.addEventListener('model-loaded', this.onModelLoaded);
  },

  removeEventListeners: function () {
    var el = this.el;
    el.removeEventListener('buttonchanged', this.onButtonChanged);
    el.removeEventListener('buttondown', this.onButtonDown);
    el.removeEventListener('buttonup', this.onButtonUp);
    el.removeEventListener('touchstart', this.onButtonTouchStart);
    el.removeEventListener('touchend', this.onButtonTouchEnd);
    el.removeEventListener('model-loaded', this.onModelLoaded);
  },

  checkIfControllerPresent: function () {
    var data = this.data;
    var isPresent = this.isControllerPresent(this.el.sceneEl, GAMEPAD_ID_PREFIX, { hand: data.hand });
    if (isPresent === this.controllerPresent) { return; }
    this.controllerPresent = isPresent;
    if (isPresent) {
      this.injectTrackedControls(); // inject track-controls
      this.addEventListeners();
    } else {
      this.removeEventListeners();
    }
  },

  onGamepadConnected: function (evt) {
    // for now, don't disable controller update listening, due to
    // apparent issue with FF Nightly only sending one event and seeing one controller;
    // this.everGotGamepadEvent = true;
    // this.removeControllersUpdateListener();
    this.checkIfControllerPresent();
  },

  onGamepadDisconnected: function (evt) {
    // for now, don't disable controller update listening, due to
    // apparent issue with FF Nightly only sending one event and seeing one controller;
    // this.everGotGamepadEvent = true;
    // this.removeControllersUpdateListener();
    this.checkIfControllerPresent();
  },

  play: function () {
    this.checkIfControllerPresent();
    window.addEventListener('gamepadconnected', this.onGamepadConnected, false);
    window.addEventListener('gamepaddisconnected', this.onGamepadDisconnected, false);
    this.addControllersUpdateListener();
  },

  pause: function () {
    window.removeEventListener('gamepadconnected', this.onGamepadConnected, false);
    window.removeEventListener('gamepaddisconnected', this.onGamepadDisconnected, false);
    this.removeControllersUpdateListener();
    this.removeEventListeners();
  },

  updateControllerModel: function () {
    var objUrl, mtlUrl;
    if (!this.data.model) { return; }
    if (this.data.hand === 'right') {
      objUrl = 'url(' + TOUCH_CONTROLLER_MODEL_OBJ_URL_R + ')';
      mtlUrl = 'url(' + TOUCH_CONTROLLER_MODEL_OBJ_MTL_R + ')';
    } else {
      objUrl = 'url(' + TOUCH_CONTROLLER_MODEL_OBJ_URL_L + ')';
      mtlUrl = 'url(' + TOUCH_CONTROLLER_MODEL_OBJ_MTL_L + ')';
    }
    this.el.setAttribute('obj-model', {obj: objUrl, mtl: mtlUrl});
  },

  injectTrackedControls: function () {
    var el = this.el;
    var data = this.data;
    var isRightHand = data.hand === 'right';

    // since each hand is named differently, avoid enumeration
    el.setAttribute('tracked-controls', {
      id: isRightHand ? 'Oculus Touch (Right)' : 'Oculus Touch (Left)',
      controller: 0,
      rotationOffset: data.rotationOffset !== -999 ? data.rotationOffset : isRightHand ? -90 : 90
    });
    this.updateControllerModel();
  },

  addControllersUpdateListener: function () {
    this.el.sceneEl.addEventListener('controllersupdated', this.onControllersUpdate, false);
  },

  removeControllersUpdateListener: function () {
    this.el.sceneEl.removeEventListener('controllersupdated', this.onControllersUpdate, false);
  },

  onControllersUpdate: function () {
    if (!this.everGotGamepadEvent) { this.checkIfControllerPresent(); }
  },

  // currently, browser bugs prevent capacitive touch events from firing on trigger and grip;
  // however those have analog values, and this (below button-down values) can be used to fake them
  isEmulatedTouchEvent: function (analogValue) {
    return analogValue && (analogValue >= EMULATED_TOUCH_THRESHOLD);
  },

  onButtonChanged: function (evt) {
    var button = this.mapping[this.data.hand]['button' + evt.detail.id];
    var buttonMeshes = this.buttonMeshes;
    var isPreviousValueEmulatedTouch;
    var analogValue;
    var isEmulatedTouch;

    // at the moment, if trigger or grip,
    // touch events aren't happening (touched is stuck true);
    // synthesize touch events from very low analog values
    if (button !== 'trigger' && button !== 'grip') { return; }
    analogValue = evt.detail.state.value;
    isPreviousValueEmulatedTouch = this.isEmulatedTouchEvent(this.previousButtonValues[button]);
    this.previousButtonValues[button] = analogValue;
    isEmulatedTouch = this.isEmulatedTouchEvent(analogValue);
    if (isEmulatedTouch !== isPreviousValueEmulatedTouch) {
      (isEmulatedTouch ? this.onButtonTouchStart : this.onButtonTouchEnd)(evt);
    }
    if (button !== 'trigger' || !buttonMeshes || !buttonMeshes.trigger) { return; }
    buttonMeshes.trigger.rotation.x = -analogValue * (Math.PI / 12);
  },

  onModelLoaded: function (evt) {
    var controllerObject3D = evt.detail.model;
    var buttonMeshes;
    if (!this.data.model) { return; }

    var leftHand = this.data.hand === 'left';
    buttonMeshes = this.buttonMeshes = {};

    buttonMeshes.grip = controllerObject3D.getObjectByName(leftHand ? 'grip tooche1 group3' : 'grip tooche group4');
    buttonMeshes.thumbstick = controllerObject3D.getObjectByName(leftHand ? 'tooche1 group3 control_surface group2 thumb_stick' : 'tooche group4 control_surface group2 thumb_stick');
    buttonMeshes.trigger = controllerObject3D.getObjectByName(leftHand ? 'tooche1 group3 trigger' : 'tooche group4 trigger');
    buttonMeshes['X'] = controllerObject3D.getObjectByName('tooche1 group3 control_surface group2 button2');
    buttonMeshes['A'] = controllerObject3D.getObjectByName('tooche group4 control_surface group2 button2');
    buttonMeshes['Y'] = controllerObject3D.getObjectByName('tooche1 group3 control_surface group2 button3');
    buttonMeshes['B'] = controllerObject3D.getObjectByName('tooche group4 control_surface group2 button3');
    buttonMeshes.surface = controllerObject3D.getObjectByName(leftHand ? 'tooche1 group3 face control_surface group2' : 'tooche group4 face control_surface group2');

    // Offset pivot point
    controllerObject3D.position = PIVOT_OFFSET;
  },

  onButtonEvent: function (id, evtName) {
    var buttonName = this.mapping[this.data.hand]['button' + id];
    var i;
    if (Array.isArray(buttonName)) {
      for (i = 0; i < buttonName.length; i++) {
        this.el.emit(buttonName[i] + evtName);
      }
    } else {
      this.el.emit(buttonName + evtName);
    }
    this.updateModel(buttonName, evtName);
  },

  updateModel: function (buttonName, evtName) {
    var i;
    if (Array.isArray(buttonName)) {
      for (i = 0; i < buttonName.length; i++) {
        this.updateButtonModel(buttonName[i], evtName);
      }
    } else {
      this.updateButtonModel(buttonName, evtName);
    }
  },

  updateButtonModel: function (buttonName, state) {
    var color = state === 'up' ? this.data.buttonColor : this.data.buttonHighlightColor;
    var buttonMeshes = this.buttonMeshes;
    if (!this.data.model) { return; }
    if (buttonMeshes && buttonMeshes[buttonName]) {
      buttonMeshes[buttonName].material.color.set(color);
    }
  }
});
<commit_msg>Revert "Changes to bring consistency on file names" (#2284)<commit_after>var registerComponent = require('../core/component').registerComponent;
var bind = require('../utils/bind');
var isControllerPresent = require('../utils/tracked-controls').isControllerPresent;

var TOUCH_CONTROLLER_MODEL_BASE_URL = 'https://cdn.aframe.io/controllers/oculus/oculus-touch-controller-';
var TOUCH_CONTROLLER_MODEL_OBJ_URL_L = TOUCH_CONTROLLER_MODEL_BASE_URL + 'left.obj';
var TOUCH_CONTROLLER_MODEL_OBJ_MTL_L = TOUCH_CONTROLLER_MODEL_BASE_URL + 'left.mtl';
var TOUCH_CONTROLLER_MODEL_OBJ_URL_R = TOUCH_CONTROLLER_MODEL_BASE_URL + 'right.obj';
var TOUCH_CONTROLLER_MODEL_OBJ_MTL_R = TOUCH_CONTROLLER_MODEL_BASE_URL + 'right.mtl';

var GAMEPAD_ID_PREFIX = 'Oculus Touch';

var PIVOT_OFFSET = {x: 0, y: -0.015, z: 0.04};

// currently, browser bugs prevent capacitive touch events from firing on trigger and grip;
// however those have analog values, and this (below button-down values) can be used to fake them
var EMULATED_TOUCH_THRESHOLD = 0.001;

/**
 * Oculus Touch Controls Component
 * Interfaces with Oculus Touch controllers and maps Gamepad events to
 * common controller buttons: trackpad, trigger, grip, menu and system
 * It loads a controller model and highlights the pressed buttons
 */
module.exports.Component = registerComponent('oculus-touch-controls', {
  schema: {
    hand: {default: 'left'},
    buttonColor: {default: '#FAFAFA'},          // Off-white.
    buttonHighlightColor: {default: '#22D1EE'}, // Light blue.
    model: {default: true},
    rotationOffset: {default: 0} // no default offset; -999 is sentinel value to auto-determine based on hand
  },

  // buttonId
  // 0 - thumbstick
  // 1 - trigger ( intensity value from 0.5 to 1 )
  // 2 - grip
  // 3 - menu ( dispatch but better for menu options )
  // 4 - system ( never dispatched on this layer )
  mapping: {
    'left': {
      axis0: 'thumbstick',
      axis1: 'thumbstick',
      button0: 'thumbstick',
      button1: 'trigger',
      button2: 'grip',
      button3: 'X',
      button4: 'Y',
      button5: 'surface'
    },
    'right': {
      axis0: 'thumbstick',
      axis1: 'thumbstick',
      button0: 'thumbstick',
      button1: 'trigger',
      button2: 'grip',
      button3: 'A',
      button4: 'B',
      button5: 'surface'
    }
  },

  bindMethods: function () {
    this.onModelLoaded = bind(this.onModelLoaded, this);
    this.onControllersUpdate = bind(this.onControllersUpdate, this);
    this.checkIfControllerPresent = bind(this.checkIfControllerPresent, this);
    this.removeControllersUpdateListener = bind(this.removeControllersUpdateListener, this);
    this.onGamepadConnected = bind(this.onGamepadConnected, this);
    this.onGamepadDisconnected = bind(this.onGamepadDisconnected, this);
  },

  init: function () {
    var self = this;
    this.animationActive = 'pointing';
    this.onButtonChanged = bind(this.onButtonChanged, this);
    this.onButtonDown = function (evt) { self.onButtonEvent(evt.detail.id, 'down'); };
    this.onButtonUp = function (evt) { self.onButtonEvent(evt.detail.id, 'up'); };
    this.onButtonTouchStart = function (evt) { self.onButtonEvent(evt.detail.id, 'touchstart'); };
    this.onButtonTouchEnd = function (evt) { self.onButtonEvent(evt.detail.id, 'touchend'); };
    this.controllerPresent = false;
    this.everGotGamepadEvent = false;
    this.lastControllerCheck = 0;
    this.previousButtonValues = {};
    this.bindMethods();
    this.isControllerPresent = isControllerPresent; // to allow mock
  },

  addEventListeners: function () {
    var el = this.el;
    el.addEventListener('buttonchanged', this.onButtonChanged);
    el.addEventListener('buttondown', this.onButtonDown);
    el.addEventListener('buttonup', this.onButtonUp);
    el.addEventListener('touchstart', this.onButtonTouchStart);
    el.addEventListener('touchend', this.onButtonTouchEnd);
    el.addEventListener('model-loaded', this.onModelLoaded);
  },

  removeEventListeners: function () {
    var el = this.el;
    el.removeEventListener('buttonchanged', this.onButtonChanged);
    el.removeEventListener('buttondown', this.onButtonDown);
    el.removeEventListener('buttonup', this.onButtonUp);
    el.removeEventListener('touchstart', this.onButtonTouchStart);
    el.removeEventListener('touchend', this.onButtonTouchEnd);
    el.removeEventListener('model-loaded', this.onModelLoaded);
  },

  checkIfControllerPresent: function () {
    var data = this.data;
    var isPresent = this.isControllerPresent(this.el.sceneEl, GAMEPAD_ID_PREFIX, { hand: data.hand });
    if (isPresent === this.controllerPresent) { return; }
    this.controllerPresent = isPresent;
    if (isPresent) {
      this.injectTrackedControls(); // inject track-controls
      this.addEventListeners();
    } else {
      this.removeEventListeners();
    }
  },

  onGamepadConnected: function (evt) {
    // for now, don't disable controller update listening, due to
    // apparent issue with FF Nightly only sending one event and seeing one controller;
    // this.everGotGamepadEvent = true;
    // this.removeControllersUpdateListener();
    this.checkIfControllerPresent();
  },

  onGamepadDisconnected: function (evt) {
    // for now, don't disable controller update listening, due to
    // apparent issue with FF Nightly only sending one event and seeing one controller;
    // this.everGotGamepadEvent = true;
    // this.removeControllersUpdateListener();
    this.checkIfControllerPresent();
  },

  play: function () {
    this.checkIfControllerPresent();
    window.addEventListener('gamepadconnected', this.onGamepadConnected, false);
    window.addEventListener('gamepaddisconnected', this.onGamepadDisconnected, false);
    this.addControllersUpdateListener();
  },

  pause: function () {
    window.removeEventListener('gamepadconnected', this.onGamepadConnected, false);
    window.removeEventListener('gamepaddisconnected', this.onGamepadDisconnected, false);
    this.removeControllersUpdateListener();
    this.removeEventListeners();
  },

  updateControllerModel: function () {
    var objUrl, mtlUrl;
    if (!this.data.model) { return; }
    if (this.data.hand === 'right') {
      objUrl = 'url(' + TOUCH_CONTROLLER_MODEL_OBJ_URL_R + ')';
      mtlUrl = 'url(' + TOUCH_CONTROLLER_MODEL_OBJ_MTL_R + ')';
    } else {
      objUrl = 'url(' + TOUCH_CONTROLLER_MODEL_OBJ_URL_L + ')';
      mtlUrl = 'url(' + TOUCH_CONTROLLER_MODEL_OBJ_MTL_L + ')';
    }
    this.el.setAttribute('obj-model', {obj: objUrl, mtl: mtlUrl});
  },

  injectTrackedControls: function () {
    var el = this.el;
    var data = this.data;
    var isRightHand = data.hand === 'right';

    // since each hand is named differently, avoid enumeration
    el.setAttribute('tracked-controls', {
      id: isRightHand ? 'Oculus Touch (Right)' : 'Oculus Touch (Left)',
      controller: 0,
      rotationOffset: data.rotationOffset !== -999 ? data.rotationOffset : isRightHand ? -90 : 90
    });
    this.updateControllerModel();
  },

  addControllersUpdateListener: function () {
    this.el.sceneEl.addEventListener('controllersupdated', this.onControllersUpdate, false);
  },

  removeControllersUpdateListener: function () {
    this.el.sceneEl.removeEventListener('controllersupdated', this.onControllersUpdate, false);
  },

  onControllersUpdate: function () {
    if (!this.everGotGamepadEvent) { this.checkIfControllerPresent(); }
  },

  // currently, browser bugs prevent capacitive touch events from firing on trigger and grip;
  // however those have analog values, and this (below button-down values) can be used to fake them
  isEmulatedTouchEvent: function (analogValue) {
    return analogValue && (analogValue >= EMULATED_TOUCH_THRESHOLD);
  },

  onButtonChanged: function (evt) {
    var button = this.mapping[this.data.hand]['button' + evt.detail.id];
    var buttonMeshes = this.buttonMeshes;
    var isPreviousValueEmulatedTouch;
    var analogValue;
    var isEmulatedTouch;

    // at the moment, if trigger or grip,
    // touch events aren't happening (touched is stuck true);
    // synthesize touch events from very low analog values
    if (button !== 'trigger' && button !== 'grip') { return; }
    analogValue = evt.detail.state.value;
    isPreviousValueEmulatedTouch = this.isEmulatedTouchEvent(this.previousButtonValues[button]);
    this.previousButtonValues[button] = analogValue;
    isEmulatedTouch = this.isEmulatedTouchEvent(analogValue);
    if (isEmulatedTouch !== isPreviousValueEmulatedTouch) {
      (isEmulatedTouch ? this.onButtonTouchStart : this.onButtonTouchEnd)(evt);
    }
    if (button !== 'trigger' || !buttonMeshes || !buttonMeshes.trigger) { return; }
    buttonMeshes.trigger.rotation.x = -analogValue * (Math.PI / 12);
  },

  onModelLoaded: function (evt) {
    var controllerObject3D = evt.detail.model;
    var buttonMeshes;
    if (!this.data.model) { return; }

    var leftHand = this.data.hand === 'left';
    buttonMeshes = this.buttonMeshes = {};

    buttonMeshes.grip = controllerObject3D.getObjectByName(leftHand ? 'grip tooche1 group3' : 'grip tooche group4');
    buttonMeshes.thumbstick = controllerObject3D.getObjectByName(leftHand ? 'tooche1 group3 control_surface group2 thumb_stick' : 'tooche group4 control_surface group2 thumb_stick');
    buttonMeshes.trigger = controllerObject3D.getObjectByName(leftHand ? 'tooche1 group3 trigger' : 'tooche group4 trigger');
    buttonMeshes['X'] = controllerObject3D.getObjectByName('tooche1 group3 control_surface group2 button2');
    buttonMeshes['A'] = controllerObject3D.getObjectByName('tooche group4 control_surface group2 button2');
    buttonMeshes['Y'] = controllerObject3D.getObjectByName('tooche1 group3 control_surface group2 button3');
    buttonMeshes['B'] = controllerObject3D.getObjectByName('tooche group4 control_surface group2 button3');
    buttonMeshes.surface = controllerObject3D.getObjectByName(leftHand ? 'tooche1 group3 face control_surface group2' : 'tooche group4 face control_surface group2');

    // Offset pivot point
    controllerObject3D.position = PIVOT_OFFSET;
  },

  onButtonEvent: function (id, evtName) {
    var buttonName = this.mapping[this.data.hand]['button' + id];
    var i;
    if (Array.isArray(buttonName)) {
      for (i = 0; i < buttonName.length; i++) {
        this.el.emit(buttonName[i] + evtName);
      }
    } else {
      this.el.emit(buttonName + evtName);
    }
    this.updateModel(buttonName, evtName);
  },

  updateModel: function (buttonName, evtName) {
    var i;
    if (Array.isArray(buttonName)) {
      for (i = 0; i < buttonName.length; i++) {
        this.updateButtonModel(buttonName[i], evtName);
      }
    } else {
      this.updateButtonModel(buttonName, evtName);
    }
  },

  updateButtonModel: function (buttonName, state) {
    var color = state === 'up' ? this.data.buttonColor : this.data.buttonHighlightColor;
    var buttonMeshes = this.buttonMeshes;
    if (!this.data.model) { return; }
    if (buttonMeshes && buttonMeshes[buttonName]) {
      buttonMeshes[buttonName].material.color.set(color);
    }
  }
});
<|endoftext|>


<commit_before>/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */

import React, { PropTypes, Component } from 'react';
import styles from './NflPage.css';
import withStyles from '../../../decorators/withStyles';
import RankingsStore from '../../../stores/RankingsStore';
import ActionCreator from '../../../actions/ActionCreator';
import Table from '../../core/table/table';
import Format from '../../../utils/format';

@withStyles(styles)
class NflPage extends Component {

  static contextTypes = {
    onSetTitle: PropTypes.func.isRequired,
  };

  constructor(props) {
    super(props);
    this.state = {
      rankings: []
    };

    this._onChange = this._onChange.bind(this)
  }

  componentWillMount() {
    RankingsStore.addChangeListener(this._onChange);
  }

  componentDidMount() {
    ActionCreator.getRankings();
  }

  componentWillUnmount() {
    RankingsStore.removeChangeListener(this._onChange);
  }

  _onChange() {
    this.setState({
      rankings: RankingsStore.getRankings()
    });
  }

  _buildTableColumns() {
    return [
      { label: 'TM', property: 'id', title: 'Team' },
      { label: 'W', property: 'wins', title: 'Wins' },
      { label: 'L', property: 'losses', title: 'Losses' },
      { label: 'RNK', property: 'power_ranking', formatter: this._formatDecimal, title: 'Ranking' },
      { label: 'SOS', property: 'sos', formatter: this._formatSpecialDecimal, title: 'Strength of Schedule' },
      { label: 'SOV', property: 'sov', formatter: this._formatSpecialDecimal, title: 'Strength of Victory' },
      { label: 'PD', property: 'point_differential', title: 'Point Differential' },
      { label: 'PS', property: 'points_scored_avg', formatter: this._formatDecimal, title: 'Points Scored Per Game' },
      { label: 'PA', property: 'points_against_avg', formatter: this._formatDecimal, title: 'Points Against Per Game' },
      { label: 'TD', property: 'turnover_differential', title: 'Turnover Differential' }
    ];
  }

  _formatDecimal(num) {
    return Format.toFixedFloat(num, 2);
  }

  _formatSpecialDecimal(num) {
    var fixedNum = Format.toFixedFloat(num, 2);

    return Format.stripLeadingZero(fixedNum);
  }

  render() {
    var tableData,
        tableColumns = this._buildTableColumns(),
        sortBy = {
          property: 'power_ranking',
          order: 'descending'
        };

    const title = 'Contact Us';

    this.context.onSetTitle(title);

    if (this.state.rankings.length) {
      tableData = this.state.rankings[1].data;
    } else {
      tableData = this.state.rankings;
    }

    return (

NFL Power Rankings

WEEK 9:

    );
  }

}

export default NflPage;
<commit_msg>Only display the rankings table when data exists<commit_after>/*! React Starter Kit | MIT License | http://www.reactstarterkit.com/ */

import React, { PropTypes, Component } from 'react';
import styles from './NflPage.css';
import withStyles from '../../../decorators/withStyles';
import RankingsStore from '../../../stores/RankingsStore';
import ActionCreator from '../../../actions/ActionCreator';
import Table from '../../core/table/table';
import Format from '../../../utils/format';

@withStyles(styles)
class NflPage extends Component {

  static contextTypes = {
    onSetTitle: PropTypes.func.isRequired,
  };

  constructor(props) {
    super(props);
    this.state = {
      rankings: []
    };

    this._onChange = this._onChange.bind(this)
  }

  componentWillMount() {
    RankingsStore.addChangeListener(this._onChange);
  }

  componentDidMount() {
    ActionCreator.getRankings();
  }

  componentWillUnmount() {
    RankingsStore.removeChangeListener(this._onChange);
  }

  _onChange() {
    this.setState({
      rankings: RankingsStore.getRankings()
    });
  }

  _buildTableColumns() {
    return [
      { label: 'TM', property: 'id', title: 'Team' },
      { label: 'W', property: 'wins', title: 'Wins' },
      { label: 'L', property: 'losses', title: 'Losses' },
      { label: 'RNK', property: 'power_ranking', formatter: this._formatDecimal, title: 'Ranking' },
      { label: 'SOS', property: 'sos', formatter: this._formatSpecialDecimal, title: 'Strength of Schedule' },
      { label: 'SOV', property: 'sov', formatter: this._formatSpecialDecimal, title: 'Strength of Victory' },
      { label: 'PD', property: 'point_differential', title: 'Point Differential' },
      { label: 'PS', property: 'points_scored_avg', formatter: this._formatDecimal, title: 'Points Scored Per Game' },
      { label: 'PA', property: 'points_against_avg', formatter: this._formatDecimal, title: 'Points Against Per Game' },
      { label: 'TD', property: 'turnover_differential', title: 'Turnover Differential' }
    ];
  }

  _formatDecimal(num) {
    return Format.toFixedFloat(num, 2);
  }

  _formatSpecialDecimal(num) {
    var fixedNum = Format.toFixedFloat(num, 2);

    return Format.stripLeadingZero(fixedNum);
  }

  render() {
    var tableData,
        tableColumns = this._buildTableColumns(),
        sortBy = {
          property: 'power_ranking',
          order: 'descending'
        };

    const title = 'Contact Us';

    this.context.onSetTitle(title);

    if (this.state.rankings.length) {
      tableData = this.state.rankings[0].data;
    }

    return (

NFL Power Rankings

          {tableData &&

WEEK 9:

}

    );
  }

}

export default NflPage;
<|endoftext|>


<commit_before>'use strict'
import './widgets.less'
var constructors = {
  TextBox: require('./primitives/textBox')
  , Slide: require('./primitives/slide')
}

let WidgetFactory = function (component) {
  let name = component.type || component
  return constructors[name]
}

module.exports = WidgetFactory
<commit_msg>set default widget to TextBox<commit_after>'use strict'
import './widgets.less'
var constructors = {
  TextBox: require('./primitives/textBox')
  , Slide: require('./primitives/slide')
  , default: require('./primitives/textBox')
}

let WidgetFactory = function (component) {
  let name = component.type || component
  return constructors[name] || constructors['default']
}

module.exports = WidgetFactory
<|endoftext|>


<commit_before>/* jshint browser:true */
/* global require */
require(['oro/mediator'],
function(mediator) {
    mediator.once('tab:changed', function() {
        setTimeout(function() {
            // emulates 'document ready state' for selenium tests
            document['page-rendered'] = true;
        }, 50);
    });
});
require(['jquery', 'underscore', 'oro/translator', 'oro/app', 'oro/mediator', 'oro/layout', 'oro/navigation', 'oro/modal', 'oro/messenger',
    'bootstrap', 'jquery-ui', 'jquery-ui-timepicker'],
function($, _, __, app, mediator, layout, Navigation, Modal, messenger) {
    'use strict';

    /* ============================================================
     * from layout.js
     * ============================================================ */
    $(function() {
        layout.init();

        /* hide progress bar on page ready in case we don't need hash navigation request*/
        if (!Navigation.isEnabled() || !Navigation.prototype.checkHashForUrl()) {
            if ($('#page-title').size()) {
                document.title = $('#page-title').text();
            }
            layout.hideProgressBar();
        }

        /* side bar functionality */
        $('div.side-nav').each(function() {
            var myParent = $(this),
                myParentHolder = $(myParent).parent().height() -18;
            $(myParent).height(myParentHolder);
            /* open close bar */
            $(this).find("span.maximaze-bar").click(function() {
                if (($(myParent).hasClass("side-nav-open")) || ($(myParent).hasClass("side-nav-locked"))) {
                    $(myParent).removeClass("side-nav-locked side-nav-open");
                    if( $(myParent).hasClass('left-panel')){
                        $(myParent).parent('div.page-container').removeClass('left-locked');
                    }else{
                        $(myParent).parent('div.page-container').removeClass('right-locked');
                    }
                    $(myParent).find('.bar-tools').css({
                        "height": "auto",
                        "overflow" : "visible"
                    });
                } else {
                    $(myParent).addClass("side-nav-open");
                    var openBarHeight = $("div.page-container").height() - 20,
                        testBarScroll = $(myParent).find('.bar-tools').height();
                    /* minus top-padding and bottom-padding */
                    $(myParent).height(openBarHeight);
                    if(openBarHeight < testBarScroll ){
                        $(myParent).find('.bar-tools').height((openBarHeight - 20)).css({
                            "overflow" : "auto"
                        });
                    }
                }
            });

            /* lock&unlock bar */
            $(this).find("span.lock-bar").click(function() {
                if ($(this).hasClass("lock-bar-locked")) {
                    $(myParent).addClass("side-nav-open")
                        .removeClass("side-nav-locked");
                    if( $(myParent).hasClass('left-panel')){
                        $(myParent).parent('div.page-container').removeClass('left-locked');
                    }else{
                        $(myParent).parent('div.page-container').removeClass('right-locked');
                    }
                } else {
                    $(myParent).addClass("side-nav-locked")
                        .removeClass("side-nav-open");
                    if( $(myParent).hasClass('left-panel')){
                        $(myParent).parent('div.page-container').addClass('left-locked');
                    }else{
                        $(myParent).parent('div.page-container').addClass('right-locked');
                    }

                }
                $(this).toggleClass('lock-bar-locked');
            });

            /* open&close popup for bar items when bar is minimized. */
            $(this).find('.bar-tools li').each(function() {
                var myItem = $(this);
                $(myItem).find('.sn-opener').click(function() {
                    $(myItem).find("div.nav-box").fadeToggle("slow");
                    var overlayHeight = $('#page').height(),
                        overlayWidth = $('#page > .wrapper').width();
                    $('#bar-drop-overlay').width(overlayWidth).height(overlayHeight);
                    $('#bar-drop-overlay').toggleClass('bar-open-overlay');
                });
                $(myItem).find("span.close").click(function() {
                    $(myItem).find("div.nav-box").fadeToggle("slow");
                    $('#bar-drop-overlay').toggleClass('bar-open-overlay');
                });
                $('#bar-drop-overlay').on({
                    click:function() {
                        $(myItem).find("div.nav-box").animate({
                            opacity:0,
                            display:'none'
                        }, function() {
                            $(this).css({
                                opacity:1,
                                display:'none'
                            });
                        });
                        $('#bar-drop-overlay').removeClass('bar-open-overlay');
                    }
                });
            });
            /* open content for open bar */
            $(myParent).find('ul.bar-tools > li').each(function(){
                var _barLi = $(this);
                $(_barLi).find('span.open-bar-item').click(function(){
                    $(_barLi).find('div.nav-content').slideToggle();
                    $(_barLi).toggleClass('open-item');
                });
            });
        });

        /* ============================================================
         * Oro Dropdown close prevent
         * ============================================================ */
        var dropdownToggles = $('.oro-dropdown-toggle');
        dropdownToggles.click(function(e) {
            var $parent = $(this).parent().toggleClass('open');
            if ($parent.hasClass('open')) {
                $parent.find('input[type=text]').first().focus().select();
            }
        });
        $('body').on('focus.dropdown.data-api', '[data-toggle=dropdown]', _.debounce(function(e) {
            $(e.target).parent().find('input[type=text]').first().focus();
        }, 10));

        $('html').click(function(e) {
            var $target = $(e.target),
                clickingTarget = null;
            if ($target.hasClass('dropdown') || $target.hasClass('oro-drop')) {
                clickingTarget = $target;
            } else {
                clickingTarget = $target.closest('.dropdown, .oro-drop');
            }
            clickingTarget.addClass('_currently_clicked');
            $('.open:not(._currently_clicked)').removeClass('open');
            clickingTarget.removeClass('_currently_clicked');
        });

        $('#main-menu').mouseover(function() {
            $('.open').removeClass('open');
        });
     });

    /**
     * Init page layout js and hide progress bar after hash navigation request is completed
     */
    mediator.bind("hash_navigation_request:complete", function() {
        layout.hideProgressBar();
        layout.init();
    });

    /* ============================================================
     * from height_fix.js
     * ============================================================ */
    (function() {
        /* dynamic height for central column */
        var debugBar = $('.sf-toolbar'),
            anchor = $('#bottom-anchor'),
            content = false,
            initializeContent = function() {
                if (!content) {
                    content = $('.scrollable-container').filter(':parents(.ui-widget)');
                    content.css('overflow', 'auto');

                    $('.scrollable-substructure').css({
                        'padding-bottom': '0px',
                        'margin-bottom': '0px'
                    });
                }
            },
            adjustHeight = function() {
                initializeContent();
                var debugBarHeight = debugBar.length && debugBar.is(':visible') ? debugBar.height() : 0,
                    anchorTop = anchor.position().top;
                content.each(function(pos, el) {
                    el = $(el);
                    el.height(anchorTop - el.position().top - debugBarHeight);
                });
            },
            tries = 0,
            waitForDebugBar = function() {
                if (debugBar.children().length) {
                    window.setTimeout(adjustHeight, 500);
                } else if (tries < 100) {
                    tries += 1;
                    window.setTimeout(waitForDebugBar, 500);
                }
            },
            adjustReloaded = function() {
                content = false;
                adjustHeight();
            };

        if (!anchor.length) {
            anchor = $('<div id="bottom-anchor"/>')
                .css({
                    position: 'fixed',
                    bottom: '0',
                    left: '0',
                    width: '1px',
                    height: '1px'
                })
                .appendTo($(document.body));
        }

        if (debugBar.length) {
            waitForDebugBar();
        } else {
            adjustHeight();
        }

        $(window).on('resize', adjustHeight);

        mediator.bind("hash_navigation_request:complete", adjustReloaded);
    }());

    /* ============================================================
     * from form_buttons.js
     * ============================================================ */
    $(document).on('click', '.action-button', function() {
        var actionInput = $('input[name = "input_action"]');
        actionInput.val($(this).attr('data-action'));
        $('#' + actionInput.attr('data-form-id')).submit();
    });

    /* ============================================================
     * from remove.confirm.js
     * ============================================================ */
    $(function() {
        $(document).on('click', '.remove-button', function (e) {
            var confirm,
                el = $(this),
                message = el.data('message');

            confirm = new Modal({
                title: __('Delete Confirmation'),
                content: message,
                okText: __('Yes, Delete')
            });

            confirm.on('ok', function() {
                var navigation = Navigation.getInstance();
                if (navigation) {
                    navigation.loadingMask.show();
                }

                $.ajax({
                    url: el.data('url'),
                    type: 'DELETE',
                    success: function (data) {
                        el.trigger('removesuccess');
                        messenger.addMessage('success', el.data('success-message'), {'hashNavEnabled': Navigation.isEnabled()});
                        if (el.data('redirect')) {
                            $.isActive(true);
                            if (navigation) {
                                navigation.setLocation(el.data('redirect'));
                            } else {
                                window.location.href = el.data('redirect');
                            }
                        }
                    },
                    error: function () {
                        if (navigation) {
                            navigation.loadingMask.hide();
                        }

                        messenger.notificationMessage(
                            'error',
                            el.data('error-message') ||  __('Unexpected error occured. Please contact system administrator.')
                        );
                    }
                });
            });
            confirm.open();

            return false;
        });
    });

    /* ============================================================
     * from form/collection.js'
     * ============================================================ */
    $(document).on('click', '.add-list-item', function (e) {
        e.preventDefault();
        var cList  = $(this).siblings('.collection-fields-list'),
            widget = cList.attr('data-prototype').replace(/__name__/g, cList.children().length),
            data = $('<div/>').html(widget);

        data.children().appendTo(cList);
        /* temporary solution need add init only for new created row */
        layout.styleForm(data);
        /* temporary solution finish */
    });

    $(document).on('click', '.removeRow', function (e) {
        e.preventDefault();
        $(this).parents('*[data-content]').remove();
    });
});
<commit_msg>CRM-575: Flow Item Delete on opportunity page is broken - fix bug<commit_after>/* jshint browser:true */
/* global require */
require(['oro/mediator'],
function(mediator) {
    mediator.once('tab:changed', function() {
        setTimeout(function() {
            // emulates 'document ready state' for selenium tests
            document['page-rendered'] = true;
        }, 50);
    });
});
require(['jquery', 'underscore', 'oro/translator', 'oro/app', 'oro/mediator', 'oro/layout', 'oro/navigation', 'oro/modal', 'oro/messenger',
    'bootstrap', 'jquery-ui', 'jquery-ui-timepicker'],
function($, _, __, app, mediator, layout, Navigation, Modal, messenger) {
    'use strict';

    /* ============================================================
     * from layout.js
     * ============================================================ */
    $(function() {
        layout.init();

        /* hide progress bar on page ready in case we don't need hash navigation request*/
        if (!Navigation.isEnabled() || !Navigation.prototype.checkHashForUrl()) {
            if ($('#page-title').size()) {
                document.title = $('#page-title').text();
            }
            layout.hideProgressBar();
        }

        /* side bar functionality */
        $('div.side-nav').each(function() {
            var myParent = $(this),
                myParentHolder = $(myParent).parent().height() -18;
            $(myParent).height(myParentHolder);
            /* open close bar */
            $(this).find("span.maximaze-bar").click(function() {
                if (($(myParent).hasClass("side-nav-open")) || ($(myParent).hasClass("side-nav-locked"))) {
                    $(myParent).removeClass("side-nav-locked side-nav-open");
                    if( $(myParent).hasClass('left-panel')){
                        $(myParent).parent('div.page-container').removeClass('left-locked');
                    }else{
                        $(myParent).parent('div.page-container').removeClass('right-locked');
                    }
                    $(myParent).find('.bar-tools').css({
                        "height": "auto",
                        "overflow" : "visible"
                    });
                } else {
                    $(myParent).addClass("side-nav-open");
                    var openBarHeight = $("div.page-container").height() - 20,
                        testBarScroll = $(myParent).find('.bar-tools').height();
                    /* minus top-padding and bottom-padding */
                    $(myParent).height(openBarHeight);
                    if(openBarHeight < testBarScroll ){
                        $(myParent).find('.bar-tools').height((openBarHeight - 20)).css({
                            "overflow" : "auto"
                        });
                    }
                }
            });

            /* lock&unlock bar */
            $(this).find("span.lock-bar").click(function() {
                if ($(this).hasClass("lock-bar-locked")) {
                    $(myParent).addClass("side-nav-open")
                        .removeClass("side-nav-locked");
                    if( $(myParent).hasClass('left-panel')){
                        $(myParent).parent('div.page-container').removeClass('left-locked');
                    }else{
                        $(myParent).parent('div.page-container').removeClass('right-locked');
                    }
                } else {
                    $(myParent).addClass("side-nav-locked")
                        .removeClass("side-nav-open");
                    if( $(myParent).hasClass('left-panel')){
                        $(myParent).parent('div.page-container').addClass('left-locked');
                    }else{
                        $(myParent).parent('div.page-container').addClass('right-locked');
                    }

                }
                $(this).toggleClass('lock-bar-locked');
            });

            /* open&close popup for bar items when bar is minimized. */
            $(this).find('.bar-tools li').each(function() {
                var myItem = $(this);
                $(myItem).find('.sn-opener').click(function() {
                    $(myItem).find("div.nav-box").fadeToggle("slow");
                    var overlayHeight = $('#page').height(),
                        overlayWidth = $('#page > .wrapper').width();
                    $('#bar-drop-overlay').width(overlayWidth).height(overlayHeight);
                    $('#bar-drop-overlay').toggleClass('bar-open-overlay');
                });
                $(myItem).find("span.close").click(function() {
                    $(myItem).find("div.nav-box").fadeToggle("slow");
                    $('#bar-drop-overlay').toggleClass('bar-open-overlay');
                });
                $('#bar-drop-overlay').on({
                    click:function() {
                        $(myItem).find("div.nav-box").animate({
                            opacity:0,
                            display:'none'
                        }, function() {
                            $(this).css({
                                opacity:1,
                                display:'none'
                            });
                        });
                        $('#bar-drop-overlay').removeClass('bar-open-overlay');
                    }
                });
            });
            /* open content for open bar */
            $(myParent).find('ul.bar-tools > li').each(function(){
                var _barLi = $(this);
                $(_barLi).find('span.open-bar-item').click(function(){
                    $(_barLi).find('div.nav-content').slideToggle();
                    $(_barLi).toggleClass('open-item');
                });
            });
        });

        /* ============================================================
         * Oro Dropdown close prevent
         * ============================================================ */
        var dropdownToggles = $('.oro-dropdown-toggle');
        dropdownToggles.click(function(e) {
            var $parent = $(this).parent().toggleClass('open');
            if ($parent.hasClass('open')) {
                $parent.find('input[type=text]').first().focus().select();
            }
        });
        $('body').on('focus.dropdown.data-api', '[data-toggle=dropdown]', _.debounce(function(e) {
            $(e.target).parent().find('input[type=text]').first().focus();
        }, 10));

        $('html').click(function(e) {
            var $target = $(e.target),
                clickingTarget = null;
            if ($target.hasClass('dropdown') || $target.hasClass('oro-drop')) {
                clickingTarget = $target;
            } else {
                clickingTarget = $target.closest('.dropdown, .oro-drop');
            }
            clickingTarget.addClass('_currently_clicked');
            $('.open:not(._currently_clicked)').removeClass('open');
            clickingTarget.removeClass('_currently_clicked');
        });

        $('#main-menu').mouseover(function() {
            $('.open').removeClass('open');
        });
     });

    /**
     * Init page layout js and hide progress bar after hash navigation request is completed
     */
    mediator.bind("hash_navigation_request:complete", function() {
        layout.hideProgressBar();
        layout.init();
    });

    /* ============================================================
     * from height_fix.js
     * ============================================================ */
    (function() {
        /* dynamic height for central column */
        var debugBar = $('.sf-toolbar'),
            anchor = $('#bottom-anchor'),
            content = false,
            initializeContent = function() {
                if (!content) {
                    content = $('.scrollable-container').filter(':parents(.ui-widget)');
                    content.css('overflow', 'auto');

                    $('.scrollable-substructure').css({
                        'padding-bottom': '0px',
                        'margin-bottom': '0px'
                    });
                }
            },
            adjustHeight = function() {
                initializeContent();
                var debugBarHeight = debugBar.length && debugBar.is(':visible') ? debugBar.height() : 0,
                    anchorTop = anchor.position().top;
                content.each(function(pos, el) {
                    el = $(el);
                    el.height(anchorTop - el.position().top - debugBarHeight);
                });
            },
            tries = 0,
            waitForDebugBar = function() {
                if (debugBar.children().length) {
                    window.setTimeout(adjustHeight, 500);
                } else if (tries < 100) {
                    tries += 1;
                    window.setTimeout(waitForDebugBar, 500);
                }
            },
            adjustReloaded = function() {
                content = false;
                adjustHeight();
            };

        if (!anchor.length) {
            anchor = $('<div id="bottom-anchor"/>')
                .css({
                    position: 'fixed',
                    bottom: '0',
                    left: '0',
                    width: '1px',
                    height: '1px'
                })
                .appendTo($(document.body));
        }

        if (debugBar.length) {
            waitForDebugBar();
        } else {
            adjustHeight();
        }

        $(window).on('resize', adjustHeight);

        mediator.bind("hash_navigation_request:complete", adjustReloaded);
    }());

    /* ============================================================
     * from form_buttons.js
     * ============================================================ */
    $(document).on('click', '.action-button', function() {
        var actionInput = $('input[name = "input_action"]');
        actionInput.val($(this).attr('data-action'));
        $('#' + actionInput.attr('data-form-id')).submit();
    });

    /* ============================================================
     * from remove.confirm.js
     * ============================================================ */
    $(function() {
        $(document).on('click', '.remove-button', function (e) {
            var confirm,
                el = $(this),
                message = el.data('message');

            confirm = new Modal({
                title: __('Delete Confirmation'),
                content: message,
                okText: __('Yes, Delete')
            });

            confirm.on('ok', function() {
                var navigation = Navigation.getInstance();
                if (navigation) {
                    navigation.loadingMask.show();
                }

                $.ajax({
                    url: el.data('url'),
                    type: 'DELETE',
                    success: function (data) {
                        el.trigger('removesuccess');
                        messenger.addMessage('success', el.data('success-message'), {'hashNavEnabled': Navigation.isEnabled()});
                        if (el.data('redirect')) {
                            $.isActive(true);
                            if (navigation) {
                                navigation.setLocation(el.data('redirect'));
                            } else {
                                window.location.href = el.data('redirect');
                            }
                        } else if (navigation) {
                            navigation.loadingMask.hide();
                        }
                    },
                    error: function () {
                        if (navigation) {
                            navigation.loadingMask.hide();
                        }

                        messenger.notificationMessage(
                            'error',
                            el.data('error-message') ||  __('Unexpected error occured. Please contact system administrator.')
                        );
                    }
                });
            });
            confirm.open();

            return false;
        });
    });

    /* ============================================================
     * from form/collection.js'
     * ============================================================ */
    $(document).on('click', '.add-list-item', function (e) {
        e.preventDefault();
        var cList  = $(this).siblings('.collection-fields-list'),
            widget = cList.attr('data-prototype').replace(/__name__/g, cList.children().length),
            data = $('<div/>').html(widget);

        data.children().appendTo(cList);
        /* temporary solution need add init only for new created row */
        layout.styleForm(data);
        /* temporary solution finish */
    });

    $(document).on('click', '.removeRow', function (e) {
        e.preventDefault();
        $(this).parents('*[data-content]').remove();
    });
});
<|endoftext|>


<commit_before>/*jslint browser: true, undef: true *//*global Ext*/
Ext.define('SlateAdmin.view.people.details.Contacts', {
    extend: 'SlateAdmin.view.people.details.AbstractDetails',
    xtype: 'people-details-contacts',
    requires: [
        'Ext.grid.Panel',
        'Ext.grid.column.Action',
        'Ext.grid.column.Template',
        'Ext.grid.plugin.CellEditing',
        'Ext.grid.feature.Grouping',
        'Ext.form.field.ComboBox',
        'SlateAdmin.model.person.Relationship',
        'SlateAdmin.store.people.RelationshipTemplates',
        'SlateAdmin.model.person.ContactPoint',
        'SlateAdmin.store.people.ContactPointTemplates',
        'SlateAdmin.widget.field.Person',
        'SlateAdmin.widget.field.contact.Postal',
        'SlateAdmin.widget.grid.ContactPointCellEditor'
    ],

    title: 'Contacts',
    glyph: 0xf095,
    itemId: 'contacts',

    // panel config
    autoScroll: true,
    layout: 'anchor',
    defaults: {
        anchor: '100%',
        border: false,
        bodyBorder: false
    },

    items: [{
        xtype: 'grid',
        itemId: 'relationships',
        title: 'Related People',
        componentCls: 'slate-people-details-related',
        bodyBorder: '1 0',
        store: {
            model: 'SlateAdmin.model.person.Relationship',
            pageSize: false,
            remoteSort: true,
            autoSync: false
        },
        viewConfig: {
            loadMask: false,
            autoScroll: false,
            emptyText: 'No related people',
            getRowClass: function(record) {
                var cls = record.get('Class') == 'Emergence\\People\\GuardianRelationship' ? 'relationship-guardian' : 'relationship-nonguardian';

                if (record.phantom) {
                    cls += ' slate-grid-phantom';
                }

                if (record.dirty) {
                    cls += ' slate-grid-dirty';
                }

                if (!record.get('InverseRelationship')) {
                    cls += ' relationship-noinverse';
                }

                return cls;
            }
        },
        plugins: [
            {
                ptype: 'cellediting',
                clicksToEdit: 1
            }
        ],
        columns: {
            defaults: {
                menuDisabled: true
            },
            items: [
                {
                    itemId: 'person',
                    xtype: 'templatecolumn',
                    text: 'Name',
                    dataIndex: 'RelatedPerson',
                    tdCls: 'relationship-cell-person slate-grid-cell-primary',
                    flex: 1,
                    tpl: [
                        '<tpl if="RelatedPerson">',
                            '<tpl if="ID && RelatedPerson.ID"></tpl>',
                                '<tpl for="RelatedPerson">{FirstName} {MiddleName} {LastName}</tpl>',
                            '<tpl if="ID && RelatedPerson.ID"></tpl>',
                        '<tpl else>',
                            ' Add new…',
                        '</tpl>',
                        {
                            getSearchRoute: function(relationship) {
                                var path = ['people', 'search', 'related-to-id:'+relationship.PersonID],
                                    relatedPerson = relationship.RelatedPerson,
                                    relatedUsername = relatedPerson.Username;

                                if (relatedUsername) {
                                    path.push(relatedUsername);
                                } else {
                                    path.push('?id='+relatedPerson.ID);
                                }

                                path.push('contacts');

                                return Ext.util.History.encodeRouteArray(path);
                            }
                        }
                    ],
                    editor: {
                        xtype: 'slate-personfield',
                        listeners: {
                            select: function(comboField) {
                                comboField.collapse();
                            }
                        },
                        xhooks: {
                            setValue: function(value, doSelect) {
                                // transform value from object form back into string or number
                                if (Ext.isObject(value) && !value.isModel) {
                                    if (value.ID) {
                                        value = value.ID;
                                    } else {
                                        value = Ext.Array.clean([value.FirstName, value.MiddleName, value.LastName]).join(' ');
                                    }
                                }

                                this.callParent([value || null, doSelect]);
                            }
                        }
                    }
                },
                {
                    itemId: 'relationship',
                    text: 'Relationship',
                    dataIndex: 'Label',
                    width: 120,
                    editor: {
                        xtype: 'combobox',
                        store: 'people.RelationshipTemplates',
                        allowBlank: false,
                        queryMode: 'local',
                        valueField: 'label',
                        displayField: 'label',
                        triggerAction: 'all',
                        autoSelect: false,
                        listeners: {
                            focus: function(comboField) {
                                comboField.expand();
                            },
                            select: function(comboField) {
                                comboField.collapse();
                            }
                        }
                    }
                },
                {
                    itemId: 'inverse',
                    xtype: 'templatecolumn',
                    text: 'Inverse',
                    dataIndex: 'InverseRelationship.Label',
                    tdCls: 'relationship-cell-inverse',
                    width: 120,
                    tpl: [
                        '<tpl if="InverseRelationship">',
                            '{InverseRelationship.Label}',
    //                    '<tpl else>',
    //                        'Unknown',
                        '</tpl>'
                    ],
                    editor: {
                        xtype: 'textfield'
                    }
                },
                {
                    xtype: 'actioncolumn',
                    dataIndex: 'Class',
                    width: 54,
                    items: [
                        {
                            action: 'delete',
                            iconCls: 'relationship-delete glyph-danger',
                            glyph: 0xf056, // fa-minus-circle
                            tooltip: 'Delete relationship'
                        },
                        {
                            action: 'guardian',
                            iconCls: 'relationship-guardian glyph-shield',
                            glyph: 0xf132, // fa-shield
                            getTip: function(v, meta, record) {
                                return (v == 'Emergence\\People\\Relationship' ? 'Designate' : 'Undesignate') + ' guardian';
                            }
                        }
                        // {
                        //     action: 'emergency',
                        //     iconCls: 'relationship-emergency glyph-emergency',
                        //     glyph: 0xf0f9, // fa-ambulance
                        //     getTip: function(v, meta, record) {
                        //         // TODO make this work
                        //         return (v == 'Emergence\\People\\Relationship' ? 'Designate' : 'Undesignate') + ' emergency contact';
                        //     }
                        // }
                    ]
                }
            ]
        }
    },{
        xtype: 'grid',
        itemId: 'contactPoints',
        title: 'Contact Points',
        // columnLines: true,
        hideHeaders: true,
        componentCls: 'slate-people-details-contacts',
        disableSelection: true,
        store: {
            model: 'SlateAdmin.model.person.ContactPoint',
            groupField: 'Class',
            pageSize: false,
            sorters: [
                {
                    property: 'Class',
                    direction: 'ASC'
                },
                {
                    property: 'Primary',
                    direction: 'DESC'
                },
                {
                    property: 'ID',
                    direction: 'DESC'
                }
            ]
        },
        viewConfig: {
            loadMask: false,
            autoScroll: false,
            getRowClass: function(record) {
                var cls = '';

                switch (record.get('Class')) {
                    case 'Emergence\\People\\ContactPoint\\Email':
                        cls = 'contact-email';
                        break;
                    case 'Emergence\\People\\ContactPoint\\Link':
                        cls = 'contact-link';
                        break;
                    case 'Emergence\\People\\ContactPoint\\Network':
                        cls = 'contact-network';
                        break;
                    case 'Emergence\\People\\ContactPoint\\Phone':
                        cls = 'contact-phone ';
                        break;
                    case 'Emergence\\People\\ContactPoint\\Postal':
                        cls = 'contact-postal';
                        break;
                    default:
                        cls = 'contact-unknown';
                        break;
                }

                if (record.phantom) {
                    cls += ' slate-grid-phantom';
                }

                if (record.dirty) {
                    cls += ' slate-grid-dirty';
                }

                if (record.get('Primary')) {
                    cls += ' contact-primary';
                }

                return cls;
            }
        },
        plugins: [
            {
                ptype: 'cellediting',
                clicksToEdit: 1
            }
        ],
        features: [
            {
                ftype: 'grouping',
                collapsible: false,
                groupHeaderTpl: [
                    '<tpl for="this.getHeaderConfig(values)">',
                        ' {title}',
                    '</tpl>',
                    {
                        getHeaderConfig: function(values) {
                            var title, typeCls, glyph;

                            switch (values.groupValue) {
                                case 'Emergence\\People\\ContactPoint\\Email':
                                    title = 'Email Addresses';
                                    typeCls = 'contact-email';
                                    glyph = 'fa-envelope-o';
                                    break;
                                case 'Emergence\\People\\ContactPoint\\Link':
                                    title = 'Website Links';
                                    typeCls = 'contact-link';
                                    glyph = 'fa-link';
                                    break;
                                case 'Emergence\\People\\ContactPoint\\Network':
                                    title = 'Online Networks';
                                    typeCls = 'contact-network';
                                    glyph = 'fa-globe';
                                    break;
                                case 'Emergence\\People\\ContactPoint\\Phone':
                                    title = 'Phone Numbers';
                                    typeCls = 'contact-phone';
                                    glyph = 'fa-phone';
                                    break;
                                case 'Emergence\\People\\ContactPoint\\Postal':
                                    title = 'Postal Addresses';
                                    typeCls = 'contact-postal';
                                    glyph = 'fa-home';
                                    break;
                                default:
                                    return null;
                            }

                            return {
                                title: title,
                                typeCls: typeCls,
                                glyph: glyph
                            };
                        }
                    }
                ]
            }
        ],
        columns: [
            {
                itemId: 'label',
                text: 'Label',
                dataIndex: 'Label',
                width: 145,
                tdCls: 'slate-grid-cell-primary',
                editor: {
                    xtype: 'combobox',
                    store: {
                        type: 'contactpointtemplates'
                    },
                    allowBlank: false,
                    queryMode: 'local',
                    valueField: 'label',
                    displayField: 'label',
                    triggerAction: 'all',
                    autoSelect: false,
                    listeners: {
                        focus: function(comboField) {
                            comboField.expand();
                        },
                        select: function(comboField) {
                            comboField.up('editor').completeEdit();
                        }
                    }
                },
                renderer: function(v, m, r) {
                    return v || ' Add new…';
                }
            },
            {
                itemId: 'value',
                text: 'Value',
                dataIndex: 'String',
                tdCls: 'contact-cell-value',
                flex: 1,
                renderer: function (v) {
                    return v ? v.replace(/\n/g, ', ') : '';
                },
                getEditor: function(record) {
                    var me = this,
                        pointCls = record.get('Class'),
                        editorId = me.getItemId()+'-'+pointCls,
                        editors = me.up('grid').findPlugin('cellediting').editors,
                        editor = editors.getByKey(editorId),
                        field;

                    if (editor) {
                        return editor;
                    }

                    switch (pointCls) {
//                        case 'Emergence\\People\\ContactPoint\\Email':
//                            return 'contact-email';
//                        case 'Emergence\\People\\ContactPoint\\Link':
//                            return 'contact-link';
//                        case 'Emergence\\People\\ContactPoint\\Network':
//                            return 'contact-network';
//                        case 'Emergence\\People\\ContactPoint\\Phone':
//                            return 'contact-phone ';
                        case 'Emergence\\People\\ContactPoint\\Postal':
                            field = Ext.create('SlateAdmin.widget.field.contact.Postal');
                            break;
                        default:
                            field = Ext.create('Ext.form.field.Text');
                            break;
                    }

                    editor = Ext.create('SlateAdmin.widget.grid.ContactPointCellEditor', {
                        floating: true,
                        editorId: editorId,
                        field: field
                    });

                    editors.add(editor);

                    return editor;
                }
            },
            {
                xtype: 'actioncolumn',
                dataIndex: 'Primary',
                width: 36,
                items: [
                    {
                        action: 'delete',
                        iconCls: 'contact-point-delete glyph-danger',
                        glyph: 0xf056, // fa-minus-circle
                        tooltip: 'Delete contact point'
                    },
                    {
                        action: 'primary',
                        iconCls: 'contact-point-primary glyph-star',
                        glyph: 0xf005, // fa-star
                        getTip: function(v, meta, record) {
                            return (v ? 'Unmark' : 'Mark') + ' as primary point for this type';
                        }
                    }
                ]
            }
        ]
    }]
});<commit_msg>Adjust contact sorting to prevent resort during editing<commit_after>/*jslint browser: true, undef: true *//*global Ext*/
Ext.define('SlateAdmin.view.people.details.Contacts', {
    extend: 'SlateAdmin.view.people.details.AbstractDetails',
    xtype: 'people-details-contacts',
    requires: [
        'Ext.grid.Panel',
        'Ext.grid.column.Action',
        'Ext.grid.column.Template',
        'Ext.grid.plugin.CellEditing',
        'Ext.grid.feature.Grouping',
        'Ext.form.field.ComboBox',
        'SlateAdmin.model.person.Relationship',
        'SlateAdmin.store.people.RelationshipTemplates',
        'SlateAdmin.model.person.ContactPoint',
        'SlateAdmin.store.people.ContactPointTemplates',
        'SlateAdmin.widget.field.Person',
        'SlateAdmin.widget.field.contact.Postal',
        'SlateAdmin.widget.grid.ContactPointCellEditor'
    ],

    title: 'Contacts',
    glyph: 0xf095,
    itemId: 'contacts',

    // panel config
    autoScroll: true,
    layout: 'anchor',
    defaults: {
        anchor: '100%',
        border: false,
        bodyBorder: false
    },

    items: [{
        xtype: 'grid',
        itemId: 'relationships',
        title: 'Related People',
        componentCls: 'slate-people-details-related',
        bodyBorder: '1 0',
        store: {
            model: 'SlateAdmin.model.person.Relationship',
            pageSize: false,
            remoteSort: true,
            autoSync: false
        },
        viewConfig: {
            loadMask: false,
            autoScroll: false,
            emptyText: 'No related people',
            getRowClass: function(record) {
                var cls = record.get('Class') == 'Emergence\\People\\GuardianRelationship' ? 'relationship-guardian' : 'relationship-nonguardian';

                if (record.phantom) {
                    cls += ' slate-grid-phantom';
                }

                if (record.dirty) {
                    cls += ' slate-grid-dirty';
                }

                if (!record.get('InverseRelationship')) {
                    cls += ' relationship-noinverse';
                }

                return cls;
            }
        },
        plugins: [
            {
                ptype: 'cellediting',
                clicksToEdit: 1
            }
        ],
        columns: {
            defaults: {
                menuDisabled: true
            },
            items: [
                {
                    itemId: 'person',
                    xtype: 'templatecolumn',
                    text: 'Name',
                    dataIndex: 'RelatedPerson',
                    tdCls: 'relationship-cell-person slate-grid-cell-primary',
                    flex: 1,
                    tpl: [
                        '<tpl if="RelatedPerson">',
                            '<tpl if="ID && RelatedPerson.ID"></tpl>',
                                '<tpl for="RelatedPerson">{FirstName} {MiddleName} {LastName}</tpl>',
                            '<tpl if="ID && RelatedPerson.ID"></tpl>',
                        '<tpl else>',
                            ' Add new…',
                        '</tpl>',
                        {
                            getSearchRoute: function(relationship) {
                                var path = ['people', 'search', 'related-to-id:'+relationship.PersonID],
                                    relatedPerson = relationship.RelatedPerson,
                                    relatedUsername = relatedPerson.Username;

                                if (relatedUsername) {
                                    path.push(relatedUsername);
                                } else {
                                    path.push('?id='+relatedPerson.ID);
                                }

                                path.push('contacts');

                                return Ext.util.History.encodeRouteArray(path);
                            }
                        }
                    ],
                    editor: {
                        xtype: 'slate-personfield',
                        listeners: {
                            select: function(comboField) {
                                comboField.collapse();
                            }
                        },
                        xhooks: {
                            setValue: function(value, doSelect) {
                                // transform value from object form back into string or number
                                if (Ext.isObject(value) && !value.isModel) {
                                    if (value.ID) {
                                        value = value.ID;
                                    } else {
                                        value = Ext.Array.clean([value.FirstName, value.MiddleName, value.LastName]).join(' ');
                                    }
                                }

                                this.callParent([value || null, doSelect]);
                            }
                        }
                    }
                },
                {
                    itemId: 'relationship',
                    text: 'Relationship',
                    dataIndex: 'Label',
                    width: 120,
                    editor: {
                        xtype: 'combobox',
                        store: 'people.RelationshipTemplates',
                        allowBlank: false,
                        queryMode: 'local',
                        valueField: 'label',
                        displayField: 'label',
                        triggerAction: 'all',
                        autoSelect: false,
                        listeners: {
                            focus: function(comboField) {
                                comboField.expand();
                            },
                            select: function(comboField) {
                                comboField.collapse();
                            }
                        }
                    }
                },
                {
                    itemId: 'inverse',
                    xtype: 'templatecolumn',
                    text: 'Inverse',
                    dataIndex: 'InverseRelationship.Label',
                    tdCls: 'relationship-cell-inverse',
                    width: 120,
                    tpl: [
                        '<tpl if="InverseRelationship">',
                            '{InverseRelationship.Label}',
    //                    '<tpl else>',
    //                        'Unknown',
                        '</tpl>'
                    ],
                    editor: {
                        xtype: 'textfield'
                    }
                },
                {
                    xtype: 'actioncolumn',
                    dataIndex: 'Class',
                    width: 54,
                    items: [
                        {
                            action: 'delete',
                            iconCls: 'relationship-delete glyph-danger',
                            glyph: 0xf056, // fa-minus-circle
                            tooltip: 'Delete relationship'
                        },
                        {
                            action: 'guardian',
                            iconCls: 'relationship-guardian glyph-shield',
                            glyph: 0xf132, // fa-shield
                            getTip: function(v, meta, record) {
                                return (v == 'Emergence\\People\\Relationship' ? 'Designate' : 'Undesignate') + ' guardian';
                            }
                        }
                        // {
                        //     action: 'emergency',
                        //     iconCls: 'relationship-emergency glyph-emergency',
                        //     glyph: 0xf0f9, // fa-ambulance
                        //     getTip: function(v, meta, record) {
                        //         // TODO make this work
                        //         return (v == 'Emergence\\People\\Relationship' ? 'Designate' : 'Undesignate') + ' emergency contact';
                        //     }
                        // }
                    ]
                }
            ]
        }
    },{
        xtype: 'grid',
        itemId: 'contactPoints',
        title: 'Contact Points',
        // columnLines: true,
        hideHeaders: true,
        componentCls: 'slate-people-details-contacts',
        disableSelection: true,
        store: {
            model: 'SlateAdmin.model.person.ContactPoint',
            groupField: 'Class',
            pageSize: false,
            sorters: [
                {
                    property: 'Class',
                    direction: 'ASC'
                },
                {
                    sorterFn: function(r1, r2) {
                        r1 = r1.phantom;
                        r2 = r2.phantom;

                        if (r1 == r2) {
                            return 0;
                        }

                        return r1 ? 1 : -1;
                    }
                },
                {
                    property: 'ID',
                    direction: 'ASC'
                }
            ]
        },
        viewConfig: {
            loadMask: false,
            autoScroll: false,
            getRowClass: function(record) {
                var cls = '';

                switch (record.get('Class')) {
                    case 'Emergence\\People\\ContactPoint\\Email':
                        cls = 'contact-email';
                        break;
                    case 'Emergence\\People\\ContactPoint\\Link':
                        cls = 'contact-link';
                        break;
                    case 'Emergence\\People\\ContactPoint\\Network':
                        cls = 'contact-network';
                        break;
                    case 'Emergence\\People\\ContactPoint\\Phone':
                        cls = 'contact-phone ';
                        break;
                    case 'Emergence\\People\\ContactPoint\\Postal':
                        cls = 'contact-postal';
                        break;
                    default:
                        cls = 'contact-unknown';
                        break;
                }

                if (record.phantom) {
                    cls += ' slate-grid-phantom';
                }

                if (record.dirty) {
                    cls += ' slate-grid-dirty';
                }

                if (record.get('Primary')) {
                    cls += ' contact-primary';
                }

                return cls;
            }
        },
        plugins: [
            {
                ptype: 'cellediting',
                clicksToEdit: 1
            }
        ],
        features: [
            {
                ftype: 'grouping',
                collapsible: false,
                groupHeaderTpl: [
                    '<tpl for="this.getHeaderConfig(values)">',
                        ' {title}',
                    '</tpl>',
                    {
                        getHeaderConfig: function(values) {
                            var title, typeCls, glyph;

                            switch (values.groupValue) {
                                case 'Emergence\\People\\ContactPoint\\Email':
                                    title = 'Email Addresses';
                                    typeCls = 'contact-email';
                                    glyph = 'fa-envelope-o';
                                    break;
                                case 'Emergence\\People\\ContactPoint\\Link':
                                    title = 'Website Links';
                                    typeCls = 'contact-link';
                                    glyph = 'fa-link';
                                    break;
                                case 'Emergence\\People\\ContactPoint\\Network':
                                    title = 'Online Networks';
                                    typeCls = 'contact-network';
                                    glyph = 'fa-globe';
                                    break;
                                case 'Emergence\\People\\ContactPoint\\Phone':
                                    title = 'Phone Numbers';
                                    typeCls = 'contact-phone';
                                    glyph = 'fa-phone';
                                    break;
                                case 'Emergence\\People\\ContactPoint\\Postal':
                                    title = 'Postal Addresses';
                                    typeCls = 'contact-postal';
                                    glyph = 'fa-home';
                                    break;
                                default:
                                    return null;
                            }

                            return {
                                title: title,
                                typeCls: typeCls,
                                glyph: glyph
                            };
                        }
                    }
                ]
            }
        ],
        columns: [
            {
                itemId: 'label',
                text: 'Label',
                dataIndex: 'Label',
                width: 145,
                tdCls: 'slate-grid-cell-primary',
                editor: {
                    xtype: 'combobox',
                    store: {
                        type: 'contactpointtemplates'
                    },
                    allowBlank: false,
                    queryMode: 'local',
                    valueField: 'label',
                    displayField: 'label',
                    triggerAction: 'all',
                    autoSelect: false,
                    listeners: {
                        focus: function(comboField) {
                            comboField.expand();
                        },
                        select: function(comboField) {
                            comboField.up('editor').completeEdit();
                        }
                    }
                },
                renderer: function(v, m, r) {
                    return v || ' Add new…';
                }
            },
            {
                itemId: 'value',
                text: 'Value',
                dataIndex: 'String',
                tdCls: 'contact-cell-value',
                flex: 1,
                renderer: function (v) {
                    return v ? v.replace(/\n/g, ', ') : '';
                },
                getEditor: function(record) {
                    var me = this,
                        pointCls = record.get('Class'),
                        editorId = me.getItemId()+'-'+pointCls,
                        editors = me.up('grid').findPlugin('cellediting').editors,
                        editor = editors.getByKey(editorId),
                        field;

                    if (editor) {
                        return editor;
                    }

                    switch (pointCls) {
//                        case 'Emergence\\People\\ContactPoint\\Email':
//                            return 'contact-email';
//                        case 'Emergence\\People\\ContactPoint\\Link':
//                            return 'contact-link';
//                        case 'Emergence\\People\\ContactPoint\\Network':
//                            return 'contact-network';
//                        case 'Emergence\\People\\ContactPoint\\Phone':
//                            return 'contact-phone ';
                        case 'Emergence\\People\\ContactPoint\\Postal':
                            field = Ext.create('SlateAdmin.widget.field.contact.Postal');
                            break;
                        default:
                            field = Ext.create('Ext.form.field.Text');
                            break;
                    }

                    editor = Ext.create('SlateAdmin.widget.grid.ContactPointCellEditor', {
                        floating: true,
                        editorId: editorId,
                        field: field
                    });

                    editors.add(editor);

                    return editor;
                }
            },
            {
                xtype: 'actioncolumn',
                dataIndex: 'Primary',
                width: 36,
                items: [
                    {
                        action: 'delete',
                        iconCls: 'contact-point-delete glyph-danger',
                        glyph: 0xf056, // fa-minus-circle
                        tooltip: 'Delete contact point'
                    },
                    {
                        action: 'primary',
                        iconCls: 'contact-point-primary glyph-star',
                        glyph: 0xf005, // fa-star
                        getTip: function(v, meta, record) {
                            return (v ? 'Unmark' : 'Mark') + ' as primary point for this type';
                        }
                    }
                ]
            }
        ]
    }]
});<|endoftext|>


<commit_before>/*jslint browser: true, undef: true *//*global Ext*/
Ext.define('SlateAdmin.view.people.details.Progress', {
    extend: 'SlateAdmin.view.people.details.AbstractDetails',
    xtype: 'people-details-progress',
    requires: [
        'Ext.grid.Panel'
    ],

    title: 'Progress',
    glyph: 0xf095,
    itemId: 'progress',

    layout: 'fit',

    dockedItems: [{
        xtype: 'toolbar',
        dock: 'top',
        items: [{
            xtype: 'button',
            text: 'New Note',
            action: 'composeNote',
            cls: 'glyph-success',
            glyph: 0xf055 // fa-plus-circle
        },{
            xtype: 'button',
            text: 'Types',
            itemId: 'reportTypes',
            glyph: 0xf0ca, // fa-list-ul
            menu: {
                floating: true,
                items: [{
                    xtype: 'menucheckitem',
                    checked: true,
                    text: 'Progress Notes',
                    value: 'progressnotes'
                // },{
                //     xtype: 'menucheckitem',
                //     checked: true,
                //     text: 'Narratives',
                //     value: 'narratives'
                // },{
                //     xtype: 'menucheckitem',
                //     checked: true,
                //     text: 'Interims',
                //     value: 'interims'
                // },{
                //     xtype: 'menucheckitem',
                //     checked: true,
                //     text: 'Standards',
                //     value: 'standards'
                }]
            }
        },{
            xtype: 'tbspacer'
        },{
            xtype: 'tbseparator'
        },{
            xtype: 'tbtext',
            text: 'Term: '
        },{
            flex: 1,
            xtype: 'combobox',
            itemId: 'progressReportsTermSelector',
            name: 'progressReportsTermSelector',
            emptyText: 'Current',
            store: 'Terms',
            valueField: 'ID',
            displayField: 'Title',
            queryMode: 'local',
            forceSelection: true
        }]
    },{
        xtype: 'toolbar',
        dock: 'bottom',
        items: ['->',{
            xtype: 'button',
            text: 'Export',
            action: 'export-reports',
            glyph: 0xf064 // fa-share
        }]
    }],

    items: [{
        xtype: 'dataview',
        itemId: 'progressReportsList',
        store: 'people.ProgressReports',
        itemSelector: '.person-record',
        emptyText: '
No progress records found for selected type and term.
',
        autoScroll: true,
        tpl: [
            '
',
                '<tpl for=".">',
                    '
',
                        '
',
                            '{Type}',
                            '{AuthorUsername}',
                            '<time class="datum token index date" datetime="{Date:date(\'c\')}" title="{Date:date(\'F j, Y, g:i a\')}">',
                            '{Date:date(\'M j\')}',
                            '{Date:date(\', Y, g:i a\')}',
                            '</time>',
                        '
',
                        '
{Subject}
',
                    '
',
                '</tpl>',
            '
'
        ]
    }]
});<commit_msg>Enable remaining people.Progress filters<commit_after>/*jslint browser: true, undef: true *//*global Ext*/
Ext.define('SlateAdmin.view.people.details.Progress', {
    extend: 'SlateAdmin.view.people.details.AbstractDetails',
    xtype: 'people-details-progress',
    requires: [
        'Ext.grid.Panel'
    ],

    title: 'Progress',
    glyph: 0xf095,
    itemId: 'progress',

    layout: 'fit',

    dockedItems: [{
        xtype: 'toolbar',
        dock: 'top',
        items: [{
            xtype: 'button',
            text: 'New Note',
            action: 'composeNote',
            cls: 'glyph-success',
            glyph: 0xf055 // fa-plus-circle
        },{
            xtype: 'button',
            text: 'Types',
            itemId: 'reportTypes',
            glyph: 0xf0ca, // fa-list-ul
            menu: {
                floating: true,
                items: [{
                    xtype: 'menucheckitem',
                    checked: true,
                    text: 'Progress Notes',
                    value: 'progressnotes'
                },{
                    xtype: 'menucheckitem',
                    checked: true,
                    text: 'Narratives',
                    value: 'narratives'
                },{
                    xtype: 'menucheckitem',
                    checked: true,
                    text: 'Interims',
                    value: 'interims'
                },{
                    xtype: 'menucheckitem',
                    checked: true,
                    text: 'Standards',
                    value: 'standards'
                }]
            }
        },{
            xtype: 'tbspacer'
        },{
            xtype: 'tbseparator'
        },{
            xtype: 'tbtext',
            text: 'Term: '
        },{
            flex: 1,
            xtype: 'combobox',
            itemId: 'progressReportsTermSelector',
            name: 'progressReportsTermSelector',
            emptyText: 'Current',
            store: 'Terms',
            valueField: 'ID',
            displayField: 'Title',
            queryMode: 'local',
            forceSelection: true
        }]
    },{
        xtype: 'toolbar',
        dock: 'bottom',
        items: ['->',{
            xtype: 'button',
            text: 'Export',
            action: 'export-reports',
            glyph: 0xf064 // fa-share
        }]
    }],

    items: [{
        xtype: 'dataview',
        itemId: 'progressReportsList',
        store: 'people.ProgressReports',
        itemSelector: '.person-record',
        emptyText: '
No progress records found for selected type and term.
',
        autoScroll: true,
        tpl: [
            '
',
                '<tpl for=".">',
                    '
',
                        '
',
                            '{Type}',
                            '{AuthorUsername}',
                            '<time class="datum token index date" datetime="{Date:date(\'c\')}" title="{Date:date(\'F j, Y, g:i a\')}">',
                            '{Date:date(\'M j\')}',
                            '{Date:date(\', Y, g:i a\')}',
                            '</time>',
                        '
',
                        '
{Subject}
',
                    '
',
                '</tpl>',
            '
'
        ]
    }]
});<|endoftext|>


<commit_before>import webpack from 'webpack'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import CleanPlugin from 'clean-webpack-plugin'
import webpackConfig from 'config/webpack.base.config'
import { isomorphicPlugin } from 'server/isomorphicTools'
import autoprefixer from 'autoprefixer'

export default {
  ...webpackConfig,
  devtool: null,
  plugins: [
    new CleanPlugin([ webpackConfig.output.path ]),
    isomorphicPlugin,
    ...webpackConfig.plugins,
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
         screw_ie8: true, // eslint-disable-line camelcase
         warnings: false
      }
    }),
  ],
  postcss: [ autoprefixer({ browsers: [ 'last 2 versions' ] }) ],
  module: {
    loaders: [ {
      test: /module\.s?css$/,
      include: [ /src\/app/ ],
      loader: ExtractTextPlugin.extract(
        'style',
        'css?modules&localIdentName=[path][name]-[local]' +
        '!postcss' +
        '!sass?outputStyle=compressed'
      ),
    }, {
      test: /\.s?css$/,
      include: [ /src\/app/ ],
      exclude: /module\.s?css$/,
      loader: ExtractTextPlugin.extract(
        'style', 'css!postcss!sass?outputStyle=compressed'
      ),
    }, {
      test: /\.(es6?|jsx?)$/,
      include: [ /src\/app/ ],
      loader: 'babel',
      query: {
        'presets': [ 'es2015', 'react', 'stage-0' ],
        'plugins': [
          'add-module-exports',
          'lodash',
          'react-require',
          'babel-root-import',
          'transform-decorators-legacy',
        ],
      },
    }, ...webpackConfig.module.loaders ],
  },
}
<commit_msg>fixing style<commit_after>import webpack from 'webpack'
import ExtractTextPlugin from 'extract-text-webpack-plugin'
import CleanPlugin from 'clean-webpack-plugin'
import webpackConfig from 'config/webpack.base.config'
import { isomorphicPlugin } from 'server/isomorphicTools'
import autoprefixer from 'autoprefixer'

export default {
  ...webpackConfig,
  devtool: null,
  plugins: [
    new CleanPlugin([ webpackConfig.output.path ]),
    isomorphicPlugin,
    ...webpackConfig.plugins,
    new webpack.optimize.DedupePlugin(),
    new webpack.optimize.UglifyJsPlugin({
      compress: {
        screw_ie8: true, // eslint-disable-line camelcase
        warnings: false,
      },
    }),
  ],
  postcss: [ autoprefixer({ browsers: [ 'last 2 versions' ] }) ],
  module: {
    loaders: [ {
      test: /module\.s?css$/,
      include: [ /src\/app/ ],
      loader: ExtractTextPlugin.extract(
        'style',
        'css?modules&localIdentName=[path][name]-[local]' +
        '!postcss' +
        '!sass?outputStyle=compressed'
      ),
    }, {
      test: /\.s?css$/,
      include: [ /src\/app/ ],
      exclude: /module\.s?css$/,
      loader: ExtractTextPlugin.extract(
        'style', 'css!postcss!sass?outputStyle=compressed'
      ),
    }, {
      test: /\.(es6?|jsx?)$/,
      include: [ /src\/app/ ],
      loader: 'babel',
      query: {
        'presets': [ 'es2015', 'react', 'stage-0' ],
        'plugins': [
          'add-module-exports',
          'lodash',
          'react-require',
          'babel-root-import',
          'transform-decorators-legacy',
        ],
      },
    }, ...webpackConfig.module.loaders ],
  },
}
<|endoftext|>