1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-23 15:19:44 +02:00

Add validation to background field

This commit is contained in:
Maksim Eltyshev 2020-06-03 22:27:20 +05:00
parent 7811d60efb
commit f85d499bbf
10 changed files with 130 additions and 25 deletions

View file

@ -1,6 +1,7 @@
import { Model, attr, many } from 'redux-orm';
import ActionTypes from '../constants/ActionTypes';
import { ProjectBackgroundTypes } from '../constants/Enums';
export default class extends Model {
static modelName = 'Project';
@ -28,10 +29,20 @@ export default class extends Model {
});
break;
case ActionTypes.PROJECT_UPDATE:
Project.withId(payload.id).update(payload.data);
case ActionTypes.PROJECT_UPDATE: {
const project = Project.withId(payload.id);
project.update(payload.data);
if (
payload.data.backgroundImage === null &&
project.background &&
project.background.type === ProjectBackgroundTypes.IMAGE
) {
project.background = null;
}
break;
}
case ActionTypes.PROJECT_DELETE:
Project.withId(payload.id).deleteWithRelated();