Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Ember from 'ember';
- const { Controller, computed, computed: { reads }, getOwner } = Ember;
- export default Controller.extend({
- departments: Ember.computed.reads('model'),
- searchableDepartments: computed('{selectedDepartments,departments}.[]', {
- get() {
- const Decorator = getOwner(this).factoryFor('decorator:searchable-departments');
- return Decorator.create({
- content: this.get('departments'),
- selected: this.get('selectedDepartments')
- });
- }
- }),
- assignableDepartments: computed('{selectedDepartment,departments.[]}', {
- get() {
- const Decorator = getOwner(this).factoryFor('decorator:assignable-departments');
- return Decorator.create({
- content: this.get('departments'),
- selected: [this.get('selectedDepartment')]
- });
- }
- }),
- actions: {
- toggleSelectedDepartments(code) {
- let selected = this.get('selectedDepartments') || [];
- if (selected.includes(code)) {
- selected.removeObject(code);
- } else {
- selected.pushObject(code);
- }
- this.set('selectedDepartments', selected);
- }
- }
- });
Add Comment
Please, Sign In to add comment