byPathDidChange: observer('byPath', 'value', function() {
    let byPath = get(this, 'byPath');
    let value = get(this, 'value');

    if (isEmpty(byPath)) {
      defineProperty(this, 'content', []);
      return;
    }

    let filterFn;

    if (isPresent(value)) {
      if (typeof value === 'function') {
        filterFn = (item) => !value(get(item, byPath));
      } else {
        filterFn = (item) => !isEqual(get(item, byPath), value);
      }
    } else {
      filterFn = (item) => !get(item, byPath);
    }

    let cp = filter(`array.@each.${byPath}`, filterFn);

    defineProperty(this, 'content', cp);
  }),
Esempio n. 2
0
	pathDidChange: observer('path', 'value', function() {

		let func = () => null;
		let path = get(this, 'path');
		let value = get(this, 'value');

		if ( isEmpty(path) ) {
			defineProperty(this, 'content', []);
			return;
		}

		if ( isPresent(value) ) {
			if (typeof value === 'function') {
				func = (item) => !value( get(item, path) );
			} else {
				func = (item) => get(item, path) !== value;
			}
		} else {
			func = (item) => isEmpty( get(item, path) );
		}

		defineProperty(this, 'content', filter(`array.@each.${path}`, func));

	}),
Esempio n. 3
0
export default Controller.extend({
  categoryNameSorting: ['name:asc'],
  categoryPositionSorting: ['position:asc'],

  categories: alias('model.categories'),
  category: alias('model.category'),

  categoryDescription: oneWay('category.description'),
  categoryName: oneWay('category.name'),
  categoryParent: oneWay('category.parent.id'),
  categoryPosition: oneWay('category.position'),

  subcategories: sort('category.subcategories', 'categoryPositionSorting'),
  siblingCategories: filter('categories', function(item) {
    return item.get('parent.id') === this.get('category.parent.id');
  }),
  sortedSiblingCategories: sort('siblingCategories', 'categoryPositionSorting'),
  hasSiblingCategories: gt('siblingCategories.length', 1),

  isTopLevelCategory: empty('category.parent'),

  topLevelCategories: filterBy('categories', 'parent', null),
  alphabeticTopLevelCategories: sort('topLevelCategories', 'categoryNameSorting'),

  newCategoryName: '',
  newCategoryDescription: '',
  newCategoryPosition: -1,

  actions: {
    addSubcategory() {
Esempio n. 4
0
   * @type boolean
   * @public
   */
  active: overrideableCP('_active', function() {
    return this.get('_active');
  }),
  _active: false,

  /**
   * Collection of all `Ember.LinkComponent`s that are children
   *
   * @property childLinks
   * @private
   */
  childLinks: filter('children', function(view) {
    return view instanceof LinkComponent;
  }),

  activeChildLinks: filterBy('childLinks', 'active'),
  hasActiveChildLinks: gt('activeChildLinks.length', 0),

  disabledChildLinks: filterBy('childLinks', 'disabled'),
  hasDisabledChildLinks: gt('disabledChildLinks.length', 0),

  /**
   * Called when clicking the nav item
   *
   * @event onClick
   * @public
   */
  onClick() {},
Esempio n. 5
0
  filteredColumns: filter('columns', function(name) {
    let modelName = get(this, 'model-record.name');
    let allowColumn = true;

    /*jshint -W024 */
    let {
      admin: {
        includedColumns: adminIncludedColumns,
        excludedColumns: adminExcludedColumns
      },
      includedColumns,
      excludedColumns
    } = this;
    /*jshint +W024 */

    if (adminIncludedColumns) {
      if (!columnIncludes(adminIncludedColumns[modelName], name)) {
        allowColumn = false;
      }
    }

    if (adminExcludedColumns) {
      if (columnIncludes(adminExcludedColumns[modelName], name)) {
        allowColumn = false;
      }
    }

    if (columnIncludes(excludedColumns, name)) {
      allowColumn = false;
    }

    if (columnIncludes(includedColumns, name)) {
      allowColumn = true;
    }

    return allowColumn;
  })
Esempio n. 6
0
      }
    }
  },
  // dates are sorted
  datesForFirstDay: readOnly('groupedDates.firstObject.items'),

  // errorMessage should be reset to null on all user interactions
  errorMesage: null,
  resetErrorMessage: observer('*****@*****.**', function() {
    this.set('errorMessage', null);
  }),

  // can't use multiple computed macros at once
  _timesForFirstDay: mapBy('datesForFirstDay', 'time'),
  timesForFirstDay: filter('_timesForFirstDay', function(time) {
    return isPresent(time);
  }),

  groupedDates: groupBy('dates', raw('day')),

  childFormElements: computed('_nestedChildViews', function() {
    let form = this.childViews.find((childView) => {
      return childView instanceof BsForm;
    });

    if (!form) {
      return [];
    }

    return form.childViews.filter((childView) => {
      return childView instanceof BsFormElement;
  @module Component
  @extends Ember.Component
 */
export default Component.extend({
  classNames: ['thank-you-container'],

  onboarding: service(),

  /**
    A filter for the project's approved users

    @property approvedProjectUsers
    @type Ember.Array
   */
  approvedProjectUsers: filter('project.projectUsers', function(projectUser) {
    return get(projectUser, 'role') !== 'pending';
  }),

  /**
    A computed array of approved project users

    @property approvedUsers
    @type Ember.Array
   */
  approvedUsers: mapBy('approvedProjectUsers', 'user'),

  /**
    Retuns a subset of at most `MAX_VOLUNTEERS` members from the `approvedUsers` array.

    @property volunteers
    @type Ember.Array
Esempio n. 8
0
  filtered: filter(
    'model.@each.{createdAt,fulfilledBranch,rejectedBranch,pendingBranch,isVisible}', function(item) {

      // exclude cleared promises
      if (this.get('createdAfter') && item.get('createdAt') < this.get('createdAfter')) {
        return false;
      }

      if (!item.get('isVisible')) {
        return false;
      }

      // Exclude non-filter complying promises
      // If at least one of their children passes the filter,
      // then they pass
      let include = true;
      if (this.get('filter') === 'pending') {
        include = item.get('pendingBranch');
      } else if (this.get('filter') === 'rejected') {
        include = item.get('rejectedBranch');
      } else if (this.get('filter') === 'fulfilled') {
        include = item.get('fulfilledBranch');
      }
      if (!include) {
        return false;
      }

      // Search filter
      // If they or at least one of their children
      // match the search, then include them
      let search = this.get('effectiveSearch');
      if (!isEmpty(search)) {
        return item.matches(search);
      }
      return true;

    }
  ),
Esempio n. 9
0
  }),

  center: false,
  dimBackground: true,
  outline: false,

  classNameBindings: [
    'hasProxiedComponent:md-proxy-focus', 'shouldBeClickable:md-clickable',
    'focused:md-focused', 'hasPrimaryAction:_md-button-wrap'
  ],
  attributeBindings: ['role', 'tabindex'],
  role: 'listitem',
  tabindex: '-1',

  proxiedComponents: filter('childComponents', function(c) {
    return !c.get('skipProxy');
  }),

  hasProxiedComponent: bool('proxiedComponents.length'),
  shouldBeClickable: or('hasProxiedComponent', 'onClick'),

  hasPrimaryAction: or('onClick', 'href'),

  noProxy: computed('hasPrimaryAction', 'hasProxiedComponent', function() {
    return !this.get('hasPrimaryAction') && !this.get('hasProxiedComponent');
  }),

  secondaryItem: computed('proxiedComponents.[]', function() {
    let proxiedComponents = this.get('proxiedComponents');
    return proxiedComponents.objectAt(0);
  }),
Esempio n. 10
0
    let contacts = [];
    let numOfContacts = this.get('numOfContacts');

    for (let i = 0; i < numOfContacts; i++) {
      contacts.push({
        name: faker.name.findName(),
        email: faker.internet.email(),
        image: faker.internet.avatar()
      });
    }

    return contacts;
  }),

  selectedContacts: filter('contacts', function(c, index) {
    return index % 2 === 0;
  }),

  remainingContacts: computed('contacts.[]', 'selectedContacts.[]', function() {
    return this.get('contacts').filter((c) => {
      return this.get('selectedContacts').indexOf(c) === -1;
    });
  }),

  altContacts: computed('numOfContacts', function() {
    let contacts = [];
    let numOfContacts = this.get('numOfContacts');

    for (let i = 0; i < numOfContacts; i++) {
      let firstName = faker.name.firstName();
      let lastName = faker.name.lastName();
Esempio n. 11
0
import { A as emberArray, isArray as isEmberArray } from '@ember/array';
import { filter } from '@ember/object/computed';
import Helper from '@ember/component/helper';
import { get } from '@ember/object';
import { observer } from '@ember/object';
import { set } from '@ember/object';
import { isPresent } from '@ember/utils';

export default Helper.extend({
  compute([array]) {
    if (!isEmberArray(array)) {
      return emberArray([array]);
    }

    set(this, 'array', array);

    return get(this, 'content');
  },

  content: filter('array', isPresent),

  contentDidChange: observer('content', function() {
    this.recompute();
  })
});
Esempio n. 12
0
import { isNone } from '@ember/utils';
import { get, computed } from '@ember/object';
import Controller, { inject as controller } from '@ember/controller';
import { alias, notEmpty, filter } from '@ember/object/computed';

export default Controller.extend({
  repoController: controller('repo'),
  tab: alias('repoController.tab'),

  defaultBranch: computed('model', function () {
    let model = this.get('model');
    return model.filterBy('default_branch')[0];
  }),

  branchesExist: notEmpty('model'),
  nonDefaultBranches: filter('model', (branch) => !branch.default_branch),

  activeBranches: computed('nonDefaultBranches', function () {
    let nonDefaultBranches = this.get('nonDefaultBranches');
    const activeBranches = nonDefaultBranches.filterBy('exists_on_github');
    return this._sortBranchesByFinished(activeBranches);
  }),

  inactiveBranches: computed('nonDefaultBranches', function () {
    let nonDefaultBranches = this.get('nonDefaultBranches');
    const inactiveBranches = nonDefaultBranches.filterBy('exists_on_github', false);
    return this._sortBranchesByFinished(inactiveBranches);
  }),

  _sortBranchesByFinished(branches) {
    const unfinished = branches.filter(branch => {
Esempio n. 13
0
  // bound to the input field, updates the `search` property
  // 300ms after changing
  searchField: debounceComputed('search', 300),

  // model filtered based on this value
  search: '',

  escapedSearch: computed('search', function() {
    return escapeRegExp(this.get('search').toLowerCase());
  }),

  filtered: filter('model', function(item) {
    let search = this.get('escapedSearch');
    if (isEmpty(search)) {
      return true;
    }
    let regExp = new RegExp(search);
    return !!recursiveMatch(item, regExp);
  }).property('*****@*****.**', 'search')
});

function recursiveMatch(item, regExp) {
  let children, child;
  let name = get(item, 'name');
  if (name.toLowerCase().match(regExp)) {
    return true;
  }
  children = get(item, 'children');
  for (let i = 0; i < children.length; i++) {
    child = children[i];
    if (recursiveMatch(child, regExp)) {
Esempio n. 14
0
// specificity to re-use keys for i18n lookups

export default Service.extend({
    delayedNotifications: null,
    content: null,

    init() {
        this._super(...arguments);
        this.delayedNotifications = emberA();
        this.content = emberA();
    },

    upgradeStatus: service(),

    alerts: filter('content', function (notification) {
        let status = get(notification, 'status');
        return status === 'alert';
    }),

    notifications: filter('content', function (notification) {
        let status = get(notification, 'status');
        return status === 'notification';
    }),

    handleNotification(message, delayed) {
        // If this is an alert message from the server, treat it as html safe
        if (typeof message.toJSON === 'function' && message.get('status') === 'alert') {
            message.set('message', htmlSafe(message.get('message')));
        }

        if (!get(message, 'status')) {
            set(message, 'status', 'notification');
Esempio n. 15
0
import Component from '@ember/component';
import { filter, mapBy } from '@ember/object/computed';
import { get, set, computed } from '@ember/object';
import { inject as service } from '@ember/service';

export default Component.extend({
  router: service(),
  classNames: ['build-step-collection', 'row'],
  stepNames: mapBy('buildSteps', 'name'),
  setupSteps: filter('stepNames', item => /^sd-setup/.test(item)),
  teardownSteps: filter('stepNames', item => /^sd-teardown/.test(item)),
  selectedStep: computed('buildSteps.@each.{code,startTime,endTime}', 'preselectedStepName', {
    get() {
      const steps = get(this, 'buildSteps');
      const preselectedStepName = get(this, 'preselectedStepName');
      const preselectedStep = steps.findBy('name', preselectedStepName);

      if (preselectedStep) {
        return preselectedStep.name;
      }

      const runningStep = steps.find(s => s.startTime && !s.endTime);
      const failedStep = steps.find(s => s.code);
      const name = (runningStep && runningStep.name) || (failedStep && failedStep.name) || null;

      return name;
    }
  }),
  setupCollapsed: computed('selectedStep', {
    get() {
      const name = get(this, 'selectedStep');