From 2336cd203260e014a61e75dbf75e467c20fed7aa Mon Sep 17 00:00:00 2001 From: BenjaVR Date: Mon, 18 Feb 2019 17:25:42 +0100 Subject: [PATCH] WIP plannings detail for student --- src/components/students/StudentsTable.tsx | 87 ++++++++++++++++++----- 1 file changed, 70 insertions(+), 17 deletions(-) diff --git a/src/components/students/StudentsTable.tsx b/src/components/students/StudentsTable.tsx index 4928bd9..44445df 100644 --- a/src/components/students/StudentsTable.tsx +++ b/src/components/students/StudentsTable.tsx @@ -1,4 +1,4 @@ -import { Button, Col, Popconfirm, Row, Spin, Table, Tooltip } from "antd"; +import { Button, Col, Popconfirm, Row, Spin, Table, Tooltip, Modal } from "antd"; import { ColumnFilterItem, ColumnProps } from "antd/lib/table"; import React from "react"; import { emptyFilterOptionValue, exactMatchOrDefaultOptionFilter, hasElementWithId } from "../../helpers/filters"; @@ -20,31 +20,56 @@ interface IStudentsTableProps { onEditStudentRequest: (student: Student) => void; } -class StudentsTable extends React.Component { +interface IStudentTableState { + isPlanningDetailsOpen: boolean; + selectedStudentPlanningDetails: Student | undefined; +} + +class StudentsTable extends React.Component { constructor(props: IStudentsTableProps) { super(props); + this.state = { + isPlanningDetailsOpen: false, + selectedStudentPlanningDetails: undefined, + }; + this.renderSchoolName = this.renderSchoolName.bind(this); this.renderActions = this.renderActions.bind(this); this.renderTableTitle = this.renderTableTitle.bind(this); + this.renderPlannedCell = this.renderPlannedCell.bind(this); + this.handleClosePlanningDetails = this.handleClosePlanningDetails.bind(this); } public render(): React.ReactNode { const columns = this.getTableColumns(); - return ( - + +
+ + heh + + ); } @@ -54,7 +79,7 @@ class StudentsTable extends React.Component { } if (student.schoolId === undefined) { - return ""; + return null; } return this.getSchoolNameForStudent(student); @@ -66,7 +91,7 @@ class StudentsTable extends React.Component { } if (student.educationId === undefined) { - return ""; + return null; } return this.getEducationNameForStudent(student); @@ -183,7 +208,7 @@ class StudentsTable extends React.Component { { title: "Ingepland", key: "isPlanned", - render: (record: Student) => record.isPlanned ? "Ja" : "", + render: (record: Student) => this.renderPlannedCell(record), filters: [{ text: "Ingepland", value: "1" }, { text: "Niet ingepland", value: "0" }], onFilter: (value, record: Student) => exactMatchOrDefaultOptionFilter(value, record.isPlanned ? "1" : "0"), }, @@ -197,6 +222,34 @@ class StudentsTable extends React.Component { ]; } + private renderPlannedCell(student: Student): React.ReactNode { + if (!student.isPlanned) { + return null; + } + const openPlanningsDetailsFn = () => this.showPlanningDetails(student); + return ( + + Ja +   + (details) + + ); + } + + private showPlanningDetails(student: Student): void { + this.setState({ + isPlanningDetailsOpen: true, + selectedStudentPlanningDetails: student, + }); + } + + private handleClosePlanningDetails(): void { + this.setState({ + isPlanningDetailsOpen: false, + selectedStudentPlanningDetails: undefined, + }); + } + private getSchoolFilters(): ColumnFilterItem[] { const filters: ColumnFilterItem[] = this.props.schools.map((school) => { return {