Skip to content

Commit

Permalink
fix: Improved animation for roll call and enabled swipe to skipp part…
Browse files Browse the repository at this point in the history
…icipants (#1253)

Co-authored-by: Simon <33730997+TheSlimvReal@users.noreply.github.com>
Co-authored-by: Simon <therealslimv@yahoo.de>
  • Loading branch information
3 people authored May 22, 2022
1 parent fe46ab4 commit ec324bf
Show file tree
Hide file tree
Showing 17 changed files with 326 additions and 121 deletions.
11 changes: 4 additions & 7 deletions e2e/integration/LinkingChildToSchool.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
describe("Scenario: Linking a child to a school - E2E test", () => {
before(() => {
// GIVEN I am on the details page of a child
describe("Scenario: Linking a child to a school - E2E test", function () {
before("GIVEN I am on the details page of a child", function () {
cy.visit("");
cy.create("Children", "E2E Child");
cy.create("Schools", "E2E School");
cy.get("[ng-reflect-angulartics-label=Children]").click();
});

// WHEN I add an entry in the 'Previous Schools' section with a specific school
it("Add an entry in the Previous School section", function () {
it("WHEN I add an entry in the 'Previous Schools' section with a specific school", function () {
// type to the input "Filter" the name of child
cy.get('[data-placeholder="e.g. name, age"]').type("E2E Child");

Expand Down Expand Up @@ -36,8 +34,7 @@ describe("Scenario: Linking a child to a school - E2E test", () => {
cy.wait(100);
});

// THEN I can see that child in the 'Children Overview' of the details page of this school
it("Check for child in Children Overview of specific school", function () {
it("THEN I can see that child in the 'Children Overview' of the details page of this school", function () {
// Click on the school that was added to the child profile
cy.contains("span", "E2E School").click();
// Open the students overview
Expand Down
14 changes: 5 additions & 9 deletions e2e/integration/MarkingChildAsDropout.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
describe("Scenario: Marking a child as dropout - E2E test", () => {
before(() => {
// GIVEN I am on the details page of a specific child
describe("Scenario: Marking a child as dropout - E2E test", function () {
before("GIVEN I am on the details page of a specific child", function () {
// go to the url with the Child
cy.visit("child/1");
// save the name of this Child to the variable
cy.get(".header-row > .header-title").invoke("text").as("childName");
});

// WHEN I select a dropout date for this child
it("Select a dropout date for the child", function () {
it("WHEN I select a dropout date for this child", () => {
// click on "Dropout" menu
cy.contains("Dropout").click();
cy.get("#mat-tab-label-0-7").click();
Expand All @@ -21,8 +19,7 @@ describe("Scenario: Marking a child as dropout - E2E test", () => {
cy.contains("span", "Save").should("be.visible").click();
});

// THEN I should not see this child in the list of all children at first
it("This child is not in the list of all children at first", function () {
it("THEN I should not see this child in the list of all children at first", function () {
// click on "Children" menu in navigation
cy.get('[ng-reflect-angulartics-label="Children"]').click();
// type to the input "Filter" the name of child
Expand All @@ -31,8 +28,7 @@ describe("Scenario: Marking a child as dropout - E2E test", () => {
cy.get("table").contains(this.childName.trim()).should("not.exist");
});

// AND I should see the child when I activate the 'inactive' filter
it("The child is seen when the 'inactive' filter activated", function () {
it("AND I should see the child when I activate the 'inactive' filter", function () {
// click on the button with the content "Inactive"
cy.get('[ng-reflect-placeholder="isActive"]').click();
cy.contains("span", "Inactive").should("be.visible").click();
Expand Down
32 changes: 14 additions & 18 deletions e2e/integration/RecordingAttendanceOfChild.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,33 @@
describe("Scenario: Recording attendance of a child - E2E test", () => {
before(() => {
// GIVEN A specific child is attending a specific class
describe("Scenario: Recording attendance of a child - E2E test", function () {
before("GIVEN A specific child is attending a specific class", function () {
cy.visit("attendance");
});

// WHEN I record attendance for this class
it("Record attendance for the class", function () {
it("WHEN I record attendance for this class", () => {
cy.get(".mat-card", { timeout: 10000 }).should("be.visible").eq(0).click();
cy.contains("button", "Record").click();
});

// AND I set the attendance of the specific child to 'present'
it("set the attendance of the specific child to 'present'", function () {
it("AND I set the attendance of the specific child to 'present'", function () {
cy.contains("button", "Show more").click({ scrollBehavior: "center" });
cy.contains("mat-card", "School Class")
.eq(0)
.click({ scrollBehavior: "center" });
cy.get(".options-wrapper > :nth-child(1)").click();
cy.get(".mat-body-1").invoke("text").as("childName");
cy.get(".group-select-option").contains("Present").click();
cy.get('[fxflex=""] > .ng-star-inserted > .mat-focus-indicator').click();
cy.contains("button", "Save").click();
});

// THEN in the details page of this child under 'attendance' for the specific class I should see a green background for the current day
it("In the details page of this child under 'attendance' for the specific class should be a green background for the current day", function () {
cy.get(".mat-card", { timeout: 10000 })
.should("be.visible")
.eq(0)
.click({ force: true });
// Click on ChildBlock inside roll-call to navigate to child
cy.get(".navigation-bar > :nth-child(1)").click();
cy.get(".child-block").click();
it("THEN in the details page of this child under 'attendance' for the specific class I should see a green background for the current day", function () {
cy.get("#mat-input-2")
.focus()
.type(this.childName)
.wait(500)
.type("{downArrow}")
.type("{enter}");
cy.get("#mat-tab-label-0-2").click();
cy.get(".attendance-P").should(
cy.get(".mat-calendar-body-active").should(
"have.css",
"background-color",
"rgb(200, 230, 201)"
Expand Down
27 changes: 27 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"deep-object-diff": "^1.1.7",
"faker": "^5.5.3",
"flag-icon-css": "^3.5.0",
"hammerjs": "^2.0.8",
"json-query": "^2.2.2",
"lodash": "^4.17.21",
"md5": "^2.3.0",
Expand Down Expand Up @@ -80,6 +81,7 @@
"@types/crypto-js": "^4.0.2",
"@types/faker": "^5.5.7",
"@types/file-saver": "^2.0.3",
"@types/hammerjs": "^2.0.41",
"@types/jasmine": "~3.8.2",
"@types/lodash": "^4.14.168",
"@types/node": "^14.14.31",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<h2 *ngIf="currentStage === 0">
{{ stages[currentStage] }}
</h2>
<div fxLayout="row" *ngIf="currentStage !== 0">
<button mat-icon-button style="margin-top: -4px" (click)="exit()">
<div class="subject-line" *ngIf="currentStage !== 0">
<button mat-icon-button (click)="exit()">
<fa-icon icon="arrow-left"></fa-icon>
</button>
<h2>{{event.subject}}</h2>
<h2 class="remove-margin-bottom">{{event.subject}}</h2>
</div>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,13 @@
.flex-fill-section {
min-height: 0;
}

.subject-line {
display: flex;
flex-direction: row;
align-items: center;

// correctly left-aligns the items with the other content
position: relative;
left: -13px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div [@translateTab]="{
value: _position,
params: {animationDuration: '800ms'}
}"
style="width: 100%"
>
<ng-content></ng-content>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { ComponentFixture, TestBed } from "@angular/core/testing";

import { RollCallTabComponent } from "./roll-call-tab.component";
import { NoopAnimationsModule } from "@angular/platform-browser/animations";

describe("RollCallTabComponent", () => {
let component: RollCallTabComponent;
let fixture: ComponentFixture<RollCallTabComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [RollCallTabComponent],
imports: [NoopAnimationsModule],
}).compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(RollCallTabComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it("should create", () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { Component, Input } from "@angular/core";
import {
animate,
state,
style,
transition,
trigger,
} from "@angular/animations";

/**
* These position states are used internally as animation states for the tab body. Setting the
* position state to left, right, or center will transition the tab body from its current
* position to its respective state. If there is no current position (void, in the case of a new
* tab body), then there will be no transition animation to its state.
*
* In the case of a new tab body that should immediately be centered with an animating transition,
* then left-origin-center or right-origin-center can be used, which will use left or right as its
* pseudo-prior state.
*/
type PositionState = "left" | "center" | "right";

@Component({
selector: "app-roll-call-tab",
templateUrl: "./roll-call-tab.component.html",
animations: [
trigger("translateTab", [
// Transitions to `none` instead of 0, because some browsers might blur the content.
state("center, void", style({ transform: "none" })),

// If the tab is either on the left or right, we additionally add a `min-height` of 1px
// in order to ensure that the element has a height before its state changes. This is
// necessary because Chrome does seem to skip the transition in RTL mode if the element does
// not have a static height and is not rendered. See related issue: #9465
state(
"left",
style({
transform: "translate(-110%)",
minHeight: "1px",
visibility: "hidden",
})
),
state(
"right",
style({
transform: "translate(110%)",
minHeight: "1px",
visibility: "hidden",
})
),

transition("void => *", []),
transition(
"* => left, * => right, left => center, right => center",
animate("{{animationDuration}} cubic-bezier(0.35, 0, 0.25, 1)")
),
]),
],
})
export class RollCallTabComponent {
/** Current position of the tab-body in the tab-group. Zero means that the tab is visible. */
private _positionIndex: number;

/** Tab body position state. Used by the animation trigger for the current state. */
_position: PositionState;

@Input()
set position(position: number) {
this._positionIndex = position;
this._computePositionAnimationState();
}

/** Computes the position state that will be used for the tab-body animation trigger. */
private _computePositionAnimationState() {
if (this._positionIndex < 0) {
this._position = "left";
} else if (this._positionIndex > 0) {
this._position = "right";
} else {
this._position = "center";
}
}
}
Loading

0 comments on commit ec324bf

Please sign in to comment.