Files
icehrm/web/components/TaskList.js
Thilina Pituwala b1df0037db License updated to GPLv3
🧲 New features
Custom user role permissions
Employee edit form updated
Employee daily task list
Attendance and employee distribution charts on dashboard
Improvements to company structure and company assets module
Improved tables for displaying data in several modules
Faster data loading (specially for employee module)
Initials based profile pictures
Re-designed login page
Re-designed user profile page
Improvements to filtering
New REST endpoints for employee qualifications

🐛 Bug fixes
Fixed, issue with managers being able to create performance reviews for employees who are not their direct reports
Fixed, issues related to using full profile image instead of using smaller version of profile image
Changing third gender to other
Improvements and fixes for internal frontend data caching
2020-10-31 19:02:37 +01:00

188 lines
5.0 KiB
JavaScript

import React from 'react';
import {
Timeline, Drawer, Empty, Button, Space, Typography, Popover,
} from 'antd';
import {
ClockCircleOutlined,
PlusCircleOutlined,
InfoCircleOutlined,
PauseCircleOutlined,
MedicineBoxOutlined,
} from '@ant-design/icons';
const { Paragraph } = Typography;
class TaskList extends React.Component {
state = {
tasks: [],
showAll: false,
}
constructor(props) {
super(props);
this.state.tasks = this.props.tasks.map(item => false);
}
render() {
return this.createTaskList(4);
}
createTaskList(maxNumberOfTasks) {
const tasks = this.props.tasks.slice(0, maxNumberOfTasks);
return (
<>
<Space direction="vertical" size="large" style={{ width: '100%' }}>
{this.props.tasks && this.props.tasks.length > 0
&& (
<Space direction="vertical" style={{ width: '100%' }}>
<Timeline style={{ width: '100%' }}>
{tasks.map(
(task, index) => (
this.createTask(task, index)
),
)}
</Timeline>
{this.props.tasks.length > maxNumberOfTasks &&
<Button type="primary" onClick={() => this.showAllTasks()}>
View All
{' '}
{this.props.tasks.length}
{' '}
Tasks
</Button>
}
</Space>
)}
{this.props.tasks && this.props.tasks.length === 0
&& <Empty description="You're all caught up!" />}
</Space>
<Drawer
title="Task List"
width={470}
onClose={() => this.hideAllTasks()}
visible={this.state.showAll}
bodyStyle={{ paddingBottom: 80 }}
zIndex={1200}
maskClosable={false}
>
<Timeline style={{ width: '100%' }}>
{this.props.tasks.map(
(task, index) => (
this.createTask(task, index)
),
)}
</Timeline>
</Drawer>
</>
);
}
visitLink(link) {
setTimeout(() => {window.open(link);}, 100);
}
handleTaskHover(index) {
this.setState({tasks : this.props.tasks.map((item,i) => index === i)})
}
createTask(task, index) {
if (task.priority === 100) {
return (
<Timeline.Item onMouseEnter={() => this.handleTaskHover(index)}
dot={<ClockCircleOutlined style={{ fontSize: '16px' }} />} color="red" >
{this.getText(task)}
{task.link && this.state.tasks[index]
&& (
<Button type="link" onClick={() => this.visitLink(task.link)}>
<MedicineBoxOutlined style={{ fontSize: '16px' }} />
{' '}
{task.action}
</Button>
)}
</Timeline.Item>
);
} if (task.priority === 50) {
return (
<Timeline.Item onMouseEnter={() => this.handleTaskHover(index)}
dot={<InfoCircleOutlined style={{ fontSize: '16px' }} />} color="blue">
{this.getText(task)}
{task.link && this.state.tasks[index]
&& (
<Button type="link" onClick={() => this.visitLink(task.link)}>
<MedicineBoxOutlined style={{ fontSize: '16px' }} />
{' '}
{task.action}
</Button>
)}
</Timeline.Item>
);
} if (task.priority === 20) {
return (
<Timeline.Item onMouseEnter={() => this.handleTaskHover(index)}
dot={<PlusCircleOutlined style={{ fontSize: '16px' }} />} color="blue">
{this.getText(task)}
{task.link && this.state.tasks[index]
&& (
<Button type="link" onClick={() => this.visitLink(task.link)}>
<MedicineBoxOutlined style={{ fontSize: '16px' }} />
{' '}
{task.action}
</Button>
)}
</Timeline.Item>
);
} if (task.priority === 10) {
return (
<Timeline.Item onMouseEnter={() => this.handleTaskHover(index)}
dot={<PauseCircleOutlined style={{ fontSize: '16px' }} />} color="green">
{this.getText(task)}
{task.link && this.state.tasks[index]
&& (
<Button type="link" onClick={() => this.visitLink(task.link)}>
<MedicineBoxOutlined style={{ fontSize: '16px' }} />
{' '}
{task.action}
</Button>
)}
</Timeline.Item>
);
}
}
getText(task) {
if (!task.details) {
return (<Paragraph
ellipsis={{
rows: 1,
expandable: true,
}}
>
{task.text}
</Paragraph>);
}
return (
<Popover content={task.details}>
<Paragraph
ellipsis={{
rows: 1,
expandable: true,
}}
>
{task.text}
</Paragraph>
</Popover>
);
}
showAllTasks() {
this.setState({showAll: true});
}
hideAllTasks() {
this.setState({showAll: false});
}
}
export default TaskList;