Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
**/node_modules
# testing
**/coverage
# production
**/build
# misc
**/.DS_Store
npm-debug.log*
**/yarn-debug.log*
**/yarn-error.log*
# Created by https://www.toptal.com/developers/gitignore/api/webstorm
# Edit at https://www.toptal.com/developers/gitignore?templates=webstorm
### WebStorm ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
.idea/**/*.xml
.idea/**/*.iml
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Sonarlint plugin
.idea/**/sonarlint/
# SonarQube Plugin
.idea/**/sonarIssues.xml
# Markdown Navigator plugin
.idea/**/markdown-navigator.xml
.idea/**/markdown-navigator-enh.xml
.idea/**/markdown-navigator/
# Cache file creation bug
# See https://youtrack.jetbrains.com/issue/JBR-2257
.idea/$CACHE_FILE$
5 changes: 5 additions & 0 deletions .idea/.gitignore

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

6 changes: 6 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

12 changes: 12 additions & 0 deletions .idea/todo-frontend.iml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

3 changes: 3 additions & 0 deletions package-lock.json

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

126 changes: 0 additions & 126 deletions static/.gitignore

This file was deleted.

5 changes: 3 additions & 2 deletions static/src/component/board/card/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@ import Task from "../task";
import '../../../css/Card.css';

function Card(props) {
const {subject, tasks, move} = props;
const {subject, tasks, move, remove} = props;
return (
<div className='card'>
<div className='title'>{subject}</div>
{
tasks.map(task => {
return <Task key={task.id} title={task.title} subject={subject} id={task.id} move={move}/>
return <Task key={task.id} title={task.title} priority={task.priority} assignee={task.assignee}
subject={subject} id={task.id} created={task.created} move={move} remove={remove}/>
})
}

Expand Down
9 changes: 7 additions & 2 deletions static/src/component/board/task/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,27 @@ import {isDone, isTodo, toToggledValue} from "../../../utility/status";
import Button from "../../atom/Button";

function Task(props) {
const {title, subject, id, move} = props;
const {title, subject, id, priority, assignee, created, move, remove} = props;
const onClick = (event) => {
event.stopPropagation();
const toggledValue = toToggledValue(subject);
move(id, toggledValue);
};
function handle(event) {
remove(id);
}

return (
<div className='task'>
{
isTodo(subject) && <Button className='task-left-btn' onClick={onClick} value='>'/>
}
{title}
{title} {String(priority)+'순위'} <br/>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String 타입으로 변경하지 않아도, '순위' 문자열이 추가되면서 string 타입으로 변경될 거 같아~

{assignee} {created}
{
isDone(subject) && <Button className='task-right-btn' onClick={onClick} value='<'/>
}
<Button className='task-remove-btn' onClick={handle} value='X'/>
</div>
);
}
Expand Down
48 changes: 47 additions & 1 deletion static/src/page/Board.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import '../css/Board.css';
import moveTo from "../service/moveTo";
import {Link} from "react-router-dom";
import {toName, toToggleName} from '../utility/status';
import deleteCard from "../service/deleteCard";

function Board() {
const [cards, updateCards] = useState({});
Expand All @@ -25,19 +26,64 @@ function Board() {
const changedStatus = toName(result.status);
cards[changedStatus].push(result);

// case 1:
// const changedCards = await getCards();
// updateCards({
// todo: changedCards.todo,
// done: changedCards.done
// });

// case 2:
cards.todo.sort(function (a, b) {
return a.priority-b.priority;
});
cards.done.sort(function (a, b) {
return a.priority-b.priority;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sort() 함수 잘 사용했네 굿굿 👍 👍 👍

몇가지 추가로 살펴보면
Tasktodo 에서 done으로 이동한 경우에는 todo를 새로 정렬할 필요없고,
반대로 done 에서 todo로 이동한 경우에도 done을 새로 정렬할 필요없거든

그래서, Task가 이동한 Card 상태를 의미하는 changedStatus(todo or done) 를 이용해서,
변경된 Card 대해서만 정렬를 수행해주면 불필요한 작업은 줄일 수 있어~

});

updateCards({
todo: cards.todo,
done: cards.done
});
}
};
function remove(id) {
const todo = cards.todo;
const done = cards.done;

let index = todo.findIndex((value) => {
return value.id === id;
});
Comment on lines +54 to +56
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 코드가 65번 라인의 index = done.findIndex((value) => { return value.id === id;}); 코드하고 비슷한 형식으로 중복되는 것을 볼 수 있는데,

index = done.findIndex((value) => {
return value.id === id;
});

remove() 함수 인자로 status 값까지 받아온다면, 아래처럼 좀더 일반화된 방식으로 중복 코드를 제거할 수 있을 거 같아~

function remove(id, status) {
       ...
       const index = cards[originStatus].findIndex((task) => task.id === id);
       ...
}

if(index!==-1) {
todo.splice(index, 1);
const isSuccesses = deleteCard(id);
if (!isSuccesses) {
alert('NotFound(todo)');
}
Comment on lines +58 to +62
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

해당 부분도 68~72 라인하고 중복되는 형식인거 같아

done.splice(index, 1);
const isSuccesses = deleteCard(id);
if (!isSuccesses) {
alert('NotFound(done)');
}

일반화하기 앞서서, 먼저 중복 코드를 별도의 함수로 분리해보는 것도 좋을거 같아~

}
else{
index = done.findIndex((value) => {
return value.id === id;
});
done.splice(index, 1);
const isSuccesses = deleteCard(id);
if (!isSuccesses) {
alert('NotFound(done)');
}
}

updateCards({
"todo": cards.todo,
"done": cards.done
});
}

return (
<div className='board'>
<div className='board-list'>
{
Object.entries(cards).map(([subject, tasks]) => {
return <Card key={subject} subject={subject} tasks={tasks} move={move}/>;
return <Card key={subject} subject={subject} tasks={tasks} move={move} remove={remove}/>;
})
}
</div>
Expand Down
Loading