How to use the rsvp.filter function in rsvp

To help you get started, we’ve selected a few rsvp 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 ilios / frontend / app / components / visualizer-session-type-terms.js View on Github external
const terms = await map(sessions.toArray(), async session => {
      const sessionTerms = await session.get('terms');
      const course = await session.get('course');
      const courseTerms = await course.get('terms');

      const sessionTermsInThisVocabulary = await filter(sessionTerms.toArray(), async term => {
        const termVocab = await term.get('vocabulary');
        return termVocab.get('id') === vocabulary.get('id');
      });
      const courseTermsInThisVocabulary = await filter(courseTerms.toArray(), async term => {
        const termVocab = await term.get('vocabulary');
        return termVocab.get('id') === vocabulary.get('id');
      });
      const sessionTermsObjects = await sessionTermsInThisVocabulary.map(term => {
        return {
          term,
          session,
          course: null
        };
      });
      const courseTermsObjects = await courseTermsInThisVocabulary.map(term => {
        return {
github ilios / frontend / app / components / visualizer-program-year-competencies.js View on Github external
const courseTitles = courses.mapBy('title');
      const sessionTitles = sessions.mapBy('title');

      const rhett = {
        name: parent.get('title'),
        children: childrenTree,
        meta: {
          courseTitles,
          sessionTitles
        }
      };

      return rhett;
    };
    const objectives = await programYear.get('objectives');
    const objectivesWithCompetency = await filter(objectives.toArray(), async objective => {
      const competency = await objective.get('competency');
      return !!competency;
    });
    const objectiveObjects = await map(objectivesWithCompetency, async objective => {
      const obj = await buildTree(objective);
      const competency = await objective.get('competency');
      obj.competencyId = competency.get('id');

      return obj;
    });

    return objectiveObjects;
  }),
github ilios / frontend / app / components / taxonomy-manager.js View on Github external
filteredTerms: computed('topLevelTerms.[]', 'termFilter', async function() {
    const termFilter = this.get('termFilter');
    const topLevelTerms = await this.get('topLevelTerms');
    if (isEmpty(termFilter)) {
      return topLevelTerms;
    }
    let exp = new RegExp(termFilter, 'gi');
    return filter(topLevelTerms.toArray(), async term => {
      const searchString = await term.get('titleWithDescendantTitles');
      return searchString.match(exp);
    });
  }),
github ilios / frontend / app / components / visualizer-course-vocabulary.js View on Github external
const terms = await map(sessions.toArray(), async session => {
      const sessionTerms = await session.get('terms');

      const sessionTermsInThisVocabulary = await filter(sessionTerms.toArray(), async term => {
        const termVocab = await term.get('vocabulary');
        return termVocab.get('id') === vocabulary.get('id');
      });
      return sessionTermsInThisVocabulary.map(term => {
        return {
          term,
          session
        };
      });
    });
github ilios / frontend / app / components / detail-steward-manager.js View on Github external
availableSchools: computed('selectedDepartments.[]', 'selectedSchools.[]', 'allSchools.[]', async function() {
    const allSchools = await this.allSchools;
    const selectedDepartments = await this.selectedDepartments;
    const selectedSchools = await this.selectedSchools;

    const selectedDepartmentIds = selectedDepartments.mapBy('id');
    const selectedSchoolIds = selectedSchools.mapBy('id');
    const unselectedSchoolsAndSchoolsWithUnselectedDepartments = await filter(allSchools.toArray(), async school => {
      const departments = await school.get('departments');
      const unselectedDepartments = departments.filter(department => {
        return !selectedDepartmentIds.includes(department.get('id'));
      });
      return !selectedSchoolIds.includes(school.get('id')) || isPresent(unselectedDepartments);
    });

    const availableSchools = await map(unselectedSchoolsAndSchoolsWithUnselectedDepartments.toArray(), async school => {
      const allSchoolDepartments = await school.get('departments');
      const departments = allSchoolDepartments.filter(department => {
        return !selectedDepartmentIds.includes(department.get('id'));
      });
      return {
        school,
        departments
      };
github ilios / frontend / app / components / user-profile-cohorts.js View on Github external
setup: task(function* (user) {
    this.set('finishedSetup', false);
    const store = this.store;
    const currentUser = this.currentUser;
    const permissionChecker = this.permissionChecker;

    const cohorts = yield user.get('cohorts');
    const selectedCohorts = cohorts.toArray();
    const primaryCohort = yield user.get('primaryCohort');

    const sessionUser = yield currentUser.get('model');
    const primarySchool = yield sessionUser.get('school');

    const allCohorts = yield store.findAll('cohort');
    const allSchools = yield store.findAll('school');
    const schoolsWithUpdateUserPermission = yield filter(allSchools.toArray(), async school => {
      return permissionChecker.canUpdateUserInSchool(school);
    });

    this.set('selectedCohorts', selectedCohorts);
    this.set('primaryCohort', primaryCohort);
    this.set('schools', schoolsWithUpdateUserPermission);
    this.set('allCohorts', allCohorts);
    this.set('selectedSchoolId', primarySchool.get('id'));

    //preload relationships for cohorts to make rendering smoother
    yield all(allCohorts.mapBy('school'));

    this.set('finishedSetup', true);
  }),
github ilios / frontend / app / routes / assign-students.js View on Github external
async model() {
    const currentUser = this.currentUser;
    const store = this.store;
    const permissionChecker = this.permissionChecker;
    const user = await currentUser.get('model');
    const schools = await store.findAll('school');
    const primarySchool = await user.get('school');
    const schoolsWithUpdateUserPermission = await filter(schools.toArray(), async school => {
      return permissionChecker.canUpdateUserInSchool(school);
    });

    return {
      primarySchool,
      schools: schoolsWithUpdateUserPermission
    };
  },
});
github ilios / frontend / app / components / user-profile-cohorts.js View on Github external
assignableCohortsForSelectedSchool: computed('assignableCohorts.[]', 'selectedSchool', async function() {
    const selectedSchool = this.selectedSchool;
    const assignableCohorts = await this.assignableCohorts;
    return filter(assignableCohorts, async cohort => {
      const school = await cohort.get('school');
      return school.get('id') === selectedSchool.get('id');
    });
  }),
github ilios / frontend / app / components / bulk-new-users.js View on Github external
save: task(function * () {
    this.set('savedUserIds', []);
    const store = this.store;
    const nonStudentMode = this.nonStudentMode;
    const selectedSchool = yield this.bestSelectedSchool;
    const selectedCohort = yield this.bestSelectedCohort;
    const roles = yield store.findAll('user-role');
    const studentRole = roles.findBy('id', '4');

    const proposedUsers = this.selectedUsers;

    const validUsers = yield filter(proposedUsers, obj => {
      return obj.validate().then(({validations}) => {
        return validations.get('isValid');
      });
    });
    const records = validUsers.map(userInput => {
      const user = store.createRecord('user', userInput.getProperties(
        'firstName',
        'lastName',
        'middleName',
        'phone',
        'email',
        'campusId',
        'otherId',
        'addedViaIlios',
        'enabled'
      ));
github ilios / frontend / app / components / session-copy.js View on Github external
const permissionChecker = this.get('permissionChecker');
    const session = this.get('session');
    if (!session) {
      return [];
    }
    const selectedYear = await this.get('bestSelectedYear');
    const course = await session.get('course');
    const school = await course.get('school');
    const courses = await store.query('course', {
      filters: {
        year: selectedYear,
        school: school.get('id')
      }
    });

    const filteredCourses = await filter(courses.toArray(), async course => {
      return permissionChecker.canCreateSession(course);
    });

    return filteredCourses.sortBy('title');
  }),