Skip to content

Commit a303486

Browse files
fix: Delete complex field values if empty (#4665)
1 parent a15e807 commit a303486

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

app/serializers/session.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import ApplicationSerializer from 'open-event-frontend/serializers/application';
2+
import CustomPrimaryKeyMixin from 'open-event-frontend/mixins/custom-primary-key';
3+
4+
export default ApplicationSerializer.extend(CustomPrimaryKeyMixin, {
5+
6+
serialize() {
7+
const json = this._super(...arguments);
8+
9+
const { attributes } = json.data;
10+
if (Object.keys(attributes['complex-field-values']).length === 0) {
11+
// If object is empty, remove it so that validations on server aren't triggered
12+
delete attributes['complex-field-values'];
13+
}
14+
15+
return json;
16+
}
17+
18+
});

0 commit comments

Comments
 (0)