Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ITG-104] Add icon of type to the task. #42

Merged
merged 22 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
e69545e
feat: Task types icons
gregori0o May 5, 2022
8256aad
Merge branch 'develop' into feature/ITG-104
gregori0o May 6, 2022
98da816
fix: Fix connection with backend
gregori0o May 6, 2022
57aafeb
Added relation_types to Task; code refactor
bkulawska May 6, 2022
71fd39f
fix: Rename variables in task interface
gregori0o May 10, 2022
4fd2434
Merge branch 'features/ITG-103' into feature/ITG-104
gregori0o May 10, 2022
736398f
Made suggested changes.
bkulawska May 11, 2022
26c696d
Merge branch 'develop' into features/ITG-103
bkulawska May 11, 2022
956bd74
Fixed import.
bkulawska May 11, 2022
68677f6
Fixed import.
bkulawska May 11, 2022
61e6e3c
Merge branch 'features/ITG-103' of https://github.com/it-goats/it-goa…
bkulawska May 11, 2022
c69d539
damniwillsquashitiswear
bkulawska May 11, 2022
af4a1a1
Made changes.
bkulawska May 11, 2022
6f3c226
Merge branch 'features/ITG-103' of https://github.com/it-goats/it-goa…
bkulawska May 11, 2022
8147c25
style: Change style of icon and subtask card
gregori0o May 11, 2022
3734694
Fixed mistake with blocking order (1).
bkulawska May 11, 2022
ec1f84f
Fixed get_relation_types; minor code refactor.
bkulawska May 11, 2022
76ab89b
Merge branch 'features/ITG-103' into feature/ITG-104
gregori0o May 11, 2022
786b2cf
Merge branch 'develop' into feature/ITG-104
gregori0o May 11, 2022
190a306
refactor: Small changes as suggested in review.
gregori0o May 12, 2022
78b8381
Merge branch 'develop' into feature/ITG-104
gregori0o May 12, 2022
d52df02
style: Change style of icons card
gregori0o May 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions cabra/package-lock.json

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

1 change: 1 addition & 0 deletions cabra/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"react-query": "^3.34.18",
"react-router-dom": "^6.3.0",
"react-select": "^5.2.2",
"react-tooltip": "^4.2.21",
"vite": "^2.6.14",
"yup": "^0.32.11"
},
Expand Down
2 changes: 1 addition & 1 deletion cabra/src/api/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const filtersToUrlParams = (filters: IFilterFormState): string => {
return params.toString();
};

interface TaskApiInput extends Omit<ITask, "id" | "dueDate"> {
interface TaskApiInput extends Omit<ITask, "id" | "dueDate" | "relationTypes"> {
dueDate: Date | string | null;
}

Expand Down
2 changes: 1 addition & 1 deletion cabra/src/pages/components/CreateTaskForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import TaskForm from "./TaskForm";
import { routeHelpers } from "../../routes";
import { useNavigate } from "react-router-dom";

const emptyTask: Omit<ITask, "id"> = {
const emptyTask: Omit<ITask, "id" | "relationTypes"> = {
description: "",
dueDate: null,
title: "",
Expand Down
2 changes: 1 addition & 1 deletion cabra/src/pages/components/SubtasksListEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const AddDependenceButton = styled.button(
);
const Label = styled.label(tw`text-gray-50 font-bold`);

const emptyTask: Omit<ITask, "id"> = {
const emptyTask: Omit<ITask, "id" | "relationTypes"> = {
description: "",
dueDate: null,
title: "",
Expand Down
4 changes: 2 additions & 2 deletions cabra/src/pages/components/TaskForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import { zonedTimeToUtc } from "date-fns-tz";

type Props = {
onSubmit: (inputs: TaskFormInputs) => Promise<unknown>;
task: Omit<ITask, "id">;
task: Omit<ITask, "id" | "relationTypes">;
};
export type TaskFormInputs = Omit<ITask, "id" | "dueDate"> & {
export type TaskFormInputs = Omit<ITask, "id" | "dueDate" | "relationTypes"> & {
dueDate: Date | null;
};

Expand Down
18 changes: 17 additions & 1 deletion cabra/src/pages/components/TaskListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { useMutation, useQueryClient } from "react-query";

import { ArrowRightIcon } from "@heroicons/react/solid";
import CheckBox from "./CheckBox";
import { DirectedRelationType } from "../../types/taskRelation";
import { Link } from "react-router-dom";
import NavigationButton from "./NavigationButton";
import { TaskTypeIcon } from "./TaskTypeIcon";
import { formatDateTime } from "../../utils/dates";
import { routeHelpers } from "../../routes";
import { useState } from "react";
Expand Down Expand Up @@ -44,8 +46,15 @@ export default function TaskListItem({ task }: Props) {
}
};

const isSubtask = task.relationTypes.includes(DirectedRelationType.Subtask);

return (
<div tw="rounded-xl w-full bg-primary text-stone-50 shadow-2xl p-4 grid grid-cols-[1fr 30%] gap-x-4">
<div
css={[
tw`rounded-xl w-full text-stone-50 shadow-2xl p-4 grid grid-cols-[1fr 30%] gap-x-4`,
isSubtask ? tw`bg-primary bg-opacity-60` : tw`bg-primary`,
]}
>
gregori0o marked this conversation as resolved.
Show resolved Hide resolved
<Column>
<Card tw="text-lg font-bold py-4">{task.title}</Card>
<Card tw="text-sm flex gap-y-1 gap-x-2">
Expand Down Expand Up @@ -76,6 +85,13 @@ export default function TaskListItem({ task }: Props) {
</Link>
</Card>
</div>
{task.relationTypes.length > 0 && (
<Card tw="flex gap-2">
{task?.relationTypes.map((type) => (
<TaskTypeIcon key={type} type={type} />
))}
</Card>
)}
gregori0o marked this conversation as resolved.
Show resolved Hide resolved
</Column>
{errorMessage && (
<p tw="flex items-center text-orange-500 pt-1">&nbsp;{errorMessage}</p>
Expand Down
62 changes: 62 additions & 0 deletions cabra/src/pages/components/TaskTypeIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
import {
ArrowCircleDownIcon,
ArrowCircleUpIcon,
CollectionIcon,
DuplicateIcon,
SwitchHorizontalIcon,
} from "@heroicons/react/solid";
import tw, { styled } from "twin.macro";

import { DirectedRelationType } from "../../types/taskRelation";
import ReactTooltip from "react-tooltip";

interface Props {
type: DirectedRelationType;
}

const Icon = styled.div`
${tw`text-blue-700 bg-tertiary p-0.5 rounded`}
`;

export function TaskTypeIcon({ type }: Props) {
let icon;
let message: string = type;
switch (type) {
case DirectedRelationType.Subtask:
icon = <DuplicateIcon height={20} width={20} data-tip data-for={type} />;
message = "Subtask";
break;
case DirectedRelationType.Supertask:
icon = <CollectionIcon height={20} width={20} data-tip data-for={type} />;
message = "Has subtask";
break;
case DirectedRelationType.Blocks:
icon = (
<ArrowCircleDownIcon height={20} width={20} data-tip data-for={type} />
);
message = "Blocks task";
break;
case DirectedRelationType.IsBlockedBy:
icon = (
<ArrowCircleUpIcon height={20} width={20} data-tip data-for={type} />
);
message = "Is blocked by task";
break;
case DirectedRelationType.Interchangable:
icon = (
<SwitchHorizontalIcon height={20} width={20} data-tip data-for={type} />
);
message = "Interchangeable task";
break;
default:
return <div></div>;
}
return (
<Icon>
{icon}
<ReactTooltip id={type} place="bottom" effect="solid">
{message}
</ReactTooltip>
</Icon>
);
}
gregori0o marked this conversation as resolved.
Show resolved Hide resolved
3 changes: 3 additions & 0 deletions cabra/src/types/task.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { DirectedRelationType } from "./taskRelation";

export interface ITag {
id: string;
name: string;
Expand All @@ -16,4 +18,5 @@ export interface ITask {
dueDate: string | null;
status: TaskStatus;
tags: ITag[];
relationTypes: DirectedRelationType[];
}