Initial commit

This commit is contained in:
Maksim Eltyshev
2019-08-31 04:07:25 +05:00
commit 5ffef61fe7
613 changed files with 91659 additions and 0 deletions

58
client/src/models/Label.js Executable file
View File

@@ -0,0 +1,58 @@
import { Model, attr, fk } from 'redux-orm';
import ActionTypes from '../constants/ActionTypes';
export default class extends Model {
static modelName = 'Label';
static fields = {
id: attr(),
name: attr(),
color: attr(),
boardId: fk({
to: 'Board',
as: 'board',
relatedName: 'labels',
}),
};
static reducer({ type, payload }, Label) {
switch (type) {
case ActionTypes.BOARD_CREATE_SUCCEEDED:
case ActionTypes.BOARD_CREATE_RECEIVED:
case ActionTypes.BOARD_FETCH_SUCCEEDED:
payload.labels.forEach((label) => {
Label.upsert(label);
});
break;
case ActionTypes.LABEL_CREATE:
case ActionTypes.LABEL_CREATE_RECEIVED:
Label.upsert(payload.label);
break;
case ActionTypes.LABEL_UPDATE:
Label.withId(payload.id).update(payload.data);
break;
case ActionTypes.LABEL_DELETE:
Label.withId(payload.id).delete();
break;
case ActionTypes.LABEL_CREATE_SUCCEEDED:
Label.withId(payload.localId).delete();
Label.upsert(payload.label);
break;
case ActionTypes.LABEL_UPDATE_RECEIVED:
Label.withId(payload.label.id).update(payload.label);
break;
case ActionTypes.LABEL_DELETE_RECEIVED:
Label.withId(payload.label.id).delete();
break;
default:
}
}
}