mirror of
https://github.com/plankanban/planka.git
synced 2025-07-29 18:19:46 +02:00
Add file attachments
This commit is contained in:
parent
202abacaec
commit
6a68ec9c1e
103 changed files with 1847 additions and 305 deletions
51
client/src/api/attachments.js
Executable file
51
client/src/api/attachments.js
Executable file
|
@ -0,0 +1,51 @@
|
|||
import http from './http';
|
||||
import socket from './socket';
|
||||
|
||||
/* Transformers */
|
||||
|
||||
export const transformAttachment = (attachment) => ({
|
||||
...attachment,
|
||||
createdAt: new Date(attachment.createdAt),
|
||||
});
|
||||
|
||||
/* Actions */
|
||||
|
||||
const createAttachment = (cardId, data, headers) =>
|
||||
http.post(`/cards/${cardId}/attachments`, data, headers).then((body) => ({
|
||||
...body,
|
||||
item: transformAttachment(body.item),
|
||||
}));
|
||||
|
||||
const updateAttachment = (id, data, headers) =>
|
||||
socket.patch(`/attachments/${id}`, data, headers).then((body) => ({
|
||||
...body,
|
||||
item: transformAttachment(body.item),
|
||||
}));
|
||||
|
||||
const deleteAttachment = (id, headers) =>
|
||||
socket.delete(`/attachments/${id}`, undefined, headers).then((body) => ({
|
||||
...body,
|
||||
item: transformAttachment(body.item),
|
||||
}));
|
||||
|
||||
/* Event handlers */
|
||||
|
||||
const makeHandleAttachmentCreate = (next) => (body) => {
|
||||
next({
|
||||
...body,
|
||||
item: transformAttachment(body.item),
|
||||
});
|
||||
};
|
||||
|
||||
const makeHandleAttachmentUpdate = makeHandleAttachmentCreate;
|
||||
|
||||
const makeHandleAttachmentDelete = makeHandleAttachmentCreate;
|
||||
|
||||
export default {
|
||||
createAttachment,
|
||||
updateAttachment,
|
||||
deleteAttachment,
|
||||
makeHandleAttachmentCreate,
|
||||
makeHandleAttachmentUpdate,
|
||||
makeHandleAttachmentDelete,
|
||||
};
|
|
@ -1,5 +1,6 @@
|
|||
import socket from './socket';
|
||||
import { transformCard } from './cards';
|
||||
import { transformAttachment } from './attachments';
|
||||
|
||||
/* Actions */
|
||||
|
||||
|
@ -12,6 +13,7 @@ const getBoard = (id, headers) =>
|
|||
included: {
|
||||
...body.included,
|
||||
cards: body.included.cards.map(transformCard),
|
||||
attachments: body.included.attachments.map(transformAttachment),
|
||||
},
|
||||
}));
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import cards from './cards';
|
|||
import cardMemberships from './card-memberships';
|
||||
import cardLabels from './card-labels';
|
||||
import tasks from './tasks';
|
||||
import attachments from './attachments';
|
||||
import actions from './actions';
|
||||
import commentActions from './comment-actions';
|
||||
import notifications from './notifications';
|
||||
|
@ -29,6 +30,7 @@ export default {
|
|||
...cardMemberships,
|
||||
...cardLabels,
|
||||
...tasks,
|
||||
...attachments,
|
||||
...actions,
|
||||
...commentActions,
|
||||
...notifications,
|
||||
|
|
|
@ -19,14 +19,8 @@ const updateUserPassword = (id, data, headers) =>
|
|||
const updateUserUsername = (id, data, headers) =>
|
||||
socket.patch(`/users/${id}/username`, data, headers);
|
||||
|
||||
const uploadUserAvatar = (id, file, headers) =>
|
||||
http.post(
|
||||
`/users/${id}/upload-avatar`,
|
||||
{
|
||||
file,
|
||||
},
|
||||
headers,
|
||||
);
|
||||
const updateUserAvatar = (id, data, headers) =>
|
||||
http.post(`/users/${id}/update-avatar`, data, headers);
|
||||
|
||||
const deleteUser = (id, headers) => socket.delete(`/users/${id}`, undefined, headers);
|
||||
|
||||
|
@ -38,6 +32,6 @@ export default {
|
|||
updateUserEmail,
|
||||
updateUserPassword,
|
||||
updateUserUsername,
|
||||
uploadUserAvatar,
|
||||
updateUserAvatar,
|
||||
deleteUser,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue