Implemented issue drag and drop
This commit is contained in:
@@ -3,6 +3,7 @@ import express from 'express';
|
||||
import { Project } from 'entities';
|
||||
import { catchErrors } from 'errors';
|
||||
import { findEntityOrThrow, updateEntity } from 'utils/typeorm';
|
||||
import { issuePartial } from 'serializers/issues';
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
@@ -10,9 +11,14 @@ router.get(
|
||||
'/project',
|
||||
catchErrors(async (req, res) => {
|
||||
const project = await findEntityOrThrow(Project, req.currentUser.projectId, {
|
||||
relations: ['users', 'issues', 'issues.comments'],
|
||||
relations: ['users', 'issues'],
|
||||
});
|
||||
res.respond({
|
||||
project: {
|
||||
...project,
|
||||
issues: project.issues.map(issuePartial),
|
||||
},
|
||||
});
|
||||
res.respond({ project });
|
||||
}),
|
||||
);
|
||||
|
||||
|
||||
@@ -24,10 +24,11 @@ const seedProjects = (users: User[]): Promise<Project[]> => {
|
||||
const seedIssues = (projects: Project[]): Promise<Issue[]> => {
|
||||
const issues = projects
|
||||
.map(project =>
|
||||
times(10, () =>
|
||||
times(10, i =>
|
||||
createEntity(
|
||||
Issue,
|
||||
generateIssue({
|
||||
listPosition: i + 1,
|
||||
reporterId: (sample(project.users) as User).id,
|
||||
project,
|
||||
users: [sample(project.users) as User],
|
||||
|
||||
@@ -40,6 +40,7 @@ const seedIssues = (project: Project): Promise<Issue[]> => {
|
||||
type: IssueType.TASK,
|
||||
status: IssueStatus.BACKLOG,
|
||||
priority: IssuePriority.LOWEST,
|
||||
listPosition: 1,
|
||||
estimate: 8,
|
||||
reporterId: getRandomUser().id,
|
||||
project,
|
||||
@@ -50,6 +51,7 @@ const seedIssues = (project: Project): Promise<Issue[]> => {
|
||||
type: IssueType.TASK,
|
||||
status: IssueStatus.BACKLOG,
|
||||
priority: IssuePriority.LOW,
|
||||
listPosition: 2,
|
||||
description: 'Nothing in particular.',
|
||||
estimate: 40,
|
||||
reporterId: getRandomUser().id,
|
||||
@@ -60,6 +62,7 @@ const seedIssues = (project: Project): Promise<Issue[]> => {
|
||||
type: IssueType.BUG,
|
||||
status: IssueStatus.BACKLOG,
|
||||
priority: IssuePriority.MEDIUM,
|
||||
listPosition: 3,
|
||||
estimate: 15,
|
||||
reporterId: getRandomUser().id,
|
||||
project,
|
||||
@@ -70,6 +73,7 @@ const seedIssues = (project: Project): Promise<Issue[]> => {
|
||||
type: IssueType.STORY,
|
||||
status: IssueStatus.BACKLOG,
|
||||
priority: IssuePriority.HIGH,
|
||||
listPosition: 4,
|
||||
description:
|
||||
"#### Colons can be used to align columns.\n\n| Tables | Are | Cool |\n| ------------- |:-------------:| -----:|\n| col 3 is | right-aligned | |\n| col 2 is | centered | |\n| zebra stripes | are neat | |\n\nThe outer pipes (|) are optional, and you don't need to make the raw Markdown line up prettily. You can also use inline Markdown.\n\nMarkdown | Less | Pretty\n--- | --- | ---\n*Still* | `renders` | **nicely**\n1 | 2 | 3",
|
||||
estimate: 4,
|
||||
@@ -82,6 +86,7 @@ const seedIssues = (project: Project): Promise<Issue[]> => {
|
||||
type: IssueType.TASK,
|
||||
status: IssueStatus.SELECTED,
|
||||
priority: IssuePriority.HIGHEST,
|
||||
listPosition: 5,
|
||||
estimate: 15,
|
||||
reporterId: getRandomUser().id,
|
||||
project,
|
||||
@@ -91,6 +96,7 @@ const seedIssues = (project: Project): Promise<Issue[]> => {
|
||||
type: IssueType.STORY,
|
||||
status: IssueStatus.SELECTED,
|
||||
priority: IssuePriority.MEDIUM,
|
||||
listPosition: 6,
|
||||
estimate: 55,
|
||||
reporterId: getRandomUser().id,
|
||||
project,
|
||||
@@ -101,6 +107,7 @@ const seedIssues = (project: Project): Promise<Issue[]> => {
|
||||
type: IssueType.TASK,
|
||||
status: IssueStatus.SELECTED,
|
||||
priority: IssuePriority.MEDIUM,
|
||||
listPosition: 7,
|
||||
estimate: 12,
|
||||
reporterId: getRandomUser().id,
|
||||
project,
|
||||
|
||||
@@ -41,6 +41,9 @@ class Issue extends BaseEntity {
|
||||
@Column('varchar')
|
||||
priority: IssuePriority;
|
||||
|
||||
@Column('double precision')
|
||||
listPosition: number;
|
||||
|
||||
@Column('text', { nullable: true })
|
||||
description: string | null;
|
||||
|
||||
|
||||
16
api/src/serializers/issues.ts
Normal file
16
api/src/serializers/issues.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { pick } from 'lodash';
|
||||
|
||||
import { Issue } from 'entities';
|
||||
|
||||
export const issuePartial = (issue: Issue): Partial<Issue> =>
|
||||
pick(issue, [
|
||||
'id',
|
||||
'title',
|
||||
'type',
|
||||
'status',
|
||||
'priority',
|
||||
'listPosition',
|
||||
'createdAt',
|
||||
'updatedAt',
|
||||
'userIds',
|
||||
]);
|
||||
Reference in New Issue
Block a user