From 0ae45e3793839bc73da654c6d7820a4a4390e15d Mon Sep 17 00:00:00 2001 From: Geoffrey Kwan Date: Wed, 14 Feb 2024 11:45:15 -0500 Subject: [PATCH] feat(Authoring): Click lesson bar to expand and collapse steps (#1629) --- .../project-authoring-lesson.component.html | 62 +++++++++---------- .../project-authoring-lesson.component.scss | 32 +++++++++- ...project-authoring-lesson.component.spec.ts | 8 +-- .../project-authoring-lesson.harness.ts | 13 ++-- src/messages.xlf | 17 ++--- 5 files changed, 74 insertions(+), 58 deletions(-) diff --git a/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.html b/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.html index fcf696a1fdb..0d7716f09d3 100644 --- a/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.html +++ b/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.html @@ -1,4 +1,4 @@ -
+
-
-
- -
-
- +
+ +
+
+
+
+ expand_more +
+
+ expand_less +
+
@@ -56,5 +53,8 @@ [projectId]="projectId" > +
+ This lesson has no steps +
diff --git a/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.scss b/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.scss index 777531dc697..64dd9d178fb 100644 --- a/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.scss +++ b/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.scss @@ -6,8 +6,18 @@ position: relative; } -.lesson-bar:hover { - background-color: #add8e6; +.lesson:hover { + &.lesson-collapsed { + background-color: #add8e6; + } +} + +.lesson:hover .edit-lesson-button { + display: block; +} + +.lesson-bar { + height: 40px; } .full-width { @@ -17,3 +27,21 @@ .pointer { cursor: pointer; } + +.edit-lesson-button { + display: none; + + &.lesson-expanded { + display: block; + } +} + +.expand-collapse-icon { + width: 40px; + margin-right: 10px; +} + +.no-steps-message { + height: 40px; + margin-left: 40px; +} diff --git a/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.spec.ts b/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.spec.ts index 1195f2a30a7..e36d42e3034 100644 --- a/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.spec.ts +++ b/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.spec.ts @@ -79,10 +79,10 @@ describe('ProjectAuthoringLessonComponent', () => { function lessonIsExpanded_clickCollapseButton_hideSteps() { describe('lesson is expanded', () => { - describe('collapse button is clicked', () => { + describe('lesson div is clicked', () => { it('hides steps', async () => { component.expanded = true; - await (await harness.getCollapseButton()).click(); + (await harness.getToggleDiv()).click(); expect(component.expanded).toBeFalse(); const steps = await harness.getSteps(); expect(steps.length).toEqual(0); @@ -93,10 +93,10 @@ function lessonIsExpanded_clickCollapseButton_hideSteps() { function lessonIsCollapsed_clickExpandButton_showSteps() { describe('lesson is collapsed', () => { - describe('expand button is clicked', () => { + describe('lesson div is clicked', () => { it('shows steps', async () => { component.expanded = false; - await (await harness.getExpandButton()).click(); + (await harness.getToggleDiv()).click(); expect(component.expanded).toBeTrue(); const steps = await harness.getSteps(); expect(steps.length).toEqual(2); diff --git a/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.harness.ts b/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.harness.ts index 257b48b16da..c4661f6c611 100644 --- a/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.harness.ts +++ b/src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.harness.ts @@ -1,22 +1,17 @@ import { ComponentHarness } from '@angular/cdk/testing'; -import { MatButtonHarness } from '@angular/material/button/testing'; import { ProjectAuthoringStepHarness } from '../project-authoring-step/project-authoring-step.harness'; export class ProjectAuthoringLessonHarness extends ComponentHarness { static hostSelector = 'project-authoring-lesson'; - getExpandButton = this.locatorForOptional( - MatButtonHarness.with({ selector: '[matTooltip="Click to expand"]' }) - ); - getCollapseButton = this.locatorForOptional( - MatButtonHarness.with({ selector: '[matTooltip="Click to collapse"]' }) - ); + getExpandCollapseIcon = this.locatorFor('.expand-collapse-icon .mat-icon'); getSteps = this.locatorForAll(ProjectAuthoringStepHarness); + getToggleDiv = this.locatorFor('.toggle-div'); async isExpanded(): Promise { - return (await this.getExpandButton()) == null; + return (await (await this.getExpandCollapseIcon()).text()) === 'expand_less'; } async isCollapsed(): Promise { - return (await this.getCollapseButton()) == null; + return (await (await this.getExpandCollapseIcon()).text()) === 'expand_more'; } } diff --git a/src/messages.xlf b/src/messages.xlf index 7d66c65c4fb..af4938987ee 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -12190,27 +12190,20 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.7 - - Click to enter lesson + + Click to expand/collapse lesson src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.html - 15 + 17 - - Click to expand + + Edit lesson src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.html 30 - - Click to collapse - - src/assets/wise5/authoringTool/project-authoring-lesson/project-authoring-lesson.component.html - 41 - - Select step