1
0
mirror of https://github.com/TryGhost/Ghost.git synced 2024-12-24 03:14:03 +03:00
Ghost/ghost/admin/app/serializers/custom-theme-setting-list.js
Gabriel Csapo d51f2bcf23 [chore] migrate to eslint@8 and run --fix ()
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
2022-02-10 10:41:36 +00:00

24 lines
1.0 KiB
JavaScript

import ApplicationSerializer from './application';
import {EmbeddedRecordsMixin} from '@ember-data/serializer/rest';
export default class CustomThemeSettingList extends ApplicationSerializer.extend(EmbeddedRecordsMixin) {
attrs = {
customThemeSettings: {embedded: 'always'}
};
serializeIntoHash(hash, type, record, options) {
// replace the whole request hash with the embedded custom_theme_settings array
const settings = this.serialize(record, options);
Object.assign(hash, settings);
}
normalizeSingleResponse(store, primaryModelClass, _payload, id, requestType) {
// response will come back as a custom theme settings array, not a "customThemeSettingList" array/object
// make it look like the list model so Ember Data does it's thing and doesn't complain
const payload = {
customThemeSettingLists: [Object.assign({id: 0}, _payload)]
};
return super.normalizeSingleResponse(store, primaryModelClass, payload, id, requestType);
}
}