mirror of
https://github.com/plankanban/planka.git
synced 2025-07-23 15:19:44 +02:00
Add file attachments
This commit is contained in:
parent
202abacaec
commit
6a68ec9c1e
103 changed files with 1847 additions and 305 deletions
57
client/src/models/Attachment.js
Normal file
57
client/src/models/Attachment.js
Normal file
|
@ -0,0 +1,57 @@
|
|||
import { Model, attr, fk } from 'redux-orm';
|
||||
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
static modelName = 'Attachment';
|
||||
|
||||
static fields = {
|
||||
id: attr(),
|
||||
url: attr(),
|
||||
thumbnailUrl: attr(),
|
||||
name: attr(),
|
||||
cardId: fk({
|
||||
to: 'Card',
|
||||
as: 'card',
|
||||
relatedName: 'attachments',
|
||||
}),
|
||||
};
|
||||
|
||||
static reducer({ type, payload }, Attachment) {
|
||||
switch (type) {
|
||||
case ActionTypes.BOARD_FETCH_SUCCEEDED:
|
||||
payload.attachments.forEach((attachment) => {
|
||||
Attachment.upsert(attachment);
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.ATTACHMENT_CREATE:
|
||||
case ActionTypes.ATTACHMENT_CREATE_RECEIVED:
|
||||
Attachment.upsert(payload.attachment);
|
||||
|
||||
break;
|
||||
case ActionTypes.ATTACHMENT_UPDATE:
|
||||
Attachment.withId(payload.id).update(payload.data);
|
||||
|
||||
break;
|
||||
case ActionTypes.ATTACHMENT_DELETE:
|
||||
Attachment.withId(payload.id).delete();
|
||||
|
||||
break;
|
||||
case ActionTypes.ATTACHMENT_CREATE_SUCCEEDED:
|
||||
Attachment.withId(payload.localId).delete();
|
||||
Attachment.upsert(payload.attachment);
|
||||
|
||||
break;
|
||||
case ActionTypes.ATTACHMENT_UPDATE_RECEIVED:
|
||||
Attachment.withId(payload.attachment.id).update(payload.attachment);
|
||||
|
||||
break;
|
||||
case ActionTypes.ATTACHMENT_DELETE_RECEIVED:
|
||||
Attachment.withId(payload.attachment.id).delete();
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
|
@ -145,6 +145,10 @@ export default class extends Model {
|
|||
return this.tasks.orderBy('id');
|
||||
}
|
||||
|
||||
getOrderedAttachmentsQuerySet() {
|
||||
return this.attachments.orderBy('id', false);
|
||||
}
|
||||
|
||||
getOrderedInCardActionsQuerySet() {
|
||||
return this.actions.orderBy('id', false);
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ export default class extends Model {
|
|||
id: attr(),
|
||||
email: attr(),
|
||||
name: attr(),
|
||||
avatar: attr(),
|
||||
avatarUrl: attr(),
|
||||
phone: attr(),
|
||||
organization: attr(),
|
||||
subscribeToOwnCards: attr(),
|
||||
|
@ -44,7 +44,7 @@ export default class extends Model {
|
|||
isAdmin: attr({
|
||||
getDefault: () => false,
|
||||
}),
|
||||
isAvatarUploading: attr({
|
||||
isAvatarUpdating: attr({
|
||||
getDefault: () => false,
|
||||
}),
|
||||
emailUpdateForm: attr({
|
||||
|
@ -228,22 +228,22 @@ export default class extends Model {
|
|||
|
||||
break;
|
||||
}
|
||||
case ActionTypes.USER_AVATAR_UPLOAD_REQUESTED:
|
||||
case ActionTypes.USER_AVATAR_UPDATE_REQUESTED:
|
||||
User.withId(payload.id).update({
|
||||
isAvatarUploading: true,
|
||||
isAvatarUpdating: true,
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.USER_AVATAR_UPLOAD_SUCCEEDED:
|
||||
case ActionTypes.USER_AVATAR_UPDATE_SUCCEEDED:
|
||||
User.withId(payload.id).update({
|
||||
avatar: payload.avatar,
|
||||
isAvatarUploading: false,
|
||||
avatarUrl: payload.avatarUrl,
|
||||
isAvatarUpdating: false,
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.USER_AVATAR_UPLOAD_FAILED:
|
||||
case ActionTypes.USER_AVATAR_UPDATE_FAILED:
|
||||
User.withId(payload.id).update({
|
||||
isAvatarUploading: false,
|
||||
isAvatarUpdating: false,
|
||||
});
|
||||
|
||||
break;
|
||||
|
|
|
@ -6,7 +6,20 @@ import List from './List';
|
|||
import Label from './Label';
|
||||
import Card from './Card';
|
||||
import Task from './Task';
|
||||
import Attachment from './Attachment';
|
||||
import Action from './Action';
|
||||
import Notification from './Notification';
|
||||
|
||||
export { User, Project, ProjectMembership, Board, List, Label, Card, Task, Action, Notification };
|
||||
export {
|
||||
User,
|
||||
Project,
|
||||
ProjectMembership,
|
||||
Board,
|
||||
List,
|
||||
Label,
|
||||
Card,
|
||||
Task,
|
||||
Attachment,
|
||||
Action,
|
||||
Notification,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue