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 all 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
3 changes: 2 additions & 1 deletion cabra/src/api/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const filtersToUrlParams = (filters: IFilterFormState): string => {
return params.toString();
};

interface TaskApiInput extends Omit<ITask, "id" | "dueDate" | "isBlocked"> {
interface TaskApiInput
extends Omit<ITask, "id" | "dueDate" | "relationTypes" | "isBlocked"> {
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 @@ -5,7 +5,7 @@ import { useNavigate, useSearchParams } from "react-router-dom";

import TaskForm from "./TaskForm";

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

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

Expand Down
17 changes: 14 additions & 3 deletions cabra/src/pages/components/TaskListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { EmptyIcon, TaskTypeIcon } from "./TaskTypeIcon";
import { ITask, TaskStatus } from "../../types/task";
import { getTask, getTasks, updateTask } from "../../api/tasks";
import tw, { styled } from "twin.macro";
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 { formatDateTime } from "../../utils/dates";
Expand Down Expand Up @@ -45,10 +47,10 @@ export default function TaskListItem({ task }: Props) {
};

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 tw="rounded-xl w-full text-stone-50 bg-primary shadow-2xl p-4 grid grid-cols-[1fr 30%] gap-x-4">
<Column>
<Card tw="text-lg font-bold py-4">{task.title}</Card>
<Card tw="text-sm flex gap-y-1 gap-x-2">
<Card tw="text-lg font-bold py-8">{task.title}</Card>
<Card tw="text-sm flex gap-y-1 gap-x-2 py-3">
Tags:
{task.tags.length > 0
? task.tags.map((tag) => <TagChip key={tag.id}>{tag.name}</TagChip>)
Expand Down Expand Up @@ -77,6 +79,15 @@ export default function TaskListItem({ task }: Props) {
</Link>
</Card>
</div>
<Card tw="grid grid-cols-5 py-2 gap-1.5 justify-items-center">
{Object.values(DirectedRelationType).map((type) =>
task.relationTypes.includes(type) ? (
<TaskTypeIcon key={type} type={type} />
) : (
<EmptyIcon />
)
)}
</Card>
</Column>
{errorMessage && (
<p tw="flex items-center text-orange-500 pt-1">&nbsp;{errorMessage}</p>
Expand Down
58 changes: 58 additions & 0 deletions cabra/src/pages/components/TaskTypeIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
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 IconContainer = styled.div`
${tw`text-blue-700 bg-tertiary p-1 rounded`}
`;

export const EmptyIcon = styled.div`
${tw`bg-primary p-1 h-7 w-7 rounded`}
`;

const TYPES_TO_ICONS = {
[DirectedRelationType.Subtask]: {
Icon: DuplicateIcon,
message: "Subtask",
},
[DirectedRelationType.Supertask]: {
Icon: CollectionIcon,
message: "Has subtask",
},
[DirectedRelationType.Blocks]: {
Icon: ArrowCircleDownIcon,
message: "Blocks another task",
},
[DirectedRelationType.IsBlockedBy]: {
Icon: ArrowCircleUpIcon,
message: "Is blocked by another task",
},
[DirectedRelationType.Interchangable]: {
Icon: SwitchHorizontalIcon,
message: "Interchangeable task",
},
};

export function TaskTypeIcon({ type }: Props) {
const { Icon, message } = TYPES_TO_ICONS[type];
return (
<IconContainer>
<Icon height={20} width={20} data-tip data-for={type} />
<ReactTooltip id={type} place="bottom" effect="solid">
{message}
</ReactTooltip>
</IconContainer>
);
}
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 @@ -17,4 +19,5 @@ export interface ITask {
status: TaskStatus;
isBlocked: boolean;
tags: ITag[];
relationTypes: DirectedRelationType[];
}
6 changes: 3 additions & 3 deletions cabra/src/types/taskRelation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ export interface IRelatedTask {
}

export enum DirectedRelationType {
Blocks = "blocks",
IsBlockedBy = "is_blocked_by",
Subtask = "subtask",
Supertask = "supertask",
Subtask = "subtask",
IsBlockedBy = "is_blocked_by",
Interchangable = "interchangable",
Blocks = "blocks",
}