From cff70e82a37bf01a6fb070cd47cdc67283b23b3f Mon Sep 17 00:00:00 2001 From: Michael Chadwick Date: Fri, 23 Aug 2024 09:58:57 -0700 Subject: [PATCH] removed unneeded slice() calls --- .../frontend/app/components/courses/root.js | 4 +-- .../new-sequence-block.js | 10 +++---- .../curriculum-inventory/report-rollover.js | 2 +- .../curriculum-inventory/reports.js | 10 +++---- .../sequence-block-overview.js | 6 ++--- .../sequence-block-session-manager.js | 10 +++---- .../app/components/instructor-group/users.js | 2 +- .../app/components/instructor-groups/root.js | 4 +-- .../learner-group/bulk-assignment.js | 4 +-- .../app/components/learner-group/calendar.js | 2 +- .../learner-group/instructor-manager.js | 6 ++--- .../app/components/learner-group/list-item.js | 6 ++--- .../app/components/learner-group/root.js | 14 +++++----- .../components/learner-group/upload-data.js | 4 +-- .../app/components/learner-groups/root.js | 20 +++++++------- .../components/program-year/competencies.js | 4 +-- .../app/components/program-year/list.js | 10 +++---- .../managed-competency-list-item.js | 4 +-- .../app/components/program-year/new.js | 2 +- .../objective-list-item-expanded.js | 2 +- .../program-year/objective-list-item.js | 8 +++--- .../components/program-year/objective-list.js | 2 +- .../app/components/program-year/objectives.js | 2 +- .../app/components/reports/new-subject.js | 2 +- .../visualizer-session-type-vocabularies.js | 2 +- .../visualizer-session-type-vocabulary.js | 2 +- .../components/program-year/list-test.js | 26 +++++++++---------- .../components/school-list-test.js | 2 +- 28 files changed, 86 insertions(+), 86 deletions(-) diff --git a/packages/frontend/app/components/courses/root.js b/packages/frontend/app/components/courses/root.js index ed06bf591f..f72e45eec2 100644 --- a/packages/frontend/app/components/courses/root.js +++ b/packages/frontend/app/components/courses/root.js @@ -133,7 +133,7 @@ export default class CoursesRootComponent extends Component { get selectedSchool() { if (this.args.schoolId) { - const school = findById(this.args.schools.slice(), this.args.schoolId); + const school = findById(this.args.schools, this.args.schoolId); if (school) { return school; } @@ -161,7 +161,7 @@ export default class CoursesRootComponent extends Component { } removeCourse = dropTask(async (course) => { - const courses = (await this.selectedSchool.courses).slice(); + const courses = await this.selectedSchool.courses; courses.splice(courses.indexOf(course), 1); this.selectedSchool.set('courses', courses); await course.destroyRecord(); diff --git a/packages/frontend/app/components/curriculum-inventory/new-sequence-block.js b/packages/frontend/app/components/curriculum-inventory/new-sequence-block.js index b6883050ce..4581a1978b 100644 --- a/packages/frontend/app/components/curriculum-inventory/new-sequence-block.js +++ b/packages/frontend/app/components/curriculum-inventory/new-sequence-block.js @@ -225,7 +225,7 @@ export default class CurriculumInventoryNewSequenceBlock extends Component { this.orderInSequence = 0; if (this.isInOrderedSequence) { const siblings = await this.args.parent.children; - for (let i = 0, n = siblings.slice().length + 1; i < n; i++) { + for (let i = 0, n = siblings.length + 1; i < n; i++) { this.orderInSequenceOptions.push(i + 1); } this.orderInSequence = 1; @@ -242,8 +242,8 @@ export default class CurriculumInventoryNewSequenceBlock extends Component { this.startingAcademicLevel = await this.args.parent.startingAcademicLevel; this.endingAcademicLevel = await this.args.parent.endingAcademicLevel; } else { - this.startingAcademicLevel = this.academicLevels.slice()[0]; - this.endingAcademicLevel = this.academicLevels.slice()[0]; + this.startingAcademicLevel = this.academicLevels[0]; + this.endingAcademicLevel = this.academicLevels[0]; } this.linkableCourses = await this.getLinkableCourses(this.args.report); } @@ -256,8 +256,8 @@ export default class CurriculumInventoryNewSequenceBlock extends Component { this.startingAcademicLevel = await this.args.parent.startingAcademicLevel; this.endingAcademicLevel = await this.args.parent.endingAcademicLevel; } else { - this.startingAcademicLevel = this.academicLevels.slice()[0]; - this.endingAcademicLevel = this.academicLevels.slice()[0]; + this.startingAcademicLevel = this.academicLevels[0]; + this.endingAcademicLevel = this.academicLevels[0]; } this.linkableCourses = await this.getLinkableCourses(this.args.report); } diff --git a/packages/frontend/app/components/curriculum-inventory/report-rollover.js b/packages/frontend/app/components/curriculum-inventory/report-rollover.js index 1b5d4fc20f..582065de3e 100644 --- a/packages/frontend/app/components/curriculum-inventory/report-rollover.js +++ b/packages/frontend/app/components/curriculum-inventory/report-rollover.js @@ -49,7 +49,7 @@ export default class CurriculumInventoryReportRolloverComponent extends Componen const programs = await school.programs; this.selectedProgram = program; - this.programs = programs.slice(); + this.programs = programs; this.years = years; this.selectedYear = selectedYear.year; this.name = this.args.report.name; diff --git a/packages/frontend/app/components/curriculum-inventory/reports.js b/packages/frontend/app/components/curriculum-inventory/reports.js index a66ce9519e..5e8c4ecab4 100644 --- a/packages/frontend/app/components/curriculum-inventory/reports.js +++ b/packages/frontend/app/components/curriculum-inventory/reports.js @@ -29,7 +29,7 @@ export default class CurriculumInventoryReportsComponent extends Component { } get curriculumInventoryReports() { - return this.reports ? this.reports.slice() : []; + return this.reports ?? []; } @action @@ -68,14 +68,14 @@ export default class CurriculumInventoryReportsComponent extends Component { if (!this.args.schools) { return; } - this.sortedSchools = sortBy(this.args.schools.slice(), 'title'); + this.sortedSchools = sortBy(this.args.schools, 'title'); this.hasMoreThanOneSchool = this.sortedSchools.length > 1; if (!this.args.schoolId) { const user = await this.currentUser.getModel(); this.selectedSchool = await user.school; } else { - this.selectedSchool = findById(this.args.schools.slice(), this.args.schoolId); + this.selectedSchool = findById(this.args.schools, this.args.schoolId); } if (this.selectedSchool) { @@ -83,7 +83,7 @@ export default class CurriculumInventoryReportsComponent extends Component { this.selectedSchool, ); const programs = await this.selectedSchool.programs; - this.programs = sortBy(programs.slice(), 'title'); + this.programs = sortBy(programs, 'title'); } if (this.args.programId) { @@ -94,7 +94,7 @@ export default class CurriculumInventoryReportsComponent extends Component { }); removeCurriculumInventoryReport = dropTask(async (report) => { - const reports = (await this.selectedProgram.curriculumInventoryReports).slice(); + const reports = await this.selectedProgram.curriculumInventoryReports; reports.splice(reports.indexOf(report), 1); this.selectedProgram.set('curriculumInventoryReports', reports); await report.destroyRecord(); diff --git a/packages/frontend/app/components/curriculum-inventory/sequence-block-overview.js b/packages/frontend/app/components/curriculum-inventory/sequence-block-overview.js index 99db249cb1..0ade0314e7 100644 --- a/packages/frontend/app/components/curriculum-inventory/sequence-block-overview.js +++ b/packages/frontend/app/components/curriculum-inventory/sequence-block-overview.js @@ -83,13 +83,13 @@ export default class CurriculumInventorySequenceBlockOverviewComponent extends C load = restartableTask(async (element, [sequenceBlock]) => { this.report = await sequenceBlock.report; this.parent = await sequenceBlock.parent; - this.academicLevels = (await this.report.academicLevels).slice(); + this.academicLevels = await this.report.academicLevels; this.isInOrderedSequence = false; this.orderInSequenceOptions = []; if (isPresent(this.parent) && this.parent.isOrdered) { this.isInOrderedSequence = true; const siblings = await this.parent.children; - for (let i = 0, n = siblings.slice().length; i < n; i++) { + for (let i = 0, n = siblings.length; i < n; i++) { const num = i + 1; this.orderInSequenceOptions.push(num); } @@ -192,7 +192,7 @@ export default class CurriculumInventorySequenceBlockOverviewComponent extends C published: true, }, }); - return sessions.slice(); + return sessions; } changeRequired = dropTask(async () => { diff --git a/packages/frontend/app/components/curriculum-inventory/sequence-block-session-manager.js b/packages/frontend/app/components/curriculum-inventory/sequence-block-session-manager.js index 6ef2cea2c2..102a784960 100644 --- a/packages/frontend/app/components/curriculum-inventory/sequence-block-session-manager.js +++ b/packages/frontend/app/components/curriculum-inventory/sequence-block-session-manager.js @@ -109,7 +109,7 @@ export default class SequenceBlockSessionManagerComponent extends Component { if (this.allSelected) { this.linkedSessions = []; } else { - this.linkedSessions = this.sessions.slice(); + this.linkedSessions = this.sessions; } } @@ -118,7 +118,7 @@ export default class SequenceBlockSessionManagerComponent extends Component { if (this.allExcluded) { this.excludedSessions = []; } else { - this.excludedSessions = this.sessions.slice(); + this.excludedSessions = this.sessions; } } @@ -136,9 +136,9 @@ export default class SequenceBlockSessionManagerComponent extends Component { } load = restartableTask(async () => { - this.linkedSessions = (await this.args.sequenceBlock.sessions).slice(); - this.excludedSessions = (await this.args.sequenceBlock.excludedSessions).slice(); - this.sessions = (await this.args.sessions).slice(); + this.linkedSessions = await this.args.sequenceBlock.sessions; + this.excludedSessions = await this.args.sequenceBlock.excludedSessions; + this.sessions = await this.args.sessions; }); saveChanges = dropTask(async () => { diff --git a/packages/frontend/app/components/instructor-group/users.js b/packages/frontend/app/components/instructor-group/users.js index 1bb7c6a375..1f22576dc0 100644 --- a/packages/frontend/app/components/instructor-group/users.js +++ b/packages/frontend/app/components/instructor-group/users.js @@ -27,7 +27,7 @@ export default class InstructorGroupUsersComponent extends Component { } manage = dropTask(async () => { - this.usersBuffer = (await this.args.instructorGroup.users).slice(); + this.usersBuffer = await this.args.instructorGroup.users; this.isManaging = true; }); diff --git a/packages/frontend/app/components/instructor-groups/root.js b/packages/frontend/app/components/instructor-groups/root.js index 362d073117..87532fcd76 100644 --- a/packages/frontend/app/components/instructor-groups/root.js +++ b/packages/frontend/app/components/instructor-groups/root.js @@ -80,11 +80,11 @@ export default class InstructorGroupsRootComponent extends Component { get bestSelectedSchool() { if (this.args.schoolId) { - return findById(this.args.schools.slice(), this.args.schoolId); + return findById(this.args.schools, this.args.schoolId); } const schoolId = this.user?.belongsTo('school').id(); - return schoolId ? findById(this.args.schools.slice(), schoolId) : this.args.schools.slice()[0]; + return schoolId ? findById(this.args.schools, schoolId) : this.args.schools[0]; } get filteredInstructorGroups() { diff --git a/packages/frontend/app/components/learner-group/bulk-assignment.js b/packages/frontend/app/components/learner-group/bulk-assignment.js index bdaf240e6c..aecba14356 100644 --- a/packages/frontend/app/components/learner-group/bulk-assignment.js +++ b/packages/frontend/app/components/learner-group/bulk-assignment.js @@ -24,7 +24,7 @@ export default class LearnerGroupBulkAssignmentComponent extends Component { @action async addMatch(name, groupId) { const group = await this.store.findRecord('learner-group', groupId); - const matchedGroups = this.matchedGroups.slice(); + const matchedGroups = this.matchedGroups; const match = findBy(matchedGroups, 'name', name); if (match) { this.removeMatch(name); @@ -49,7 +49,7 @@ export default class LearnerGroupBulkAssignmentComponent extends Component { parent: learnerGroup, }); const savedGroup = await group.save(); - const children = (await learnerGroup.children).slice(); + const children = await learnerGroup.children; learnerGroup.set('children', [...children, savedGroup]); this.matchedGroups = [...this.matchedGroups, { name: title, group: savedGroup }]; } diff --git a/packages/frontend/app/components/learner-group/calendar.js b/packages/frontend/app/components/learner-group/calendar.js index 9299b11d4c..7363176c0d 100644 --- a/packages/frontend/app/components/learner-group/calendar.js +++ b/packages/frontend/app/components/learner-group/calendar.js @@ -47,7 +47,7 @@ export default class LearnerGroupCalendarComponent extends Component { } const offerings = await all(mapBy(learnerGroups, 'offerings')); const flat = offerings.reduce((flattened, obj) => { - return [...flattened, ...obj.slice()]; + return [...flattened, ...obj]; }, []); return await map(flat, async (offering) => { const session = await offering.session; diff --git a/packages/frontend/app/components/learner-group/instructor-manager.js b/packages/frontend/app/components/learner-group/instructor-manager.js index ec3ca52a78..bb76207508 100644 --- a/packages/frontend/app/components/learner-group/instructor-manager.js +++ b/packages/frontend/app/components/learner-group/instructor-manager.js @@ -20,9 +20,9 @@ export default class LearnerGroupInstructorManagerComponent extends Component { const school = await program.get('school'); const availableInstructorGroups = await school.get('instructorGroups'); - this.instructors = instructors.slice(); - this.instructorGroups = instructorGroups.slice(); - this.availableInstructorGroups = availableInstructorGroups.slice(); + this.instructors = instructors; + this.instructorGroups = instructorGroups; + this.availableInstructorGroups = availableInstructorGroups; } }); diff --git a/packages/frontend/app/components/learner-group/list-item.js b/packages/frontend/app/components/learner-group/list-item.js index dc66935a99..888bea2e08 100644 --- a/packages/frontend/app/components/learner-group/list-item.js +++ b/packages/frontend/app/components/learner-group/list-item.js @@ -63,15 +63,15 @@ export default class LearnerGroupListItemComponent extends Component { } async isLinkedToOfferingsOrIlms(learnerGroup) { - const offerings = (await learnerGroup.offerings).slice(); + const offerings = await learnerGroup.offerings; if (offerings.length) { return true; } - const ilms = (await learnerGroup.ilmSessions).slice(); + const ilms = await learnerGroup.ilmSessions; if (ilms.length) { return true; } - const children = (await learnerGroup.children).slice(); + const children = await learnerGroup.children; const linkedChildren = await filter(children, async (child) => { return this.isLinkedToOfferingsOrIlms(child); }); diff --git a/packages/frontend/app/components/learner-group/root.js b/packages/frontend/app/components/learner-group/root.js index 971886ad09..28d2948dc3 100644 --- a/packages/frontend/app/components/learner-group/root.js +++ b/packages/frontend/app/components/learner-group/root.js @@ -52,7 +52,7 @@ export default class LearnerGroupRootComponent extends Component { if (!this.subGroups) { return []; } - return this.subGroups.slice(); + return this.subGroups; } get bestUrl() { @@ -185,8 +185,8 @@ export default class LearnerGroupRootComponent extends Component { @action saveInstructors(newInstructors, newInstructorGroups) { - this.args.learnerGroup.set('instructors', newInstructors.slice()); - this.args.learnerGroup.set('instructorGroups', newInstructorGroups.slice()); + this.args.learnerGroup.set('instructors', newInstructors); + this.args.learnerGroup.set('instructorGroups', newInstructorGroups); return this.args.learnerGroup.save(); } @@ -251,7 +251,7 @@ export default class LearnerGroupRootComponent extends Component { } else { users = await this.args.learnerGroup.getUsersOnlyAtThisLevel(); } - return await map(users.slice(), async (user) => { + return await map(users, async (user) => { const lowestGroupInTree = await user.getLowestMemberGroupInALearnerGroupTree(this.treeGroups); return ObjectProxy.create({ content: user, @@ -298,8 +298,8 @@ export default class LearnerGroupRootComponent extends Component { }); async getCoursesForGroupWithSubgroupName(prefix, learnerGroup) { - const offerings = (await learnerGroup.offerings).slice(); - const ilms = (await learnerGroup.ilmSessions).slice(); + const offerings = await learnerGroup.offerings; + const ilms = await learnerGroup.ilmSessions; const arr = [].concat(offerings, ilms); const sessions = await Promise.all(mapBy(arr, 'session')); const filteredSessions = uniqueValues(sessions.filter(Boolean)); @@ -316,7 +316,7 @@ export default class LearnerGroupRootComponent extends Component { } return obj; }); - const children = (await learnerGroup.children).slice(); + const children = await learnerGroup.children; const childCourses = await map(children, async (child) => { return await this.getCoursesForGroupWithSubgroupName(learnerGroup.title, child); }); diff --git a/packages/frontend/app/components/learner-group/upload-data.js b/packages/frontend/app/components/learner-group/upload-data.js index 8053b11a72..ea6993b4c3 100644 --- a/packages/frontend/app/components/learner-group/upload-data.js +++ b/packages/frontend/app/components/learner-group/upload-data.js @@ -116,9 +116,9 @@ export default class LearnerGroupUploadDataComponent extends Component { } else if (users.length > 1) { errors.push(this.intl.t('general.multipleUsersFoundWithCampusId', { campusId })); } else { - const user = users.slice()[0]; + const user = users[0]; const cohorts = await user.cohorts; - const cohortIds = mapBy(cohorts.slice(), 'id'); + const cohortIds = mapBy(cohorts, 'id'); if (!cohortIds.includes(cohort.id)) { errors.push( this.intl.t('general.userNotInGroupCohort', { cohortTitle: cohort.get('title') }), diff --git a/packages/frontend/app/components/learner-groups/root.js b/packages/frontend/app/components/learner-groups/root.js index ae3cc4b73f..75cbdf0271 100644 --- a/packages/frontend/app/components/learner-groups/root.js +++ b/packages/frontend/app/components/learner-groups/root.js @@ -110,7 +110,7 @@ export default class LearnerGroupsRootComponent extends Component { get selectedSchool() { const schoolId = this.args.schoolId ?? this.user?.belongsTo('school').id(); - const school = findById(this.args.schools.slice(), schoolId) ?? this.args.schools.slice()[0]; + const school = findById(this.args.schools, schoolId) ?? this.args.schools[0]; //trigger a pre-load of the data we need to load an individual group in this school this.dataLoader.loadInstructorGroupsForSchool(school.id); return school; @@ -121,7 +121,7 @@ export default class LearnerGroupsRootComponent extends Component { return null; } if (this.args.programId) { - return findById(this.programs.slice(), this.args.programId); + return findById(this.programs, this.args.programId); } return this.defaultSelectedProgram; @@ -132,10 +132,10 @@ export default class LearnerGroupsRootComponent extends Component { return null; } if (this.args.programYearId) { - return findById(this.programYears.slice(), this.args.programYearId); + return findById(this.programYears, this.args.programYearId); } - return sortBy(this.programYears.slice(), 'startYear').reverse()[0]; + return sortBy(this.programYears, 'startYear').reverse()[0]; } get rootLevelLearnerGroups() { @@ -147,7 +147,7 @@ export default class LearnerGroupsRootComponent extends Component { get filteredLearnerGroups() { if (!this.args.titleFilter) { - return this.rootLevelLearnerGroups.slice(); + return this.rootLevelLearnerGroups; } const filter = this.args.titleFilter.trim().toLowerCase(); return this.rootLevelLearnerGroups.filter((learnerGroup) => { @@ -161,7 +161,7 @@ export default class LearnerGroupsRootComponent extends Component { cohort: this.selectedCohort, }); if (fillWithCohort) { - const users = (await this.selectedCohort.users).slice(); + const users = await this.selectedCohort.users; group.set('users', users); } this.savedLearnerGroup = await group.save(); @@ -188,9 +188,9 @@ export default class LearnerGroupsRootComponent extends Component { if (!programs) { return null; } - const sortingPrograms = await map(programs.slice(), async (program) => { + const sortingPrograms = await map(programs, async (program) => { const thisYear = new Date().getFullYear(); - const programYears = (await program.programYears).slice(); + const programYears = await program.programYears; const sorters = await map(programYears, async (programYear) => { const groupCount = (await programYear.cohort).hasMany('learnerGroups').ids().length; return { @@ -236,7 +236,7 @@ export default class LearnerGroupsRootComponent extends Component { } setProgramId = dropTask(async (programId) => { - const program = findById(this.programs.slice(), programId); + const program = findById(this.programs, programId); const school = await program.school; this.args.setSchoolId(school.id); this.args.setProgramId(program.id); @@ -244,7 +244,7 @@ export default class LearnerGroupsRootComponent extends Component { }); setProgramYearId = dropTask(async (programYearId) => { - const programYear = findById(this.programYears.slice(), programYearId); + const programYear = findById(this.programYears, programYearId); const program = await programYear.program; const school = await program.school; this.args.setSchoolId(school.id); diff --git a/packages/frontend/app/components/program-year/competencies.js b/packages/frontend/app/components/program-year/competencies.js index c898eb3fb7..92cf8f856f 100644 --- a/packages/frontend/app/components/program-year/competencies.js +++ b/packages/frontend/app/components/program-year/competencies.js @@ -66,14 +66,14 @@ export default class ProgramYearCompetenciesComponent extends Component { const program = await programYear.program; const school = await program.school; const competencies = await school.competencies; - const domains = await map(competencies.slice(), async (c) => c.getDomain()); + const domains = await map(competencies, async (c) => c.getDomain()); const programYearCompetencies = await programYear.competencies; return { program, school, competencies, domains, programYearCompetencies }; } async getCompetenciesWithSelectedChildren(selectedCompetencies, competencies) { - return await filter(competencies.slice(), async (competency) => { + return await filter(competencies, async (competency) => { const children = await competency.children; const selectedChildren = children.filter((c) => selectedCompetencies.includes(c)); return selectedChildren.length > 0; diff --git a/packages/frontend/app/components/program-year/list.js b/packages/frontend/app/components/program-year/list.js index 88e03d7fbf..bd5cc9400a 100644 --- a/packages/frontend/app/components/program-year/list.js +++ b/packages/frontend/app/components/program-year/list.js @@ -26,7 +26,7 @@ export default class ProgramYearListComponent extends Component { } get sortedProgramYears() { - return sortBy(this.programYears.slice(), 'startYear'); + return sortBy(this.programYears, 'startYear'); } @cached @@ -42,9 +42,9 @@ export default class ProgramYearListComponent extends Component { }); if (latestProgramYear) { - const directors = (await latestProgramYear.directors).slice(); - const competencies = (await latestProgramYear.competencies).slice(); - const terms = (await latestProgramYear.terms).slice(); + const directors = await latestProgramYear.directors; + const competencies = await latestProgramYear.competencies; + const terms = await latestProgramYear.terms; newProgramYear.set('directors', directors); newProgramYear.set('competencies', competencies); newProgramYear.set('terms', terms); @@ -52,7 +52,7 @@ export default class ProgramYearListComponent extends Component { const savedProgramYear = await newProgramYear.save(); if (latestProgramYear) { const relatedObjectives = await latestProgramYear.programYearObjectives; - const programYearObjectives = sortBy(relatedObjectives.slice(), 'id'); + const programYearObjectives = sortBy(relatedObjectives, 'id'); const newObjectiveObjects = programYearObjectives.map((pyoToCopy) => { const terms = pyoToCopy diff --git a/packages/frontend/app/components/program-year/managed-competency-list-item.js b/packages/frontend/app/components/program-year/managed-competency-list-item.js index cc655687c7..48de2a8d3a 100644 --- a/packages/frontend/app/components/program-year/managed-competency-list-item.js +++ b/packages/frontend/app/components/program-year/managed-competency-list-item.js @@ -14,12 +14,12 @@ export default class ProgramYearManagedCompetencyListItemComponent extends Compo } addCompetencyToBuffer = task(async (competency) => { - const children = (await competency.children).slice(); + const children = await competency.children; this.args.addCompetencyToBuffer(competency, children); }); removeCompetencyFromBuffer = task(async (competency) => { - const children = (await competency.children).slice(); + const children = await competency.children; this.args.removeCompetencyFromBuffer(competency, children); }); } diff --git a/packages/frontend/app/components/program-year/new.js b/packages/frontend/app/components/program-year/new.js index ad42a5cf22..4e39bc37b3 100644 --- a/packages/frontend/app/components/program-year/new.js +++ b/packages/frontend/app/components/program-year/new.js @@ -8,7 +8,7 @@ export default class NewProgramYearComponent extends Component { @tracked year; get existingStartYears() { - return mapBy(this.args.programYears?.slice() ?? [], 'startYear').map(Number); + return mapBy(this.args.programYears ?? [], 'startYear').map(Number); } get selectedYear() { diff --git a/packages/frontend/app/components/program-year/objective-list-item-expanded.js b/packages/frontend/app/components/program-year/objective-list-item-expanded.js index 0066459b61..33912f5d97 100644 --- a/packages/frontend/app/components/program-year/objective-list-item-expanded.js +++ b/packages/frontend/app/components/program-year/objective-list-item-expanded.js @@ -12,7 +12,7 @@ export default class ProgramYearObjectiveListItemExpandedComponent extends Compo if (!programYearObjective) { return; } - const courseObjectives = (await programYearObjective.courseObjectives).slice(); + const courseObjectives = await programYearObjective.courseObjectives; const objectiveObjects = await map(courseObjectives, async (courseObjective) => { const course = await courseObjective.course; return { diff --git a/packages/frontend/app/components/program-year/objective-list-item.js b/packages/frontend/app/components/program-year/objective-list-item.js index de2ddb7194..94e477441a 100644 --- a/packages/frontend/app/components/program-year/objective-list-item.js +++ b/packages/frontend/app/components/program-year/objective-list-item.js @@ -56,7 +56,7 @@ export default class ProgramYearObjectiveListItemComponent extends Component { } get assignableVocabularies() { - return this.vocabularies?.slice() ?? []; + return this.vocabularies ?? []; } get isManaging() { @@ -107,14 +107,14 @@ export default class ProgramYearObjectiveListItemComponent extends Component { manageDescriptors = dropTask(async () => { const meshDescriptors = await this.args.programYearObjective.meshDescriptors; - this.descriptorsBuffer = meshDescriptors.slice(); + this.descriptorsBuffer = meshDescriptors; this.isManagingDescriptors = true; }); manageTerms = dropTask(async (vocabulary) => { this.selectedVocabulary = vocabulary; const terms = await this.args.programYearObjective.terms; - this.termsBuffer = terms.slice(); + this.termsBuffer = terms; this.isManagingTerms = true; }); @@ -158,7 +158,7 @@ export default class ProgramYearObjectiveListItemComponent extends Component { } @action setCompetencyBuffer(competencyId) { - this.competencyBuffer = findById(this.args.programYearCompetencies.slice(), competencyId); + this.competencyBuffer = findById(this.args.programYearCompetencies, competencyId); } @action addDescriptorToBuffer(descriptor) { diff --git a/packages/frontend/app/components/program-year/objective-list.js b/packages/frontend/app/components/program-year/objective-list.js index dd7605ad3f..543be8e856 100644 --- a/packages/frontend/app/components/program-year/objective-list.js +++ b/packages/frontend/app/components/program-year/objective-list.js @@ -50,7 +50,7 @@ export default class ProgramYearObjectiveListComponent extends Component { } async getDomainTrees(programYearCompetencies) { - const domains = programYearCompetencies.slice().filter((competency) => { + const domains = programYearCompetencies.filter((competency) => { return !competency.belongsTo('parent').id(); }); const parents = await Promise.all(mapBy(programYearCompetencies, 'parent')); diff --git a/packages/frontend/app/components/program-year/objectives.js b/packages/frontend/app/components/program-year/objectives.js index 5d9432a1fa..3c5fccda1f 100644 --- a/packages/frontend/app/components/program-year/objectives.js +++ b/packages/frontend/app/components/program-year/objectives.js @@ -29,7 +29,7 @@ export default class ProgramYearObjectivesComponent extends Component { saveNewObjective = dropTask(async (title) => { const programYearObjectives = await this.args.programYear.programYearObjectives; const position = programYearObjectives.length - ? sortBy(programYearObjectives.slice(), 'position').reverse()[0].position + 1 + ? sortBy(programYearObjectives, 'position').reverse()[0].position + 1 : 0; const newProgramYearObjective = this.store.createRecord('program-year-objective'); diff --git a/packages/frontend/app/components/reports/new-subject.js b/packages/frontend/app/components/reports/new-subject.js index c1c7ba5e8c..706bcb6be8 100644 --- a/packages/frontend/app/components/reports/new-subject.js +++ b/packages/frontend/app/components/reports/new-subject.js @@ -334,7 +334,7 @@ export default class ReportsNewSubjectComponent extends Component { @action changeSchool(schoolId) { - this.selectedSchool = findById(this.allSchools.slice(), schoolId); + this.selectedSchool = findById(this.allSchools, schoolId); this.schoolChanged = true; } diff --git a/packages/frontend/app/components/school/visualizer-session-type-vocabularies.js b/packages/frontend/app/components/school/visualizer-session-type-vocabularies.js index 462c174fc5..c14b1257b8 100644 --- a/packages/frontend/app/components/school/visualizer-session-type-vocabularies.js +++ b/packages/frontend/app/components/school/visualizer-session-type-vocabularies.js @@ -33,7 +33,7 @@ export default class SchoolVisualizerSessionTypeVocabulariesComponent extends Co } const sessionsWithTerms = await map(sessions, async (session) => { - const terms = (await session.terms).slice(); + const terms = await session.terms; return terms.map((term) => { return { session, term }; }); diff --git a/packages/frontend/app/components/school/visualizer-session-type-vocabulary.js b/packages/frontend/app/components/school/visualizer-session-type-vocabulary.js index b6d8b2ca9b..88d2f6d6dd 100644 --- a/packages/frontend/app/components/school/visualizer-session-type-vocabulary.js +++ b/packages/frontend/app/components/school/visualizer-session-type-vocabulary.js @@ -31,7 +31,7 @@ export default class SchoolVisualizerSessionTypeVocabularyComponent extends Comp } const termsWithSession = await map(sessions, async (session) => { - const sessionTerms = (await session.terms).slice(); + const sessionTerms = await session.terms; const terms = await filter(sessionTerms, async (term) => { const termVocab = await term.vocabulary; diff --git a/packages/frontend/tests/integration/components/program-year/list-test.js b/packages/frontend/tests/integration/components/program-year/list-test.js index 0bd9897cb5..c80ee6a815 100644 --- a/packages/frontend/tests/integration/components/program-year/list-test.js +++ b/packages/frontend/tests/integration/components/program-year/list-test.js @@ -96,29 +96,29 @@ module('Integration | Component | program-year/list', function (hooks) { await component.newProgramYear.years.select(thisYear); await component.newProgramYear.done.click(); const programYears = await this.owner.lookup('service:store').findAll('program-year'); - const sortedProgramYears = sortBy(programYears.slice(), 'id'); + const sortedProgramYears = sortBy(programYears, 'id'); const newProgramYear = sortedProgramYears.slice().reverse()[0]; const originalProgramYear = sortedProgramYears[sortedProgramYears.length - 2]; assert.strictEqual(parseInt(newProgramYear.startYear, 10), thisYear); - const terms = (await newProgramYear.terms).slice(); - const originalTerms = (await originalProgramYear.terms).slice(); + const terms = await newProgramYear.terms; + const originalTerms = await originalProgramYear.terms; assert.strictEqual(terms.length, 4); assert.strictEqual(terms[0], originalTerms[0]); assert.strictEqual(terms[1], originalTerms[1]); assert.strictEqual(terms[2], originalTerms[2]); assert.strictEqual(terms[3], originalTerms[3]); - const competencies = (await newProgramYear.competencies).slice(); - const originalCompetencies = (await originalProgramYear.competencies).slice(); + const competencies = await newProgramYear.competencies; + const originalCompetencies = await originalProgramYear.competencies; assert.strictEqual(competencies.length, 2); assert.strictEqual(competencies[0], originalCompetencies[0]); assert.strictEqual(competencies[1], originalCompetencies[1]); - const directors = (await newProgramYear.directors).slice(); - const originalDirectors = (await originalProgramYear.directors).slice(); + const directors = await newProgramYear.directors; + const originalDirectors = await originalProgramYear.directors; assert.strictEqual(directors.length, 2); assert.strictEqual(directors[0], originalDirectors[0]); assert.strictEqual(directors[1], originalDirectors[1]); - const objectives = (await newProgramYear.programYearObjectives).slice(); - const originalObjectives = (await originalProgramYear.programYearObjectives).slice(); + const objectives = await newProgramYear.programYearObjectives; + const originalObjectives = await originalProgramYear.programYearObjectives; assert.strictEqual(objectives.length, 3); assert.strictEqual(objectives[0].description, originalObjectives[0].description); assert.strictEqual(objectives[1].description, originalObjectives[1].description); @@ -130,14 +130,14 @@ module('Integration | Component | program-year/list', function (hooks) { assert.strictEqual(ancestorObjective1, originalObjectives[0]); assert.strictEqual(ancestorObjective2, originalObjectives[1]); assert.strictEqual(ancestorObjective3, originalObjectivesAncestor); - const objectiveMeshDescriptors = (await objectives[0].meshDescriptors).slice(); - const originalObjectiveMeshDescriptors = (await originalObjectives[0].meshDescriptors).slice(); + const objectiveMeshDescriptors = await objectives[0].meshDescriptors; + const originalObjectiveMeshDescriptors = await originalObjectives[0].meshDescriptors; assert.strictEqual(objectiveMeshDescriptors.length, 3); assert.strictEqual(objectiveMeshDescriptors[0], originalObjectiveMeshDescriptors[0]); assert.strictEqual(objectiveMeshDescriptors[1], originalObjectiveMeshDescriptors[1]); assert.strictEqual(objectiveMeshDescriptors[2], originalObjectiveMeshDescriptors[2]); - const objectiveTerms = (await objectives[0].terms).slice(); - const originalObjectiveTerms = (await originalObjectives[0].terms).slice(); + const objectiveTerms = await objectives[0].terms; + const originalObjectiveTerms = await originalObjectives[0].terms; assert.strictEqual(objectiveTerms.length, 4); assert.strictEqual(objectiveTerms[0], originalObjectiveTerms[0]); assert.strictEqual(objectiveTerms[1], originalObjectiveTerms[1]); diff --git a/packages/frontend/tests/integration/components/school-list-test.js b/packages/frontend/tests/integration/components/school-list-test.js index 25274aac9c..5dcc8d3c38 100644 --- a/packages/frontend/tests/integration/components/school-list-test.js +++ b/packages/frontend/tests/integration/components/school-list-test.js @@ -80,7 +80,7 @@ module('Integration | Component | school list', function (hooks) { await component.newSchoolForm.submit(); assert.ok(component.savedSchool.isVisible); assert.strictEqual(component.savedSchool.text, 'school of rocket surgery Saved Successfully'); - schools = (await this.owner.lookup('service:store').findAll('school')).slice(); + schools = await this.owner.lookup('service:store').findAll('school'); assert.strictEqual(schools.length, 3); assert.strictEqual(schools[2].title, 'school of rocket surgery'); assert.strictEqual(schools[2].iliosAdministratorEmail, 'rocketsurgeongeneral@hoekacademy.edu');