mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-24 06:35:49 +03:00
d51f2bcf23
closes https://github.com/TryGhost/Admin/pull/2107 - updated related babel dependencies - bumped eslint - ran `yarn lint:js --fix` - added eslint ignore comments for some required non-camel-case properties
35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
/* eslint-disable camelcase */
|
|
import ApplicationSerializer from './application';
|
|
import {pluralize} from 'ember-inflector';
|
|
|
|
export default class LabelSerializer extends ApplicationSerializer {
|
|
attrs = {
|
|
createdAtUTC: {key: 'created_at'},
|
|
updatedAtUTC: {key: 'updated_at'}
|
|
};
|
|
|
|
serialize(/*snapshot, options*/) {
|
|
let json = super.serialize(...arguments);
|
|
|
|
// Properties that exist on the model but we don't want sent in the payload
|
|
delete json.count;
|
|
|
|
return json;
|
|
}
|
|
|
|
// if we use `queryRecord` ensure we grab the first record to avoid
|
|
// DS.SERIALIZER.REST.QUERYRECORD-ARRAY-RESPONSE deprecations
|
|
normalizeResponse(store, primaryModelClass, payload, id, requestType) {
|
|
if (requestType === 'queryRecord') {
|
|
let singular = primaryModelClass.modelName;
|
|
let plural = pluralize(singular);
|
|
|
|
if (payload[plural]) {
|
|
payload[singular] = payload[plural][0];
|
|
delete payload[plural];
|
|
}
|
|
}
|
|
return super.normalizeResponse(...arguments);
|
|
}
|
|
}
|