mirror of
https://github.com/plankanban/planka.git
synced 2025-07-27 09:09:46 +02:00
Project managers, board members, auto-update after reconnection, refactoring
This commit is contained in:
parent
d6cb1f6683
commit
b39119ace4
478 changed files with 21226 additions and 19495 deletions
84
client/src/models/ProjectManager.js
Normal file
84
client/src/models/ProjectManager.js
Normal file
|
@ -0,0 +1,84 @@
|
|||
import { Model, attr, fk } from 'redux-orm';
|
||||
|
||||
import ActionTypes from '../constants/ActionTypes';
|
||||
|
||||
export default class extends Model {
|
||||
static modelName = 'ProjectManager';
|
||||
|
||||
static fields = {
|
||||
id: attr(),
|
||||
projectId: fk({
|
||||
to: 'Project',
|
||||
as: 'project',
|
||||
relatedName: 'managers',
|
||||
}),
|
||||
userId: fk({
|
||||
to: 'User',
|
||||
as: 'user',
|
||||
relatedName: 'projectManagers',
|
||||
}),
|
||||
};
|
||||
|
||||
static reducer({ type, payload }, ProjectManager) {
|
||||
switch (type) {
|
||||
case ActionTypes.SOCKET_RECONNECT_HANDLE:
|
||||
ProjectManager.all().delete();
|
||||
|
||||
payload.projectManagers.forEach((projectManager) => {
|
||||
ProjectManager.upsert(projectManager);
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.CORE_INITIALIZE:
|
||||
case ActionTypes.PROJECT_CREATE__SUCCESS:
|
||||
case ActionTypes.PROJECT_CREATE_HANDLE:
|
||||
payload.projectManagers.forEach((projectManager) => {
|
||||
ProjectManager.upsert(projectManager);
|
||||
});
|
||||
|
||||
break;
|
||||
case ActionTypes.PROJECT_MANAGER_CREATE:
|
||||
ProjectManager.upsert(payload.projectManager);
|
||||
|
||||
break;
|
||||
case ActionTypes.PROJECT_MANAGER_CREATE__SUCCESS:
|
||||
ProjectManager.withId(payload.localId).delete();
|
||||
ProjectManager.upsert(payload.projectManager);
|
||||
|
||||
break;
|
||||
case ActionTypes.PROJECT_MANAGER_CREATE_HANDLE:
|
||||
ProjectManager.upsert(payload.projectManager);
|
||||
|
||||
if (payload.projectManagers) {
|
||||
payload.projectManagers.forEach((projectManager) => {
|
||||
ProjectManager.upsert(projectManager);
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
case ActionTypes.PROJECT_MANAGER_DELETE:
|
||||
ProjectManager.withId(payload.id).delete();
|
||||
|
||||
break;
|
||||
case ActionTypes.PROJECT_MANAGER_DELETE__SUCCESS:
|
||||
case ActionTypes.PROJECT_MANAGER_DELETE_HANDLE: {
|
||||
const projectManagerModel = ProjectManager.withId(payload.projectManager.id);
|
||||
|
||||
if (projectManagerModel) {
|
||||
projectManagerModel.delete();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ActionTypes.BOARD_MEMBERSHIP_CREATE_HANDLE:
|
||||
if (payload.projectManagers) {
|
||||
payload.projectManagers.forEach((projectManager) => {
|
||||
ProjectManager.upsert(projectManager);
|
||||
});
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue