How to use the ember-can.computed function in ember-can

To help you get started, we’ve selected a few ember-can examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github code-corps / code-corps-ember / app / components / task-assignment.js View on Github external
export default Component.extend(EmberKeyboardMixin, {
  classNames: ['task-assignment'],

  currentUser: service(),
  store: service(),
  taskAssignment: service(),

  isAssigning: false,
  canTriggerAssignment: null,
  deferredRendering: null,
  task: null,
  taskUser: null,
  users: null,

  // auto-assigns 'task' property from component as ability 'model'
  ability: EmberCan.computed.ability('task'),
  canAssign: alias('ability.canAssign'),
  currentUserId: alias('currentUser.user.id'),
  taskUserId: alias('taskUser.id'),

  assignedToSelf: computed('currentUserId', 'taskUser.id', function() {
    return isEqual(get(this, 'taskUser.id'), get(this, 'currentUserId'));
  }),

  init() {
    this._super(...arguments);

    set(this, 'keyboardActivated', true);
  },

  // TODO: this updates selection when it changes. However, it updates while
  // the change is still processing, and rolls back if it fails.
github code-corps / code-corps-ember / app / components / task-card.js View on Github external
flashMessages: service(),
  session: service(),
  store: service(),

  bound: false,
  editingDetails: false,
  hasHovered: false,
  hovering: false,
  shouldShowUsers: false,
  task: null,
  taskUser: null,
  users: null,

  // auto-assigns 'task' property from component as ability 'model'
  ability: EmberCan.computed.ability('task'),
  canArchive: alias('ability.canArchive'),
  canReposition: alias('ability.canReposition'),
  isLoading: alias('task.isLoading'),
  taskSkills: mapBy('task.taskSkills', 'skill'),

  init() {
    this._super(...arguments);
  },

  /**
  For usage with data attribute bindings. Needs to be a function because it
  needs to send 'true' and 'false' strings.
  */
  'data-can-reposition': computed('canReposition', function() {
    let canReposition = get(this, 'canReposition');
    return canReposition ? 'true' : 'false';
github code-corps / code-corps-ember / app / components / task / archive-task.js View on Github external
import Component from '@ember/component';
import { alias } from '@ember/object/computed';
import { get } from '@ember/object';
import EmberCan from 'ember-can';

export default Component.extend({
  classNames: ['archive-task'],

  // auto-assigns 'task' property from component as ability 'model'
  ability: EmberCan.computed.ability('task'),
  canArchive: alias('ability.canArchive'),

  actions: {
    archiveTask() {
      if (window.confirm(`Are you sure you want to archive this task? Archiving this task will remove it from your ${get(this, 'task.taskList.title')} task list.`)) {
        get(this, 'archiveTask')();
      }
    }
  }
});
github code-corps / code-corps-ember / app / routes / project / tasks / new.js View on Github external
import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';
import RSVP from 'rsvp';
import { set, get } from '@ember/object';
import EmberCan from 'ember-can';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';

export default Route.extend(AuthenticatedRouteMixin, {
  currentUser: service(),

  ability: EmberCan.computed.ability('organization', 'membership'),

  /**
   * model - Route lifecycle hook
   *
   * @return {RSVP.hash}  promise hash containing the project,
   * the task type for the new task and the current user
   */
  model() {
    let project = this.modelFor('project').reload();
    let user = get(this, 'currentUser.user');

    return RSVP.hash({ project, user });
  },

  /**
   * setupController - Route lifecycle hook

ember-can

Simple authorization addon for Ember apps

MIT
Latest version published 2 years ago

Package Health Score

60 / 100
Full package analysis