Skip to content
This repository was archived by the owner on Dec 26, 2022. It is now read-only.

Commit ec3ccc4

Browse files
author
Dmitry Yadrikhinsky
committed
Delete time items
1 parent 797a500 commit ec3ccc4

File tree

4 files changed

+25
-5
lines changed

4 files changed

+25
-5
lines changed

src/components/CircleButton/CircleButton.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import React from 'react';
1+
import React, { SyntheticEvent } from 'react';
22

33
import './CircleButton.less';
44

55
import cn from '../../helpers/ClassNameHelper';
66

77
interface CircleButtonProps {
88
className?: string;
9-
onClick: () => void;
9+
onClick: (e: SyntheticEvent) => void;
1010
children: React.ReactNode;
1111
}
1212

src/components/PlayStopButton/PlayStopButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React from 'react';
1+
import React, { SyntheticEvent } from 'react';
22
import { CaretRightFilled, PauseOutlined } from '@ant-design/icons';
33

44
import './PlayStopButton.less';
@@ -14,7 +14,8 @@ interface PlayStopButtonProps {
1414
}
1515

1616
export default function PlayStopButton({ task }: PlayStopButtonProps) {
17-
function handleClick() {
17+
function handleClick(e: SyntheticEvent) {
18+
e.stopPropagation();
1819
if (task) {
1920
if (!task?.active) {
2021
tasksStore.startTimer(task);

src/components/TimeRangeModal/TimeRangeModal.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import React, { useEffect, useState } from 'react';
2-
import { Col, Form, Input, Modal, Row, Space, TimePicker } from 'antd';
2+
import { Button, Col, Form, Input, Modal, Row, TimePicker } from 'antd';
33
import { Moment } from 'moment/moment';
44
import moment from 'moment';
5+
import { DeleteFilled } from '@ant-design/icons';
56

67
import './TimeRangeModal.less';
78

@@ -50,6 +51,13 @@ export default function TimeRangeModal({
5051
onClose();
5152
}
5253

54+
function handleDelete() {
55+
if (taskTime) {
56+
tasksStore.deleteTime(taskTime.task, taskTime.index);
57+
}
58+
onClose();
59+
}
60+
5361
function handleCancel() {
5462
onClose();
5563
}
@@ -104,6 +112,9 @@ export default function TimeRangeModal({
104112
</Form.Item>
105113
</Col>
106114
</Row>
115+
<Button icon={<DeleteFilled />} onClick={handleDelete}>
116+
Remove
117+
</Button>
107118
</Form>
108119
</Modal>
109120
);

src/services/tasks/TaskStore.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,14 @@ export default class TaskStore {
2424
this.tasksService.save(this.tasks);
2525
}
2626

27+
deleteTime(task: TaskModel, timeIndex: number) {
28+
if (!task.time[timeIndex].end) {
29+
task.end();
30+
}
31+
task.time.splice(timeIndex, 1);
32+
this.tasksService.save(this.tasks);
33+
}
34+
2735
getTasks(projectId: string): TaskModel[] {
2836
return this.tasks[projectId] || [];
2937
}

0 commit comments

Comments
 (0)